summaryrefslogtreecommitdiff
path: root/tools/ltgrey.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-30 04:07:01 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-30 04:07:01 (GMT)
commit292a76b35fd16cf11613f79ea38693449e3317f6 (patch)
treeed1a516a2a8576279cc69e92fb10b20ca2915b64 /tools/ltgrey.c
parent63be414b62f3234ad80607b95e8e71e33bfd8025 (diff)
separate dnscheck functionality from other features; clean up a little
Diffstat (limited to 'tools/ltgrey.c')
-rw-r--r--tools/ltgrey.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/tools/ltgrey.c b/tools/ltgrey.c
index afdb4c1..c9f384f 100644
--- a/tools/ltgrey.c
+++ b/tools/ltgrey.c
@@ -14,17 +14,24 @@ string progname;
// forward reference:
void scan(const string progid, const string p, const int copies=1);
+
int main(int _argc, char** _argv){
+ char* namevar;
+ std::string hostname;
+ char* ipvar;
+ std::string ipbase;
+ std::string ipname;
+
mypid = getpid();
int argc(_argc);
char** argv(_argv);
- const string dirname("/var/qmail/greylist");
- whatsit foo(argv[0], dirname); argc--; argv++;
+ const string parent_dir("/var/qmail/ltgrey");
+ whatsit foo(argv[0], parent_dir); argc--; argv++;
int scanmode(0);
int copies(1);
int penalty(0);
int stain(0);
- int check(0);
+ int dnscheck(0);
while (argc > 0) {
string arg = argv[0]; argc--; argv++;
if (prefix(arg, "-scan")) {
@@ -33,8 +40,8 @@ int main(int _argc, char** _argv){
copies++;
} else if (prefix(arg, "-verbose")) {
foo.verbosity++;
- } else if (prefix(arg, "-check")) {
- check++;
+ } else if (prefix(arg, "-dnscheck")) {
+ dnscheck++;
} else if (prefix(arg, "-penalize")
|| prefix(arg, "-penalty")) {
if (!argc){
@@ -61,23 +68,29 @@ int main(int _argc, char** _argv){
}
if (foo.setup()) return ex_syserr;
+// dnscheck mode ...
+// Probably a better design would be to
+// (a) make more thorough DNS checks, and
+// (b) move all the DNS checking to a separate module
+
+ ipvar = getenv("TCPREMOTEIP");
+ if (ipvar) ipbase = ipvar;
+ namevar = getenv("TCPREMOTEHOST");
+ if (namevar) hostname = namevar;
+
+ if (dnscheck) {
+ exeunt(foo.check_dns(ipvar, namevar));
+ }
+
if (scanmode) {
+ string dirname = parent_dir + "/quarante";
scan(foo.progid, dirname, copies);
return 0;
}
int sts = foo.doit(penalty, stain);
- if (sts == ex_syserr) return sts;
- if (!check) return ex_good;
-
-// check mode ... perform some extra checks.
-// Probably a better design would be to
-// (a) make more thorough DNS checks, and
-// (b) move all the DNS checking to a separate module
+ return sts;
- int dns = foo.check_dns();
- if (dns == ex_syserr || dns == ex_spam) return dns;
- exeunt(sts);
}
//////////////////////////////////////////////////////////////////////