aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-27 19:06:18 +0100
committerGitHub <noreply@github.com>2018-09-27 19:06:18 +0100
commit4cf94ce5492657adf002920df2fa6f03c1f02f5f (patch)
tree7805e55370f06d2646d431eb02558a222513a5d5 /src
parent30365705c8a07abb207d5d867f00ca697a7e6e37 (diff)
parent023a17c1da5fa20491e2926e753f532f2a43d06f (diff)
downloadrspamd-4cf94ce5492657adf002920df2fa6f03c1f02f5f.tar.gz
rspamd-4cf94ce5492657adf002920df2fa6f03c1f02f5f.zip
Merge pull request #2540 from negram/dns-sync-rspamadm
Dns sync rspamadm
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_dns.c45
-rw-r--r--src/rspamadm/rspamadm.c5
2 files changed, 36 insertions, 14 deletions
diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c
index 77a7ef855..fe4b7ff2e 100644
--- a/src/lua/lua_dns.c
+++ b/src/lua/lua_dns.c
@@ -39,6 +39,7 @@ lua_dns_request (lua_State *L)
{
GError *err = NULL;
struct rspamd_async_session *session = NULL;
+ struct rspamd_config *cfg = NULL;
struct lua_rspamd_dns_cbdata *cbdata = NULL;
const gchar *to_resolve = NULL;
const gchar *type_str = NULL;
@@ -49,8 +50,8 @@ lua_dns_request (lua_State *L)
/* Check arguments */
if (!rspamd_lua_parse_table_arguments (L, 1, &err,
- "*name=S;*task=U{task};*type=S;forced=B",
- &to_resolve, &task, &type_str, &forced)) {
+ "*name=S;task=U{task};*type=S;forced=B;session=U{session};config=U{config}",
+ &to_resolve, &task, &type_str, &forced, &session, &cfg)) {
if (err) {
ret = luaL_error (L, "invalid arguments: %s", err->message);
@@ -65,6 +66,10 @@ lua_dns_request (lua_State *L)
if (task) {
session = task->s;
pool = task->task_pool;
+ cfg = task->cfg;
+ }
+ else if (session && cfg) {
+ pool = cfg->cfg_pool;
}
else {
return luaL_error (L, "invalid arguments: either task or session/config should be set");
@@ -97,23 +102,35 @@ lua_dns_request (lua_State *L)
free (ptr_str);
}
- if (forced) {
- ret = make_dns_request_task_forced (task,
- lua_dns_callback,
- cbdata,
- type,
- to_resolve);
+
+ if (task == NULL) {
+ ret = make_dns_request (cfg->dns_resolver,
+ session,
+ pool,
+ lua_dns_callback,
+ cbdata,
+ type,
+ to_resolve);
}
else {
- ret = make_dns_request_task (task,
- lua_dns_callback,
- cbdata,
- type,
- to_resolve);
+ if (forced) {
+ ret = make_dns_request_task_forced (task,
+ lua_dns_callback,
+ cbdata,
+ type,
+ to_resolve);
+ }
+ else {
+ ret = make_dns_request_task (task,
+ lua_dns_callback,
+ cbdata,
+ type,
+ to_resolve);
+ }
}
if (ret) {
- cbdata->thread = lua_thread_pool_get_running_entry (task->cfg->lua_thread_pool);
+ cbdata->thread = lua_thread_pool_get_running_entry (cfg->lua_thread_pool);
cbdata->s = session;
cbdata->w = rspamd_session_get_watcher (session);
rspamd_session_watcher_push (session);
diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c
index 052dcd1d6..49242ccaf 100644
--- a/src/rspamadm/rspamadm.c
+++ b/src/rspamadm/rspamadm.c
@@ -423,6 +423,11 @@ main (gint argc, gchar **argv, gchar **env)
rspamd_set_logger (cfg, process_quark, &rspamd_main->logger,
rspamd_main->server_pool);
(void) rspamd_log_open (rspamd_main->logger);
+
+ (void) dns_resolver_init (rspamd_main->logger,
+ rspamd_main->ev_base,
+ cfg);
+
g_log_set_default_handler (rspamd_glib_log_function, rspamd_main->logger);
g_set_printerr_handler (rspamd_glib_printerr_function);
rspamd_config_post_load (cfg,