aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_dns.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-02-19 18:41:19 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-02-19 18:41:19 +0000
commit5c026b66583e20f4f1455f7f0da773f64c26992d (patch)
tree40943808c082c9d9445f33e620ff2affe3689f0b /src/lua/lua_dns.c
parent5b78ecce464ef90e4794ed3c6f1d0dcfd5ed2e83 (diff)
downloadrspamd-5c026b66583e20f4f1455f7f0da773f64c26992d.tar.gz
rspamd-5c026b66583e20f4f1455f7f0da773f64c26992d.zip
Fix PTR requests handling.
Diffstat (limited to 'src/lua/lua_dns.c')
-rw-r--r--src/lua/lua_dns.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c
index b3d8f768f..c53688ef5 100644
--- a/src/lua/lua_dns.c
+++ b/src/lua/lua_dns.c
@@ -178,7 +178,6 @@ lua_dns_resolver_resolve_common (lua_State *L, struct rspamd_dns_resolver *resol
struct rspamd_async_session *session, **psession;
memory_pool_t *pool, **ppool;
const gchar *to_resolve;
- struct in_addr ina;
struct lua_dns_cbdata *cbdata;
/* Check arguments */
@@ -191,17 +190,23 @@ lua_dns_resolver_resolve_common (lua_State *L, struct rspamd_dns_resolver *resol
to_resolve = luaL_checkstring (L, 4);
if (pool != NULL && session != NULL && to_resolve != NULL && lua_isfunction (L, 5)) {
- if (type == DNS_REQUEST_PTR) {
- if (inet_aton (to_resolve, &ina) == 0) {
+ cbdata = memory_pool_alloc (pool, sizeof (struct lua_dns_cbdata));
+ cbdata->L = L;
+ cbdata->resolver = resolver;
+ if (type != DNS_REQUEST_PTR) {
+ cbdata->to_resolve = memory_pool_strdup (pool, to_resolve);
+ }
+ else {
+ char *ptr_str;
+ ptr_str = rdns_generate_ptr_from_str (to_resolve);
+ if (ptr_str == NULL) {
msg_err ("wrong resolve string to PTR request: %s", to_resolve);
lua_pushnil (L);
return 1;
}
+ cbdata->to_resolve = memory_pool_strdup (pool, ptr_str);
+ free (ptr_str);
}
- cbdata = memory_pool_alloc (pool, sizeof (struct lua_dns_cbdata));
- cbdata->L = L;
- cbdata->resolver = resolver;
- cbdata->to_resolve = memory_pool_strdup (pool, to_resolve);
lua_pushvalue (L, 5);
cbdata->cbref = luaL_ref (L, LUA_REGISTRYINDEX);
@@ -211,13 +216,7 @@ lua_dns_resolver_resolve_common (lua_State *L, struct rspamd_dns_resolver *resol
else {
cbdata->user_str = NULL;
}
-
- if (type == DNS_REQUEST_PTR) {
- make_dns_request (resolver, session, pool, lua_dns_callback, cbdata, type, &ina);
- }
- else {
- make_dns_request (resolver, session, pool, lua_dns_callback, cbdata, type, to_resolve);
- }
+ make_dns_request (resolver, session, pool, lua_dns_callback, cbdata, type, to_resolve);
lua_pushboolean (L, TRUE);
}
else {