From 85e5de3d81b8bf6ef7bf4592ff77d56cd59191c6 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 8 Jun 2018 18:08:25 +0100 Subject: [PATCH] [Fix] Send DMARC reports compressed --- src/plugins/lua/dmarc.lua | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index 58e48bd01..5c24bff53 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -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) -- 2.39.5