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/conf.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/conf.c | 40 |
1 files changed, 33 insertions, 7 deletions
@@ -288,7 +288,7 @@ static void free_config (struct config_s *conf) safefree (conf->stathost); safefree (conf->user); safefree (conf->group); - safefree (conf->ipAddr); + vector_delete(conf->listen_addrs); #ifdef FILTER_ENABLE safefree (conf->filter); #endif /* FILTER_ENABLE */ @@ -465,8 +465,18 @@ static void initialize_with_defaults (struct config_s *conf, conf->group = safestrdup (defaults->group); } - if (defaults->ipAddr) { - conf->ipAddr = safestrdup (defaults->ipAddr); + if (defaults->listen_addrs) { + ssize_t i; + + conf->listen_addrs = vector_create(); + for (i=0; i < vector_length(defaults->listen_addrs); i++) { + char *addr; + size_t size; + addr = (char *)vector_getentry(defaults->listen_addrs, + i, &size); + vector_append(conf->listen_addrs, addr, size); + } + } #ifdef FILTER_ENABLE @@ -882,11 +892,26 @@ static HANDLE_FUNC (handle_bind) static HANDLE_FUNC (handle_listen) { - int r = set_string_arg (&conf->ipAddr, line, &match[2]); + char *arg = get_string_arg (line, &match[2]); - if (r) - return r; - log_message (LOG_INFO, "Listening on IP %s", conf->ipAddr); + if (arg == NULL) { + return -1; + } + + if (conf->listen_addrs == NULL) { + conf->listen_addrs = vector_create(); + if (conf->listen_addrs == NULL) { + log_message(LOG_WARNING, "Could not create a list " + "of listen addresses."); + return -1; + } + } + + vector_append (conf->listen_addrs, arg, strlen(arg) + 1); + + log_message(LOG_INFO, "Added address [%s] to listen addresses.", arg); + + safefree (arg); return 0; } @@ -933,6 +958,7 @@ static HANDLE_FUNC (handle_addheader) /* * Log level's strings. + */ struct log_levels_s { const char *string; |