static const int default_tcp_timeout = 5000;
static struct rspamd_dns_resolver *
-lua_tcp_global_resolver (struct event_base *ev_base)
+lua_tcp_global_resolver (struct event_base *ev_base,
+ struct rspamd_config *cfg)
{
static struct rspamd_dns_resolver *global_resolver;
+ if (cfg && cfg->dns_resolver) {
+ return cfg->dns_resolver;
+ }
+
if (global_resolver == NULL) {
- global_resolver = dns_resolver_init (NULL, ev_base, NULL);
+ global_resolver = dns_resolver_init (NULL, ev_base, cfg);
}
return global_resolver;
struct rspamd_dns_resolver *resolver;
struct rspamd_async_session *session;
struct rspamd_task *task = NULL;
+ struct rspamd_config *cfg;
struct iovec *iov = NULL;
guint niov = 0, total_out;
guint64 h;
}
lua_pop (L, 1);
- lua_pushstring (L, "resolver");
+ lua_pushstring (L, "session");
lua_gettable (L, -2);
- if (rspamd_lua_check_udata_maybe (L, -1, "rspamd{resolver}")) {
- resolver = *(struct rspamd_dns_resolver **)lua_touserdata (L, -1);
+ if (rspamd_lua_check_udata_maybe (L, -1, "rspamd{session}")) {
+ session = *(struct rspamd_async_session **)lua_touserdata (L, -1);
}
else {
- resolver = lua_tcp_global_resolver (ev_base);
+ session = NULL;
}
lua_pop (L, 1);
- lua_pushstring (L, "session");
+ lua_pushstring (L, "config");
lua_gettable (L, -2);
- if (rspamd_lua_check_udata_maybe (L, -1, "rspamd{session}")) {
- session = *(struct rspamd_async_session **)lua_touserdata (L, -1);
+ if (rspamd_lua_check_udata_maybe (L, -1, "rspamd{config}")) {
+ cfg = *(struct rspamd_config **)lua_touserdata (L, -1);
}
else {
- session = NULL;
+ cfg = NULL;
+ }
+ lua_pop (L, 1);
+
+ lua_pushstring (L, "resolver");
+ lua_gettable (L, -2);
+ if (rspamd_lua_check_udata_maybe (L, -1, "rspamd{resolver}")) {
+ resolver = *(struct rspamd_dns_resolver **)lua_touserdata (L, -1);
+ }
+ else {
+ resolver = lua_tcp_global_resolver (ev_base, cfg);
}
lua_pop (L, 1);
}