Loading changes/bug32588 0 → 100644 +4 −0 Original line number Diff line number Diff line o Minor bugfixes (relays): - Stop advertising incorrect IPv6 ORPorts in relay and bridge descriptors, when the IPv6 port was configured as "auto". Fixes bug 32588; bugfix on 0.2.3.9-alpha src/app/config/config.c +1 −4 Original line number Diff line number Diff line Loading @@ -825,9 +825,6 @@ static char *get_windows_conf_root(void); static int options_check_transition_cb(const void *old, const void *new, char **msg); static int parse_ports(or_options_t *options, int validate_only, char **msg_out, int *n_ports_out, int *world_writable_control_socket); static int validate_data_directories(or_options_t *options); static int write_configuration_file(const char *fname, const or_options_t *options); Loading Loading @@ -6563,7 +6560,7 @@ port_count_real_listeners(const smartlist_t *ports, int listenertype, * If <b>validate_only</b> is false, set configured_client_ports to the * new list of ports parsed from <b>options</b>. **/ static int STATIC int parse_ports(or_options_t *options, int validate_only, char **msg, int *n_ports_out, int *world_writable_control_socket) Loading src/app/config/config.h +4 −0 Original line number Diff line number Diff line Loading @@ -319,6 +319,10 @@ int options_validate(const or_options_t *old_options, char **msg); #endif STATIC int parse_ports(or_options_t *options, int validate_only, char **msg, int *n_ports_out, int *world_writable_control_socket); #endif /* defined(CONFIG_PRIVATE) */ #endif /* !defined(TOR_CONFIG_H) */ src/feature/relay/router.c +49 −28 Original line number Diff line number Diff line Loading @@ -1446,6 +1446,50 @@ router_get_advertised_or_port_by_af(const or_options_t *options, return port; } /** As router_get_advertised_or_port(), but returns the IPv6 address and * port in ipv6_ap_out, which must not be NULL. Returns a null address and * zero port, if no ORPort is found. */ void router_get_advertised_ipv6_or_ap(const or_options_t *options, tor_addr_port_t *ipv6_ap_out) { /* Bug in calling function, we can't return a sensible result, and it * shouldn't use the NULL pointer once we return. */ tor_assert(ipv6_ap_out); /* If there is no valid IPv6 ORPort, return a null address and port. */ tor_addr_make_null(&ipv6_ap_out->addr, AF_INET6); ipv6_ap_out->port = 0; const tor_addr_t *addr = get_first_advertised_addr_by_type_af( CONN_TYPE_OR_LISTENER, AF_INET6); const uint16_t port = router_get_advertised_or_port_by_af( options, AF_INET6); if (!addr || port == 0) { log_info(LD_CONFIG, "There is no advertised IPv6 ORPort."); return; } /* If the relay is configured using the default authorities, disallow * internal IPs. Otherwise, allow them. For IPv4 ORPorts and DirPorts, * this check is done in resolve_my_address(). See #33681. */ const int default_auth = using_default_dir_authorities(options); if (tor_addr_is_internal(addr, 0) && default_auth) { log_warn(LD_CONFIG, "Unable to use configured IPv6 ORPort \"%s\" in a " "descriptor. Skipping it. " "Try specifying a globally reachable address explicitly.", fmt_addrport(addr, port)); return; } tor_addr_copy(&ipv6_ap_out->addr, addr); ipv6_ap_out->port = port; } /** Return the port that we should advertise as our DirPort; * this is one of three possibilities: * The one that is passed as <b>dirport</b> if the DirPort option is 0, or Loading Loading @@ -1990,34 +2034,11 @@ router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out)) sizeof(curve25519_public_key_t)); /* For now, at most one IPv6 or-address is being advertised. */ { const port_cfg_t *ipv6_orport = NULL; SMARTLIST_FOREACH_BEGIN(get_configured_ports(), const port_cfg_t *, p) { if (p->type == CONN_TYPE_OR_LISTENER && ! p->server_cfg.no_advertise && ! p->server_cfg.bind_ipv4_only && tor_addr_family(&p->addr) == AF_INET6) { /* Like IPv4, if the relay is configured using the default * authorities, disallow internal IPs. Otherwise, allow them. */ const int default_auth = using_default_dir_authorities(options); if (! tor_addr_is_internal(&p->addr, 0) || ! default_auth) { ipv6_orport = p; break; } else { char addrbuf[TOR_ADDR_BUF_LEN]; log_warn(LD_CONFIG, "Unable to use configured IPv6 address \"%s\" in a " "descriptor. Skipping it. " "Try specifying a globally reachable address explicitly.", tor_addr_to_str(addrbuf, &p->addr, sizeof(addrbuf), 1)); } } } SMARTLIST_FOREACH_END(p); if (ipv6_orport) { tor_addr_copy(&ri->ipv6_addr, &ipv6_orport->addr); ri->ipv6_orport = ipv6_orport->port; } } tor_addr_port_t ipv6_orport; router_get_advertised_ipv6_or_ap(options, &ipv6_orport); /* If there is no valud IPv6 ORPort, the address and port are null. */ tor_addr_copy(&ri->ipv6_addr, &ipv6_orport.addr); ri->ipv6_orport = ipv6_orport.port; ri->identity_pkey = crypto_pk_dup_key(get_server_identity_key()); if (BUG(crypto_pk_get_digest(ri->identity_pkey, Loading src/feature/relay/router.h +2 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ int init_keys_client(void); uint16_t router_get_active_listener_port_by_type_af(int listener_type, sa_family_t family); uint16_t router_get_advertised_or_port(const or_options_t *options); void router_get_advertised_ipv6_or_ap(const or_options_t *options, tor_addr_port_t *ipv6_ap_out); uint16_t router_get_advertised_or_port_by_af(const or_options_t *options, sa_family_t family); uint16_t router_get_advertised_dir_port(const or_options_t *options, Loading Loading
changes/bug32588 0 → 100644 +4 −0 Original line number Diff line number Diff line o Minor bugfixes (relays): - Stop advertising incorrect IPv6 ORPorts in relay and bridge descriptors, when the IPv6 port was configured as "auto". Fixes bug 32588; bugfix on 0.2.3.9-alpha
src/app/config/config.c +1 −4 Original line number Diff line number Diff line Loading @@ -825,9 +825,6 @@ static char *get_windows_conf_root(void); static int options_check_transition_cb(const void *old, const void *new, char **msg); static int parse_ports(or_options_t *options, int validate_only, char **msg_out, int *n_ports_out, int *world_writable_control_socket); static int validate_data_directories(or_options_t *options); static int write_configuration_file(const char *fname, const or_options_t *options); Loading Loading @@ -6563,7 +6560,7 @@ port_count_real_listeners(const smartlist_t *ports, int listenertype, * If <b>validate_only</b> is false, set configured_client_ports to the * new list of ports parsed from <b>options</b>. **/ static int STATIC int parse_ports(or_options_t *options, int validate_only, char **msg, int *n_ports_out, int *world_writable_control_socket) Loading
src/app/config/config.h +4 −0 Original line number Diff line number Diff line Loading @@ -319,6 +319,10 @@ int options_validate(const or_options_t *old_options, char **msg); #endif STATIC int parse_ports(or_options_t *options, int validate_only, char **msg, int *n_ports_out, int *world_writable_control_socket); #endif /* defined(CONFIG_PRIVATE) */ #endif /* !defined(TOR_CONFIG_H) */
src/feature/relay/router.c +49 −28 Original line number Diff line number Diff line Loading @@ -1446,6 +1446,50 @@ router_get_advertised_or_port_by_af(const or_options_t *options, return port; } /** As router_get_advertised_or_port(), but returns the IPv6 address and * port in ipv6_ap_out, which must not be NULL. Returns a null address and * zero port, if no ORPort is found. */ void router_get_advertised_ipv6_or_ap(const or_options_t *options, tor_addr_port_t *ipv6_ap_out) { /* Bug in calling function, we can't return a sensible result, and it * shouldn't use the NULL pointer once we return. */ tor_assert(ipv6_ap_out); /* If there is no valid IPv6 ORPort, return a null address and port. */ tor_addr_make_null(&ipv6_ap_out->addr, AF_INET6); ipv6_ap_out->port = 0; const tor_addr_t *addr = get_first_advertised_addr_by_type_af( CONN_TYPE_OR_LISTENER, AF_INET6); const uint16_t port = router_get_advertised_or_port_by_af( options, AF_INET6); if (!addr || port == 0) { log_info(LD_CONFIG, "There is no advertised IPv6 ORPort."); return; } /* If the relay is configured using the default authorities, disallow * internal IPs. Otherwise, allow them. For IPv4 ORPorts and DirPorts, * this check is done in resolve_my_address(). See #33681. */ const int default_auth = using_default_dir_authorities(options); if (tor_addr_is_internal(addr, 0) && default_auth) { log_warn(LD_CONFIG, "Unable to use configured IPv6 ORPort \"%s\" in a " "descriptor. Skipping it. " "Try specifying a globally reachable address explicitly.", fmt_addrport(addr, port)); return; } tor_addr_copy(&ipv6_ap_out->addr, addr); ipv6_ap_out->port = port; } /** Return the port that we should advertise as our DirPort; * this is one of three possibilities: * The one that is passed as <b>dirport</b> if the DirPort option is 0, or Loading Loading @@ -1990,34 +2034,11 @@ router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out)) sizeof(curve25519_public_key_t)); /* For now, at most one IPv6 or-address is being advertised. */ { const port_cfg_t *ipv6_orport = NULL; SMARTLIST_FOREACH_BEGIN(get_configured_ports(), const port_cfg_t *, p) { if (p->type == CONN_TYPE_OR_LISTENER && ! p->server_cfg.no_advertise && ! p->server_cfg.bind_ipv4_only && tor_addr_family(&p->addr) == AF_INET6) { /* Like IPv4, if the relay is configured using the default * authorities, disallow internal IPs. Otherwise, allow them. */ const int default_auth = using_default_dir_authorities(options); if (! tor_addr_is_internal(&p->addr, 0) || ! default_auth) { ipv6_orport = p; break; } else { char addrbuf[TOR_ADDR_BUF_LEN]; log_warn(LD_CONFIG, "Unable to use configured IPv6 address \"%s\" in a " "descriptor. Skipping it. " "Try specifying a globally reachable address explicitly.", tor_addr_to_str(addrbuf, &p->addr, sizeof(addrbuf), 1)); } } } SMARTLIST_FOREACH_END(p); if (ipv6_orport) { tor_addr_copy(&ri->ipv6_addr, &ipv6_orport->addr); ri->ipv6_orport = ipv6_orport->port; } } tor_addr_port_t ipv6_orport; router_get_advertised_ipv6_or_ap(options, &ipv6_orport); /* If there is no valud IPv6 ORPort, the address and port are null. */ tor_addr_copy(&ri->ipv6_addr, &ipv6_orport.addr); ri->ipv6_orport = ipv6_orport.port; ri->identity_pkey = crypto_pk_dup_key(get_server_identity_key()); if (BUG(crypto_pk_get_digest(ri->identity_pkey, Loading
src/feature/relay/router.h +2 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ int init_keys_client(void); uint16_t router_get_active_listener_port_by_type_af(int listener_type, sa_family_t family); uint16_t router_get_advertised_or_port(const or_options_t *options); void router_get_advertised_ipv6_or_ap(const or_options_t *options, tor_addr_port_t *ipv6_ap_out); uint16_t router_get_advertised_or_port_by_af(const or_options_t *options, sa_family_t family); uint16_t router_get_advertised_dir_port(const or_options_t *options, Loading