struct rdns_reply_entry *elt;
gsize keylen = 0;
- if (reply->code != DNS_RC_NOERROR) {
+ if (reply->code != RDNS_RC_NOERROR) {
g_set_error (&err, DKIM_ERROR, DKIM_SIGERROR_NOKEY, "dns request to %s failed: %s", cbdata->ctx->dns_key,
rdns_strerror (reply->code));
cbdata->handler (NULL, 0, cbdata->ctx, cbdata->ud, err);
}
else {
LL_FOREACH (reply->entries, elt) {
- if (elt->type == DNS_REQUEST_TXT) {
+ if (elt->type == RDNS_REQUEST_TXT) {
key = rspamd_dkim_parse_key (elt->content.txt.data, &keylen, &err);
if (key) {
key->ttl = elt->ttl;
cbdata->handler = handler;
cbdata->ud = ud;
- return make_dns_request (resolver, s, ctx->pool, rspamd_dkim_dns_cb, cbdata, DNS_REQUEST_TXT, ctx->dns_key);
+ return make_dns_request (resolver, s, ctx->pool, rspamd_dkim_dns_cb, cbdata, RDNS_REQUEST_TXT, ctx->dns_key);
}
static gboolean
reqdata->ud = ud;
req = rdns_make_request_full (resolver->r, rspamd_dns_callback, reqdata,
- resolver->request_timeout, resolver->max_retransmits, name, 1, type);
+ resolver->request_timeout, resolver->max_retransmits, 1, name, type);
if (req != NULL) {
register_async_event (session, (event_finalizer_t)rspamd_dns_fin_cb, req,
/*
* XXX: rework to handle different request types
*/
- if (reply->code == DNS_RC_NOERROR) {
+ if (reply->code == RDNS_RC_NOERROR) {
lua_newtable (cd->L);
LL_FOREACH (reply->entries, elt) {
switch (elt->type) {
- case DNS_REQUEST_A:
+ case RDNS_REQUEST_A:
lua_ip_push (cd->L, AF_INET, &elt->content.a.addr);
lua_rawseti (cd->L, -2, ++i);
break;
- case DNS_REQUEST_AAA:
+ case RDNS_REQUEST_AAAA:
lua_ip_push (cd->L, AF_INET6, &elt->content.aaa.addr);
lua_rawseti (cd->L, -2, ++i);
break;
- case DNS_REQUEST_PTR:
+ case RDNS_REQUEST_PTR:
lua_pushstring (cd->L, elt->content.ptr.name);
lua_rawseti (cd->L, -2, ++i);
break;
- case DNS_REQUEST_TXT:
- case DNS_REQUEST_SPF:
+ case RDNS_REQUEST_TXT:
+ case RDNS_REQUEST_SPF:
lua_pushstring (cd->L, elt->content.txt.data);
lua_rawseti (cd->L, -2, ++i);
break;
- case DNS_REQUEST_MX:
+ case RDNS_REQUEST_MX:
/* mx['name'], mx['priority'] */
lua_newtable (cd->L);
lua_set_table_index (cd->L, "name", elt->content.mx.name);
cbdata = memory_pool_alloc (pool, sizeof (struct lua_dns_cbdata));
cbdata->L = L;
cbdata->resolver = resolver;
- if (type != DNS_REQUEST_PTR) {
+ if (type != RDNS_REQUEST_PTR) {
cbdata->to_resolve = memory_pool_strdup (pool, to_resolve);
}
else {
struct rspamd_dns_resolver *dns_resolver = lua_check_dns_resolver (L);
if (dns_resolver) {
- return lua_dns_resolver_resolve_common (L, dns_resolver, DNS_REQUEST_A, 2);
+ return lua_dns_resolver_resolve_common (L, dns_resolver, RDNS_REQUEST_A, 2);
}
else {
lua_pushnil (L);
struct rspamd_dns_resolver *dns_resolver = lua_check_dns_resolver (L);
if (dns_resolver) {
- return lua_dns_resolver_resolve_common (L, dns_resolver, DNS_REQUEST_PTR, 2);
+ return lua_dns_resolver_resolve_common (L, dns_resolver, RDNS_REQUEST_PTR, 2);
}
else {
lua_pushnil (L);
struct rspamd_dns_resolver *dns_resolver = lua_check_dns_resolver (L);
if (dns_resolver) {
- return lua_dns_resolver_resolve_common (L, dns_resolver, DNS_REQUEST_TXT, 2);
+ return lua_dns_resolver_resolve_common (L, dns_resolver, RDNS_REQUEST_TXT, 2);
}
else {
lua_pushnil (L);
struct rspamd_dns_resolver *dns_resolver = lua_check_dns_resolver (L);
if (dns_resolver) {
- return lua_dns_resolver_resolve_common (L, dns_resolver, DNS_REQUEST_MX, 2);
+ return lua_dns_resolver_resolve_common (L, dns_resolver, RDNS_REQUEST_MX, 2);
}
else {
lua_pushnil (L);
lua_newtable(L);
{
- LUA_ENUM(L, DNS_REQUEST_A, DNS_REQUEST_A);
- LUA_ENUM(L, DNS_REQUEST_PTR, DNS_REQUEST_PTR);
- LUA_ENUM(L, DNS_REQUEST_MX, DNS_REQUEST_MX);
- LUA_ENUM(L, DNS_REQUEST_TXT, DNS_REQUEST_TXT);
- LUA_ENUM(L, DNS_REQUEST_SRV, DNS_REQUEST_SRV);
- LUA_ENUM(L, DNS_REQUEST_SPF, DNS_REQUEST_SRV);
- LUA_ENUM(L, DNS_REQUEST_AAA, DNS_REQUEST_SRV);
+ LUA_ENUM(L, RDNS_REQUEST_A, RDNS_REQUEST_A);
+ LUA_ENUM(L, RDNS_REQUEST_PTR, RDNS_REQUEST_PTR);
+ LUA_ENUM(L, RDNS_REQUEST_MX, RDNS_REQUEST_MX);
+ LUA_ENUM(L, RDNS_REQUEST_TXT, RDNS_REQUEST_TXT);
+ LUA_ENUM(L, RDNS_REQUEST_SRV, RDNS_REQUEST_SRV);
+ LUA_ENUM(L, RDNS_REQUEST_SPF, RDNS_REQUEST_SRV);
+ LUA_ENUM(L, RDNS_REQUEST_AAA, RDNS_REQUEST_SRV);
}
luaL_register (L, NULL, dns_resolverlib_m);
struct in_addr ina;
struct timeval tv;
- if (reply->code != DNS_RC_NOERROR) {
+ if (reply->code != RDNS_RC_NOERROR) {
lua_http_push_error (450, ud);
return;
}
/* Resolve hostname */
if (make_dns_request (task->resolver, task->s, task->task_pool, lua_http_dns_callback, ud,
- DNS_REQUEST_A, hostname)) {
+ RDNS_REQUEST_A, hostname)) {
task->dns_requests ++;
}
struct rdns_reply_entry *elt;
- if (reply->code != DNS_RC_NOERROR) {
+ if (reply->code != RDNS_RC_NOERROR) {
lua_redis_push_error (rdns_strerror (reply->code), ud, FALSE);
return;
}
if (inet_aton (ud->server, &ud->ina) == 0) {
/* Need to make dns request */
/* Resolve hostname */
- if (make_dns_request (task->resolver, task->s, task->task_pool, lua_redis_dns_callback, ud,
- DNS_REQUEST_A, ud->server)) {
+ if (make_dns_request (task->resolver, task->s, task->task_pool,
+ lua_redis_dns_callback, ud,
+ RDNS_REQUEST_A, ud->server)) {
task->dns_requests ++;
lua_pushboolean (L, TRUE);
}
param->host_resolve = memory_pool_strdup (task->task_pool, surbl_req);
debug_task ("send surbl dns request %s", surbl_req);
if (make_dns_request (task->resolver, task->s, task->task_pool, dns_callback,
- (void *)param, DNS_REQUEST_A, surbl_req)) {
+ (void *)param, RDNS_REQUEST_A, surbl_req)) {
task->dns_requests ++;
}
}
debug_task ("in surbl request callback");
/* If we have result from DNS server, this url exists in SURBL, so increase score */
- if (reply->code == DNS_RC_NOERROR && reply->entries) {
+ if (reply->code == RDNS_RC_NOERROR && reply->entries) {
msg_info ("<%s> domain [%s] is in surbl %s", param->task->message_id,
param->host_resolve, param->suffix->suffix);
elt = reply->entries;
- if (elt->type == DNS_REQUEST_A) {
+ if (elt->type == RDNS_REQUEST_A) {
process_dns_results (param->task, param->suffix,
param->host_resolve, (guint32)elt->content.a.addr.s_addr);
}
-Subproject commit 38f3dc889752939835591ee1d29495c00117f41e
+Subproject commit cc5f39ee1862df1e8bcd2a1bb65fa3fac538a420
switch (session->state) {
case SMTP_STATE_RESOLVE_REVERSE:
/* Parse reverse reply and start resolve of this ip */
- if (reply->code != DNS_RC_NOERROR) {
+ if (reply->code != RDNS_RC_NOERROR) {
rspamd_conditional_debug(rspamd_main->logger, session->client_addr.s_addr, __FUNCTION__,
"DNS error: %s", dns_strerror (reply->code));
- if (reply->code == DNS_RC_NXDOMAIN) {
+ if (reply->code == RDNS_RC_NXDOMAIN) {
session->hostname = memory_pool_strdup (session->pool, XCLIENT_HOST_UNAVAILABLE);
}
else {
elt = reply->elements->data;
session->hostname = memory_pool_strdup (session->pool, elt->ptr.name);
session->state = SMTP_STATE_RESOLVE_NORMAL;
- make_dns_request (session->resolver, session->s, session->pool, smtp_dns_cb, session, DNS_REQUEST_A, session->hostname);
+ make_dns_request (session->resolver, session->s, session->pool,
+ smtp_dns_cb, session, RDNS_REQUEST_A, session->hostname);
}
}
break;
case SMTP_STATE_RESOLVE_NORMAL:
- if (reply->code != DNS_RC_NOERROR) {
+ if (reply->code != RDNS_RC_NOERROR) {
rspamd_conditional_debug(rspamd_main->logger, session->client_addr.s_addr, __FUNCTION__,
"DNS error: %s", dns_strerror (reply->code));
- if (reply->code == DNS_RC_NXDOMAIN) {
+ if (reply->code == RDNS_RC_NXDOMAIN) {
session->hostname = memory_pool_strdup (session->pool, XCLIENT_HOST_UNAVAILABLE);
}
else {
session->s = new_async_session (session->pool, NULL, NULL, free_smtp_session, session);
session->state = SMTP_STATE_RESOLVE_REVERSE;
if (! make_dns_request (session->resolver, session->s, session->pool,
- smtp_dns_cb, session, DNS_REQUEST_PTR, &session->client_addr)) {
+ smtp_dns_cb, session, RDNS_REQUEST_PTR, &session->client_addr)) {
msg_err ("cannot resolve %s", inet_ntoa (session->client_addr));
g_free (session);
close (nfd);
if (session->state != SMTP_PROXY_STATE_REJECT) {
- if (reply->code == DNS_RC_NOERROR) {
+ if (reply->code == RDNS_RC_NOERROR) {
/* This means that address is in dnsbl */
p = rdns_request_get_name (reply->request);
while (*p) {
rspamd_snprintf (dst, len, "%ud.%ud.%ud.%ud.%s", (guint)p[3],
(guint)p[2], (guint)p[1], (guint)p[0], cur->data);
if (make_dns_request (session->resolver, session->s, session->pool,
- smtp_dnsbl_cb, session, DNS_REQUEST_A, dst)) {
+ smtp_dnsbl_cb, session, RDNS_REQUEST_A, dst)) {
session->rbl_requests ++;
msg_debug ("send request to %s", dst);
}
{
case SMTP_PROXY_STATE_RESOLVE_REVERSE:
/* Parse reverse reply and start resolve of this ip */
- if (reply->code != DNS_RC_NOERROR) {
+ if (reply->code != RDNS_RC_NOERROR) {
rspamd_conditional_debug (rspamd_main->logger,
session->client_addr.s_addr, __FUNCTION__, "DNS error: %s",
rdns_strerror (reply->code));
- if (reply->code == DNS_RC_NXDOMAIN) {
+ if (reply->code == RDNS_RC_NXDOMAIN) {
session->hostname = memory_pool_strdup (session->pool,
XCLIENT_HOST_UNAVAILABLE);
}
elt->content.ptr.name);
session->state = SMTP_PROXY_STATE_RESOLVE_NORMAL;
make_dns_request (session->resolver, session->s, session->pool,
- smtp_dns_cb, session, DNS_REQUEST_A, session->hostname);
+ smtp_dns_cb, session, RDNS_REQUEST_A, session->hostname);
}
}
break;
case SMTP_PROXY_STATE_RESOLVE_NORMAL:
- if (reply->code != DNS_RC_NOERROR) {
+ if (reply->code != RDNS_RC_NOERROR) {
rspamd_conditional_debug (rspamd_main->logger,
session->client_addr.s_addr, __FUNCTION__, "DNS error: %s",
rdns_strerror (reply->code));
- if (reply->code == DNS_RC_NXDOMAIN) {
+ if (reply->code == RDNS_RC_NXDOMAIN) {
session->hostname = memory_pool_strdup (session->pool,
XCLIENT_HOST_UNAVAILABLE);
}
session->s = new_async_session (session->pool, NULL, NULL, free_smtp_proxy_session, session);
session->state = SMTP_PROXY_STATE_RESOLVE_REVERSE;
if (! make_dns_request (session->resolver, session->s, session->pool,
- smtp_dns_cb, session, DNS_REQUEST_PTR, session->ptr_str)) {
+ smtp_dns_cb, session, RDNS_REQUEST_PTR, session->ptr_str)) {
msg_err ("cannot resolve %s", inet_ntoa (session->client_addr));
g_slice_free1 (sizeof (struct smtp_proxy_session), session);
close (nfd);
cb->rec->requests_inflight --;
- if (reply->code == DNS_RC_NOERROR) {
+ if (reply->code == RDNS_RC_NOERROR) {
/* Add all logic for all DNS states here */
LL_FOREACH (reply->entries, elt_data) {
switch (cb->cur_action) {
case SPF_RESOLVE_MX:
- if (elt_data->type == DNS_REQUEST_MX) {
+ if (elt_data->type == RDNS_REQUEST_MX) {
/* Now resolve A record for this MX */
if (make_dns_request (task->resolver, task->s, task->task_pool,
- spf_record_dns_callback, (void *)cb, DNS_REQUEST_A, elt_data->content.mx.name)) {
+ spf_record_dns_callback, (void *)cb, RDNS_REQUEST_A, elt_data->content.mx.name)) {
task->dns_requests ++;
cb->rec->requests_inflight ++;
}
}
- else if (elt_data->type == DNS_REQUEST_A) {
+ else if (elt_data->type == RDNS_REQUEST_A) {
if (!cb->addr->data.normal.parsed) {
cb->addr->data.normal.d.in4.s_addr = elt_data->content.a.addr.s_addr;
cb->addr->data.normal.mask = 32;
}
#ifdef HAVE_INET_PTON
- else if (elt_data->type == DNS_REQUEST_AAA) {
+ else if (elt_data->type == RDNS_REQUEST_AAAA) {
if (!cb->addr->data.normal.parsed) {
memcpy (&cb->addr->data.normal.d.in6, &elt_data->content.aaa.addr, sizeof (struct in6_addr));
cb->addr->data.normal.mask = 32;
#endif
break;
case SPF_RESOLVE_A:
- if (elt_data->type == DNS_REQUEST_A) {
+ if (elt_data->type == RDNS_REQUEST_A) {
/* XXX: process only one record */
cb->addr->data.normal.d.in4.s_addr = elt_data->content.a.addr.s_addr;
cb->addr->data.normal.mask = 32;
cb->addr->data.normal.parsed = TRUE;
}
#ifdef HAVE_INET_PTON
- else if (elt_data->type == DNS_REQUEST_AAA) {
+ else if (elt_data->type == RDNS_REQUEST_AAAA) {
memcpy (&cb->addr->data.normal.d.in6, &elt_data->content.aaa.addr, sizeof (struct in6_addr));
cb->addr->data.normal.mask = 32;
cb->addr->data.normal.parsed = TRUE;
break;
#ifdef HAVE_INET_PTON
case SPF_RESOLVE_AAA:
- if (elt_data->type == DNS_REQUEST_A) {
+ if (elt_data->type == RDNS_REQUEST_A) {
/* XXX: process only one record */
cb->addr->data.normal.d.in4.s_addr = elt_data->content.a.addr.s_addr;
cb->addr->data.normal.mask = 32;
cb->addr->data.normal.parsed = TRUE;
}
- else if (elt_data->type == DNS_REQUEST_AAA) {
+ else if (elt_data->type == RDNS_REQUEST_AAAA) {
memcpy (&cb->addr->data.normal.d.in6, &elt_data->content.aaa.addr, sizeof (struct in6_addr));
cb->addr->data.normal.mask = 32;
cb->addr->data.normal.parsed = TRUE;
case SPF_RESOLVE_PTR:
break;
case SPF_RESOLVE_REDIRECT:
- if (elt_data->type == DNS_REQUEST_TXT) {
+ if (elt_data->type == RDNS_REQUEST_TXT) {
begin = elt_data->content.txt.data;
if (!cb->in_include && cb->rec->addrs) {
}
break;
case SPF_RESOLVE_INCLUDE:
- if (elt_data->type == DNS_REQUEST_TXT) {
+ if (elt_data->type == RDNS_REQUEST_TXT) {
begin = elt_data->content.txt.data;
#ifdef SPF_DEBUG
msg_info ("before include");
case SPF_RESOLVE_EXP:
break;
case SPF_RESOLVE_EXISTS:
- if (elt_data->type == DNS_REQUEST_A) {
+ if (elt_data->type == RDNS_REQUEST_A) {
/* If specified address resolves, we can accept connection from every IP */
cb->addr->data.normal.d.in4.s_addr = INADDR_NONE;
cb->addr->data.normal.mask = 0;
}
}
}
- else if (reply->code == DNS_RC_NXDOMAIN) {
+ else if (reply->code == RDNS_RC_NXDOMAIN) {
switch (cb->cur_action) {
case SPF_RESOLVE_MX:
- if (rdns_request_has_type (reply->request, DNS_REQUEST_MX)) {
+ if (rdns_request_has_type (reply->request, RDNS_REQUEST_MX)) {
msg_info ("<%s>: spf error for domain %s: cannot find MX record for %s",
task->message_id, cb->rec->sender_domain, cb->rec->cur_domain);
cb->addr->data.normal.d.in4.s_addr = INADDR_NONE;
}
break;
case SPF_RESOLVE_A:
- if (rdns_request_has_type (reply->request, DNS_REQUEST_A)) {
+ if (rdns_request_has_type (reply->request, RDNS_REQUEST_A)) {
cb->addr->data.normal.d.in4.s_addr = INADDR_NONE;
cb->addr->data.normal.mask = 32;
}
break;
#ifdef HAVE_INET_PTON
case SPF_RESOLVE_AAA:
- if (rdns_request_has_type (reply->request, DNS_REQUEST_AAA)) {
+ if (rdns_request_has_type (reply->request, RDNS_REQUEST_AAAA)) {
memset (&cb->addr->data.normal.d.in6, 0xff, sizeof (struct in6_addr));
cb->addr->data.normal.mask = 32;
}
cb->cur_action = SPF_RESOLVE_A;
cb->in_include = rec->in_include;
if (make_dns_request (task->resolver, task->s, task->task_pool,
- spf_record_dns_callback, (void *)cb, DNS_REQUEST_A, host)) {
+ spf_record_dns_callback, (void *)cb, RDNS_REQUEST_A, host)) {
task->dns_requests ++;
rec->requests_inflight ++;
return TRUE;
cb->cur_action = SPF_RESOLVE_MX;
cb->in_include = rec->in_include;
if (make_dns_request (task->resolver, task->s, task->task_pool,
- spf_record_dns_callback, (void *)cb, DNS_REQUEST_MX, host)) {
+ spf_record_dns_callback, (void *)cb, RDNS_REQUEST_MX, host)) {
task->dns_requests ++;
rec->requests_inflight ++;
addr->data.list = NULL;
domain = memory_pool_strdup (task->task_pool, begin);
if (make_dns_request (task->resolver, task->s, task->task_pool,
- spf_record_dns_callback, (void *)cb, DNS_REQUEST_TXT, domain)) {
+ spf_record_dns_callback, (void *)cb, RDNS_REQUEST_TXT, domain)) {
task->dns_requests ++;
rec->requests_inflight ++;
cb->in_include = rec->in_include;
domain = memory_pool_strdup (task->task_pool, begin);
if (make_dns_request (task->resolver, task->s, task->task_pool,
- spf_record_dns_callback, (void *)cb, DNS_REQUEST_TXT, domain)) {
+ spf_record_dns_callback, (void *)cb, RDNS_REQUEST_TXT, domain)) {
task->dns_requests ++;
rec->requests_inflight ++;
host = memory_pool_strdup (task->task_pool, begin);
if (make_dns_request (task->resolver, task->s, task->task_pool,
- spf_record_dns_callback, (void *)cb, DNS_REQUEST_A, host)) {
+ spf_record_dns_callback, (void *)cb, RDNS_REQUEST_A, host)) {
task->dns_requests ++;
rec->requests_inflight ++;
struct rdns_reply_entry *elt;
rec->requests_inflight --;
- if (reply->code == DNS_RC_NOERROR) {
+ if (reply->code == RDNS_RC_NOERROR) {
LL_FOREACH (reply->entries, elt) {
start_spf_parse (rec, elt->content.txt.data, elt->ttl);
}
rec->sender_domain = rec->cur_domain;
if (make_dns_request (task->resolver, task->s, task->task_pool, spf_dns_callback,
- (void *)rec, DNS_REQUEST_TXT, rec->cur_domain)) {
+ (void *)rec, RDNS_REQUEST_TXT, rec->cur_domain)) {
task->dns_requests ++;
rec->requests_inflight ++;
return TRUE;
}
rec->sender_domain = rec->cur_domain;
if (make_dns_request (task->resolver, task->s, task->task_pool,
- spf_dns_callback, (void *)rec, DNS_REQUEST_TXT, rec->cur_domain)) {
+ spf_dns_callback, (void *)rec, RDNS_REQUEST_TXT, rec->cur_domain)) {
task->dns_requests ++;
rec->requests_inflight ++;
return TRUE;