comparison src/context.cpp @ 163:97d7da45fe2a

spamassassin changes
author carl
date Sun, 26 Aug 2007 19:03:17 -0700
parents c4bce911c276
children 5809bcdc325b
comparison
equal deleted inserted replaced
162:c4bce911c276 163:97d7da45fe2a
48 char *token_on; 48 char *token_on;
49 char *token_rate; 49 char *token_rate;
50 char *token_rbrace; 50 char *token_rbrace;
51 char *token_semi; 51 char *token_semi;
52 char *token_soft; 52 char *token_soft;
53 char *token_spamassassin;
53 char *token_substitute; 54 char *token_substitute;
54 char *token_tld; 55 char *token_tld;
55 char *token_cctld; 56 char *token_cctld;
56 char *token_unknown; 57 char *token_unknown;
57 char *token_uribl; 58 char *token_uribl;
676 host_limit = (parent) ? parent->host_limit : 0; 677 host_limit = (parent) ? parent->host_limit : 0;
677 host_limit_message = NULL; 678 host_limit_message = NULL;
678 host_random = (parent) ? parent->host_random : false; 679 host_random = (parent) ? parent->host_random : false;
679 tag_limit = (parent) ? parent->tag_limit : 0; 680 tag_limit = (parent) ? parent->tag_limit : 0;
680 tag_limit_message = NULL; 681 tag_limit_message = NULL;
682 spamassassin_limit = (parent) ? parent->spamassassin_limit : 0;
681 default_rcpt_rate = INT_MAX; 683 default_rcpt_rate = INT_MAX;
682 } 684 }
683 685
684 686
685 CONTEXT::~CONTEXT() { 687 CONTEXT::~CONTEXT() {
859 if (dnsbl_list.empty() && parent) return parent->get_dnsbl_list(); 861 if (dnsbl_list.empty() && parent) return parent->get_dnsbl_list();
860 return dnsbl_list; 862 return dnsbl_list;
861 } 863 }
862 864
863 865
864 bool CONTEXT::acceptable_content(recorder &memory, char *&msg) { 866 bool CONTEXT::acceptable_content(recorder &memory, int score, char *&msg) {
867 if (spamassassin_limit && (score > spamassassin_limit)) {
868 msg = "Mail rejected by spam assassin";
869 }
865 if (memory.excessive_bad_tags(tag_limit)) { 870 if (memory.excessive_bad_tags(tag_limit)) {
866 msg = tag_limit_message; 871 msg = tag_limit_message;
867 return false; 872 return false;
868 } 873 }
869 if (!host_random && memory.excessive_hosts(host_limit)) { 874 if (!host_random && memory.excessive_hosts(host_limit)) {
951 printf("%s html_limit on %d \"%s\"; \n", indent, tag_limit, tag_limit_message); 956 printf("%s html_limit on %d \"%s\"; \n", indent, tag_limit, tag_limit_message);
952 } 957 }
953 else { 958 else {
954 printf("%s html_limit off; \n", indent); 959 printf("%s html_limit off; \n", indent);
955 } 960 }
961 printf("%s spamassassin %d; \n", indent, spamassassin_limit);
956 printf("%s }; \n", indent); 962 printf("%s }; \n", indent);
957 } 963 }
958 else { 964 else {
959 printf("%s content off {}; \n", indent, env_from_default); 965 printf("%s content off {}; \n", indent, env_from_default);
960 } 966 }
1213 tok.token_error("on/off/soft", have); 1219 tok.token_error("on/off/soft", have);
1214 return false; 1220 return false;
1215 } 1221 }
1216 if (!tsa(tok, token_semi)) return false; 1222 if (!tsa(tok, token_semi)) return false;
1217 } 1223 }
1224 else if (have == token_spamassassin) {
1225 me.set_spamassassin_limit(tok.nextint());
1226 if (!tsa(tok, token_semi)) return false;
1227 }
1218 else if (have == token_rbrace) { 1228 else if (have == token_rbrace) {
1219 break; // done 1229 break; // done
1220 } 1230 }
1221 else { 1231 else {
1222 tok.token_error("content keyword", have); 1232 tok.token_error("content keyword", have);
1501 1511
1502 //////////////////////////////////////////////// 1512 ////////////////////////////////////////////////
1503 // init the tokens 1513 // init the tokens
1504 // 1514 //
1505 void token_init() { 1515 void token_init() {
1506 token_autowhite = register_string("autowhite"); 1516 token_autowhite = register_string("autowhite");
1507 token_black = register_string("black"); 1517 token_black = register_string("black");
1508 token_cctld = register_string("cctld"); 1518 token_cctld = register_string("cctld");
1509 token_content = register_string("content"); 1519 token_content = register_string("content");
1510 token_context = register_string("context"); 1520 token_context = register_string("context");
1511 token_dccfrom = register_string("dcc_from"); 1521 token_dccfrom = register_string("dcc_from");
1512 token_dccto = register_string("dcc_to"); 1522 token_dccto = register_string("dcc_to");
1513 token_default = register_string("default"); 1523 token_default = register_string("default");
1514 token_dnsbl = register_string("dnsbl"); 1524 token_dnsbl = register_string("dnsbl");
1515 token_dnsbll = register_string("dnsbl_list"); 1525 token_dnsbll = register_string("dnsbl_list");
1516 token_envfrom = register_string("env_from"); 1526 token_envfrom = register_string("env_from");
1517 token_envto = register_string("env_to"); 1527 token_envto = register_string("env_to");
1518 token_filter = register_string("filter"); 1528 token_filter = register_string("filter");
1519 token_host_limit = register_string("host_limit"); 1529 token_host_limit = register_string("host_limit");
1520 token_html_limit = register_string("html_limit"); 1530 token_html_limit = register_string("html_limit");
1521 token_html_tags = register_string("html_tags"); 1531 token_html_tags = register_string("html_tags");
1522 token_ignore = register_string("ignore"); 1532 token_ignore = register_string("ignore");
1523 token_include = register_string("include"); 1533 token_include = register_string("include");
1524 token_inherit = register_string("inherit"); 1534 token_inherit = register_string("inherit");
1525 token_lbrace = register_string("{"); 1535 token_lbrace = register_string("{");
1526 token_mailhost = register_string("mail_host"); 1536 token_mailhost = register_string("mail_host");
1527 token_many = register_string("many"); 1537 token_many = register_string("many");
1528 token_off = register_string("off"); 1538 token_off = register_string("off");
1529 token_ok = register_string("ok"); 1539 token_ok = register_string("ok");
1530 token_ok2 = register_string("ok2"); 1540 token_ok2 = register_string("ok2");
1531 token_on = register_string("on"); 1541 token_on = register_string("on");
1532 token_rate = register_string("rate_limit"); 1542 token_rate = register_string("rate_limit");
1533 token_rbrace = register_string("}"); 1543 token_rbrace = register_string("}");
1534 token_semi = register_string(";"); 1544 token_semi = register_string(";");
1535 token_soft = register_string("soft"); 1545 token_soft = register_string("soft");
1536 token_substitute = register_string("substitute"); 1546 token_spamassassin = register_string("spamassassin");
1537 token_tld = register_string("tld"); 1547 token_substitute = register_string("substitute");
1538 token_unknown = register_string("unknown"); 1548 token_tld = register_string("tld");
1539 token_uribl = register_string("uribl"); 1549 token_unknown = register_string("unknown");
1540 token_verify = register_string("verify"); 1550 token_uribl = register_string("uribl");
1541 token_white = register_string("white"); 1551 token_verify = register_string("verify");
1552 token_white = register_string("white");
1542 1553
1543 if (gethostname(myhostname, HOST_NAME_MAX+1) != 0) { 1554 if (gethostname(myhostname, HOST_NAME_MAX+1) != 0) {
1544 strncpy(myhostname, "localhost", HOST_NAME_MAX+1); 1555 strncpy(myhostname, "localhost", HOST_NAME_MAX+1);
1545 } 1556 }
1546 myhostname[HOST_NAME_MAX] = '\0'; // ensure null termination 1557 myhostname[HOST_NAME_MAX] = '\0'; // ensure null termination