Przeglądaj źródła

all listeners listen on 0.0.0.0 except AP which listens on 127.0.0.1

svn:r126
Roger Dingledine 23 lat temu
rodzic
commit
b3b763ad11
1 zmienionych plików z 10 dodań i 8 usunięć
  1. 10 8
      src/or/connection.c

+ 10 - 8
src/or/connection.c

@@ -279,11 +279,12 @@ int retry_all_connections(int role, uint16_t or_listenport,
     return -1;
 
   local.sin_port = htons(or_listenport);
-
   if(role & ROLE_OR_CONNECT_ALL) {
     router_retry_connections(&local);
   }
 
+  local.sin_addr.s_addr = htonl(INADDR_ANY); /* anyone can connect */
+
   if(role & ROLE_OR_LISTEN) {
     if(!connection_get_by_type(CONN_TYPE_OR_LISTENER)) {
       connection_or_create_listener(&local);
@@ -297,13 +298,6 @@ int retry_all_connections(int role, uint16_t or_listenport,
     }
   }
 
-  if(role & ROLE_AP_LISTEN) {
-    local.sin_port = htons(ap_listenport);
-    if(!connection_get_by_type(CONN_TYPE_AP_LISTENER)) {
-      connection_ap_create_listener(&local);
-    }
-  }
-
   if(role & ROLE_DIR_LISTEN) {
     local.sin_port = htons(dir_listenport);
     if(!connection_get_by_type(CONN_TYPE_DIR_LISTENER)) {
@@ -311,6 +305,14 @@ int retry_all_connections(int role, uint16_t or_listenport,
     }
   }
  
+  if(role & ROLE_AP_LISTEN) {
+    local.sin_port = htons(ap_listenport);
+    inet_aton("127.0.0.1", &(local.sin_addr)); /* the AP listens only on localhost! */
+    if(!connection_get_by_type(CONN_TYPE_AP_LISTENER)) {
+      connection_ap_create_listener(&local);
+    }
+  }
+
   return 0;
 }