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

Remove support for the useless 'REPORT' and 'REPORT_IFSPAM' commands.

Simplify the rejection threshold feature (requires 'PROCESS' command).
parent 4104cd17
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,14 @@
// Example mailproc.ini entries:
// [spamc.js -c]
// ;Process and pass-through all messages:
// [spamc.js]
// ;Check for and reject SPAM messages:
// [spamc.js check]
// ;Check for and reject SPAM messages over specified threshold
// [spamc.js reject 8.0]
// $Id$
......@@ -18,26 +25,30 @@ function main()
var tcp_port = 783;
var user;
var cmd = 'PROCESS'; // Default: process
var threshold;
var reject_threshold;
// Process arguments:
for(i in argv) {
if(argv[i]=='-d' || argv[i]=='--dest')
// Strip any pre-pended slashes
while(argv[i].charAt(0)=='-')
argv[i]=argv[i].slice(1);
// Standard spamc options:
if(argv[i]=='d' || argv[i]=='dest')
address = argv[++i]; // Note: only one address supported (unlike spamc)
else if(argv[i]=='-p' || argv[i]=='--port')
else if(argv[i]=='p' || argv[i]=='port')
tcp_port = Number(argv[++i]);
else if(argv[i]=='-u' || argv[i]=='--username')
else if(argv[i]=='u' || argv[i]=='username')
user = argv[++i];
else if(argv[i]=='-T' || argv[i]=='--threshold')
threshold = parseFloat(argv[++i]);
else if(argv[i]=='-c' || argv[i]=='--check')
// spamc.js command:
else if(argv[i]=='reject') // Only valid with PROCESS command
reject_threshold = parseFloat(argv[++i]);
else if(argv[i]=='check')
cmd = 'CHECK';
else if(argv[i]=='-y' || argv[i]=='--tests')
else if(argv[i]=='check-verbose' || argv[i]=='tests')
cmd = 'SYMBOLS';
else if(argv[i]=='-R' || argv[i]=='--full')
cmd = 'REPORT';
else if(argv[i]=='-r' || argv[i]=='--fullspam')
cmd = 'REPORT_IFSPAM';
}
var msg=new SPAMC_Message(message_text_filename, address, tcp_port, user);
......@@ -57,7 +68,7 @@ function main()
log(LOG_INFO, "spamc: Score: " + ret.score + ' / ' + ret.threshold);
if(cmd == 'PROCESS' || (threshold && ret.score < threshold)) {
if(cmd == 'PROCESS' && (!reject_threshold || ret.score < reject_threshold)) {
var msg_file = new File(message_text_filename);
if(!msg_file.open("w")) {
log(LOG_ERR,format("spamc: !ERROR %d opening message text file: %s"
......
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