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

[or-cvs] add a ControlPort and control listener conn.



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	config.c connection.c or.h 
Log Message:
add a ControlPort and control listener conn.
note that print_usage is obsolete.


Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.201
retrieving revision 1.202
diff -u -d -r1.201 -r1.202
--- config.c	4 Nov 2004 04:01:19 -0000	1.201
+++ config.c	4 Nov 2004 06:41:49 -0000	1.202
@@ -85,6 +85,7 @@
   VAR("BandwidthBurstBytes", UINT,     BandwidthBurstBytes,  "50000000"),
   VAR("ClientOnly",          BOOL,     ClientOnly,           "0"),
   VAR("ContactInfo",         STRING,   ContactInfo,          NULL),
+  VAR("ControlPort",         UINT,     ControlPort,          "0"),
   VAR("DebugLogFile",        STRING,   DebugLogFile,         NULL),
   VAR("DataDirectory",       STRING,   DataDirectory,        NULL),
   VAR("DirPort",             UINT,     DirPort,              "0"),
@@ -499,10 +500,10 @@
 print_usage(void)
 {
   printf("tor -f <torrc> [args]\n"
-         "See man page for more options. This -h is probably obsolete.\n\n"
+         "See man page for more options. This -h is obsolete.\n");
+#if 0
          "-b <bandwidth>\t\tbytes/second rate limiting\n"
          "-d <file>\t\tDebug file\n"
-//         "-m <max>\t\tMax number of connections\n"
          "-l <level>\t\tLog level\n"
          "-r <file>\t\tList of known routers\n");
   printf("\nClient options:\n"
@@ -512,6 +513,7 @@
          "-n <nick>\t\tNickname of router\n"
          "-o <port>\t\tOR port to bind to\n"
          "-p <file>\t\tPID file\n");
+#endif
 }
 
 /**
@@ -810,7 +812,7 @@
       options->command = CMD_LIST_FINGERPRINT;
     } else if (!strcmp(argv[i],"--hash-password")) {
       options->command = CMD_HASH_PASSWORD;
-      options->command_arg = tor_strdup(argv[i+1]);
+      options->command_arg = tor_strdup( (i < argc-1) ? argv[i+1] : "");
       ++i;
     }
 
@@ -932,6 +934,11 @@
     result = -1;
   }
 
+  if (options->ControlPort < 0 || options->ControlPort > 65535) {
+    log(LOG_WARN, "ControlPort option out of bounds.");
+    result = -1;
+  }
+
   if (options->DirPort < 0 || options->DirPort > 65535) {
     log(LOG_WARN, "DirPort option out of bounds.");
     result = -1;

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.281
retrieving revision 1.282
diff -u -d -r1.281 -r1.282
--- connection.c	4 Nov 2004 03:25:43 -0000	1.281
+++ connection.c	4 Nov 2004 06:41:49 -0000	1.282
@@ -471,7 +471,7 @@
       conn->state = DIR_CONN_STATE_SERVER_COMMAND_WAIT;
       break;
     case CONN_TYPE_CONTROL:
-      /* XXXX009 NM control */
+      conn->state = CONTROL_CONN_STATE_NEEDAUTH;
       break;
   }
   return 0;
@@ -651,7 +651,9 @@
   if (retry_listeners(CONN_TYPE_AP_LISTENER, options.SocksBindAddress,
                       options.SocksPort, "127.0.0.1", force)<0)
     return -1;
-  /* XXXX009 control NM */
+  if (retry_listeners(CONN_TYPE_CONTROL_LISTENER, NULL,
+                      options.ControlPort, "127.0.0.1", force)<0)
+    return -1;
 
   return 0;
 }

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.458
retrieving revision 1.459
diff -u -d -r1.458 -r1.459
--- or.h	4 Nov 2004 03:25:43 -0000	1.458
+++ or.h	4 Nov 2004 06:41:49 -0000	1.459
@@ -903,6 +903,7 @@
                              * length (alpha in geometric distribution). */
   int ORPort; /**< Port to listen on for OR connections. */
   int SocksPort; /**< Port to listen on for SOCKS connections. */
+  int ControlPort; /**< Port to listen on for control connections. */
   int DirPort; /**< Port to listen on for directory connections. */
   int AuthoritativeDir; /**< Boolean: is this an authoritative directory? */
   int ClientOnly; /**< Boolean: should we never evolve into a server role? */