Skip to content

Instantly share code, notes, and snippets.

@ericho
Last active July 3, 2016 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericho/992b6ffed459eb06f0bc932f68a48761 to your computer and use it in GitHub Desktop.
Save ericho/992b6ffed459eb06f0bc932f68a48761 to your computer and use it in GitHub Desktop.
Fix for #18529
diff --git a/src/or/config.c b/src/or/config.c
index 754b0af..1487b57 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2387,7 +2387,7 @@ resolve_my_address(int warn_severity, const or_options_t *options,
addr_string = tor_dup_ip(addr);
if (tor_addr_is_internal(&myaddr, 0)) {
/* make sure we're ok with publishing an internal IP */
- if (!options->DirAuthorities && !options->AlternateDirAuthority) {
+ if (is_default_dir_authorities(options)) {
/* if they are using the default authorities, disallow internal IPs
* always. */
log_fn(warn_severity, LD_CONFIG,
diff --git a/src/or/config.h b/src/or/config.h
index a0fe6e4..7bcae69 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -76,6 +76,8 @@ MOCK_DECL(char *,
#define get_datadir_fname_suffix(sub1, suffix) \
get_datadir_fname2_suffix((sub1), NULL, (suffix))
+inline int is_default_dir_authorities(const or_options_t *options);
+
int check_or_create_data_subdir(const char *subdir);
int write_to_data_subdir(const char* subdir, const char* fname,
const char* str, const char* descr);
@@ -141,6 +143,14 @@ smartlist_t *get_options_from_transport_options_line(const char *line,
const char *transport);
smartlist_t *get_options_for_server_transport(const char *transport);
+/* Check if we are using default authorities */
+inline int
+is_default_dir_authorities(const or_options_t *options)
+{
+ return (!options->DirAuthorities &&
+ !options->AlternateDirAuthority) ? 1 : 0;
+}
+
#ifdef CONFIG_PRIVATE
#define CL_PORT_NO_STREAM_OPTIONS (1u<<0)
diff --git a/src/or/router.c b/src/or/router.c
index a671591..5254078 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2008,8 +2008,7 @@ router_build_fresh_descriptor(routerinfo_t **r, extrainfo_t **e)
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 = (!options->DirAuthorities &&
- !options->AlternateDirAuthority);
+ const int default_auth = is_default_dir_authorities(options);
if (! tor_addr_is_internal(&p->addr, 0) || ! default_auth) {
ipv6_orport = p;
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment