]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Rbl: Add url_full_hostname option
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 16 Nov 2021 17:14:53 +0000 (17:14 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 16 Nov 2021 17:14:53 +0000 (17:14 +0000)
lualib/plugins/rbl.lua
src/plugins/lua/rbl.lua

index f3a2035d303df7f26e3d89daf9342e8ba765e023..973ba33c7640b85bde310272df573aa0eb514568 100644 (file)
@@ -132,6 +132,7 @@ local rule_schema_tbl = {
   symbols_prefixes = ts.map_of(ts.string, ts.string):is_optional(),
   unknown = ts.boolean:is_optional(),
   url_compose_map = lua_maps.map_schema:is_optional(),
+  url_full_hostname = ts.boolean:is_optional(),
   urls = ts.boolean:is_optional(),
   whitelist = lua_maps.map_schema:is_optional(),
   whitelist_exception = (
index 3d0e025297816019fac2950f93638b3ec753b609..8743f125d2384ca86ed9c08a8e8cf30a6d4698bd 100644 (file)
@@ -457,7 +457,8 @@ local function gen_rbl_callback(rule)
         -- We check merely mime from
         mime_from_domain = ((task:get_from('mime') or E)[1] or E).domain
         if mime_from_domain then
-          local mime_from_domain_tld = rspamd_util.get_tld(mime_from_domain)
+          local mime_from_domain_tld = rule.url_full_hostname and
+              rspamd_util.get_tld(mime_from_domain) or mime_from_domain
 
           if rule.url_compose_map then
             mime_from_domain = rule.url_compose_map:process_url(task, mime_from_domain_tld, mime_from_domain)
@@ -482,6 +483,8 @@ local function gen_rbl_callback(rule)
 
               if rule.url_compose_map then
                 domain_tld = rule.url_compose_map:process_url(task, domain_tld, domain)
+              elseif rule.url_full_hostname then
+                domain_tld = domain
               end
             end
 
@@ -494,6 +497,8 @@ local function gen_rbl_callback(rule)
               local domain_tld = rspamd_util.get_tld(domain)
               if rule.url_compose_map then
                 domain_tld = rule.url_compose_map:process_url(task, domain_tld, domain)
+              elseif rule.url_full_hostname then
+                domain_tld = domain
               end
               add_dns_request(task, domain_tld,
                   false, false, requests_table, 'dkim', whitelist)
@@ -555,9 +560,10 @@ local function gen_rbl_callback(rule)
         add_dns_request(task, to_resolve, false,
             false, requests_table, 'url', whitelist)
       else
-        local url_tld = u:get_tld()
+        local url_hostname = u:get_host()
+        local url_tld = rule.url_full_hostname and u:get_tld() or url_hostname
         if rule.url_compose_map then
-          url_tld = rule.url_compose_map:process_url(task, url_tld, u:get_host())
+          url_tld = rule.url_compose_map:process_url(task, url_tld, url_hostname)
         end
         add_dns_request(task, url_tld, false,
             false, requests_table, 'url', whitelist)
@@ -683,7 +689,7 @@ local function gen_rbl_callback(rule)
 
     for _,email in ipairs(emails) do
       local domain
-      if rule.emails_domainonly then
+      if rule.emails_domainonly and not rule.url_full_hostname then
         if rule.url_compose_map then
           domain = rule.url_compose_map:process_url(task, email:get_tld(), email:get_host())
         else