diff options
author | Werner Koch <[email protected]> | 2014-03-14 15:12:54 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2014-03-14 15:12:54 +0000 |
commit | a401f768ca8e218eef7a5c87a8f99cb1d6b4aaeb (patch) | |
tree | d8d9b285a3f2c18cb310f1bd853af85e7f146427 /g10/keyserver.c | |
parent | dirmngr: Default to a user socket name and enable autostart. (diff) | |
download | gnupg-a401f768ca8e218eef7a5c87a8f99cb1d6b4aaeb.tar.gz gnupg-a401f768ca8e218eef7a5c87a8f99cb1d6b4aaeb.zip |
gpg: Print the actual used keyserver address.
* dirmngr/ks-engine-hkp.c (ks_hkp_search, ks_hkp_get): Print SOURCE
status lines.
* g10/call-dirmngr.c (ks_status_parm_s): New.
(ks_search_parm_s): Add field stparm.
(ks_status_cb): New.
(ks_search_data_cb): Send source to the data callback.
(gpg_dirmngr_ks_search): Change callback prototope to include the
SPECIAL arg. Adjust all users. Use ks_status_cb.
(gpg_dirmngr_ks_get): Add arg r_source and use ks_status_cb.
* g10/keyserver.c (search_line_handler): Adjust callback and print
"data source" disgnostic.
(keyserver_get): Print data source diagnostic.
--
It has often been requested that the actually used IP of a keyservers
is shown in with gpg --recv-key and --search-key. This is helpful if
the keyserver is actually a pool of keyservers. This patch does this.
Diffstat (limited to 'g10/keyserver.c')
-rw-r--r-- | g10/keyserver.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/g10/keyserver.c b/g10/keyserver.c index b8ab81e46..3a3bc40e7 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -831,17 +831,29 @@ show_prompt (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int numdesc, /* This is a callback used by call-dirmngr.c to process the result of - KS_SEARCH command. LINE is the actual data line received with all - escaping removed and guaranteed to be exactly one line with - stripped LF; an EOF is indicated by LINE passed as NULL. LINE may - be modified after return. */ + KS_SEARCH command. If SPECIAL is 0, LINE is the actual data line + received with all escaping removed and guaranteed to be exactly one + line with stripped LF; an EOF is indicated by LINE passed as NULL. + If special is 1, the line conatins the source of the information + (usually an URL). LINE may be modified after return. */ static gpg_error_t -search_line_handler (void *opaque, char *line) +search_line_handler (void *opaque, int special, char *line) { struct search_line_handler_parm_s *parm = opaque; gpg_error_t err = 0; struct keyrec *keyrec; + if (special == 1) + { + log_info ("data source: %s\n", line); + return 0; + } + else if (special) + { + log_debug ("unknown value %d for special search callback", special); + return 0; + } + if (parm->eof_seen && line) { log_debug ("ooops: unexpected data after EOF\n"); @@ -1478,6 +1490,7 @@ keyserver_get (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc, char **pattern; int idx, npat; estream_t datastream; + char *source = NULL; /* Create an array filled with a search pattern for each key. The array is delimited by a NULL entry. */ @@ -1561,10 +1574,13 @@ keyserver_get (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc, } - err = gpg_dirmngr_ks_get (ctrl, pattern, &datastream); + err = gpg_dirmngr_ks_get (ctrl, pattern, &datastream, &source); for (idx=0; idx < npat; idx++) xfree (pattern[idx]); xfree (pattern); + if (opt.verbose) + log_info ("data source: %s\n", source); + if (!err) { void *stats_handle; @@ -1590,7 +1606,7 @@ keyserver_get (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc, import_release_stats_handle (stats_handle); } es_fclose (datastream); - + xfree (source); return err; } |