]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
add Address config element, use it in descriptor
authorRoger Dingledine <arma@torproject.org>
Sat, 27 Sep 2003 07:21:36 +0000 (07:21 +0000)
committerRoger Dingledine <arma@torproject.org>
Sat, 27 Sep 2003 07:21:36 +0000 (07:21 +0000)
svn:r496

src/or/config.c
src/or/main.c
src/or/or.h

index 8c42480eee0af2b98a3e68588ed91431b40891f1..4212cdff756e7033d56289a2f5007041772336bd 100644 (file)
@@ -192,6 +192,7 @@ static void config_assign(or_options_t *options, struct config_line *list) {
     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 @@ int getconfig(int argc, char **argv, or_options_t *options) {
 /* 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 662358c8ef3cf200f0a7cda3381246e155387e4d..3ce121c9e6121b3e9deb08853c5cf16abc0135de 100644 (file)
@@ -938,15 +938,19 @@ const char *router_get_my_descriptor(void) {
 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 474ffa23081b5ed971c9ef98309eeceb11a4bb31..965c6ebacb417222032ab3feceb851b138fe0bd4 100644 (file)
@@ -408,6 +408,7 @@ typedef struct {
    char *DataDirectory;
    char *RouterFile;
    char *Nickname;
+   char *Address;
    double CoinWeight;
    int Daemon;
    int ORPort;