summaryrefslogtreecommitdiff
path: root/lib/nickserver/nicknym/source.rb
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2017-07-24 09:55:28 +0200
committerAzul <azul@riseup.net>2017-07-24 10:03:22 +0200
commitb1738a78ccf5768f92068a27255f9f69be1c3147 (patch)
tree6cad7ae458d6bc349a0ba925f82477feb2010fa1 /lib/nickserver/nicknym/source.rb
parentcfa6395c7e5728de02221b94b5f9cfe8a4debf09 (diff)
fix: #3 handle domains without A-record
If a domain only has an mx record but no A record it will trigger a ConnectionError when attempting the nicknym key lookup. We need to detect and handle this in the http adapter already because once the exception is handled by Celluloid our actor will be terminated. So now we allow for handing a rescue option to the adapter with a string that is checked for inclusion in the error message. If the string is found the exception will be caught and the adapter returns nil. We only make use of this when checking the availability of nicknym so far. That should be the only http request going out.
Diffstat (limited to 'lib/nickserver/nicknym/source.rb')
-rw-r--r--lib/nickserver/nicknym/source.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/nickserver/nicknym/source.rb b/lib/nickserver/nicknym/source.rb
index 96945cb..f49547e 100644
--- a/lib/nickserver/nicknym/source.rb
+++ b/lib/nickserver/nicknym/source.rb
@@ -8,7 +8,8 @@ module Nickserver
PORT = 6425
def available_for?(domain)
- status, body = adapter.get "https://#{domain}/provider.json"
+ status, body = adapter.get "https://#{domain}/provider.json",
+ rescue: 'failed to connect: getaddrinfo'
status == 200 && provider_with_mx?(body)
end