Skip to content
Snippets Groups Projects
Commit f886a418 authored by rswindell's avatar rswindell
Browse files

Added support for inserting Return-Path and Received headers before sending

to spamd. Some SA features require these header fields.
Received header support is currently disabled due to some issues, like:
1. Getting duplicates Received fields after processing the message
2. SpamAssassin *really* doesn't like dynamic IPs in Received header fields
parent c669aa0b
No related branches found
No related tags found
No related merge requests found
......@@ -31,17 +31,38 @@ function Message_DoCommand(command)
var tmp;
var sock=new Socket(SOCK_STREAM, "spamc");
var ret={message:'', isSpam:false, score:'unknown', threshold:'unknown', symbols:[]};
var inserted_header_fields="";
if(!sock.connect(this.addr, this.port)) {
ret.error='Failed to connect to spamd';
return(ret);
}
var content_length = file_size(this.messagefile);
if(this.reverse_path)
inserted_header_fields += "Return-Path: " + this.reverse_path + "\r\n";
if(this.hello_name) {
inserted_header_fields += format(
"Received: from %s (%s [%s])\r\n" +
" by %s [%s] (%s)\r\n" +
" for %s; %s %s\r\n"
,client.host_name,this.hello_name,client.ip_address
,system.host_name,server.interface_ip_address
,server.version
,"unknown"
,strftime("%a, %d %b %Y %H:%M:%S"),system.zonestr()
);
}
log("SPAMD: inserted headers = " + inserted_header_fields);
content_length += inserted_header_fields.length;
sock.write(command.toUpperCase()+" SPAMC/1.2\r\n");
sock.write("Content-length: "+file_size(this.messagefile)+"\r\n");
sock.write("Content-length: "+content_length+"\r\n");
if(this.user) // Optional
sock.write("User: " + this.user + "\r\n");
sock.write("\r\n");
sock.write(inserted_header_fields);
sock.sendfile(this.messagefile);
sock.is_writeable=false;
......
......@@ -26,10 +26,11 @@
// Options:
// dest [ip_address]
// port [tcp_port]
// username [user]
// max-size [bytes]
// dest <ip_address>
// port <tcp_port>
// username <user>
// max-size <bytes>
// reject [threshold]
// spamonly
// debug
......@@ -86,7 +87,10 @@ function main()
}
log(LOG_INFO, "SPAMC: processing message with SPAMD at " + address + " port " + tcp_port);
msg.debug=debug;
msg.debug = debug;
msg.reverse_path = reverse_path;
// if(this.hello_name)
// msg.hello_name = this.hello_name;
var ret=msg.process();
if(ret.warning != undefined)
log(LOG_WARNING, "SPAMC: WARNING "+ret.warning);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment