summaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-12-25 18:35:49 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-12-25 18:35:49 +0000
commit35295fe9ead66b6b3aba11edac1af46d3a6e35d1 (patch)
tree0fecb56c5d57c404276a29f23bf2a4cbb9787b62 /src/libserver
parent83c6e88470c3858fd918f6366f251871a7cee144 (diff)
downloadrspamd-35295fe9ead66b6b3aba11edac1af46d3a6e35d1.tar.gz
rspamd-35295fe9ead66b6b3aba11edac1af46d3a6e35d1.zip
Allow to listen on ipv6 IP.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_utils.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index ded0e0eb9..e28f6445e 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -66,7 +66,39 @@ rspamd_parse_bind_line (struct rspamd_config *cfg,
return FALSE;
}
- tokens = g_strsplit_set (str, ":", 0);
+ if (str[0] == '[') {
+ /* This is an ipv6 address */
+ gsize len, ntok;
+ const gchar *start, *ip_pos;
+
+ start = str + 1;
+
+ len = strcspn (start, "]");
+ if (start[len] != ']') {
+ return FALSE;
+ }
+
+ ip_pos = start;
+ start += len + 1;
+ ntok = 1;
+
+ if (*start == ':') {
+ ntok = 2;
+ start ++;
+ }
+
+ tokens = g_malloc_n (ntok + 1, sizeof (gchar *));
+ tokens[ntok] = NULL;
+ tokens[0] = g_malloc (len + 1);
+ rspamd_strlcpy (tokens[0], ip_pos, len + 1);
+
+ if (ntok > 1) {
+ tokens[1] = g_strdup (start);
+ }
+ }
+ else {
+ tokens = g_strsplit_set (str, ":", 0);
+ }
if (!tokens || !tokens[0]) {
return FALSE;
}