Mercurial > dnsbl
changeset 9:8c65411cd7ab
integration work on url scanner
author | carl |
---|---|
date | Thu, 22 Apr 2004 14:00:02 -0700 |
parents | dbe18921f741 |
children | 9ca440c8d187 |
files | sendmail.st src/dnsbl.cpp src/scanner.cpp test.bash |
diffstat | 4 files changed, 29 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dnsbl.cpp Thu Apr 22 11:25:45 2004 -0700 +++ b/src/dnsbl.cpp Thu Apr 22 14:00:02 2004 -0700 @@ -9,7 +9,7 @@ -p port The port through which the MTA will connect to this milter. -t sec The timeout value. --c Check the config, and print a copy to stderr. Don't start the +-c Check the config, and print a copy to stdout. Don't start the milter or do anything with the socket. */ @@ -19,9 +19,6 @@ #include <sys/types.h> #include <sys/stat.h> #include <errno.h> -//#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include <sysexits.h> #include <unistd.h> @@ -116,7 +113,7 @@ string_map env_to_dnsbll; // map recipient to a named dnsbll string_map env_to_chkfrom; // map recipient to a named from map char * content_suffix; // for sbl url body filtering - char * content_message; + char * content_message; // "" CONFIG(); ~CONFIG(); }; @@ -157,11 +154,12 @@ //////////////////////////////////////////////// // helper to discard the strings held by a string_set // -static void discard(string_set s); -static void discard(string_set s) { +static void discard(string_set &s); +static void discard(string_set &s) { for (string_set::iterator i=s.begin(); i!=s.end(); i++) { free(*i); } + s.clear(); } @@ -434,7 +432,7 @@ int count = 0; for (string_set::iterator i=priv.urls.begin(); i!=priv.urls.end(); i++) { count++; - if (count > 20) break; // silly to check too many urls + if (count > 20) return oksofar; // silly to check too many urls url = *i; char buf[200]; snprintf(buf, sizeof(buf), "looking for url %s", url); @@ -445,6 +443,7 @@ if (st == reject) return st; } } + return oksofar; } @@ -616,9 +615,9 @@ static void dumpit(char *name, string_map map); static void dumpit(char *name, string_map map) { - fprintf(stderr, "\n"); + fprintf(stdout, "\n"); for (string_map::iterator i=map.begin(); i!=map.end(); i++) { - fprintf(stderr, "%s %s->%s\n", name, (*i).first, (*i).second); + fprintf(stdout, "%s %s->%s\n", name, (*i).first, (*i).second); } } @@ -639,25 +638,28 @@ dumpit(dc.env_from); dumpit("envelope to (dnsbl list)", dc.env_to_dnsbll); dumpit("envelope to (from map)", dc.env_to_chkfrom); - fprintf(stderr, "\ndnsbls\n"); + fprintf(stdout, "\ndnsbls\n"); for (dnsblp_map::iterator i=dc.dnsbls.begin(); i!=dc.dnsbls.end(); i++) { - fprintf(stderr, "%s %s %s\n", (*i).first, (*i).second->suffix, (*i).second->message); + fprintf(stdout, "%s %s %s\n", (*i).first, (*i).second->suffix, (*i).second->message); } - fprintf(stderr, "\ndnsbl_lists\n"); + fprintf(stdout, "\ndnsbl_lists\n"); for (dnsbllp_map::iterator i=dc.dnsblls.begin(); i!=dc.dnsblls.end(); i++) { char *name = (*i).first; DNSBLL &dl = *((*i).second); - fprintf(stderr, "%s", name); + fprintf(stdout, "%s", name); for (DNSBLL::iterator j=dl.begin(); j!=dl.end(); j++) { DNSBL &d = **j; - fprintf(stderr, " %s", d.suffix); + fprintf(stdout, " %s", d.suffix); + } + fprintf(stdout, "\n"); } - fprintf(stderr, "\n"); + if (dc.content_suffix) { + fprintf(stdout, "\ncontent filtering enabled with %s %s\n", dc.content_suffix, dc.content_message); } - fprintf(stderr, "\nfiles\n"); + fprintf(stdout, "\nfiles\n"); for (string_list::iterator i=dc.config_files.begin(); i!=dc.config_files.end(); i++) { char *f = *i; - fprintf(stderr, "config includes %s\n", f); + fprintf(stdout, "config includes %s\n", f); } } @@ -966,10 +968,11 @@ static void usage(char *prog); static void usage(char *prog) { - fprintf(stderr, "Usage: %s -p socket-addr [-t timeout]\n", prog); + fprintf(stderr, "Usage: %s [-c] -p socket-addr [-t timeout]\n", prog); fprintf(stderr, "where socket-addr is for the connection to sendmail and should be one of\n"); fprintf(stderr, " inet:port@local-ip-address\n"); fprintf(stderr, " local:local-domain-socket-file-name\n"); + fprintf(stderr, "-c will load and dump the config to stdout\n"); }
--- a/src/scanner.cpp Thu Apr 22 11:25:45 2004 -0700 +++ b/src/scanner.cpp Thu Apr 22 14:00:02 2004 -0700 @@ -843,7 +843,7 @@ for (int i=0; i<len; i++) { u_char c = buf[i]; // guard against buffer overflow - if (count == PENDING_LIMIT-1) { + if (count == (PENDING_LIMIT-1)) { if (next) next->push(pending, count); count = 0; st = init; @@ -862,10 +862,12 @@ } break; case u_reco: { + if (count > 12) { pending[count-1] = 0; if (strncasecmp((const char *)pending, "http://", 7) == 0) { urls->insert(strdup((const char *)pending+7)); } + } } // fall thru case u_init: {
--- a/test.bash Thu Apr 22 11:25:45 2004 -0700 +++ b/test.bash Thu Apr 22 14:00:02 2004 -0700 @@ -25,11 +25,7 @@ chmod 700 /var/run/dnsbl mv -f $pid $pid.save rm -f /var/run/dnsbl/dnsbl.sock -dir=`pwd` -pushd /var/dnsbl -echo "$dir/dnsbl -p local:/var/run/dnsbl/dnsbl.sock" -$dir/dnsbl -p local:/var/run/dnsbl/dnsbl.sock -popd +./dnsbl -p local:/var/run/dnsbl/dnsbl.sock sleep 5 P2=`cat $pid` mv -f $pid.save $pid