From fd165329b84285b4cc139a139e00f189bdefa261 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 17 Oct 2005 03:17:29 +0000 Subject: [PATCH] start calling it *ListenAddress rather than *BindAddress, since none of our users know what it means to bind an address or port. svn:r5260 --- src/or/config.c | 27 ++++++++++++++++----------- src/or/connection.c | 38 +++++++++++++++++++------------------- src/or/or.h | 6 +++--- src/or/router.c | 4 ++-- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/or/config.c b/src/or/config.c index 3735a04679..09fc5e25be 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -67,6 +67,9 @@ static config_abbrev_t _option_abbrevs[] = { { "BandwidthBurstBytes", "BandwidthBurst", 0, 0}, { "DirFetchPostPeriod", "StatusFetchPeriod", 0, 0}, { "MaxConn", "ConnLimit", 0, 1}, + { "ORBindAddress", "ORListenAddress", 0, 1}, + { "DirBindAddress", "DirListenAddress", 0, 1}, + { "SocksBindAddress", "SocksListenAddress", 0, 1}, { NULL, NULL, 0, 0}, }; #undef PLURAL @@ -115,8 +118,9 @@ static config_var_t _option_vars[] = { VAR("DataDirectory", STRING, DataDirectory, NULL), VAR("DebugLogFile", STRING, DebugLogFile, NULL), VAR("DirAllowPrivateAddresses",BOOL, DirAllowPrivateAddresses, NULL), - VAR("DirBindAddress", LINELIST, DirBindAddress, NULL), - VAR("DirFetchPeriod", INTERVAL, DirFetchPeriod, "0 seconds"), /** DOCDOC **/ + VAR("DirListenAddress", LINELIST, DirListenAddress, NULL), + /* if DirFetchPeriod is 0, see get_dir_fetch_period() in main.c */ + VAR("DirFetchPeriod", INTERVAL, DirFetchPeriod, "0 seconds"), VAR("DirPolicy", LINELIST, DirPolicy, NULL), VAR("DirPort", UINT, DirPort, "0"), OBSOLETE("DirPostPeriod"), @@ -159,7 +163,7 @@ static config_var_t _option_vars[] = { VAR("NodeFamily", LINELIST, NodeFamilies, NULL), VAR("NumCpus", UINT, NumCpus, "1"), VAR("NumHelperNodes", UINT, NumHelperNodes, "3"), - VAR("ORBindAddress", LINELIST, ORBindAddress, NULL), + VAR("ORListenAddress", LINELIST, ORListenAddress, NULL), VAR("ORPort", UINT, ORPort, "0"), VAR("OutboundBindAddress", STRING, OutboundBindAddress, NULL), VAR("PathlenCoinWeight", DOUBLE, PathlenCoinWeight, "0.3"), @@ -179,10 +183,11 @@ static config_var_t _option_vars[] = { VAR("RunTesting", BOOL, RunTesting, "0"), VAR("SafeLogging", BOOL, SafeLogging, "1"), VAR("ShutdownWaitLength", INTERVAL, ShutdownWaitLength, "30 seconds"), - VAR("SocksBindAddress", LINELIST, SocksBindAddress, NULL), + VAR("SocksListenAddress", LINELIST, SocksListenAddress, NULL), VAR("SocksPolicy", LINELIST, SocksPolicy, NULL), VAR("SocksPort", UINT, SocksPort, "9050"), - VAR("StatusFetchPeriod", INTERVAL, StatusFetchPeriod, "0 seconds"), /** DOCDOC */ + /* if StatusFetchPeriod is 0, see get_status_fetch_period() in main.c */ + VAR("StatusFetchPeriod", INTERVAL, StatusFetchPeriod, "0 seconds"), VAR("StrictEntryNodes", BOOL, StrictEntryNodes, "0"), VAR("StrictExitNodes", BOOL, StrictExitNodes, "0"), VAR("SysLog", LINELIST_S, OldLogOptions, NULL), @@ -1732,16 +1737,16 @@ options_validate(or_options_t *options) result = -1; } - if (options->ORPort == 0 && options->ORBindAddress != NULL) { - log(LOG_WARN, "ORPort must be defined if ORBindAddress is defined."); + if (options->ORPort == 0 && options->ORListenAddress != NULL) { + log(LOG_WARN, "ORPort must be defined if ORListenAddress is defined."); result = -1; } - if (options->DirPort == 0 && options->DirBindAddress != NULL) { - log(LOG_WARN, "DirPort must be defined if DirBindAddress is defined."); + if (options->DirPort == 0 && options->DirListenAddress != NULL) { + log(LOG_WARN, "DirPort must be defined if DirListenAddress is defined."); result = -1; } - if (options->SocksPort == 0 && options->SocksBindAddress != NULL) { - log(LOG_WARN, "SocksPort must be defined if SocksBindAddress is defined."); + if (options->SocksPort == 0 && options->SocksListenAddress != NULL) { + log(LOG_WARN, "SocksPort must be defined if SocksListenAddress is defined."); result = -1; } diff --git a/src/or/connection.c b/src/or/connection.c index 9aaa9a6a11..72e780adc8 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -13,8 +13,8 @@ const char connection_c_id[] = "$Id$"; #include "or.h" -static connection_t *connection_create_listener(const char *bindaddress, - uint16_t bindport, int type); +static connection_t *connection_create_listener(const char *listenaddress, + uint16_t listenport, int type); static int connection_init_accepted_conn(connection_t *conn); static int connection_handle_listener_read(connection_t *conn, int new_type); static int connection_receiver_bucket_should_increase(connection_t *conn); @@ -474,17 +474,17 @@ connection_expire_held_open(void) } /** Bind a new non-blocking socket listening to - * bindaddress:bindport, and add this new connection + * listenaddress:listenport, and add this new connection * (of type type) to the connection array. * - * If bindaddress includes a port, we bind on that port; otherwise, we - * use bindport. + * If listenaddress includes a port, we bind on that port; + * otherwise, we use listenport. */ static connection_t * -connection_create_listener(const char *bindaddress, uint16_t bindport, +connection_create_listener(const char *listenaddress, uint16_t listenport, int type) { - struct sockaddr_in bindaddr; /* where to bind */ + struct sockaddr_in listenaddr; /* where to bind */ char *address = NULL; connection_t *conn; uint16_t usePort; @@ -494,17 +494,17 @@ connection_create_listener(const char *bindaddress, uint16_t bindport, int one=1; #endif - memset(&bindaddr,0,sizeof(struct sockaddr_in)); - if (parse_addr_port(bindaddress, &address, &addr, &usePort)<0) { - log_fn(LOG_WARN, "Error parsing/resolving BindAddress %s",bindaddress); + memset(&listenaddr,0,sizeof(struct sockaddr_in)); + if (parse_addr_port(listenaddress, &address, &addr, &usePort)<0) { + log_fn(LOG_WARN, "Error parsing/resolving ListenAddress %s",listenaddress); return NULL; } if (usePort==0) - usePort = bindport; - bindaddr.sin_addr.s_addr = htonl(addr); - bindaddr.sin_family = AF_INET; - bindaddr.sin_port = htons((uint16_t) usePort); + usePort = listenport; + listenaddr.sin_addr.s_addr = htonl(addr); + listenaddr.sin_family = AF_INET; + listenaddr.sin_port = htons((uint16_t) usePort); log_fn(LOG_NOTICE, "Opening %s on %s:%d", conn_type_to_string(type), address, usePort); @@ -527,7 +527,7 @@ connection_create_listener(const char *bindaddress, uint16_t bindport, setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*) &one, sizeof(one)); #endif - if (bind(s,(struct sockaddr *)&bindaddr,sizeof(bindaddr)) < 0) { + if (bind(s,(struct sockaddr *)&listenaddr,sizeof(listenaddr)) < 0) { log_fn(LOG_WARN, "Could not bind to %s:%u: %s", address, usePort, tor_socket_strerror(tor_socket_errno(s))); goto err; @@ -803,7 +803,7 @@ connection_connect(connection_t *conn, char *address, /** * Launch any configured listener connections of type type. (A * listener is configured if port_option is non-zero. If any - * BindAddress configuration options are given in cfg, create a + * ListenAddress configuration options are given in cfg, create a * connection binding to each one. Otherwise, create a single * connection binding to the address default_addr.) * @@ -935,15 +935,15 @@ retry_all_listeners(int force, smartlist_t *replaced_conns, or_options_t *options = get_options(); if (server_mode(options) && - retry_listeners(CONN_TYPE_OR_LISTENER, options->ORBindAddress, + retry_listeners(CONN_TYPE_OR_LISTENER, options->ORListenAddress, options->ORPort, "0.0.0.0", force, replaced_conns, new_conns)<0) return -1; - if (retry_listeners(CONN_TYPE_DIR_LISTENER, options->DirBindAddress, + if (retry_listeners(CONN_TYPE_DIR_LISTENER, options->DirListenAddress, options->DirPort, "0.0.0.0", force, replaced_conns, new_conns)<0) return -1; - if (retry_listeners(CONN_TYPE_AP_LISTENER, options->SocksBindAddress, + if (retry_listeners(CONN_TYPE_AP_LISTENER, options->SocksListenAddress, options->SocksPort, "127.0.0.1", force, replaced_conns, new_conns)<0) return -1; diff --git a/src/or/or.h b/src/or/or.h index 2c30f6c55c..9e2707e688 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1174,11 +1174,11 @@ typedef struct { config_line_t *SocksPolicy; /**< Lists of socks policy components */ config_line_t *DirPolicy; /**< Lists of dir policy components */ /** Addresses to bind for listening for SOCKS connections. */ - config_line_t *SocksBindAddress; + config_line_t *SocksListenAddress; /** Addresses to bind for listening for OR connections. */ - config_line_t *ORBindAddress; + config_line_t *ORListenAddress; /** Addresses to bind for listening for directory connections. */ - config_line_t *DirBindAddress; + config_line_t *DirListenAddress; /** Local address to bind outbound sockets */ char *OutboundBindAddress; /** Directory server only: which versions of diff --git a/src/or/router.c b/src/or/router.c index 48b47fa22e..672709c189 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -524,7 +524,7 @@ int server_mode(or_options_t *options) { if (options->ClientOnly) return 0; - return (options->ORPort != 0 || options->ORBindAddress); + return (options->ORPort != 0 || options->ORListenAddress); } /** Remember if we've advertised ourselves to the dirservers. */ @@ -551,7 +551,7 @@ set_server_advertised(int s) int proxy_mode(or_options_t *options) { - return (options->SocksPort != 0 || options->SocksBindAddress); + return (options->SocksPort != 0 || options->SocksListenAddress); } /** Decide if we're a publishable server. We are a publishable server if: