From: Florent Bruneau Date: Sun, 5 Oct 2008 13:22:54 +0000 (+0200) Subject: Merge branch 'master' into with-dns-bl X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=f47b916bf7581b0070431eb70f43710e4c79fc98;p=apps%2Fpfixtools.git Merge branch 'master' into with-dns-bl Conflicts: postlicyd/iplist.c postlicyd/tst-rbl.c Signed-off-by: Florent Bruneau --- f47b916bf7581b0070431eb70f43710e4c79fc98 diff --cc common/Makefile index be9d473,541d5ac..3f30e73 --- a/common/Makefile +++ b/common/Makefile @@@ -32,7 -32,9 +32,9 @@@ LIBS = lib TESTS = tst-trie -lib_SOURCES = str.c buffer.c common.c epoll.c server.c trie.c file.c +lib_SOURCES = str.c buffer.c common.c epoll.c server.c trie.c file.c rbl.c tst-trie_SOURCES = tst-trie.c lib.a + all: + include ../mk/common.mk diff --cc postlicyd/Makefile index 84dec14,363a9a0..0983841 --- a/postlicyd/Makefile +++ b/postlicyd/Makefile @@@ -36,14 -36,14 +36,14 @@@ GENERATED = policy_tokens.h policy_toke filter_tokens.h filter_tokens.c \ hook_tokens.h hook_tokens.c \ param_tokens.h param_tokens.c - TESTS = test-rbl tst-filters + TESTS = tst-rbl tst-filters -FILTERS = rbl.c greylist.c strlist.c match.c +FILTERS = iplist.c greylist.c strlist.c match.c postlicyd_SOURCES = main-postlicyd.c ../common/lib.a filter.c config.c query.c $(FILTERS) $(GENERATED) postlicyd_LIBADD = $(TC_LIBS) - tst-rbl_SOURCES = tst-rbl.c -tst-rbl_SOURCES = tst-rbl.c ../common/lib.a filter.c config.c query.c rbl.c $(GENERATED) ++tst-rbl_SOURCES = tst-rbl.c ../common/lib.a filter.c config.c query.c iplist.c $(GENERATED) tst-filters_SOURCES = tst-filters.c ../common/lib.a config.c filter.c query.c $(FILTERS) $(GENERATED) tst-filters_LIBADD = $(TC_LIBS) diff --cc postlicyd/iplist.c index 256c360,4e1ac27..3c14fda --- a/postlicyd/iplist.c +++ b/postlicyd/iplist.c @@@ -314,39 -318,6 +325,39 @@@ static bool rbl_filter_constructor(filt } } break; - /* host parameter. ++ /* dns parameter. + * weight:hostname. + * define a RBL to use through DNS resolution. + */ - case ATK_HOST: { ++ case ATK_DNS: { + int weight = 0; + const char *current = param->value; + const char *p = m_strchrnul(param->value, ':'); + char *next = NULL; + for (int i = 0 ; i < 2 ; ++i) { + PARSE_CHECK(i == 1 || *p, + "host parameter must contains a weight option"); + switch (i) { + case 0: + weight = strtol(current, &next, 10); + PARSE_CHECK(next == p && weight >= 0 && weight <= 1024, + "illegal weight value %.*s", + (p - current), current); + break; + + case 1: + array_add(data->host_offsets, array_len(data->hosts)); + array_append(data->hosts, current, strlen(current) + 1); + array_add(data->host_weights, weight); + break; + } + if (i != 1) { + current = p + 1; + p = m_strchrnul(current, ':'); + } + } + } break; + /* hard_threshold parameter is an integer. * If the matching score is greater or equal than this threshold, * the hook "hard_match" is called. @@@ -451,7 -394,7 +462,8 @@@ static int rbl_init(void /* Parameters. */ (void)filter_param_register(type, "file"); - (void)filter_param_register(type, "host"); + (void)filter_param_register(type, "rbldns"); ++ (void)filter_param_register(type, "dns"); (void)filter_param_register(type, "hard_threshold"); (void)filter_param_register(type, "soft_threshold"); return 0; diff --cc postlicyd/tst-rbl.c index 057018f,7e567b1..9cafae1 --- a/postlicyd/tst-rbl.c +++ b/postlicyd/tst-rbl.c @@@ -38,7 -38,8 +38,8 @@@ __FILE__, __LINE__, __func__, ##__VA_ARGS__) #include "common.h" - #include "iplist.c" -#include "rbl.h" ++#include "iplist.h" + #include "array.h" int main(int argc, char *argv[]) {