sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 09e95230dbc330b4a4b1a4c161ca9d1d57d088fc
parent 16901db9836d2c07d8143c7acf5975cc411904bb
Author: Matthieu Rakotojaona <matthieu.rakotojaona@gmail.com>
Date:   Wed, 28 Jan 2015 21:39:31 +0100

Make keyserver url configurable

Diffstat:
M lib/sup/crypto.rb | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -359,13 +359,20 @@ EOS
 
   def retrieve fingerprint
     require 'net/http'
-    uri = URI(KEYSERVER_URL)
+    uri = URI($config[:keyserver_url] || KEYSERVER_URL)
+    unless uri.scheme == "http" and not uri.host.nil?
+      return "Invalid url: #{uri}"
+    end
+
     fingerprint = "0x" + fingerprint unless fingerprint[0..1] == "0x"
     params = {op: "get", search: fingerprint}
     uri.query = URI.encode_www_form(params)
 
-    res = Net::HTTP.get_response(uri)
-    return "Couldn't contact keyserver pool" unless res.is_a?(Net::HTTPSuccess)
+    begin
+      res = Net::HTTP.get_response(uri)
+    rescue SocketError # Host doesn't exist or we couldn't connect
+    end
+    return "Couldn't get key from keyserver at this address: #{uri}" unless res.is_a?(Net::HTTPSuccess)
 
     match = KEY_PATTERN.match(res.body)
     return "No key found" unless match && match.length > 0