mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Merge branch 'bug7011'
Conflicts: src/or/circuitbuild.c The conflict was trivial, since no line of code actually changed in both branches: There was a fmt_addr() that turned into fmt_addrport() in bug7011, and a "if (!n_conn)" that turned into "if (!n_chan)" in master.
This commit is contained in:
commit
7ea904cbc0
6
changes/bug7011
Normal file
6
changes/bug7011
Normal file
@ -0,0 +1,6 @@
|
||||
o Minor bugfixes:
|
||||
- Use square brackets around IPv6 addresses in numerous places that needed
|
||||
them, including log messages, HTTPS CONNECT proxy requests,
|
||||
TransportProxy statefile entries, and pluggable transport extra-info
|
||||
lines. Fix for bug 7011; patch by David Fifield.
|
||||
|
@ -1006,6 +1006,19 @@ fmt_addr_impl(const tor_addr_t *addr, int decorate)
|
||||
return "???";
|
||||
}
|
||||
|
||||
/** Return a string representing the pair <b>addr</b> and <b>port</b>.
|
||||
* This calls fmt_and_decorate_addr internally, so IPv6 addresses will
|
||||
* have brackets, and the caveats of fmt_addr_impl apply.
|
||||
*/
|
||||
const char *
|
||||
fmt_addrport(const tor_addr_t *addr, uint16_t port)
|
||||
{
|
||||
/* Add space for a colon and up to 5 digits. */
|
||||
static char buf[TOR_ADDR_BUF_LEN + 6];
|
||||
tor_snprintf(buf, sizeof(buf), "%s:%u", fmt_and_decorate_addr(addr), port);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/** Like fmt_addr(), but takes <b>addr</b> as a host-order IPv4
|
||||
* addresses. Also not thread-safe, also clobbers its return buffer on
|
||||
* repeated calls. */
|
||||
|
@ -145,6 +145,7 @@ char *tor_dup_addr(const tor_addr_t *addr) ATTR_MALLOC;
|
||||
* addresses. */
|
||||
#define fmt_and_decorate_addr(a) fmt_addr_impl((a), 1)
|
||||
const char *fmt_addr_impl(const tor_addr_t *addr, int decorate);
|
||||
const char *fmt_addrport(const tor_addr_t *addr, uint16_t port);
|
||||
const char * fmt_addr32(uint32_t addr);
|
||||
int get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr);
|
||||
|
||||
|
@ -1979,9 +1979,9 @@ circuit_handle_first_hop(origin_circuit_t *circ)
|
||||
tor_assert(firsthop->extend_info);
|
||||
|
||||
/* now see if we're already connected to the first OR in 'route' */
|
||||
log_debug(LD_CIRC,"Looking for firsthop '%s:%u'",
|
||||
fmt_addr(&firsthop->extend_info->addr),
|
||||
firsthop->extend_info->port);
|
||||
log_debug(LD_CIRC,"Looking for firsthop '%s'",
|
||||
fmt_addrport(&firsthop->extend_info->addr,
|
||||
firsthop->extend_info->port));
|
||||
|
||||
n_chan = channel_get_for_extend(firsthop->extend_info->identity_digest,
|
||||
&firsthop->extend_info->addr,
|
||||
@ -2497,8 +2497,8 @@ circuit_extend(cell_t *cell, circuit_t *circ)
|
||||
&should_launch);
|
||||
|
||||
if (!n_chan) {
|
||||
log_debug(LD_CIRC|LD_OR,"Next router (%s:%d): %s",
|
||||
fmt_addr(&n_addr), (int)n_port, msg?msg:"????");
|
||||
log_debug(LD_CIRC|LD_OR,"Next router (%s): %s",
|
||||
fmt_addrport(&n_addr, n_port), msg?msg:"????");
|
||||
|
||||
circ->n_hop = extend_info_new(NULL /*nickname*/,
|
||||
id_digest,
|
||||
@ -3955,8 +3955,8 @@ extend_info_from_node(const node_t *node, int for_direct_connect)
|
||||
else
|
||||
node_get_prim_orport(node, &ap);
|
||||
|
||||
log_debug(LD_CIRC, "using %s:%d for %s",
|
||||
fmt_and_decorate_addr(&ap.addr), ap.port,
|
||||
log_debug(LD_CIRC, "using %s for %s",
|
||||
fmt_addrport(&ap.addr, ap.port),
|
||||
node->ri ? node->ri->nickname : node->rs->nickname);
|
||||
|
||||
if (node->ri)
|
||||
@ -5347,8 +5347,8 @@ learned_router_identity(const tor_addr_t *addr, uint16_t port,
|
||||
get_configured_bridge_by_addr_port_digest(addr, port, digest);
|
||||
if (bridge && tor_digest_is_zero(bridge->identity)) {
|
||||
memcpy(bridge->identity, digest, DIGEST_LEN);
|
||||
log_notice(LD_DIR, "Learned fingerprint %s for bridge %s:%d",
|
||||
hex_str(digest, DIGEST_LEN), fmt_addr(addr), port);
|
||||
log_notice(LD_DIR, "Learned fingerprint %s for bridge %s",
|
||||
hex_str(digest, DIGEST_LEN), fmt_addrport(addr, port));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5393,12 +5393,12 @@ bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
|
||||
strcmp_opt(bridge->transport_name, transport_name)) {
|
||||
/* warn the user */
|
||||
char *bridge_description_new, *bridge_description_old;
|
||||
tor_asprintf(&bridge_description_new, "%s:%u:%s:%s",
|
||||
fmt_addr(addr), port,
|
||||
tor_asprintf(&bridge_description_new, "%s:%s:%s",
|
||||
fmt_addrport(addr, port),
|
||||
digest ? hex_str(digest, DIGEST_LEN) : "",
|
||||
transport_name ? transport_name : "");
|
||||
tor_asprintf(&bridge_description_old, "%s:%u:%s:%s",
|
||||
fmt_addr(&bridge->addr), bridge->port,
|
||||
tor_asprintf(&bridge_description_old, "%s:%s:%s",
|
||||
fmt_addrport(&bridge->addr, bridge->port),
|
||||
tor_digest_is_zero(bridge->identity) ?
|
||||
"" : hex_str(bridge->identity,DIGEST_LEN),
|
||||
bridge->transport_name ? bridge->transport_name : "");
|
||||
@ -5541,7 +5541,7 @@ launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
|
||||
if (routerset_contains_bridge(options->ExcludeNodes, bridge)) {
|
||||
download_status_mark_impossible(&bridge->fetch_status);
|
||||
log_warn(LD_APP, "Not using bridge at %s: it is in ExcludeNodes.",
|
||||
safe_str_client(fmt_addr(&bridge->addr)));
|
||||
safe_str_client(fmt_and_decorate_addr(&bridge->addr)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5594,7 +5594,7 @@ fetch_bridge_descriptors(const or_options_t *options, time_t now)
|
||||
if (routerset_contains_bridge(options->ExcludeNodes, bridge)) {
|
||||
download_status_mark_impossible(&bridge->fetch_status);
|
||||
log_warn(LD_APP, "Not using bridge at %s: it is in ExcludeNodes.",
|
||||
safe_str_client(fmt_addr(&bridge->addr)));
|
||||
safe_str_client(fmt_and_decorate_addr(&bridge->addr)));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -5611,9 +5611,9 @@ fetch_bridge_descriptors(const or_options_t *options, time_t now)
|
||||
|
||||
if (ask_bridge_directly &&
|
||||
!fascist_firewall_allows_address_or(&bridge->addr, bridge->port)) {
|
||||
log_notice(LD_DIR, "Bridge at '%s:%d' isn't reachable by our "
|
||||
"firewall policy. %s.", fmt_addr(&bridge->addr),
|
||||
bridge->port,
|
||||
log_notice(LD_DIR, "Bridge at '%s' isn't reachable by our "
|
||||
"firewall policy. %s.",
|
||||
fmt_addrport(&bridge->addr, bridge->port),
|
||||
can_use_bridge_authority ?
|
||||
"Asking bridge authority instead" : "Skipping");
|
||||
if (can_use_bridge_authority)
|
||||
@ -5683,8 +5683,8 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
|
||||
ri->ipv6_orport = bridge->port;
|
||||
log_info(LD_DIR,
|
||||
"Adjusted bridge routerinfo for '%s' to match configured "
|
||||
"address %s:%d.",
|
||||
ri->nickname, fmt_addr(&ri->ipv6_addr), ri->ipv6_orport);
|
||||
"address %s.",
|
||||
ri->nickname, fmt_addrport(&ri->ipv6_addr, ri->ipv6_orport));
|
||||
} else {
|
||||
log_err(LD_BUG, "Address family not supported: %d.",
|
||||
tor_addr_family(&bridge->addr));
|
||||
@ -5703,10 +5703,10 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
|
||||
node_get_pref_orport(node, &ap);
|
||||
log_notice(LD_CONFIG,
|
||||
"Bridge '%s' has both an IPv4 and an IPv6 address. "
|
||||
"Will prefer using its %s address (%s:%d).",
|
||||
"Will prefer using its %s address (%s).",
|
||||
ri->nickname,
|
||||
tor_addr_family(&ap.addr) == AF_INET6 ? "IPv6" : "IPv4",
|
||||
fmt_addr(&ap.addr), ap.port);
|
||||
fmt_addrport(&ap.addr, ap.port));
|
||||
}
|
||||
}
|
||||
if (node->rs) {
|
||||
@ -5721,8 +5721,8 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
|
||||
rs->or_port = bridge->port;
|
||||
log_info(LD_DIR,
|
||||
"Adjusted bridge routerstatus for '%s' to match "
|
||||
"configured address %s:%d.",
|
||||
rs->nickname, fmt_addr(&bridge->addr), rs->or_port);
|
||||
"configured address %s.",
|
||||
rs->nickname, fmt_addrport(&bridge->addr, rs->or_port));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3957,8 +3957,8 @@ parse_bridge_line(const char *line, int validate_only)
|
||||
}
|
||||
|
||||
if (!validate_only) {
|
||||
log_debug(LD_DIR, "Bridge at %s:%d (transport: %s) (%s)",
|
||||
fmt_addr(&addr), (int)port,
|
||||
log_debug(LD_DIR, "Bridge at %s (transport: %s) (%s)",
|
||||
fmt_addrport(&addr, port),
|
||||
transport_name ? transport_name : "no transport",
|
||||
fingerprint ? fingerprint : "no key listed");
|
||||
bridge_add_from_config(&addr, port,
|
||||
@ -4091,8 +4091,8 @@ parse_client_transport_line(const char *line, int validate_only)
|
||||
transport_add_from_config(&addr, port, smartlist_get(transport_list, 0),
|
||||
socks_ver);
|
||||
|
||||
log_info(LD_DIR, "Transport '%s' found at %s:%d",
|
||||
transports, fmt_addr(&addr), (int)port);
|
||||
log_info(LD_DIR, "Transport '%s' found at %s",
|
||||
transports, fmt_addrport(&addr, port));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4211,8 +4211,8 @@ parse_server_transport_line(const char *line, int validate_only)
|
||||
}
|
||||
|
||||
if (!validate_only) {
|
||||
log_info(LD_DIR, "Server transport '%s' at %s:%d.",
|
||||
transports, fmt_addr(&addr), (int)port);
|
||||
log_info(LD_DIR, "Server transport '%s' at %s.",
|
||||
transports, fmt_addrport(&addr, port));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4384,17 +4384,17 @@ warn_nonlocal_client_ports(const smartlist_t *ports, const char *portname)
|
||||
if (port->is_unix_addr) {
|
||||
/* Unix sockets aren't accessible over a network. */
|
||||
} else if (!tor_addr_is_internal(&port->addr, 1)) {
|
||||
log_warn(LD_CONFIG, "You specified a public address '%s:%d' for %sPort. "
|
||||
log_warn(LD_CONFIG, "You specified a public address '%s' for %sPort. "
|
||||
"Other people on the Internet might find your computer and "
|
||||
"use it as an open proxy. Please don't allow this unless you "
|
||||
"have a good reason.",
|
||||
fmt_addr(&port->addr), port->port, portname);
|
||||
fmt_addrport(&port->addr, port->port), portname);
|
||||
} else if (!tor_addr_is_loopback(&port->addr)) {
|
||||
log_notice(LD_CONFIG, "You configured a non-loopback address '%s:%d' "
|
||||
log_notice(LD_CONFIG, "You configured a non-loopback address '%s' "
|
||||
"for %sPort. This allows everybody on your local network to "
|
||||
"use your machine as a proxy. Make sure this is what you "
|
||||
"wanted.",
|
||||
fmt_addr(&port->addr), port->port, portname);
|
||||
fmt_addrport(&port->addr, port->port), portname);
|
||||
}
|
||||
} SMARTLIST_FOREACH_END(port);
|
||||
}
|
||||
|
@ -916,8 +916,8 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
||||
|
||||
tor_addr_from_sockaddr(&addr, listensockaddr, &usePort);
|
||||
|
||||
log_notice(LD_NET, "Opening %s on %s:%d",
|
||||
conn_type_to_string(type), fmt_addr(&addr), usePort);
|
||||
log_notice(LD_NET, "Opening %s on %s",
|
||||
conn_type_to_string(type), fmt_addrport(&addr, usePort));
|
||||
|
||||
s = tor_open_socket(tor_addr_family(&addr),
|
||||
is_tcp ? SOCK_STREAM : SOCK_DGRAM,
|
||||
@ -1232,7 +1232,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
|
||||
if (socks_policy_permits_address(&addr) == 0) {
|
||||
log_notice(LD_APP,
|
||||
"Denying socks connection from untrusted address %s.",
|
||||
fmt_addr(&addr));
|
||||
fmt_and_decorate_addr(&addr));
|
||||
tor_close_socket(news);
|
||||
return 0;
|
||||
}
|
||||
@ -1241,7 +1241,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
|
||||
/* check dirpolicy to see if we should accept it */
|
||||
if (dir_policy_permits_address(&addr) == 0) {
|
||||
log_notice(LD_DIRSERV,"Denying dir connection from address %s.",
|
||||
fmt_addr(&addr));
|
||||
fmt_and_decorate_addr(&addr));
|
||||
tor_close_socket(news);
|
||||
return 0;
|
||||
}
|
||||
@ -1414,12 +1414,12 @@ connection_connect(connection_t *conn, const char *address,
|
||||
if (ext_addr_len == 0) {
|
||||
log_warn(LD_NET,
|
||||
"Error converting OutboundBindAddress %s into sockaddr. "
|
||||
"Ignoring.", fmt_addr(ext_addr));
|
||||
"Ignoring.", fmt_and_decorate_addr(ext_addr));
|
||||
} else {
|
||||
if (bind(s, (struct sockaddr *) &ext_addr_sa, ext_addr_len) < 0) {
|
||||
*socket_error = tor_socket_errno(s);
|
||||
log_warn(LD_NET,"Error binding network socket to %s: %s",
|
||||
fmt_addr(ext_addr),
|
||||
fmt_and_decorate_addr(ext_addr),
|
||||
tor_socket_strerror(*socket_error));
|
||||
tor_close_socket(s);
|
||||
return -1;
|
||||
@ -1530,17 +1530,17 @@ connection_proxy_connect(connection_t *conn, int type)
|
||||
}
|
||||
|
||||
if (base64_authenticator) {
|
||||
const char *addr = fmt_addr(&conn->addr);
|
||||
tor_snprintf(buf, sizeof(buf), "CONNECT %s:%d HTTP/1.1\r\n"
|
||||
"Host: %s:%d\r\n"
|
||||
const char *addrport = fmt_addrport(&conn->addr, conn->port);
|
||||
tor_snprintf(buf, sizeof(buf), "CONNECT %s HTTP/1.1\r\n"
|
||||
"Host: %s\r\n"
|
||||
"Proxy-Authorization: Basic %s\r\n\r\n",
|
||||
addr, conn->port,
|
||||
addr, conn->port,
|
||||
addrport,
|
||||
addrport,
|
||||
base64_authenticator);
|
||||
tor_free(base64_authenticator);
|
||||
} else {
|
||||
tor_snprintf(buf, sizeof(buf), "CONNECT %s:%d HTTP/1.0\r\n\r\n",
|
||||
fmt_addr(&conn->addr), conn->port);
|
||||
tor_snprintf(buf, sizeof(buf), "CONNECT %s HTTP/1.0\r\n\r\n",
|
||||
fmt_addrport(&conn->addr, conn->port));
|
||||
}
|
||||
|
||||
connection_write_to_buf(buf, strlen(buf), conn);
|
||||
@ -4272,10 +4272,10 @@ log_failed_proxy_connection(connection_t *conn)
|
||||
return; /* if we have no proxy set up, leave this function. */
|
||||
|
||||
log_warn(LD_NET,
|
||||
"The connection to the %s proxy server at %s:%u just failed. "
|
||||
"The connection to the %s proxy server at %s just failed. "
|
||||
"Make sure that the proxy server is up and running.",
|
||||
proxy_type_to_string(get_proxy_type()), fmt_addr(&proxy_addr),
|
||||
proxy_port);
|
||||
proxy_type_to_string(get_proxy_type()),
|
||||
fmt_addrport(&proxy_addr, proxy_port));
|
||||
}
|
||||
|
||||
/** Return string representation of <b>proxy_type</b>. */
|
||||
|
@ -407,7 +407,7 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn)
|
||||
|
||||
log_info(LD_EXIT,"Exit connection to %s:%u (%s) established.",
|
||||
escaped_safe_str(conn->address), conn->port,
|
||||
safe_str(fmt_addr(&conn->addr)));
|
||||
safe_str(fmt_and_decorate_addr(&conn->addr)));
|
||||
|
||||
rep_hist_note_exit_stream_opened(conn->port);
|
||||
|
||||
|
@ -1086,17 +1086,17 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
|
||||
TO_CONN(conn)->port);
|
||||
|
||||
if (transport_name) {
|
||||
log_warn(LD_GENERAL, "We were supposed to connect to bridge '%s:%u' "
|
||||
log_warn(LD_GENERAL, "We were supposed to connect to bridge '%s' "
|
||||
"using pluggable transport '%s', but we can't find a pluggable "
|
||||
"transport proxy supporting '%s'. This can happen if you "
|
||||
"haven't provided a ClientTransportPlugin line, or if "
|
||||
"your pluggable transport proxy stopped running.",
|
||||
fmt_addr(&TO_CONN(conn)->addr), TO_CONN(conn)->port,
|
||||
fmt_addrport(&TO_CONN(conn)->addr, TO_CONN(conn)->port),
|
||||
transport_name, transport_name);
|
||||
} else {
|
||||
log_warn(LD_GENERAL, "Tried to connect to '%s:%u' through a proxy, but "
|
||||
log_warn(LD_GENERAL, "Tried to connect to '%s' through a proxy, but "
|
||||
"the proxy address could not be found.",
|
||||
fmt_addr(&TO_CONN(conn)->addr), TO_CONN(conn)->port);
|
||||
fmt_addrport(&TO_CONN(conn)->addr, TO_CONN(conn)->port));
|
||||
}
|
||||
|
||||
connection_free(TO_CONN(conn));
|
||||
|
@ -2118,11 +2118,9 @@ routerstatus_format_entry(char *buf, size_t buf_len,
|
||||
|
||||
/* Possible "a" line. At most one for now. */
|
||||
if (!tor_addr_is_null(&rs->ipv6_addr)) {
|
||||
const char *addr_str = fmt_and_decorate_addr(&rs->ipv6_addr);
|
||||
r = tor_snprintf(cp, buf_len - (cp-buf),
|
||||
"a %s:%d\n",
|
||||
addr_str,
|
||||
(int)rs->ipv6_orport);
|
||||
"a %s\n",
|
||||
fmt_addrport(&rs->ipv6_addr, rs->ipv6_orport));
|
||||
if (r<0) {
|
||||
log_warn(LD_BUG, "Not enough space in buffer.");
|
||||
return -1;
|
||||
|
@ -489,10 +489,9 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
|
||||
_compare_orports);
|
||||
if (most_alt_orport) {
|
||||
memcpy(best_alt_orport_out, most_alt_orport, sizeof(tor_addr_port_t));
|
||||
log_debug(LD_DIR, "\"a\" line winner for %s is %s:%d",
|
||||
log_debug(LD_DIR, "\"a\" line winner for %s is %s",
|
||||
most->status.nickname,
|
||||
fmt_and_decorate_addr(&most_alt_orport->addr),
|
||||
most_alt_orport->port);
|
||||
fmt_addrport(&most_alt_orport->addr, most_alt_orport->port));
|
||||
}
|
||||
|
||||
SMARTLIST_FOREACH(alt_orports, tor_addr_port_t *, ap, tor_free(ap));
|
||||
@ -3561,9 +3560,8 @@ dirvote_create_microdescriptor(const routerinfo_t *ri, int consensus_method)
|
||||
|
||||
if (consensus_method >= MIN_METHOD_FOR_A_LINES &&
|
||||
!tor_addr_is_null(&ri->ipv6_addr) && ri->ipv6_orport)
|
||||
smartlist_add_asprintf(chunks, "a %s:%d\n",
|
||||
fmt_and_decorate_addr(&ri->ipv6_addr),
|
||||
ri->ipv6_orport);
|
||||
smartlist_add_asprintf(chunks, "a %s\n",
|
||||
fmt_addrport(&ri->ipv6_addr, ri->ipv6_orport));
|
||||
|
||||
if (family)
|
||||
smartlist_add_asprintf(chunks, "family %s\n", family);
|
||||
|
@ -272,8 +272,8 @@ rend_add_service(rend_service_t *service)
|
||||
service->directory);
|
||||
for (i = 0; i < smartlist_len(service->ports); ++i) {
|
||||
p = smartlist_get(service->ports, i);
|
||||
log_debug(LD_REND,"Service maps port %d to %s:%d",
|
||||
p->virtual_port, fmt_addr(&p->real_addr), p->real_port);
|
||||
log_debug(LD_REND,"Service maps port %d to %s",
|
||||
p->virtual_port, fmt_addrport(&p->real_addr, p->real_port));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ save_transport_to_state(const char *transport,
|
||||
if (transport_line) { /* if transport already exists in state... */
|
||||
const char *prev_bindaddr = /* get its addrport... */
|
||||
get_transport_bindaddr(transport_line->value, transport);
|
||||
tor_asprintf(&transport_addrport, "%s:%d", fmt_addr(addr), (int)port);
|
||||
transport_addrport = tor_strdup(fmt_addrport(addr, port));
|
||||
|
||||
/* if transport in state has the same address as this one, life is good */
|
||||
if (!strcmp(prev_bindaddr, transport_addrport)) {
|
||||
@ -565,9 +565,9 @@ save_transport_to_state(const char *transport,
|
||||
"address:port. Let's update the state file with the new "
|
||||
"address:port");
|
||||
tor_free(transport_line->value); /* free the old line */
|
||||
tor_asprintf(&transport_line->value, "%s %s:%d", transport,
|
||||
fmt_addr(addr),
|
||||
(int) port); /* replace old addrport line with new line */
|
||||
/* replace old addrport line with new line */
|
||||
tor_asprintf(&transport_line->value, "%s %s", transport,
|
||||
fmt_addrport(addr, port));
|
||||
}
|
||||
} else { /* never seen this one before; save it in state for next time */
|
||||
log_info(LD_CONFIG, "It's the first time we see this transport. "
|
||||
@ -584,8 +584,7 @@ save_transport_to_state(const char *transport,
|
||||
/* allocate space for the new line and fill it in */
|
||||
*next = line = tor_malloc_zero(sizeof(config_line_t));
|
||||
line->key = tor_strdup("TransportProxy");
|
||||
tor_asprintf(&line->value, "%s %s:%d", transport,
|
||||
fmt_addr(addr), (int) port);
|
||||
tor_asprintf(&line->value, "%s %s", transport, fmt_addrport(addr, port));
|
||||
|
||||
next = &(line->next);
|
||||
}
|
||||
|
@ -270,24 +270,26 @@ transport_resolve_conflicts(const transport_t *t)
|
||||
t_tmp->marked_for_removal = 0;
|
||||
return 1;
|
||||
} else { /* same name but different addrport */
|
||||
char *new_transport_addr = tor_strdup(fmt_addr(&t->addr));
|
||||
char *new_transport_addrport =
|
||||
tor_strdup(fmt_addrport(&t->addr, t->port));
|
||||
if (t_tmp->marked_for_removal) { /* marked for removal */
|
||||
log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
|
||||
log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s' "
|
||||
"but there was already a transport marked for deletion at "
|
||||
"'%s:%u'. We deleted the old transport and registered the "
|
||||
"new one.", t->name, new_transport_addr, t->port,
|
||||
fmt_addr(&t_tmp->addr), t_tmp->port);
|
||||
"'%s'. We deleted the old transport and registered the "
|
||||
"new one.", t->name, new_transport_addrport,
|
||||
fmt_addrport(&t_tmp->addr, t_tmp->port));
|
||||
smartlist_remove(transport_list, t_tmp);
|
||||
transport_free(t_tmp);
|
||||
tor_free(new_transport_addr);
|
||||
tor_free(new_transport_addrport);
|
||||
} else { /* *not* marked for removal */
|
||||
log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
|
||||
"but the same transport already exists at '%s:%u'. "
|
||||
"Skipping.", t->name, new_transport_addr, t->port,
|
||||
fmt_addr(&t_tmp->addr), t_tmp->port);
|
||||
tor_free(new_transport_addr);
|
||||
log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s' "
|
||||
"but the same transport already exists at '%s'. "
|
||||
"Skipping.", t->name, new_transport_addrport,
|
||||
fmt_addrport(&t_tmp->addr, t_tmp->port));
|
||||
tor_free(new_transport_addrport);
|
||||
return -1;
|
||||
}
|
||||
tor_free(new_transport_addrport);
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,18 +334,18 @@ transport_add_from_config(const tor_addr_t *addr, uint16_t port,
|
||||
switch (r) {
|
||||
case -1:
|
||||
default:
|
||||
log_notice(LD_GENERAL, "Could not add transport %s at %s:%u. Skipping.",
|
||||
t->name, fmt_addr(&t->addr), t->port);
|
||||
log_notice(LD_GENERAL, "Could not add transport %s at %s. Skipping.",
|
||||
t->name, fmt_addrport(&t->addr, t->port));
|
||||
transport_free(t);
|
||||
return -1;
|
||||
case 1:
|
||||
log_info(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
|
||||
t->name, fmt_addr(&t->addr), t->port);
|
||||
log_info(LD_GENERAL, "Succesfully registered transport %s at %s.",
|
||||
t->name, fmt_addrport(&t->addr, t->port));
|
||||
transport_free(t); /* falling */
|
||||
return 0;
|
||||
case 0:
|
||||
log_info(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
|
||||
t->name, fmt_addr(&t->addr), t->port);
|
||||
log_info(LD_GENERAL, "Succesfully registered transport %s at %s.",
|
||||
t->name, fmt_addrport(&t->addr, t->port));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -644,8 +646,8 @@ register_server_proxy(const managed_proxy_t *mp)
|
||||
|
||||
SMARTLIST_FOREACH_BEGIN(mp->transports, transport_t *, t) {
|
||||
save_transport_to_state(t->name, &t->addr, t->port);
|
||||
log_notice(LD_GENERAL, "Registered server transport '%s' at '%s:%d'",
|
||||
t->name, fmt_addr(&t->addr), (int)t->port);
|
||||
log_notice(LD_GENERAL, "Registered server transport '%s' at '%s'",
|
||||
t->name, fmt_addrport(&t->addr, t->port));
|
||||
} SMARTLIST_FOREACH_END(t);
|
||||
}
|
||||
|
||||
@ -1382,19 +1384,21 @@ pt_get_extra_info_descriptor_string(void)
|
||||
/* If the transport proxy returned "0.0.0.0" as its address, and
|
||||
* we know our external IP address, use it. Otherwise, use the
|
||||
* returned address. */
|
||||
const char *addr_str = fmt_addr(&t->addr);
|
||||
const char *addrport = NULL;
|
||||
uint32_t external_ip_address = 0;
|
||||
if (tor_addr_is_null(&t->addr) &&
|
||||
router_pick_published_address(get_options(),
|
||||
&external_ip_address) >= 0) {
|
||||
/* returned addr was 0.0.0.0 and we found our external IP
|
||||
address: use it. */
|
||||
addr_str = fmt_addr32(external_ip_address);
|
||||
tor_addr_t addr;
|
||||
tor_addr_from_ipv4h(&addr, external_ip_address);
|
||||
addrport = fmt_addrport(&addr, t->port);
|
||||
} else {
|
||||
addrport = fmt_addrport(&t->addr, t->port);
|
||||
}
|
||||
|
||||
smartlist_add_asprintf(string_chunks,
|
||||
"transport %s %s:%u",
|
||||
t->name, addr_str, t->port);
|
||||
"transport %s %s",
|
||||
t->name, addrport);
|
||||
} SMARTLIST_FOREACH_END(t);
|
||||
|
||||
} SMARTLIST_FOREACH_END(mp);
|
||||
|
Loading…
Reference in New Issue
Block a user