]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Send DMARC reports compressed
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Jun 2018 17:08:25 +0000 (18:08 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Jun 2018 17:08:25 +0000 (18:08 +0100)
src/plugins/lua/dmarc.lua

index 58e48bd01e4edc27892b539356da862efd9d1f37..5c24bff532e29a99c365ff52f33dfc5d13141f79 100644 (file)
@@ -66,10 +66,10 @@ Content-Transfer-Encoding: 7bit
 This is an aggregate report from %s.
 
 ------=_NextPart_000_024E_01CC9B0A.AFE54C00
-Content-Type: text/xml
+Content-Type: application/gzip
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment;
-       filename="%s!%s!%s!%s.xml"
+       filename="%s!%s!%s!%s.xml.gz"
 
 ]]
 local report_footer = [[
@@ -744,10 +744,11 @@ if opts['reporting'] == true then
         for k in pairs(reporting_addr) do
           table.insert(tmp_addr, k)
         end
-        local encoded = rspamd_util.encode_base64(table.concat(
+        local encoded = rspamd_util.encode_base64(rspamd_util.gzip_compress(
+              table.concat(
                 {xmlf('header'),
                  xmlf('entries'),
-                 xmlf('footer')}), 78)
+                 xmlf('footer')})), 78)
         local function mail_cb(err, data, conn)
           local function no_error(merr, mdata, wantcode)
             wantcode = wantcode or '2'
@@ -808,11 +809,22 @@ if opts['reporting'] == true then
                 table.insert(atmp, k)
               end
               local addr_string = table.concat(atmp, ', ')
-              local rhead = string.format(report_template, report_settings.email, addr_string,
-                reporting_domain, report_settings.domain, report_id, rspamd_util.time_to_string(rspamd_util.get_time()),
-                rspamd_util.random_hex(12) .. '@rspamd', report_settings.domain, report_settings.domain, reporting_domain,
-                report_start, report_end)
-              conn:add_write(pre_quit_cb, {rhead, encoded, report_footer, '\r\n.\r\n'})
+              local rhead = string.format(report_template,
+                  report_settings.email,
+                  addr_string,
+                  reporting_domain,
+                  report_settings.domain,
+                  report_id,
+                  rspamd_util.time_to_string(rspamd_util.get_time()),
+                  rspamd_util.random_hex(12) .. '@rspamd',
+                  report_settings.domain,
+                  report_settings.domain,
+                  reporting_domain,
+                  report_start, report_end)
+              conn:add_write(pre_quit_cb, {rhead,
+                                           encoded,
+                                           report_footer,
+                                           '\r\n.\r\n'})
             end
           end
           local function data_cb(merr, mdata)