diff options
author | Michael Adam <obnox@samba.org> | 2013-11-07 11:00:19 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-11-09 13:34:33 +0100 |
commit | e82080a5f62991e2892b88dce108537f64960e55 (patch) | |
tree | aab2be1c8d65ae66eddb511a5bfc8605c56d219e /src/child.c | |
parent | d0732f9adeb523422e755bfc11d03e9cbccc99f6 (diff) | |
download | tinyproxy-e82080a5f62991e2892b88dce108537f64960e55.tar.gz tinyproxy-e82080a5f62991e2892b88dce108537f64960e55.zip |
[BB#63] conf: Allow multiple Listen statements in the config.
This introduces a list (vector) of addresses instead of
having just one address string.
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to '')
-rw-r--r-- | src/child.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/child.c b/src/child.c index c7490fd..01ef178 100644 --- a/src/child.c +++ b/src/child.c @@ -522,9 +522,16 @@ void child_kill_children (int sig) } } -int child_listening_sock (const char *addr, uint16_t port) + +/** + * Listen on the various configured interfaces + */ +int child_listening_sockets(vector_t listen_addrs, uint16_t port) { int ret; + ssize_t i; + + assert (port > 0); if (listen_fds == NULL) { listen_fds = vector_create(); @@ -535,8 +542,34 @@ int child_listening_sock (const char *addr, uint16_t port) } } - ret = listen_sock (addr, port, listen_fds); - return ret; + if ((listen_addrs == NULL) || + (vector_length(config.listen_addrs) == 0)) + { + /* + * no Listen directive: + * listen on the wildcard address(es) + */ + ret = listen_sock(NULL, port, listen_fds); + return ret; + } + + for (i = 0; i < vector_length(config.listen_addrs); i++) { + const char *addr; + + addr = (char *)vector_getentry(config.listen_addrs, i, NULL); + if (addr == NULL) { + log_message(LOG_WARNING, + "got NULL from listen_addrs - skipping"); + continue; + } + + ret = listen_sock(addr, port, listen_fds); + if (ret != 0) { + return ret; + } + } + + return 0; } void child_close_sock (void) |