[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8359: start remembering X-Your-Address-Is hints even if you're a c (tor/trunk/src/or)



Author: arma
Date: 2006-09-09 15:36:51 -0400 (Sat, 09 Sep 2006)
New Revision: 8359

Modified:
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/router.c
Log:
start remembering X-Your-Address-Is hints even if you're
a client, so you can become a server more smoothly.


Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2006-09-09 19:20:27 UTC (rev 8358)
+++ tor/trunk/src/or/directory.c	2006-09-09 19:36:51 UTC (rev 8359)
@@ -822,6 +822,7 @@
   int skewed=0;
   int allow_partial = conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC;
   int was_compressed=0;
+  char *guess;
 
   switch (fetch_from_buf_http(conn->_base.inbuf,
                               &headers, MAX_HEADERS_SIZE,
@@ -855,12 +856,10 @@
             escaped(reason));
 
   /* now check if it's got any hints for us about our IP address. */
-  if (server_mode(get_options())) {
-    char *guess = http_get_header(headers, X_ADDRESS_HEADER);
-    if (guess) {
-      router_new_address_suggestion(guess);
-      tor_free(guess);
-    }
+  guess = http_get_header(headers, X_ADDRESS_HEADER);
+  if (guess) {
+    router_new_address_suggestion(guess);
+    tor_free(guess);
   }
 
   if (date_header > 0) {

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2006-09-09 19:20:27 UTC (rev 8358)
+++ tor/trunk/src/or/router.c	2006-09-09 19:36:51 UTC (rev 8359)
@@ -970,6 +970,7 @@
 {
   uint32_t addr, cur;
   struct in_addr in;
+  or_options_t *options = get_options();
 
   /* first, learn what the IP address actually is */
   if (!tor_inet_aton(suggestion, &in)) {
@@ -980,7 +981,8 @@
 
   log_debug(LD_DIR, "Got X-Your-Address-Is: %s.", suggestion);
 
-  if (resolve_my_address(LOG_INFO, get_options(), &cur, NULL) >= 0) {
+  if (!server_mode(options) ||
+      resolve_my_address(LOG_INFO, options, &cur, NULL) >= 0) {
     /* We're all set -- we already know our address. Great. */
     last_guessed_ip = cur; /* store it in case we need it later */
     return;