From: Timo Sirainen Date: Wed, 9 Jun 2010 17:32:47 +0000 (+0100) Subject: doveconf: Renamed lip/rip filters to local/remote, which also support DNS lookups... X-Git-Tag: 2.0.beta6~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=de44e83f4b5e366e57e973b26f2eb0ad26984945;p=thirdparty%2Fdovecot%2Fcore.git doveconf: Renamed lip/rip filters to local/remote, which also support DNS lookups now. --HG-- branch : HEAD --- diff --git a/src/config/config-parser.c b/src/config/config-parser.c index fb8bc6ea00..e57ec490a9 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -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; diff --git a/src/config/config-parser.h b/src/config/config-parser.h index d4ce8dfbbc..882c28671c 100644 --- a/src/config/config-parser.h +++ b/src/config/config-parser.h @@ -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); diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 7d20474dac..3dcbddbd49 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -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); }