]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Distinguish remote and local addrs parsing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 28 Sep 2019 12:37:22 +0000 (13:37 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 28 Sep 2019 12:37:22 +0000 (13:37 +0100)
21 files changed:
src/client/rspamc.c
src/controller.c
src/libmime/message.c
src/libmime/mime_headers.c
src/libserver/cfg_rcl.c
src/libserver/dns.c
src/libserver/protocol.c
src/libutil/addr.c
src/libutil/addr.h
src/libutil/map.c
src/libutil/upstream.c
src/lua/lua_http.c
src/lua/lua_ip.c
src/lua/lua_redis.c
src/lua/lua_task.c
src/lua/lua_tcp.c
src/lua/lua_udp.c
src/ragel/smtp_ip_parser.rl
src/rspamadm/control.c
src/rspamd.c
test/rspamd_upstream_test.c

index 3f637cda035f9548e78bb2ed7a5480e045ac1178..075f0a4872d6fcf2eb5328595785e5f87d06d7eb 100644 (file)
@@ -564,7 +564,8 @@ add_options (GQueue *opts)
        if (ip != NULL) {
                rspamd_inet_addr_t *addr = NULL;
 
-               if (!rspamd_parse_inet_address (&addr, ip, strlen (ip))) {
+               if (!rspamd_parse_inet_address (&addr, ip, strlen (ip),
+                               RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                        /* Try to resolve */
                        struct addrinfo hints, *res, *cur;
                        gint r;
index 474e7ec9264c9914f3ac64f6384eb76d112e0b82..27c6d18ccba16ed3559552351caccb526934cc70 100644 (file)
@@ -434,7 +434,8 @@ rspamd_controller_check_forwarded (struct rspamd_controller_session *session,
                        comma = hdr->begin;
                }
                if (rspamd_parse_inet_address (&addr, comma,
-                               (hdr->begin + hdr->len) - comma)) {
+                               (hdr->begin + hdr->len) - comma,
+                               RSPAMD_INET_ADDRESS_PARSE_NO_UNIX)) {
                        /* We have addr now, so check if it is still trusted */
                        if (ctx->secure_map &&
                                        rspamd_match_radix_map_addr (ctx->secure_map, addr) != NULL) {
@@ -463,7 +464,8 @@ rspamd_controller_check_forwarded (struct rspamd_controller_session *session,
                hdr = rspamd_http_message_find_header (msg, alt_hdr_name);
 
                if (hdr) {
-                       if (rspamd_parse_inet_address (&addr, hdr->begin, hdr->len)) {
+                       if (rspamd_parse_inet_address (&addr, hdr->begin, hdr->len,
+                                       RSPAMD_INET_ADDRESS_PARSE_NO_UNIX)) {
                                /* We have addr now, so check if it is still trusted */
                                if (ctx->secure_map &&
                                                rspamd_match_radix_map_addr (ctx->secure_map, addr) != NULL) {
index 9e9d27d8af686c132f0d2955646119206afb0e2c..4169ca0b561db72869612852ce69812e7fff2ce6 100644 (file)
@@ -1287,7 +1287,8 @@ rspamd_message_parse (struct rspamd_task *task)
                if (recv->real_ip) {
                        if (!rspamd_parse_inet_address (&task->from_addr,
                                        recv->real_ip,
-                                       strlen (recv->real_ip))) {
+                                       strlen (recv->real_ip),
+                                       RSPAMD_INET_ADDRESS_PARSE_NO_UNIX)) {
                                msg_warn_task ("cannot get IP from received header: '%s'",
                                                recv->real_ip);
                                task->from_addr = NULL;
index a93a4ffd0d79e0d9f9c2d1a8becfbda54283d0b1..e83debc43def8c8d0d3e8dd356f5d54be6f61905 100644 (file)
@@ -32,6 +32,9 @@ struct rspamd_mime_headers_table {
        ref_entry_t ref;
 };
 
+#define RSPAMD_INET_ADDRESS_PARSE_RECEIVED \
+       (RSPAMD_INET_ADDRESS_PARSE_REMOTE|RSPAMD_INET_ADDRESS_PARSE_NO_UNIX)
+
 static void
 rspamd_mime_header_check_special (struct rspamd_task *task,
                struct rspamd_mime_header *rh)
@@ -1320,7 +1323,8 @@ rspamd_smtp_received_process_host_tcpinfo (struct rspamd_task *task,
                if (brace_pos) {
                        addr = rspamd_parse_inet_address_pool (data + 1,
                                        brace_pos - data - 1,
-                                       task->task_pool);
+                                       task->task_pool,
+                                       RSPAMD_INET_ADDRESS_PARSE_RECEIVED);
 
                        if (addr) {
                                rh->addr = addr;
@@ -1334,7 +1338,7 @@ rspamd_smtp_received_process_host_tcpinfo (struct rspamd_task *task,
                if (g_ascii_isxdigit (data[0])) {
                        /* Try to parse IP address */
                        addr = rspamd_parse_inet_address_pool (data,
-                                       len, task->task_pool);
+                                       len, task->task_pool, RSPAMD_INET_ADDRESS_PARSE_RECEIVED);
                        if (addr) {
                                rh->addr = addr;
                                rh->real_ip = rspamd_mempool_strdup (task->task_pool,
@@ -1355,7 +1359,8 @@ rspamd_smtp_received_process_host_tcpinfo (struct rspamd_task *task,
                                if (ebrace_pos) {
                                        addr = rspamd_parse_inet_address_pool (obrace_pos + 1,
                                                        ebrace_pos - obrace_pos - 1,
-                                                       task->task_pool);
+                                                       task->task_pool,
+                                                       RSPAMD_INET_ADDRESS_PARSE_RECEIVED);
 
                                        if (addr) {
                                                rh->addr = addr;
@@ -1420,7 +1425,8 @@ rspamd_smtp_received_process_from (struct rspamd_task *task,
                                if (brace_pos) {
                                        addr = rspamd_parse_inet_address_pool (rpart->data + 1,
                                                        brace_pos - rpart->data - 1,
-                                                       task->task_pool);
+                                                       task->task_pool,
+                                                       RSPAMD_INET_ADDRESS_PARSE_RECEIVED);
 
                                        if (addr) {
                                                seen_ip_in_data = TRUE;
@@ -1434,7 +1440,8 @@ rspamd_smtp_received_process_from (struct rspamd_task *task,
                                /* Try to parse IP address */
                                rspamd_inet_addr_t *addr;
                                addr = rspamd_parse_inet_address_pool (rpart->data,
-                                               rpart->dlen, task->task_pool);
+                                               rpart->dlen, task->task_pool,
+                                               RSPAMD_INET_ADDRESS_PARSE_RECEIVED);
                                if (addr) {
                                        seen_ip_in_data = TRUE;
                                        rh->addr = addr;
index b219e1af80361f05e70c9afd2690914e327ff6da..cdf3d9b5b74e5a5cf089bbd37507a2b3424369a4 100644 (file)
@@ -3254,13 +3254,15 @@ rspamd_rcl_parse_struct_addr (rspamd_mempool_t *pool,
        struct rspamd_rcl_struct_parser *pd = ud;
        rspamd_inet_addr_t **target;
        const gchar *val;
+       gsize size;
 
        target = (rspamd_inet_addr_t **)(((gchar *)pd->user_struct) + pd->offset);
 
        if (ucl_object_type (obj) == UCL_STRING) {
-               val = ucl_object_tostring (obj);
+               val = ucl_object_tolstring (obj, &size);
 
-               if (!rspamd_parse_inet_address (target, val, strlen (val))) {
+               if (!rspamd_parse_inet_address (target, val, size,
+                               RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                        g_set_error (err,
                                CFG_RCL_ERROR,
                                EINVAL,
index f6e533523ad99e7d4561e50b1e0bd4dcfc5816df..08454c6563b132e539a2de9959a9588ee3dcb811 100644 (file)
@@ -300,7 +300,8 @@ rspamd_dns_resolv_conf_on_server (struct rdns_resolver *resolver,
        msg_info_config ("parsed nameserver %s from resolv.conf", name);
 
        /* Try to open a connection */
-       if (!rspamd_parse_inet_address (&addr, name, strlen (name))) {
+       if (!rspamd_parse_inet_address (&addr, name, strlen (name),
+                       RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                msg_warn_config ("cannot parse nameserver address %s", name);
 
                return FALSE;
index 469b834dc462593c5c092f3e6fe138fe54ed0b0d..da02eb61bc122e3e68c63ab0cc058465c9cb2d82 100644 (file)
@@ -545,7 +545,8 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
                        case 'I':
                                IF_HEADER (IP_ADDR_HEADER) {
                                        if (!rspamd_parse_inet_address (&task->from_addr,
-                                                       hv_tok->begin, hv_tok->len)) {
+                                                       hv_tok->begin, hv_tok->len,
+                                                       RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                                                msg_err_protocol ("bad ip header: '%T'", hv_tok);
                                        }
                                        else {
index 7ab5e11eed843e598feae359c646089560cb65b3..f6aed8bf4fbadb31b685bb4eb652cdbdde55dd45 100644 (file)
@@ -315,8 +315,10 @@ out:
 }
 
 static gboolean
-rspamd_parse_unix_path (rspamd_inet_addr_t **target, const char *src,
-                                               rspamd_mempool_t *pool)
+rspamd_parse_unix_path (rspamd_inet_addr_t **target,
+                                               const char *src, gsize len,
+                                               rspamd_mempool_t *pool,
+                                               enum rspamd_inet_address_parse_flags how)
 {
        gchar **tokens, **cur_tok, *p, *pwbuf;
        glong pwlen;
@@ -325,19 +327,29 @@ rspamd_parse_unix_path (rspamd_inet_addr_t **target, const char *src,
        rspamd_inet_addr_t *addr;
        bool has_group = false;
 
-       tokens = g_strsplit_set (src, " ,", -1);
        addr = rspamd_inet_addr_create (AF_UNIX, pool);
 
-       rspamd_strlcpy (addr->u.un->addr.sun_path, tokens[0],
-                       sizeof (addr->u.un->addr.sun_path));
-       #if defined(FREEBSD) || defined(__APPLE__)
-       addr->u.un->addr.sun_len = SUN_LEN (&addr->u.un->addr);
-       #endif
-
        addr->u.un->mode = 00644;
        addr->u.un->owner = (uid_t)-1;
        addr->u.un->group = (gid_t)-1;
 
+       if (!(how & RSPAMD_INET_ADDRESS_PARSE_REMOTE)) {
+               tokens = rspamd_string_len_split (src, len, " ,", -1, pool);
+
+               if (tokens[0] == NULL) {
+                       return FALSE;
+               }
+       }
+       else {
+               rspamd_strlcpy (addr->u.un->addr.sun_path, src,
+                               MIN (len + 1, sizeof (addr->u.un->addr.sun_path)));
+#if defined(FREEBSD) || defined(__APPLE__)
+               addr->u.un->addr.sun_len = SUN_LEN (&addr->u.un->addr);
+#endif
+               return TRUE;
+       }
+
+       /* Skip for remote */
        cur_tok = &tokens[1];
 #ifdef _SC_GETPW_R_SIZE_MAX
        pwlen = sysconf (_SC_GETPW_R_SIZE_MAX);
@@ -679,12 +691,13 @@ static gboolean
 rspamd_parse_inet_address_common (rspamd_inet_addr_t **target,
                                                                  const char *src,
                                                                  gsize srclen,
-                                                                 rspamd_mempool_t *pool)
+                                                                 rspamd_mempool_t *pool,
+                                                                 enum rspamd_inet_address_parse_flags how)
 {
        gboolean ret = FALSE;
        rspamd_inet_addr_t *addr = NULL;
        union sa_inet su;
-       const char *end;
+       const char *end = NULL;
        char ipbuf[INET6_ADDRSTRLEN + 1];
        guint iplen;
        gulong portnum;
@@ -698,8 +711,9 @@ rspamd_parse_inet_address_common (rspamd_inet_addr_t **target,
 
        rspamd_ip_check_ipv6 ();
 
-       if (src[0] == '/' || src[0] == '.') {
-               return rspamd_parse_unix_path (target, src, pool);
+       if (!(how & RSPAMD_INET_ADDRESS_PARSE_NO_UNIX) &&
+               (src[0] == '/' || src[0] == '.')) {
+               return rspamd_parse_unix_path (target, src, srclen, pool, how);
        }
 
        if (src[0] == '[') {
@@ -726,7 +740,7 @@ rspamd_parse_inet_address_common (rspamd_inet_addr_t **target,
                        ret = TRUE;
                }
 
-               if (ret && end[1] == ':') {
+               if (!(how & RSPAMD_INET_ADDRESS_PARSE_NO_PORT) && ret && end[1] == ':') {
                        /* Port part */
                        rspamd_strtoul (end + 1, srclen - iplen - 3, &portnum);
                        rspamd_inet_address_set_port (addr, portnum);
@@ -734,7 +748,8 @@ rspamd_parse_inet_address_common (rspamd_inet_addr_t **target,
        }
        else {
 
-               if ((end = memchr (src, ':', srclen)) != NULL) {
+               if (!(how & RSPAMD_INET_ADDRESS_PARSE_NO_PORT) &&
+                       (end = memchr (src, ':', srclen)) != NULL) {
                        /* This is either port number and ipv4 addr or ipv6 addr */
                        /* Search for another semicolon */
                        if (memchr (end + 1, ':', srclen - (end - src + 1)) &&
@@ -789,19 +804,21 @@ rspamd_parse_inet_address_common (rspamd_inet_addr_t **target,
 gboolean
 rspamd_parse_inet_address (rspamd_inet_addr_t **target,
                                                   const char *src,
-                                                  gsize srclen)
+                                                  gsize srclen,
+                                                  enum rspamd_inet_address_parse_flags how)
 {
-       return rspamd_parse_inet_address_common (target, src, srclen, NULL);
+       return rspamd_parse_inet_address_common (target, src, srclen, NULL, how);
 }
 
 rspamd_inet_addr_t *
 rspamd_parse_inet_address_pool (const char *src,
                                                                gsize srclen,
-                                                               rspamd_mempool_t *pool)
+                                                               rspamd_mempool_t *pool,
+                                                               enum rspamd_inet_address_parse_flags how)
 {
        rspamd_inet_addr_t *ret = NULL;
 
-       if (!rspamd_parse_inet_address_common (&ret, src, srclen, pool)) {
+       if (!rspamd_parse_inet_address_common (&ret, src, srclen, pool, how)) {
                return NULL;
        }
 
@@ -1224,7 +1241,8 @@ rspamd_resolve_addrs (const char *begin, size_t len, GPtrArray **addrs,
 
        rspamd_ip_check_ipv6 ();
 
-       if (rspamd_parse_inet_address (&cur_addr, begin, len)) {
+       if (rspamd_parse_inet_address (&cur_addr,
+                       begin, len, RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                if (*addrs == NULL) {
                        *addrs = g_ptr_array_new_full (1,
                                        (GDestroyNotify) rspamd_inet_address_free);
@@ -1387,7 +1405,8 @@ rspamd_parse_host_port_priority (const gchar *str,
                        }
                }
 
-               if (!rspamd_parse_inet_address (&cur_addr, str, strlen (str))) {
+               if (!rspamd_parse_inet_address (&cur_addr,
+                               str, strlen (str), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                        msg_err_pool_check ("cannot parse unix socket definition %s: %s",
                                        str,
                                        strerror (errno));
index 06413a51a66f0a070a13a87c868c1819f83510bd..6a33ad7ec871bae21109064962f35a4a31036001 100644 (file)
@@ -86,6 +86,13 @@ rspamd_inet_addr_t *rspamd_inet_address_from_rnds (
 gboolean rspamd_parse_inet_address_ip6 (const guchar *text, gsize len,
                                                                                gpointer target);
 
+enum rspamd_inet_address_parse_flags {
+       RSPAMD_INET_ADDRESS_PARSE_DEFAULT = 0,
+       RSPAMD_INET_ADDRESS_PARSE_REMOTE = 1u << 0u,
+       RSPAMD_INET_ADDRESS_PARSE_NO_UNIX = 1u << 1u,
+       RSPAMD_INET_ADDRESS_PARSE_NO_PORT = 1u << 2u,
+};
+
 /**
  * Parse string with ipv4 address of length `len` to `target` which should be
  * at least sizeof (in4_addr_t)
@@ -105,7 +112,8 @@ gboolean rspamd_parse_inet_address_ip4 (const guchar *text, gsize len,
  * @return
  */
 gboolean rspamd_parse_inet_address_ip (const char *src,
-                                                                          gsize srclen, rspamd_inet_addr_t *target);
+                                                                          gsize srclen,
+                                                                          rspamd_inet_addr_t *target);
 
 /**
  * Try to parse address from string
@@ -115,7 +123,8 @@ gboolean rspamd_parse_inet_address_ip (const char *src,
  */
 gboolean rspamd_parse_inet_address (rspamd_inet_addr_t **target,
                                                                        const char *src,
-                                                                       gsize srclen);
+                                                                       gsize srclen,
+                                                                       enum rspamd_inet_address_parse_flags how);
 
 /**
  * Use memory pool allocated inet address
@@ -126,7 +135,8 @@ gboolean rspamd_parse_inet_address (rspamd_inet_addr_t **target,
  */
 rspamd_inet_addr_t *rspamd_parse_inet_address_pool (const char *src,
                                                                                                        gsize srclen,
-                                                                                                       rspamd_mempool_t *pool);
+                                                                                                       rspamd_mempool_t *pool,
+                                                                                                       enum rspamd_inet_address_parse_flags how);
 
 /**
  * Returns string representation of inet address
index 19612f8ffe83cadd2f5ec78a85781f64af2b6b1f..4f0e2354cf9ba6ae5aaa1ba2026ebfd046ea0ea6 100644 (file)
@@ -1469,7 +1469,8 @@ check:
        /* Try address */
        rspamd_inet_addr_t *addr = NULL;
 
-       if (rspamd_parse_inet_address (&addr, data->host, strlen (data->host))) {
+       if (rspamd_parse_inet_address (&addr, data->host,
+                       strlen (data->host), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                rspamd_inet_address_set_port (addr, cbd->data->port);
                g_ptr_array_add (cbd->addrs, (void *)addr);
                cbd->conn = rspamd_http_connection_new_client (
index 0637a0ac1b8c7464f3b5337311006c19ad8827ba..e2bfd94d993d1454a3777e09890d468188efb4d6 100644 (file)
@@ -788,7 +788,8 @@ rspamd_upstreams_add_upstream (struct upstream_list *ups, const gchar *str,
                break;
        case RSPAMD_UPSTREAM_PARSE_NAMESERVER:
                addrs = g_ptr_array_sized_new (1);
-               if (rspamd_parse_inet_address (&addr, str, strlen (str))) {
+               if (rspamd_parse_inet_address (&addr, str, strlen (str),
+                               RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                        if (ups->ctx) {
                                upstream->name = rspamd_mempool_strdup (ups->ctx->pool, str);
                        }
index ec42ab39e4e7dc7c90d36ceab5d04704f6cb7d3d..d73bd7281803bf7ac2174a9ef55c8ecdc9e35b6c 100644 (file)
@@ -984,7 +984,8 @@ lua_http_request (lua_State *L)
                cbd->session = session;
        }
 
-       if (rspamd_parse_inet_address (&cbd->addr, msg->host->str, msg->host->len)) {
+       if (rspamd_parse_inet_address (&cbd->addr,
+                       msg->host->str, msg->host->len, RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                /* Host is numeric IP, no need to resolve */
                gboolean ret;
 
index 8318125ba13ace08a9db34540468683c8fbf8242..f873c451527e938c4a08e7a9c0053759f18705b4 100644 (file)
@@ -375,7 +375,8 @@ lua_ip_from_string (lua_State *L)
        if (ip_str) {
                ip = lua_ip_new (L, NULL);
 
-               if (!rspamd_parse_inet_address (&ip->addr, ip_str, len)) {
+               if (!rspamd_parse_inet_address (&ip->addr,
+                               ip_str, len, RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                        msg_warn ("cannot parse ip: %*s", (gint) len, ip_str);
                        ip->addr = NULL;
                }
@@ -560,7 +561,8 @@ rspamd_lua_ip_push_fromstring (lua_State *L, const gchar *ip_str)
        else {
                ip = g_malloc0 (sizeof (struct rspamd_lua_ip));
 
-               if (rspamd_parse_inet_address (&ip->addr, ip_str, strlen (ip_str))) {
+               if (rspamd_parse_inet_address (&ip->addr,
+                               ip_str, strlen (ip_str), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
 
                        pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *));
                        rspamd_lua_setclass (L, "rspamd{ip}", -1);
index 279f84ffae4a9321efddb281fbc3e43936847d68..32fa554768cf4e719959194ec4b6f43cc8c631a1 100644 (file)
@@ -896,7 +896,8 @@ rspamd_lua_redis_prepare_connection (lua_State *L, gint *pcbref, gboolean is_asy
                else if (lua_type (L, -1) == LUA_TSTRING) {
                        host = lua_tostring (L, -1);
 
-                       if (rspamd_parse_inet_address (&ip, host, strlen (host))) {
+                       if (rspamd_parse_inet_address (&ip,
+                                       host, strlen (host), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                                addr = g_alloca (sizeof (*addr));
                                addr->addr = ip;
 
@@ -1165,7 +1166,8 @@ lua_redis_make_request_sync (lua_State *L)
                }
                else if (lua_type (L, -1) == LUA_TSTRING) {
                        host = lua_tostring (L, -1);
-                       if (rspamd_parse_inet_address (&ip, host, strlen (host))) {
+                       if (rspamd_parse_inet_address (&ip,
+                                       host, strlen (host), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                                addr = g_alloca (sizeof (*addr));
                                addr->addr = ip;
 
index af1a12fae038f91774e7d103f372908a50c961d1..2ec6dc29b66ab42a9e2d22e2a8d75c4d5f015e1e 100644 (file)
@@ -3867,7 +3867,8 @@ lua_task_set_from_ip (lua_State *L)
        else {
                if (!rspamd_parse_inet_address (&addr,
                                ip_str,
-                               len)) {
+                               len,
+                               RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                        msg_warn_task ("cannot get IP from received header: '%s'",
                                        ip_str);
                }
index 18c022c38ea7c37ca47b62f118a05ed62e96cb3b..379d3d8075d0754cffa8d86d1831c2cfd27052e6 100644 (file)
@@ -1760,7 +1760,8 @@ lua_tcp_request (lua_State *L)
                }
        }
 
-       if (rspamd_parse_inet_address (&cbd->addr, host, strlen (host))) {
+       if (rspamd_parse_inet_address (&cbd->addr,
+                       host, strlen (host), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                rspamd_inet_address_set_port (cbd->addr, port);
                /* Host is numeric IP, no need to resolve */
                lua_tcp_register_watcher (cbd);
@@ -1942,7 +1943,8 @@ lua_tcp_connect_sync (lua_State *L)
                }
        }
 
-       if (rspamd_parse_inet_address (&cbd->addr, host, strlen (host))) {
+       if (rspamd_parse_inet_address (&cbd->addr,
+                       host, strlen (host), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                rspamd_inet_address_set_port (cbd->addr, (guint16)port);
                /* Host is numeric IP, no need to resolve */
                if (!lua_tcp_make_connection (cbd)) {
index 966ce9788a1214be18efdef8064572b9749b954e..b72108c34e3ea1c8b4e04de689031af2dfc6fe56 100644 (file)
@@ -373,7 +373,8 @@ lua_udp_sendto (lua_State *L) {
                if (lua_type (L, -1) == LUA_TSTRING) {
                        host = luaL_checkstring (L, -1);
 
-                       if (rspamd_parse_inet_address (&addr, host, strlen (host))) {
+                       if (rspamd_parse_inet_address (&addr,
+                                       host, strlen (host), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                                if (port != 0) {
                                        rspamd_inet_address_set_port (addr, port);
                                }
index 36d9746a574f61f0feaa024dfdad44fba32e5335..617f731f2d86e18562ddbe403b405a9ae88b33d2 100644 (file)
@@ -48,7 +48,8 @@ rspamd_parse_smtp_ip (const char *data, size_t len, rspamd_mempool_t *pool)
   %% write exec;
 
   if (ip_start && ip_end && ip_end > ip_start) {
-    return rspamd_parse_inet_address_pool (ip_start, ip_end - ip_start, pool);
+    return rspamd_parse_inet_address_pool (ip_start, ip_end - ip_start, pool,
+               RSPAMD_INET_ADDRESS_PARSE_NO_UNIX|RSPAMD_INET_ADDRESS_PARSE_REMOTE);
   }
 
   return NULL;
index e605ecb0adf82425ccbc53b778c642ce008c7e55..a089b70f723a8a11a96ffa582d74080d5f7bccd7 100644 (file)
@@ -223,7 +223,8 @@ rspamadm_control (gint argc, gchar **argv, const struct rspamadm_command *_cmd)
                exit (1);
        }
 
-       if (!rspamd_parse_inet_address (&addr, control_path, strlen (control_path))) {
+       if (!rspamd_parse_inet_address (&addr,
+                       control_path, strlen (control_path), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                rspamd_fprintf (stderr, "bad control path: %s\n", control_path);
                exit (1);
        }
index aa8a6235b3020e6b61e286b7d312ee30453dffff..95cc2bd6bccf751ac717ac9ef62a33bd69e8502a 100644 (file)
@@ -1323,7 +1323,8 @@ main (gint argc, gchar **argv, gchar **env)
        if (rspamd_main->cfg->control_socket_path) {
                if (!rspamd_parse_inet_address (&control_addr,
                                rspamd_main->cfg->control_socket_path,
-                               strlen (rspamd_main->cfg->control_socket_path))) {
+                               strlen (rspamd_main->cfg->control_socket_path),
+                               RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
                        msg_err_main ("cannot parse inet address %s",
                                        rspamd_main->cfg->control_socket_path);
                }
index 12e478793f9ea07c11cd76f5bc32909ebb1a00e5..bbe47fc04a128e537f1ae4dd50d8f073f15a3344 100644 (file)
@@ -83,9 +83,11 @@ rspamd_upstream_test_func (void)
                        RSPAMD_UPSTREAM_PARSE_DEFAULT,
                        NULL));
        up = rspamd_upstream_get (nls, RSPAMD_UPSTREAM_RANDOM, NULL, 0);
-       rspamd_parse_inet_address (&paddr, "127.0.0.2", strlen ("127.0.0.2"));
+       rspamd_parse_inet_address (&paddr, "127.0.0.2", strlen ("127.0.0.2"),
+                       RSPAMD_INET_ADDRESS_PARSE_DEFAULT);
        g_assert (rspamd_upstream_add_addr (up, paddr));
-       rspamd_parse_inet_address (&paddr, "::1", strlen ("::1"));
+       rspamd_parse_inet_address (&paddr, "::1", strlen ("::1"),
+                       RSPAMD_INET_ADDRESS_PARSE_DEFAULT);
        g_assert (rspamd_upstream_add_addr (up, paddr));
        /* Rewind to start */
        addr = rspamd_upstream_addr_next (up);