Mercurial > dovecot > core-2.2
changeset 22545:425ee3581927
lmtp proxy: Avoid DNS lookup for "host" if passdb also returns "hostip"
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 08 Sep 2017 11:02:07 +0300 |
parents | 3b6fb61e5fb1 |
children | 0af134a26b4a |
files | src/lmtp/commands.c src/lmtp/lmtp-proxy.c src/lmtp/lmtp-proxy.h |
diffstat | 3 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lmtp/commands.c Fri Sep 08 11:01:20 2017 +0300 +++ b/src/lmtp/commands.c Fri Sep 08 11:02:07 2017 +0300 @@ -250,7 +250,12 @@ proxying = TRUE; else if (strcmp(key, "host") == 0) set->host = value; - else if (strcmp(key, "port") == 0) { + else if (strcmp(key, "hostip") == 0) { + if (net_addr2ip(value, &set->hostip) < 0) { + i_error("proxy: Invalid hostip %s", value); + return FALSE; + } + } else if (strcmp(key, "port") == 0) { if (net_str2port(value, &set->port) < 0) { i_error("proxy: Invalid port number %s", value); return FALSE; @@ -297,8 +302,12 @@ if (set->port != client->local_port) return FALSE; - if (net_addr2ip(set->host, &ip) < 0) - return FALSE; + if (set->hostip.family != 0) + ip = set->hostip; + else { + if (net_addr2ip(set->host, &ip) < 0) + return FALSE; + } if (!net_ip_compare(&ip, &client->local_ip)) return FALSE; return TRUE;
--- a/src/lmtp/lmtp-proxy.c Fri Sep 08 11:01:20 2017 +0300 +++ b/src/lmtp/lmtp-proxy.c Fri Sep 08 11:02:07 2017 +0300 @@ -146,7 +146,10 @@ conn = p_new(proxy->pool, struct lmtp_proxy_connection, 1); conn->proxy = proxy; - conn->set.host = p_strdup(proxy->pool, set->host); + if (set->hostip.family == 0) + conn->set.host = p_strdup(proxy->pool, set->host); + else + conn->set.host = p_strdup(proxy->pool, net_ip2addr(&set->hostip)); conn->set.port = set->port; conn->set.timeout_msecs = set->timeout_msecs; array_append(&proxy->connections, &conn, 1);