unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Fix random selection of keyserver
@ 2021-05-30 18:36 Philip Kaludercic
  2021-05-30 18:57 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Philip Kaludercic @ 2021-05-30 18:36 UTC (permalink / raw)
  To: emacs-devel

* epa-ks.el (epa-keyserver-list): Add new variable
(epa-keyserver): Use epa-keyserver-list to generate type
(epa-ks--fetch-key): Check if epa-keyserver is 'random
(epa-search-keys): Check if epa-keyserver is 'random
---
 lisp/epa-ks.el | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/lisp/epa-ks.el b/lisp/epa-ks.el
index a33025b112..dcdbefc57b 100644
--- a/lisp/epa-ks.el
+++ b/lisp/epa-ks.el
@@ -38,18 +38,23 @@ epa-ks
   :version "28.1"
   :group 'epa)
 
+(defvar epa-keyserver-list
+  '("keyring.debian.org"
+    "keys.gnupg.net"
+    "keyserver.ubuntu.com"
+    "pgp.mit.edu"
+    "pool.sks-keyservers.net"
+    "zimmermann.mayfirst.org")
+  "List of default keyservers.")
+
 (defcustom epa-keyserver "pgp.mit.edu"
   "Domain of keyserver.
 
 This is used by `epa-ks-lookup-key', for looking up public keys."
-  :type '(choice :tag "Keyserver"
+  :type `(choice :tag "Keyserver"
                  (const random)
-                 (const "keyring.debian.org")
-                 (const "keys.gnupg.net")
-                 (const "keyserver.ubuntu.com")
-                 (const "pgp.mit.edu")
-                 (const "pool.sks-keyservers.net")
-                 (const "zimmermann.mayfirst.org")
+                 ,@(mapcar (lambda (server) `(const ,server))
+                           epa-keyserver-list)
                  (string :tag "Custom keyserver"))
   :version "28.1")
 
@@ -145,7 +150,10 @@ epa-ks--fetch-key
   "Send request to import key with specified ID."
   (url-retrieve
    (format "https://%s/pks/lookup?%s"
-           epa-keyserver
+           (if (eq epa-keyserver 'random)
+               (nth (random (length epa-keyserver-list))
+                    epa-keyserver-list)
+               epa-keyserver)
            (url-build-query-string
             `(("search" ,(concat "0x" (url-hexify-string id)))
               ("options" "mr")
@@ -225,7 +233,10 @@ epa-search-keys
       (epa-ks-search-mode))
     (url-retrieve
      (format "https://%s/pks/lookup?%s"
-             epa-keyserver
+             (if (eq epa-keyserver 'random)
+               (nth (random (length epa-keyserver-list))
+                    epa-keyserver-list)
+               epa-keyserver)
              (url-build-query-string
               (append `(("search" ,query)
                         ("options" "mr")
-- 
2.30.2




^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-06-01  5:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-30 18:36 [PATCH] Fix random selection of keyserver Philip Kaludercic
2021-05-30 18:57 ` Eli Zaretskii
2021-05-30 19:46   ` Philip Kaludercic
2021-05-31  9:00     ` Lars Ingebrigtsen
2021-05-31 11:13       ` Philip Kaludercic
2021-05-31 11:43         ` Andreas Schwab
2021-05-31 12:04           ` Philip Kaludercic
2021-06-01  5:49         ` Lars Ingebrigtsen
2021-05-31 11:45       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).