]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Remove duplicate code that checks for default authorities
authorNick Mathewson <nickm@torproject.org>
Thu, 13 Oct 2016 13:16:40 +0000 (09:16 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 13 Oct 2016 13:19:37 +0000 (09:19 -0400)
Patch from ericho.

Fixes 18529. Simple refactoring.

src/or/config.c
src/or/config.h
src/or/router.c

index 93e753bb49c00da9ccf16e881d219fba9e4ad35c..bef81ab812271431c3a97578c1be7de8443c1436 100644 (file)
@@ -2471,7 +2471,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,
index 208659acb71ace01dc3ab908c026e016245b6d88..1b40efc5ecb556e563b46a27e3a23f9092964b3c 100644 (file)
@@ -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);
@@ -147,6 +149,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)
index b93b7c1a1349528f59e369b9fb02d45a75e5dcfd..287bc1691e934eceafb543a67c7a5dd43c45c0b2 100644 (file)
@@ -2093,8 +2093,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;