commit 982f577: [Minor] Add a helper method to get the current DNS timeout

Vsevolod Stakhov vsevolod at rspamd.com
Sat Aug 20 20:56:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-08-20 21:52:14 +0100
URL: https://github.com/rspamd/rspamd/commit/982f5775bc99c62dab907dbd8b4f2cd7a8a81d3a (HEAD -> master)

[Minor] Add a helper method to get the current DNS timeout

---
 src/lua/lua_config.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index de4388746..c732b67a1 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -844,6 +844,13 @@ LUA_FUNCTION_DEF (config, get_tld_path);
  */
 LUA_FUNCTION_DEF (config, get_dns_max_requests);
 
+/***
+ * @method rspamd_config:get_dns_timeout()
+ * Returns timeout for a DNS request
+ * @return {number} DNS timeout in second or 0 if not defined
+ */
+LUA_FUNCTION_DEF (config, get_dns_timeout);
+
 static const struct luaL_reg configlib_m[] = {
 	LUA_INTERFACE_DEF (config, get_module_opt),
 	LUA_INTERFACE_DEF (config, get_mempool),
@@ -917,6 +924,7 @@ static const struct luaL_reg configlib_m[] = {
 	LUA_INTERFACE_DEF (config, init_subsystem),
 	LUA_INTERFACE_DEF (config, get_tld_path),
 	LUA_INTERFACE_DEF (config, get_dns_max_requests),
+	LUA_INTERFACE_DEF (config, get_dns_timeout),
 	{"__tostring", rspamd_lua_class_tostring},
 	{"__newindex", lua_config_newindex},
 	{NULL, NULL}
@@ -4611,6 +4619,22 @@ lua_config_get_dns_max_requests (lua_State *L)
 	return 1;
 }
 
+static gint
+lua_config_get_dns_timeout (lua_State *L)
+{
+	LUA_TRACE_POINT;
+	struct rspamd_config *cfg = lua_check_config (L, 1);
+
+	if (cfg != NULL) {
+		lua_pushnumber (L, cfg->dns_timeout);
+	}
+	else {
+		return luaL_error (L, "invalid arguments");
+	}
+
+	return 1;
+}
+
 static gint
 lua_monitored_alive (lua_State *L)
 {


More information about the Commits mailing list