aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-02 15:26:39 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-13 10:41:18 -0400
commit61c06cbc66ecfaece20501417ef81b3f6f202391 (patch)
tree8e0498cbf316cb246fc35996052fdcfb09eb0f07 /src/or/connection.c
parent5fec8fe559b1a1f4bcb55c8f2c1f048f5abee3de (diff)
downloadtor-61c06cbc66ecfaece20501417ef81b3f6f202391.tar
tor-61c06cbc66ecfaece20501417ef81b3f6f202391.tar.gz
Teach retry_listener about "auto" ports.
Otherwise, it will just immediately close any port declared with "auto" on the grounds that it wasn't configured. Now, it will allow "auto" to match any port. This means FWIW if you configure a socks port with SocksPort 9999 and then transition to SocksPort auto, the original socksport will not get closed and reopened. I'm considering this a feature.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 47e5423e0..bc18dab1e 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1772,10 +1772,23 @@ retry_listeners(int type, config_line_t *cfg,
if (!parse_addr_port(LOG_WARN,
wanted->value, &address, NULL, &port)) {
int addr_matches = !strcasecmp(address, conn->address);
+ int port_matches;
tor_free(address);
- if (! port)
- port = port_option;
- if (port == conn->port && addr_matches) {
+ if (port) {
+ /* The Listener line has a port */
+ port_matches = (port == conn->port);
+ } else if (port_option == CFG_AUTO_PORT) {
+ /* The Listener line has no port, and the Port line is "auto".
+ * "auto" matches anything; transitions from any port to
+ * "auto" succeed. */
+ port_matches = 1;
+ } else {
+ /* The Listener line has no port, and the Port line is "auto".
+ * "auto" matches anything; transitions from any port to
+ * "auto" succeed. */
+ port_matches = (port_option == conn->port);
+ }
+ if (port_matches && addr_matches) {
line = wanted;
break;
}