diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-07-29 13:57:43 -0400 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2020-07-30 19:46:44 +0300 |
commit | 219edc9ab1d78e5739ed4454d50952af56ff3f43 (patch) | |
tree | 5800b17a08d9798b028da42051905252710e4371 /src/feature/relay/relay_config.c | |
parent | 2bb9acca73f37a1d63485afa6bf1e52e37b333b9 (diff) | |
download | tor-219edc9ab1d78e5739ed4454d50952af56ff3f43.tar.gz tor-219edc9ab1d78e5739ed4454d50952af56ff3f43.zip |
Handle ORPort auto when logging about removed orports.
Closes #40075
Diffstat (limited to 'src/feature/relay/relay_config.c')
-rw-r--r-- | src/feature/relay/relay_config.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/feature/relay/relay_config.c b/src/feature/relay/relay_config.c index 711fbd14e5..d3f904d286 100644 --- a/src/feature/relay/relay_config.c +++ b/src/feature/relay/relay_config.c @@ -133,6 +133,22 @@ port_warn_nonlocal_ext_orports(const smartlist_t *ports, const char *portname) } SMARTLIST_FOREACH_END(port); } +/** + * Return a static buffer describing the port number in @a port, which may + * CFG_AUTO_PORT. + **/ +static const char * +describe_portnum(int port) +{ + static char buf[16]; + if (port == CFG_AUTO_PORT) { + return "auto"; + } else { + tor_snprintf(buf, sizeof(buf), "%d", port); + return buf; + } +} + /** Return a static buffer containing the human readable logging string that * describes the given port object. */ static const char * @@ -166,8 +182,9 @@ describe_relay_port(const port_cfg_t *port) addr = ""; } - tor_snprintf(buf, sizeof(buf), "%sPort %s%s%d", - type, addr, (strlen(addr) > 0) ? ":" : "", port->port); + tor_snprintf(buf, sizeof(buf), "%sPort %s%s%s", + type, addr, (strlen(addr) > 0) ? ":" : "", + describe_portnum(port->port)); return buf; } |