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

Added support for "max_newsgroups_per_article" option (defaults to 5), for

SPAM article detection on import.
parent 977c344a
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,7 @@ var email_addresses = true; // Include e-mail addresses in headers ...@@ -52,6 +52,7 @@ var email_addresses = true; // Include e-mail addresses in headers
var import_amount = 0; // Import a fixed number of messages per group var import_amount = 0; // Import a fixed number of messages per group
var lines_per_yield = 5; // Release time-slices ever x number of lines var lines_per_yield = 5; // Release time-slices ever x number of lines
var yield_length = 1; // Length of yield (in milliseconds) var yield_length = 1; // Length of yield (in milliseconds)
var max_newsgroups_per_article = 5; // Used for spam-detection
// Parse arguments // Parse arguments
for(i=0;i<argc;i++) { for(i=0;i<argc;i++) {
...@@ -183,6 +184,9 @@ while(!cfg_file.eof) { ...@@ -183,6 +184,9 @@ while(!cfg_file.eof) {
case "yield_length": case "yield_length":
yield_length=parseInt(str[1]); yield_length=parseInt(str[1]);
break; break;
case "max_newsgroups_per_article":
max_newsgroups_per_article=parseInt(str[1]);
break;
default: default:
print("!UNRECOGNIZED configuration keyword: " + str[0]); print("!UNRECOGNIZED configuration keyword: " + str[0]);
...@@ -672,6 +676,16 @@ for(i in area) { ...@@ -672,6 +676,16 @@ for(i in area) {
continue; continue;
} }
if(max_newsgroups_per_article && hdr.newsgroups!=undefined) {
var ngarray=hdr.newsgroups.split(',');
if(ngarray.length>max_newsgroups_per_article) {
var reason = format("Too many newsgroups (%d): %s",ngarray.length, hdr.newsgroups);
printf("!%s\r\n",reason);
system.spamlog("NNTP","NOT IMPORTED",reason,hdr.from,server,hdr.to);
continue;
}
}
if(hdr.to==newsgroup && hdr.newsgroups!=undefined) if(hdr.to==newsgroup && hdr.newsgroups!=undefined)
hdr.to=hdr.newsgroups; hdr.to=hdr.newsgroups;
...@@ -686,8 +700,8 @@ for(i in area) { ...@@ -686,8 +700,8 @@ for(i in area) {
continue; continue;
if(flags.indexOf('s')==-1 && system.trashcan("subject",hdr.subject)) { if(flags.indexOf('s')==-1 && system.trashcan("subject",hdr.subject)) {
printf("!BLOCKED subject: %s\r\n",hdr.subject);
var reason = format("Blocked subject (%s)",hdr.subject); var reason = format("Blocked subject (%s)",hdr.subject);
printf("!%s\r\n",reason);
system.spamlog("NNTP","NOT IMPORTED",reason,hdr.from,server,hdr.to); system.spamlog("NNTP","NOT IMPORTED",reason,hdr.from,server,hdr.to);
continue; continue;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment