diff options
author | Werner Koch <[email protected]> | 2015-10-26 15:32:03 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-10-26 15:34:19 +0000 |
commit | 4524a2a3714f263d56bb7db349c169b456994fd9 (patch) | |
tree | 42196995be5336dad31f93d87603124a83644a00 /dirmngr/ks-engine-hkp.c | |
parent | dirmngr,w32: Remove gethostbyname hack and make it build again. (diff) | |
download | gnupg-4524a2a3714f263d56bb7db349c169b456994fd9.tar.gz gnupg-4524a2a3714f263d56bb7db349c169b456994fd9.zip |
dirmngr: Support Tor hidden services.
* dirmngr/dns-stuff.c (is_onion_address): New.
* dirmngr/ks-engine-hkp.c (hostinfo_s): Add field "onion".
(map_host): Special case onion addresses.
(ks_hkp_print_hosttable): Print an 'O' for an onion address.
* dirmngr/http.c (connect_server): Special case onion addresses.
--
Note that this requires the latest libassuan from git. Onion addresses
are always support regardless of the --use-tor flag.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r-- | dirmngr/ks-engine-hkp.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/dirmngr/ks-engine-hkp.c b/dirmngr/ks-engine-hkp.c index 340b012ad..a6587271c 100644 --- a/dirmngr/ks-engine-hkp.c +++ b/dirmngr/ks-engine-hkp.c @@ -80,6 +80,7 @@ struct hostinfo_s int poolidx; /* Index into POOL with the used host. -1 if not set. */ unsigned int v4:1; /* Host supports AF_INET. */ unsigned int v6:1; /* Host supports AF_INET6. */ + unsigned int onion:1;/* NAME is an onion (Tor HS) address. */ unsigned int dead:1; /* Host is currently unresponsive. */ time_t died_at; /* The time the host was marked dead. If this is 0 the host has been manually marked dead. */ @@ -124,6 +125,7 @@ create_new_hostinfo (const char *name) hi->lastfail = (time_t)(-1); hi->v4 = 0; hi->v6 = 0; + hi->onion = 0; hi->dead = 0; hi->died_at = 0; hi->cname = NULL; @@ -267,7 +269,15 @@ map_host (ctrl_t ctrl, const char *name, int force_reselect, /* See whether the host is in our table. */ idx = find_hostinfo (name); - if (idx == -1) + if (idx == -1 && is_onion_address (name)) + { + idx = create_new_hostinfo (name); + if (idx == -1) + return gpg_error_from_syserror (); + hi = hosttable[idx]; + hi->onion = 1; + } + else if (idx == -1) { /* We never saw this host. Allocate a new entry. */ dns_addrinfo_t aibuf, ai; @@ -512,6 +522,11 @@ map_host (ctrl_t ctrl, const char *name, int force_reselect, *r_httpflags |= HTTP_FLAG_IGNORE_IPv4; if (!hi->v6) *r_httpflags |= HTTP_FLAG_IGNORE_IPv6; + + /* Note that we do not set the HTTP_FLAG_FORCE_TOR for onion + addresses because the http module detects this itself. This + also allows us to use an onion address without Tor mode being + enabled. */ } *r_host = xtrystrdup (hi->name); @@ -683,7 +698,9 @@ ks_hkp_print_hosttable (ctrl_t ctrl) else diedstr = died = NULL; err = ks_printf_help (ctrl, "%3d %s %s %s %s%s%s%s%s%s%s%s\n", - idx, hi->v6? "6":" ", hi->v4? "4":" ", + idx, + hi->onion? "O" : hi->v6? "6":" ", + hi->v4? "4":" ", hi->dead? "d":" ", hi->name, hi->v6addr? " v6=":"", |