]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Using proper functions to create tor_addr_t.
authorrl1987 <rl1987@sdf.lonestar.org>
Wed, 20 Nov 2013 19:49:17 +0000 (21:49 +0200)
committerNick Mathewson <nickm@torproject.org>
Mon, 3 Feb 2014 19:20:24 +0000 (14:20 -0500)
src/or/config.c
src/or/directory.c
src/or/dirserv.c

index f840b5e287fec86443e205f73eeda36d73799228..a90468dfa77233d7037146ec3a372bbf252653c9 100644 (file)
@@ -2104,8 +2104,7 @@ resolve_my_address(int warn_severity, const or_options_t *options,
              "local interface. Using that.", fmt_addr32(addr));
       strlcpy(hostname, "<guessed from interfaces>", sizeof(hostname));
     } else { /* resolved hostname into addr */
-      myaddr.family = AF_INET;
-      myaddr.addr.in_addr.s_addr = htonl(addr);
+      tor_addr_from_ipv4h(&myaddr, addr);
 
       if (!explicit_hostname &&
           tor_addr_is_internal(&myaddr, 0)) {
@@ -2142,8 +2141,7 @@ resolve_my_address(int warn_severity, const or_options_t *options,
    * out if it is and we don't want that.
    */
 
-  myaddr.family = AF_INET;
-  myaddr.addr.in_addr.s_addr = htonl(addr);
+  tor_addr_from_ipv4h(&myaddr,addr);
 
   addr_string = tor_dup_ip(addr);
   if (tor_addr_is_internal(&myaddr, 0)) {
index 7f26affa20044860063c20bd94ffdf4c2e02f443..6effe45db402741bfc9a31d2ab4aed9fe45ecc64 100644 (file)
@@ -1414,20 +1414,11 @@ http_set_address_origin(const char *headers, connection_t *conn)
   if (!fwd)
     fwd = http_get_header(headers, "X-Forwarded-For: ");
   if (fwd) {
-    struct in_addr in;
-    if (!tor_inet_aton(fwd, &in)) {
-      log_debug(LD_DIR, "Ignoring unrecognized IP %s",
-                escaped(fwd));
-      tor_free(fwd);
-      return;
-    }
-
     tor_addr_t toraddr;
-    toraddr.family = AF_INET;
-    toraddr.addr.in_addr = in;
+    tor_addr_parse(&toraddr,fwd);
 
     if (tor_addr_is_internal(&toraddr,0)) {
-      log_debug(LD_DIR, "Ignoring local IP %s", escaped(fwd));
+      log_debug(LD_DIR, "Ignoring local/internal IP %s", escaped(fwd));
       tor_free(fwd);
       return;
     }
index 4a25f99a49be5d45c136cb41ecbcd1b150a766c2..b6bb607fa94ff9e4e5271135abc17958c91d0e50 100644 (file)
@@ -535,8 +535,7 @@ dirserv_router_has_valid_address(routerinfo_t *ri)
   }
 
   tor_addr_t toraddr;
-  toraddr.family = AF_INET;
-  toraddr.addr.in_addr = iaddr;
+  tor_addr_from_in(&toraddr,&iaddr);
 
   if (tor_addr_is_internal(&toraddr, 0)) {
     log_info(LD_DIRSERV,