Merge branch 'master' into with-dns-bl
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 5 Oct 2008 13:22:54 +0000 (15:22 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 5 Oct 2008 13:22:54 +0000 (15:22 +0200)
Conflicts:

postlicyd/iplist.c
postlicyd/tst-rbl.c

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
1  2 
common/Makefile
common/array.h
postlicyd/Makefile
postlicyd/iplist.c
postlicyd/tst-rbl.c

diff --cc 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 common/array.h
Simple merge
@@@ -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)
  
@@@ -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;
@@@ -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[])
  {