summaryrefslogtreecommitdiffstats
path: root/dirmngr/ks-engine-hkp.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2017-01-16 19:04:58 +0100
committerWerner Koch <wk@gnupg.org>2017-01-16 19:12:03 +0100
commite6aebfe3d0f16c483296fd125b66a44017fe15f4 (patch)
treea4b6335f5f707a20767db46257b40195cc583182 /dirmngr/ks-engine-hkp.c
parentdirmngr: Allow reverse DNS lookups in Tor-mode. (diff)
downloadgnupg2-e6aebfe3d0f16c483296fd125b66a44017fe15f4.tar.xz
gnupg2-e6aebfe3d0f16c483296fd125b66a44017fe15f4.zip
dirmngr: Implement hkps lookups using literal addresses.
* dirmngr/ks-engine-hkp.c (map_host): For literal addresses do a reverse lookup. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'dirmngr/ks-engine-hkp.c')
-rw-r--r--dirmngr/ks-engine-hkp.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/dirmngr/ks-engine-hkp.c b/dirmngr/ks-engine-hkp.c
index 8c171a5f7..08ef851b4 100644
--- a/dirmngr/ks-engine-hkp.c
+++ b/dirmngr/ks-engine-hkp.c
@@ -85,7 +85,7 @@ struct hostinfo_s
time_t died_at; /* The time the host was marked dead. If this is
0 the host has been manually marked dead. */
char *cname; /* Canonical name of the host. Only set if this
- is a pool. */
+ is a pool or NAME has a numerical IP address. */
char *v4addr; /* A string with the v4 IP address of the host.
NULL if NAME has a numeric IP address or no v4
address is available. */
@@ -571,6 +571,34 @@ map_host (ctrl_t ctrl, const char *name, const char *srvtag, int force_reselect,
hi = hosttable[hi->poolidx];
assert (hi);
}
+ else if (r_httphost && is_ip_address (hi->name))
+ {
+ /* This is a numerical IP address and not a pool. We want to
+ * find the canonical name so that it can be used in the HTTP
+ * Host header. Fixme: We should store that name in the
+ * hosttable. */
+ dns_addrinfo_t aibuf, ai;
+ char *host;
+
+ err = resolve_dns_name (hi->name, 0, 0, SOCK_STREAM, &aibuf, NULL);
+ if (!err)
+ {
+ for (ai = aibuf; ai; ai = ai->next)
+ {
+ if (ai->family == AF_INET6 || ai->family == AF_INET)
+ {
+ err = resolve_dns_addr (ai->addr, ai->addrlen, 0, &host);
+ if (!err)
+ {
+ /* Okay, we return the first found name. */
+ *r_httphost = host;
+ break;
+ }
+ }
+ }
+ }
+ free_dns_addrinfo (aibuf);
+ }
if (hi->dead)
{