X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Fiplist.c;fp=postlicyd%2Frbl.c;h=256c360d9c546923a44f6a30e7f2694d3d23af07;hb=d6f820ed2e86f48c23bc7dc4ee3f591a2d46fc5f;hp=a84f73ef905d0ca044ba99ca68ed461b2694543b;hpb=1b0d47e10359293dafc8937b8036168d7ec61a6a;p=apps%2Fpfixtools.git diff --git a/postlicyd/rbl.c b/postlicyd/iplist.c similarity index 94% rename from postlicyd/rbl.c rename to postlicyd/iplist.c index a84f73e..256c360 100644 --- a/postlicyd/rbl.c +++ b/postlicyd/iplist.c @@ -39,10 +39,11 @@ #include #include "common.h" -#include "rbl.h" +#include "iplist.h" #include "str.h" #include "file.h" #include "array.h" +#include "rbl.h" #define IPv4_BITS 5 #define IPv4_PREFIX(ip) ((uint32_t)(ip) >> IPv4_BITS) @@ -385,6 +386,7 @@ static filter_result_t rbl_filter(const filter_t *filter, const query_t *query) int32_t sum = 0; const char *end = NULL; const rbl_filter_t *data = filter->data; + bool error = true; if (parse_ipv4(query->client_address, &end, &ip) != 0) { warn("invalid client address: %s, expected ipv4", @@ -400,6 +402,30 @@ static filter_result_t rbl_filter(const filter_t *filter, const query_t *query) return HTK_HARD_MATCH; } } + error = false; + } + for (uint32_t i = 0 ; i < data->host_offsets.len ; ++i) { + const char *rbl = array_ptr(data->hosts, array_elt(data->host_offsets, i)); + int weight = array_elt(data->host_weights, i); + switch (rbl_check(rbl, ip)) { + case RBL_FOUND: + error = false; + sum += weight; + if (sum >= data->hard_threshold) { + return HTK_HARD_MATCH; + } + break; + case RBL_NOTFOUND: + error = false; + break; + case RBL_ERROR: + warn("rbl %s unavailable", rbl); + break; + } + } + if (error) { + err("filter %s: all the rbl returned an error", filter->name); + return HTK_ERROR; } if (sum >= data->hard_threshold) { return HTK_HARD_MATCH;