aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_dns.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-17 23:58:30 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-17 23:58:30 +0000
commit95ed3b732549a6f5c5a7f39dd3e815eb18d0ffb7 (patch)
tree66eeb596ddfd2e0bbb5ecf874dc438a266e26201 /src/lua/lua_dns.c
parent0d6d892baec6cbafb01ca5e84df6830991929cd3 (diff)
downloadrspamd-95ed3b732549a6f5c5a7f39dd3e815eb18d0ffb7.tar.gz
rspamd-95ed3b732549a6f5c5a7f39dd3e815eb18d0ffb7.zip
Store IP addresses properly in lua.
Diffstat (limited to 'src/lua/lua_dns.c')
-rw-r--r--src/lua/lua_dns.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c
index cb011445a..fde9da422 100644
--- a/src/lua/lua_dns.c
+++ b/src/lua/lua_dns.c
@@ -67,7 +67,6 @@ lua_dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
{
struct lua_dns_cbdata *cd = arg;
gint i = 0;
- struct in_addr ina;
struct rspamd_dns_resolver **presolver;
union rspamd_reply_element *elt;
GList *cur;
@@ -86,9 +85,19 @@ lua_dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
cur = reply->elements;
while (cur) {
elt = cur->data;
- memcpy (&ina, &elt->a.addr[0], sizeof (struct in_addr));
- /* Actually this copy memory, so using of inet_ntoa is valid */
- lua_pushstring (cd->L, inet_ntoa (ina));
+ lua_ip_push (cd->L, AF_INET, &elt->a.addr);
+ lua_rawseti (cd->L, -2, ++i);
+ cur = g_list_next (cur);
+ }
+ lua_pushnil (cd->L);
+ }
+ if (reply->type == DNS_REQUEST_AAA) {
+
+ lua_newtable (cd->L);
+ cur = reply->elements;
+ while (cur) {
+ elt = cur->data;
+ lua_ip_push (cd->L, AF_INET6, &elt->aaa.addr);
lua_rawseti (cd->L, -2, ++i);
cur = g_list_next (cur);
}