diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-09-16 00:48:38 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-09-16 00:48:38 +0100 |
commit | 85a1704ee40b0518c5e4d4eabccc6b4a387e2480 (patch) | |
tree | 1cd46e3613c88d939ec4dc058e887ce48c2b0e54 /src/cfg_utils.c | |
parent | 2fa167601ae2194bbdf4484fe2ad8e3eee813163 (diff) | |
download | rspamd-85a1704ee40b0518c5e4d4eabccc6b4a387e2480.tar.gz rspamd-85a1704ee40b0518c5e4d4eabccc6b4a387e2480.zip |
Allow multiply bind configurations.
Diffstat (limited to 'src/cfg_utils.c')
-rw-r--r-- | src/cfg_utils.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/cfg_utils.c b/src/cfg_utils.c index 6bdb3c8f7..e7e57cd8a 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -163,21 +163,16 @@ parse_host_priority (memory_pool_t *pool, const gchar *str, gchar **addr, guint return parse_host_port_priority (pool, str, addr, NULL, priority); } -gint +gboolean parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str) { - gchar **host; - guint16 *family, *port; - gchar **addr; + struct rspamd_worker_bind_conf *cnf; if (str == NULL) return 0; - host = &cf->bind_host; - port = &cf->bind_port; - *port = DEFAULT_BIND_PORT; - family = &cf->bind_family; - addr = &cf->bind_addr; + cnf = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_worker_bind_conf)); + cnf->bind_port = DEFAULT_BIND_PORT; if (str[0] == '/' || str[0] == '.') { #ifdef HAVE_DIRNAME @@ -189,7 +184,7 @@ parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str) if (errno == ENOENT) { if ((fd = open (str, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)) == -1) { msg_err ("cannot open path %s for making socket, %s", str, strerror (errno)); - return 0; + return FALSE; } else { close (fd); @@ -208,21 +203,20 @@ parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str) } } #endif - *host = memory_pool_strdup (cfg->cfg_pool, str); - *addr = *host; - *family = AF_UNIX; - return 1; + cnf->bind_host = memory_pool_strdup (cfg->cfg_pool, str); + cnf->is_unix = TRUE; + LL_PREPEND (cf->bind_conf, cnf); + return TRUE; } else { - if (parse_host_port (cfg->cfg_pool, str, addr, port)) { - *host = memory_pool_strdup (cfg->cfg_pool, str); - *family = AF_INET; - - return 1; + cnf->bind_host = memory_pool_strdup (cfg->cfg_pool, str); + if (parse_host_port (cfg->cfg_pool, str, &cnf->bind_host, &cnf->bind_port)) { + LL_PREPEND (cf->bind_conf, cnf); + return TRUE; } } - return 0; + return FALSE; } void |