]> source.dussan.org Git - rspamd.git/commitdiff
Rework lua basic API for new IP.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 12 Mar 2015 14:29:33 +0000 (14:29 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 12 Mar 2015 14:29:33 +0000 (14:29 +0000)
src/lua/lua_common.h
src/lua/lua_config.c
src/lua/lua_task.c

index c9ce211784ea469b250e7776a387ed6398f78cb1..ce817d1e193c6bff093fb23fffe7cc8e1f9cd89b 100644 (file)
@@ -146,8 +146,7 @@ int rspamd_lua_typerror (lua_State *L, int narg, const char *tname);
  * Lua IP address structure
  */
 struct rspamd_lua_ip {
-       rspamd_inet_addr_t addr;
-       gboolean is_valid;
+       rspamd_inet_addr_t *addr;
 };
 
 /**
index d535f0a1e7e260e86dfce11ea1a16cbfac596e25..5116fff93d7664fb784fb708b45c4f41df47b56e 100644 (file)
@@ -1508,7 +1508,7 @@ lua_radix_get_key (lua_State * L)
                        ud = luaL_checkudata (L, 2, "rspamd{ip}");
                        if (ud != NULL) {
                                addr = *((struct rspamd_lua_ip **)ud);
-                               if (!addr->is_valid) {
+                               if (addr->addr == NULL) {
                                        msg_err ("rspamd{ip} is not valid");
                                        addr = NULL;
                                }
@@ -1519,7 +1519,7 @@ lua_radix_get_key (lua_State * L)
                }
 
                if (addr != NULL) {
-                       if (radix_find_compressed_addr (radix, &addr->addr)
+                       if (radix_find_compressed_addr (radix, addr->addr)
                                        !=  RADIX_NO_VALUE) {
                                ret = TRUE;
                        }
index 60dfb7cf7dfe57ac05b889ee7368a1f6c22474a3..e74d7e71c10b3be7b9912ff999b633c694ecdaf3 100644 (file)
@@ -1503,7 +1503,7 @@ lua_task_get_from_ip (lua_State *L)
        struct rspamd_task *task = lua_check_task (L, 1);
 
        if (task) {
-               rspamd_lua_ip_push (L, &task->from_addr);
+               rspamd_lua_ip_push (L, task->from_addr);
        }
        else {
                lua_pushnil (L);
@@ -1533,7 +1533,7 @@ lua_task_get_client_ip (lua_State *L)
        struct rspamd_task *task = lua_check_task (L, 1);
 
        if (task) {
-               rspamd_lua_ip_push (L, &task->client_addr);
+               rspamd_lua_ip_push (L, task->client_addr);
        }
        else {
                lua_pushnil (L);