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

[or-cvs] simplify: options.OnionRouter==1 iff options.ORPort>0



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

Modified Files:
	circuit.c config.c connection_or.c directory.c main.c onion.c 
	or.h 
Log Message:
simplify: options.OnionRouter==1 iff options.ORPort>0


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- circuit.c	19 Nov 2003 13:12:43 -0000	1.109
+++ circuit.c	20 Nov 2003 17:49:44 -0000	1.110
@@ -748,7 +748,7 @@
   if(!n_conn || n_conn->state != OR_CONN_STATE_OPEN) { /* not currently connected */
     circ->n_addr = firsthop->addr;
     circ->n_port = firsthop->or_port;
-    if(options.OnionRouter) { /* we would be connected if he were up. but he's not. */
+    if(options.ORPort) { /* we would be connected if he were up. and he's not. */
       log_fn(LOG_INFO,"Route's firsthop isn't connected.");
       circuit_close(circ);
       return -1;

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- config.c	19 Nov 2003 22:48:48 -0000	1.71
+++ config.c	20 Nov 2003 17:49:44 -0000	1.72
@@ -182,7 +182,6 @@
 
     config_compare(list, "ORPort",         CONFIG_TYPE_INT, &options->ORPort) ||
     config_compare(list, "ORBindAddress",  CONFIG_TYPE_STRING, &options->ORBindAddress) ||
-    config_compare(list, "OnionRouter",    CONFIG_TYPE_BOOL, &options->OnionRouter) ||
 
     config_compare(list, "PidFile",        CONFIG_TYPE_STRING, &options->PidFile) ||
     config_compare(list, "PathlenCoinWeight",CONFIG_TYPE_DOUBLE, &options->PathlenCoinWeight) ||
@@ -283,7 +282,6 @@
   static int backup_argc;
   char *previous_pidfile = NULL;
   int previous_runasdaemon = 0;
-  int previous_onionrouter = -1;
 
   if(first_load) { /* first time we're called. save commandline args */
     backup_argv = argv;
@@ -296,7 +294,6 @@
     /* record some previous values, so we can fail if they change */
     previous_pidfile = tor_strdup(options->PidFile);
     previous_runasdaemon = options->RunAsDaemon;
-    previous_onionrouter = options->OnionRouter;
     free_options(options);
   }
   init_options(options); 
@@ -349,11 +346,6 @@
     log_fn(LOG_WARN,"During reload, change from RunAsDaemon=1 to =0 not allowed. Failing.");
     return -1;
   }
-  if(previous_onionrouter >= 0 && previous_onionrouter != options->OnionRouter) {
-    log_fn(LOG_WARN,"During reload, OnionRouter changed from %d to %d. Failing.",
-           previous_onionrouter, options->OnionRouter);
-    return -1;
-  }
 
   if(options->LogLevel) {
     if(!strcmp(options->LogLevel,"err"))
@@ -380,18 +372,13 @@
     result = -1;
   }
 
-  if(options->OnionRouter && options->ORPort == 0) {
-    log(LOG_WARN,"If OnionRouter is set, then ORPort must be positive.");
-    result = -1;
-  }
-
-  if(options->OnionRouter && options->DataDirectory == NULL) {
-    log(LOG_WARN,"DataDirectory option required for OnionRouter, but not found.");
+  if(options->ORPort && options->DataDirectory == NULL) {
+    log(LOG_WARN,"DataDirectory option required if ORPort is set, but not found.");
     result = -1;
   }
 
-  if(options->OnionRouter && options->Nickname == NULL) {
-    log_fn(LOG_WARN,"Nickname required for OnionRouter, but not found.");
+  if(options->ORPort && options->Nickname == NULL) {
+    log_fn(LOG_WARN,"Nickname required if ORPort is set, but not found.");
     result = -1;
   }
 

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- connection_or.c	19 Nov 2003 01:32:34 -0000	1.78
+++ connection_or.c	20 Nov 2003 17:49:44 -0000	1.79
@@ -186,7 +186,7 @@
   connection_watch_events(conn, POLLIN);
   log_fn(LOG_DEBUG,"tls handshake done. verifying.");
   if (! tor_tls_peer_has_cert(conn->tls)) { /* It's an OP. */
-    if (options.OnionRouter) { /* I'm an OR; good. */
+    if (options.ORPort) { /* I'm an OR; good. */
       conn->receiver_bucket = conn->bandwidth = DEFAULT_BANDWIDTH_OP;
       return 0;
     } else { /* Neither side sent a certificate: ouch. */
@@ -236,7 +236,7 @@
            nickname, conn->nickname);
     return -1;
   }
-  if (!options.OnionRouter) { /* If I'm an OP... */
+  if (!options.ORPort) { /* If I'm an OP... */
     conn->receiver_bucket = conn->bandwidth = DEFAULT_BANDWIDTH_OP;
     circuit_n_conn_open(conn); /* send the pending creates, if any. */
   }

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- directory.c	11 Nov 2003 17:21:35 -0000	1.48
+++ directory.c	20 Nov 2003 17:49:44 -0000	1.49
@@ -125,7 +125,7 @@
         } else {
           log_fn(LOG_INFO,"updated routers.");
         }
-        if(options.OnionRouter) { /* connect to them all */
+        if(options.ORPort) { /* connect to them all */
           router_retry_connections();
         }
         return -1;

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- main.c	19 Nov 2003 22:45:06 -0000	1.152
+++ main.c	20 Nov 2003 17:49:44 -0000	1.153
@@ -292,7 +292,7 @@
     return;
 
   if(now >= conn->timestamp_lastwritten + options.KeepalivePeriod) {
-    if((!options.OnionRouter && !circuit_get_by_conn(conn)) ||
+    if((!options.ORPort && !circuit_get_by_conn(conn)) ||
        (!connection_state_is_open(conn))) {
       /* we're an onion proxy, with no circuits; or our handshake has expired. kill it. */
       log_fn(LOG_INFO,"Expiring connection to %d (%s:%d).",
@@ -322,7 +322,7 @@
    *    our descriptor (if any). */
   if(time_to_fetch_directory < now) {
     /* it's time to fetch a new directory and/or post our descriptor */
-    if(options.OnionRouter) {
+    if(options.ORPort) {
       router_rebuild_descriptor();
       router_upload_desc_to_dirservers();
     }
@@ -485,7 +485,7 @@
   crypto_pk_env_t *prkey;
 
   /* OP's don't need keys.  Just initialize the TLS context.*/
-  if (!options.OnionRouter) {
+  if (!options.ORPort) {
     assert(!options.DirPort);
     if (tor_tls_context_new(NULL, 0, NULL)<0) {
       log_fn(LOG_ERR, "Error creating TLS context for OP.");
@@ -652,7 +652,7 @@
     return -1;
   }
 
-  if(options.OnionRouter) {
+  if(options.ORPort) {
     cpu_init(); /* launch cpuworkers. Need to do this *after* we've read the onion key. */
     router_upload_desc_to_dirservers(); /* upload our descriptor to all dirservers */
   }
@@ -674,7 +674,7 @@
       please_dumpstats = 0;
     }
     if(please_reset) {
-      log_fn(LOG_INFO,"Hupped. Reloading config.");
+      log_fn(LOG_WARN,"Received sighup. Reloading config.");
       /* first, reload config variables, in case they've changed */
       if (init_from_config(0, NULL) < 0) {
         /* no need to provide argc/v, they've been cached inside init_from_config */
@@ -828,7 +828,7 @@
   if (init_from_config(argc,argv) < 0)
     return -1;
 
-  if(options.OnionRouter) { /* only spawn dns handlers if we're a router */
+  if(options.ORPort) { /* only spawn dns handlers if we're a router */
     dns_init(); /* initialize the dns resolve tree, and spawn workers */
   }
   if(options.SocksPort) {

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- onion.c	19 Nov 2003 01:35:44 -0000	1.95
+++ onion.c	20 Nov 2003 17:49:45 -0000	1.96
@@ -386,7 +386,7 @@
       log_fn(LOG_DEBUG,"Nope, the directory says %d is not running.",i);
       goto next_i_loop;
     }
-    if(options.OnionRouter) {
+    if(options.ORPort) {
       conn = connection_exact_get_by_addr_port(rarray[i]->addr, rarray[i]->or_port);
       if(!conn || conn->type != CONN_TYPE_OR || conn->state != OR_CONN_STATE_OPEN) {
         log_fn(LOG_DEBUG,"Nope, %d is not connected.",i);
@@ -457,6 +457,7 @@
     return -1;
   }
  start:
+  /* XXX through each of these, don't pick nodes that are down */
   if(cur_len == 0) { /* picking entry node */
     log_fn(LOG_DEBUG, "Contemplating first hop: random choice.");
     choice = rarray[crypto_pseudo_rand_int(rarray_len)];
@@ -474,7 +475,7 @@
       !strcasecmp(choice->nickname, state->chosen_exit)) {
     goto again;
   }
-    
+
   for (i = 0, cpath = *head_ptr; i < cur_len; ++i, cpath=cpath->next) {
     r = router_get_by_addr_port(cpath->addr, cpath->port);
     if ((r && !crypto_pk_cmp_keys(r->onion_pkey, choice->onion_pkey))
@@ -482,7 +483,7 @@
             !strcasecmp(choice->nickname, state->chosen_exit))
         || (cpath->addr == choice->addr && 
             cpath->port == choice->or_port)
-        || (options.OnionRouter && 
+        || (options.ORPort &&
             !(connection_twin_get_by_addr_port(choice->addr,
                                                choice->or_port)))) {
       goto again;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -d -r1.193 -r1.194
--- or.h	19 Nov 2003 02:22:52 -0000	1.193
+++ or.h	20 Nov 2003 17:49:45 -0000	1.194
@@ -451,7 +451,6 @@
   int SocksPort;
   int DirPort;
   int MaxConn;
-  int OnionRouter;
   int TrafficShaping;
   int LinkPadding;
   int IgnoreVersion;