diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-04-20 20:02:28 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-04-20 20:02:28 +0400 |
commit | 4d4668a0d4022583208d20bac9b8a0bede6f073d (patch) | |
tree | 14fbacb9511c738b40919aecbf168151605d28cb /src/lua | |
parent | 6cc47586dbcbf21fb67be92f6736fd76ca8baffb (diff) | |
download | rspamd-4d4668a0d4022583208d20bac9b8a0bede6f073d.tar.gz rspamd-4d4668a0d4022583208d20bac9b8a0bede6f073d.zip |
* Fix spf plugin that was broken in 0.4.7
* Add partial ipv6 support for some rspamd modules.
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_task.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 7ca1c58df..5695b6f42 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -981,12 +981,26 @@ static gint lua_task_get_from_ip (lua_State *L) { struct worker_task *task = lua_check_task (L); +#ifdef HAVE_INET_PTON + gchar ipbuf[INET6_ADDRSTRLEN]; +#endif if (task) { +#ifdef HAVE_INET_PTON + if (task->from_addr.ipv6) { + inet_ntop (AF_INET6, &task->from_addr.d.in6, ipbuf, sizeof (ipbuf)); + } + else { + inet_ntop (AF_INET, &task->from_addr.d.in4, ipbuf, sizeof (ipbuf)); + } + lua_pushstring (L, ipbuf); + return 1; +#else if (task->from_addr.s_addr != INADDR_NONE && task->from_addr.s_addr != INADDR_ANY) { lua_pushstring (L, inet_ntoa (task->from_addr)); return 1; } +#endif } lua_pushnil (L); @@ -999,10 +1013,19 @@ lua_task_get_from_ip_num (lua_State *L) struct worker_task *task = lua_check_task (L); if (task) { +#ifdef HAVE_INET_PTON + if (!task->from_addr.ipv6 && task->from_addr.d.in4.s_addr != INADDR_NONE) { + lua_pushinteger (L, ntohl (task->from_addr.d.in4.s_addr)); + return 1; + } + /* TODO: do something with ipv6 numeric representation */ +#else if (task->from_addr.s_addr != INADDR_NONE && task->from_addr.s_addr != INADDR_ANY) { lua_pushinteger (L, ntohl (task->from_addr.s_addr)); return 1; } + +#endif } lua_pushnil (L); |