[tor-commits] [tor/master] Merge branch 'resolvemyaddr_squashed'

nickm at torproject.org nickm at torproject.org
Mon Dec 29 15:02:16 UTC 2014


commit e85f0c650c0509ceff777d0a7fafd6c953604ad8
Merge: 4d6a971 de432d5
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Dec 29 10:00:34 2014 -0500

    Merge branch 'resolvemyaddr_squashed'

 changes/resolvemyaddr-tests |    3 +
 src/common/address.c        |    8 +-
 src/common/address.h        |    5 +-
 src/common/compat.c         |   22 +-
 src/common/compat.h         |    3 +-
 src/common/testsupport.h    |    4 +-
 src/or/config.c             |   36 ++-
 src/test/test_config.c      |  589 +++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 654 insertions(+), 16 deletions(-)

diff --cc src/or/config.c
index e7891a5,e0a2460..ae4b089
--- a/src/or/config.c
+++ b/src/or/config.c
@@@ -2078,15 -2051,34 +2079,41 @@@ get_last_resolved_addr(void
    return last_resolved_addr;
  }
  
 +/** Reset last_resolved_addr from outside this file. */
 +void
 +reset_last_resolved_addr(void)
 +{
 +  last_resolved_addr = 0;
 +}
 +
  /**
-  * Use <b>options-\>Address</b> to guess our public IP address.
+  * Attempt getting our non-local (as judged by tor_addr_is_internal()
+  * function) IP address using following techniques, listed in
+  * order from best (most desirable, try first) to worst (least
+  * desirable, try if everything else fails).
+  *
+  * First, attempt using <b>options-\>Address</b> to get our
+  * non-local IP address.
+  *
+  * If <b>options-\>Address</b> represents a non-local IP address,
+  * consider it ours.
+  *
+  * If <b>options-\>Address</b> is a DNS name that resolves to
+  * a non-local IP address, consider this IP address ours.
+  *
+  * If <b>options-\>Address</b> is NULL, fall back to getting local
+  * hostname and using it in above-described ways to try and
+  * get our IP address.
+  *
+  * In case local hostname cannot be resolved to a non-local IP
+  * address, try getting an IP address of network interface
+  * in hopes it will be non-local one.
+  *
+  * Fail if one or more of the following is true:
+  *   - DNS name in <b>options-\>Address</b> cannot be resolved.
+  *   - <b>options-\>Address</b> is a local host address.
+  *   - Attempt to getting local hostname fails.
+  *   - Attempt to getting network interface address fails.
   *
   * Return 0 if all is well, or -1 if we can't find a suitable
   * public IP address.



More information about the tor-commits mailing list