]> source.dussan.org Git - rspamd.git/commitdiff
Allow to listen on ipv6 IP.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 25 Dec 2014 18:35:49 +0000 (18:35 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 25 Dec 2014 18:35:49 +0000 (18:35 +0000)
contrib/snowball
src/libserver/cfg_utils.c

index 558c36912b3ca63e2917d7df504a92dbc78e1b75..4bc9f365c4b674d0dd0cfd14c314a866f00e0883 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 558c36912b3ca63e2917d7df504a92dbc78e1b75
+Subproject commit 4bc9f365c4b674d0dd0cfd14c314a866f00e0883
index ded0e0eb94c3c4b974a18100572e193e9f44d260..e28f6445ec3a8989c854d68e7574ffb4f7fbd9ab 100644 (file)
@@ -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;
        }