]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveconf: Renamed lip/rip filters to local/remote, which also support DNS lookups...
authorTimo Sirainen <tss@iki.fi>
Wed, 9 Jun 2010 17:32:47 +0000 (18:32 +0100)
committerTimo Sirainen <tss@iki.fi>
Wed, 9 Jun 2010 17:32:47 +0000 (18:32 +0100)
--HG--
branch : HEAD

src/config/config-parser.c
src/config/config-parser.h
src/config/doveconf.c

index fb8bc6ea002d62d3f61d94fa5f4f936b60c4afce..e57ec490a9b8f000d3fc96471ba564a32ab94fbd 100644 (file)
@@ -183,8 +183,8 @@ config_filter_parser_find(struct config_parser_context *ctx,
        return NULL;
 }
 
-static int config_parse_net(const char *value, struct ip_addr *ip_r,
-                           unsigned int *bits_r, const char **error_r)
+int config_parse_net(const char *value, struct ip_addr *ip_r,
+                    unsigned int *bits_r, const char **error_r)
 {
        struct ip_addr *ips;
        const char *p;
index d4ce8dfbbc12652abdb7f15ca27108d6998d839e..882c28671c719b85752d6aa59b351666488e8d19 100644 (file)
@@ -14,6 +14,8 @@ extern struct config_module_parser *config_module_parsers;
 extern struct config_filter_context *config_filter;
 extern struct module *modules;
 
+int config_parse_net(const char *value, struct ip_addr *ip_r,
+                    unsigned int *bits_r, const char **error_r);
 int config_parse_file(const char *path, bool expand_values, const char *module,
                      const char **error_r);
 
index 7d20474dacabfa3a45d79f499d4abe7f8d799ac0..3dcbddbd49b478cf616ff7586defda0cb3c85d6a 100644 (file)
@@ -460,20 +460,30 @@ static const char *get_mail_location(void)
 
 static void filter_parse_arg(struct config_filter *filter, const char *arg)
 {
-       if (strncmp(arg, "service=", 8) == 0)
-               filter->service = arg + 8;
-       else if (strncmp(arg, "protocol=", 9) == 0)
-               filter->service = arg + 9;
-       else if (strncmp(arg, "lname=", 6) == 0)
-               filter->local_name = arg + 6;
-       else if (strncmp(arg, "lip=", 4) == 0) {
-               if (net_parse_range(arg + 4, &filter->local_net,
-                                   &filter->local_bits) < 0)
-                       i_fatal("lip: Invalid network mask");
-       } else if (strncmp(arg, "rip=", 4) == 0) {
-               if (net_parse_range(arg + 4, &filter->remote_net,
-                                   &filter->remote_bits) < 0)
-                       i_fatal("rip: Invalid network mask");
+       const char *key, *value, *error;
+
+       value = strchr(arg, '=');
+       if (value != NULL)
+               key = t_strdup_until(arg, value++);
+       else {
+               key = arg;
+               value = "";
+       }
+
+       if (strcmp(key, "service") == 0)
+               filter->service = value;
+       else if (strcmp(key, "protocol") == 0)
+               filter->service = value;
+       else if (strcmp(key, "lname") == 0)
+               filter->local_name = value;
+       else if (strcmp(key, "local") == 0) {
+               if (config_parse_net(value, &filter->local_net,
+                                    &filter->local_bits, &error) < 0)
+                       i_fatal("local filter: %s", error);
+       } else if (strcmp(key, "remote") == 0) {
+               if (config_parse_net(value, &filter->remote_net,
+                                    &filter->remote_bits, &error) < 0)
+                       i_fatal("remote filter: %s", error);
        } else {
                i_fatal("Unknown filter argument: %s", arg);
        }