summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-05-13 04:38:46 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-05-13 04:38:46 +0200
commitb4608ac16c27647721dfe5ee56bf9709a827c486 (patch)
treeac83dd2887d249de0c1ef5f455969c5cbdd927b9
parentff56fd8a3fa79b23fc18c4aa2d7f2983d5230096 (diff)
downloadmdns-resolver-b4608ac16c27647721dfe5ee56bf9709a827c486.tar
mdns-resolver-b4608ac16c27647721dfe5ee56bf9709a827c486.zip
Fix IPv6 resolve on systems that only return IPv4 addresses by default
-rwxr-xr-xmdns-resolver12
1 files changed, 11 insertions, 1 deletions
diff --git a/mdns-resolver b/mdns-resolver
index 762f8d9..592c754 100755
--- a/mdns-resolver
+++ b/mdns-resolver
@@ -96,7 +96,17 @@ while run do
begin
addresses = Set.new
- Socket.getaddrinfo(host+'.local.', nil).each { |addr| addresses << [addr[0], addr[3]] }
+ begin
+ Socket.getaddrinfo(host+'.local.', nil, :INET).each { |addr| addresses << [addr[0], addr[3]] }
+ rescue
+ end
+
+ begin
+ Socket.getaddrinfo(host+'.local.', nil, :INET6).each { |addr| addresses << [addr[0], addr[3]] }
+ rescue
+ end
+
+ raise if addresses.empty?
if q.qType.to_i == Net::DNS::A or q.qType.to_i == Net::DNS::ANY
addresses.each do |addr|