From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: [PATCH] Fix random selection of keyserver Date: Sun, 30 May 2021 18:36:29 +0000 Message-ID: <20210530183629.599038-1-philipk@posteo.net> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="988"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 30 20:39:30 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lnQLS-000Adl-FK for ged-emacs-devel@m.gmane-mx.org; Sun, 30 May 2021 20:39:30 +0200 Original-Received: from localhost ([::1]:33316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnQLP-0004o7-FL for ged-emacs-devel@m.gmane-mx.org; Sun, 30 May 2021 14:39:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnQIf-00043R-7k for emacs-devel@gnu.org; Sun, 30 May 2021 14:36:37 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:45441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnQIc-0005ZJ-GO for emacs-devel@gnu.org; Sun, 30 May 2021 14:36:37 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id C7EC22400FD for ; Sun, 30 May 2021 20:36:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1622399790; bh=d0hfCWqKvgY8n6NB4fV4nHHCorP/xaLHIS8Yj8geKu4=; h=From:To:Subject:Date:From; b=Pw0YN8ALhiq+Zv17SWETwL9kQMZRLFsNo9HCqKM4nN/2YuKVL1+3UY08g+4o6TzdG GXgN2DSfOV7PngxibgOo8px4lGdpj9TOUg5fCgNaB47kNrXjZZ4vCtz2pScc0XCWX8 53CffNRiOwnn1cON/JYwk7J6UQnxFogLpowa2xpROymzWhwMKcUMJiU+8j1sN4tPNI KExtzs6VGO1lMj4Oh664IJIDC9mMil0faoqCwoFXfsm5c/2/rggaZ2V02f84wYdmti xPxp6LEawANoJIjSgW3NyZAD1dWY29B1LvtLRXbZ2UTHhhDmmYIWCdrCplx9FjXhBj AHXhpSiL4QTsg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FtRvy2Wjmz9rxF for ; Sun, 30 May 2021 20:36:30 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270142 Archived-At: * 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