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) ||
/* 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;
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;