[or-cvs] add Address config element, use it in descriptor

Roger Dingledine arma at seul.org
Sat Sep 27 07:21:39 UTC 2003


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

Modified Files:
	config.c main.c or.h 
Log Message:
add Address config element, use it in descriptor


Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- config.c	26 Sep 2003 22:27:24 -0000	1.46
+++ config.c	27 Sep 2003 07:21:36 -0000	1.47
@@ -192,6 +192,7 @@
     config_compare(list, "DataDirectory",  CONFIG_TYPE_STRING, &options->DataDirectory) ||
     config_compare(list, "RouterFile",     CONFIG_TYPE_STRING, &options->RouterFile) ||
     config_compare(list, "Nickname",       CONFIG_TYPE_STRING, &options->Nickname) ||
+    config_compare(list, "Address",        CONFIG_TYPE_STRING, &options->Address) ||
 
     /* int options */
     config_compare(list, "MaxConn",         CONFIG_TYPE_INT, &options->MaxConn) ||
@@ -277,7 +278,7 @@
 /* Validate options */
 
   if(options->LogLevel) {
-    else if(!strcmp(options->LogLevel,"err"))
+    if(!strcmp(options->LogLevel,"err"))
       options->loglevel = LOG_ERR;
     else if(!strcmp(options->LogLevel,"warning"))
       options->loglevel = LOG_WARNING;

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- main.c	26 Sep 2003 22:02:02 -0000	1.105
+++ main.c	27 Sep 2003 07:21:36 -0000	1.106
@@ -938,15 +938,19 @@
 static int init_descriptor(void) {
   routerinfo_t *ri;
   char localhostname[256];
+  char *address = options.Address;
 
-  if(gethostname(localhostname,sizeof(localhostname)) < 0) {
-    log_fn(LOG_WARNING,"Error obtaining local hostname");
-    return -1;
+  if(!address) { /* if not specified in config, we find a default */
+    if(gethostname(localhostname,sizeof(localhostname)) < 0) {
+      log_fn(LOG_WARNING,"Error obtaining local hostname");
+      return -1;
+    }
+    address = localhostname;
   }
   ri = tor_malloc(sizeof(routerinfo_t));
-  ri->address = strdup(localhostname);
+  ri->address = strdup(address);
   ri->nickname = strdup(options.Nickname);
-  /* No need to set addr. ???? */
+  /* No need to set addr. */
   ri->or_port = options.ORPort;
   ri->ap_port = options.APPort;
   ri->dir_port = options.DirPort;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- or.h	26 Sep 2003 18:27:35 -0000	1.140
+++ or.h	27 Sep 2003 07:21:36 -0000	1.141
@@ -408,6 +408,7 @@
    char *DataDirectory;
    char *RouterFile;
    char *Nickname;
+   char *Address;
    double CoinWeight;
    int Daemon;
    int ORPort;



More information about the tor-commits mailing list