From 104cf0cfd71f50078cf7a7eae72de0675e546c00 Mon Sep 17 00:00:00 2001 From: Lucas Rolff Date: Wed, 17 Apr 2024 22:57:49 +0800 Subject: [PATCH] [Minor] Move hostname resolution up to cache it Instead of calling get_hostname() for every processed message, we instead reuse the variable value from rspamd boot time --- lualib/lua_selectors/extractors.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lualib/lua_selectors/extractors.lua b/lualib/lua_selectors/extractors.lua index 7a7f41a2f..97db65044 100644 --- a/lualib/lua_selectors/extractors.lua +++ b/lualib/lua_selectors/extractors.lua @@ -25,6 +25,8 @@ local maps = require "lua_selectors/maps" local E = {} local M = "selectors" +local HOSTNAME = rspamd_util.get_hostname() + local url_flags_ts = ts.array_of(ts.one_of(lua_util.keys(rspamd_url.flags))):is_optional() local function gen_exclude_flags_filter(exclude_flags) @@ -563,7 +565,7 @@ The first argument must be header name.]], }, ['rspamd_hostname'] = { ['get_value'] = function(task) - return rspamd_util.get_hostname(), 'string' + return HOSTNAME, 'string' end, ['description'] = 'Get hostname of the filter server', }, -- 2.39.5