diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-09-25 13:05:00 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-09-25 13:05:00 +0100 |
commit | 60cd96905a9eab257074634a18aae8c711d62293 (patch) | |
tree | 639c213ddb70b794216b295c074d4d02600b80b0 /src/lua/lua_tcp.c | |
parent | 89252bcf03a2213a72f348e210240bb96848e5aa (diff) | |
download | rspamd-60cd96905a9eab257074634a18aae8c711d62293.tar.gz rspamd-60cd96905a9eab257074634a18aae8c711d62293.zip |
[Fix] Same fix for lua_tcp
Diffstat (limited to 'src/lua/lua_tcp.c')
-rw-r--r-- | src/lua/lua_tcp.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 73b2c9ae2..05c9de7a2 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -1378,17 +1378,30 @@ lua_tcp_dns_handler (struct rdns_reply *reply, gpointer ud) * We set this flag as it means that we have already registered the watcher * when started DNS query */ - cbd->flags |= LUA_TCP_FLAG_RESOLVED; + struct rdns_reply_entry *entry; - if (reply->entries->type == RDNS_REQUEST_A) { - cbd->addr = rspamd_inet_address_new (AF_INET, - &reply->entries->content.a.addr); + DL_FOREACH(reply->entries, entry) { + if (entry->type == RDNS_REQUEST_A) { + cbd->addr = rspamd_inet_address_new(AF_INET, + &entry->content.a.addr); + break; + } + else if (entry->type == RDNS_REQUEST_AAAA) { + cbd->addr = rspamd_inet_address_new(AF_INET6, + &entry->content.aaa.addr); + break; + } } - else if (reply->entries->type == RDNS_REQUEST_AAAA) { - cbd->addr = rspamd_inet_address_new (AF_INET6, - &reply->entries->content.aaa.addr); + + if (cbd->addr == NULL){ + rn = rdns_request_get_name (reply->request, NULL); + lua_tcp_push_error (cbd, TRUE, "unable to resolve host: %s; no records with this name", + rn->name); + TCP_RELEASE (cbd); + return; } + cbd->flags |= LUA_TCP_FLAG_RESOLVED; rspamd_inet_address_set_port (cbd->addr, cbd->port); if (!lua_tcp_make_connection (cbd)) { |