浏览代码

tweaked it so filters.php can pass a default TTL to bulkquery.c

bbice 23 年之前
父节点
当前提交
ecee7da029
共有 2 个文件被更改,包括 13 次插入4 次删除
  1. 9 3
      plugins/filters/bulkquery/bulkquery.c
  2. 4 1
      plugins/filters/filters.php

+ 9 - 3
plugins/filters/bulkquery/bulkquery.c

@@ -10,7 +10,7 @@
 #define MAXSTR 80
 #define MAXTHREADS 50
 #define MAXRBLS 40
-#define DEFTTL 7200
+#define DEFTTL 600
 
 extern int errno;
 extern int h_errno;
@@ -29,7 +29,7 @@ pthread_mutex_t *mutexp;
 pthread_mutex_t *mutexoutput;
 
 char *dnsrbls[MAXRBLS];
-int numrbls, numthreads, numqueries;
+int numrbls, numthreads, numqueries, defttl;
 
 void do_queries () {
    iplist tIP;
@@ -64,7 +64,7 @@ void do_queries () {
 	    lwres_grbnresponse_free(ctx, &response);
 	 } else {
 	    //fprintf (stderr, "Nothing found\n");
-            printf ("%s, %s, %d\n", tIP->IP, tIP->IP, DEFTTL);
+            printf ("%s, %s, %d\n", tIP->IP, tIP->IP, defttl);
 	 }
 	 //fprintf (stderr, "freeing context\n"); fflush(stderr);
 	 lwres_context_destroy(&ctx);
@@ -106,6 +106,12 @@ main () {
    iplist tIP;
    int loop1;
 
+   if (fgets(instr, MAXSTR, stdin) != NULL) {
+      defttl = atoi(instr);
+   }
+   if (defttl < 0)
+      defttl = DEFTTL;
+
    GetRBLs();
 
 //   for (loop1=0; loop1<numrbls; loop1++)

+ 4 - 1
plugins/filters/filters.php

@@ -57,6 +57,7 @@ function filters_LoadCache () {
     global $data_dir, $SpamFilters_DNScache;
 
     if (file_exists($data_dir . "/dnscache")) {
+        $SpamFilters_DNScache = array();
         if ($fp = fopen ($data_dir . "/dnscache", "r")) {
             flock($fp,LOCK_SH);
             while ($data=fgetcsv($fp,1024)) {
@@ -73,7 +74,8 @@ function filters_LoadCache () {
 
 function filters_bulkquery($filters_spam_scan, $filters, $read) {
     global $SpamFilters_YourHop, $attachment_dir, $username,
-           $SpamFilters_DNScache, $SpamFilters_BulkQuery;
+           $SpamFilters_DNScache, $SpamFilters_BulkQuery,
+           $SpamFilters_CacheTTL;
 
     $IPs = array();
     $i = 0;
@@ -152,6 +154,7 @@ function filters_bulkquery($filters_spam_scan, $filters, $read) {
 
         $bqfil = $attachment_dir . $username . "-bq.in";
         $fp = fopen($bqfil, "w");
+        fputs ($fp, $SpamFilters_CacheTTL . "\n");
         foreach ($rbls as $key => $value) {
             fputs ($fp, "." . $key . "\n");
         }