Mercurial > dovecot > core-2.2
changeset 11510:c147a2653f9c HEAD
doveconf: Renamed lip/rip filters to local/remote, which also support DNS lookups now.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 09 Jun 2010 18:32:47 +0100 |
parents | cc6ebfa394d3 |
children | 9f9f9d9e4a79 |
files | src/config/config-parser.c src/config/config-parser.h src/config/doveconf.c |
diffstat | 3 files changed, 28 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/config/config-parser.c Wed Jun 09 18:29:55 2010 +0100 +++ b/src/config/config-parser.c Wed Jun 09 18:32:47 2010 +0100 @@ -183,8 +183,8 @@ 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;
--- a/src/config/config-parser.h Wed Jun 09 18:29:55 2010 +0100 +++ b/src/config/config-parser.h Wed Jun 09 18:32:47 2010 +0100 @@ -14,6 +14,8 @@ 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);
--- a/src/config/doveconf.c Wed Jun 09 18:29:55 2010 +0100 +++ b/src/config/doveconf.c Wed Jun 09 18:32:47 2010 +0100 @@ -460,20 +460,30 @@ 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); }