diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-04-11 14:59:39 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-04-11 14:59:39 +0100 |
commit | 641353ecb1c68ef7642a15d861ff59aba672ac54 (patch) | |
tree | d88412dbbd83c7bb2fc43f997c8c9ca59ed06281 /src/rspamadm | |
parent | 42a8b2da0117555109c35a9b6e44e73d605a0bd6 (diff) | |
download | rspamd-641353ecb1c68ef7642a15d861ff59aba672ac54.tar.gz rspamd-641353ecb1c68ef7642a15d861ff59aba672ac54.zip |
[Minor] Add resolver to rspamadm lua scripts
Diffstat (limited to 'src/rspamadm')
-rw-r--r-- | src/rspamadm/rspamadm.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c index 762a74c1f..650ae5834 100644 --- a/src/rspamadm/rspamadm.c +++ b/src/rspamadm/rspamadm.c @@ -326,10 +326,11 @@ rspamadm_command_maybe_match_name (const gchar *cmd, const gchar *input) static void -rspamadm_add_lua_globals (void) +rspamadm_add_lua_globals (struct rspamd_dns_resolver *resolver) { struct rspamd_async_session **psession; struct event_base **pev_base; + struct rspamd_dns_resolver **presolver; rspamadm_session = rspamd_session_create (rspamd_main->cfg->cfg_pool, NULL, NULL, (event_finalizer_t )NULL, NULL); @@ -343,6 +344,11 @@ rspamadm_add_lua_globals (void) rspamd_lua_setclass (L, "rspamd{ev_base}", -1); *pev_base = rspamd_main->ev_base; lua_setglobal (L, "rspamadm_ev_base"); + + presolver = lua_newuserdata (L, sizeof (struct rspamd_dns_resolver *)); + rspamd_lua_setclass (L, "rspamd{resolver}", -1); + *presolver = resolver; + lua_setglobal (L, "rspamadm_resolver"); } gint @@ -356,6 +362,7 @@ main (gint argc, gchar **argv, gchar **env) gchar **nargv, **targv; const gchar *cmd_name; const struct rspamadm_command *cmd; + struct rspamd_dns_resolver *resolver; GPtrArray *all_commands = g_ptr_array_new (); /* Discovered during check */ gint i, nargc, targc; worker_t **pworker; @@ -436,7 +443,7 @@ main (gint argc, gchar **argv, gchar **env) rspamd_main->server_pool); (void) rspamd_log_open (rspamd_main->logger); - (void) dns_resolver_init (rspamd_main->logger, + resolver = rspamd_dns_resolver_init (rspamd_main->logger, rspamd_main->ev_base, cfg); rspamd_main->http_ctx = rspamd_http_context_create (cfg, rspamd_main->ev_base, @@ -471,7 +478,7 @@ main (gint argc, gchar **argv, gchar **env) } rspamd_lua_set_globals (cfg, L); - rspamadm_add_lua_globals (); + rspamadm_add_lua_globals (resolver); #ifdef WITH_HIREDIS rspamd_redis_pool_config (cfg->redis_pool, cfg, rspamd_main->ev_base); |