Skip to content

Commit 6761f6d

Browse files
committed
Use IPv6 on CI.
1 parent 4efe3f4 commit 6761f6d

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

lib/async/dns/system.rb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,117 +14,117 @@ module Async::DNS
1414
module System
1515
RESOLV_CONF = "/etc/resolv.conf"
1616
HOSTS = "/etc/hosts"
17-
17+
1818
def self.hosts_path
1919
if RUBY_PLATFORM =~ /mswin32|mingw|bccwin/
2020
Win32::Resolv.get_hosts_path
2121
else
2222
HOSTS
2323
end
2424
end
25-
25+
2626
# This code is very experimental
2727
class Hosts
2828
def initialize
2929
@addresses = {}
3030
@names = {}
3131
end
32-
32+
3333
attr :addresses
3434
attr :names
35-
35+
3636
# This is used to match names against the list of known hosts:
3737
def call(name)
3838
@names.include?(name)
3939
end
40-
40+
4141
def lookup(name)
4242
addresses = @names[name]
43-
43+
4444
if addresses
4545
addresses.last
4646
else
4747
nil
4848
end
4949
end
50-
50+
5151
alias [] lookup
52-
52+
5353
def add(address, names)
5454
@addresses[address] ||= []
5555
@addresses[address] += names
56-
56+
5757
names.each do |name|
5858
@names[name] ||= []
5959
@names[name] << address
6060
end
6161
end
62-
62+
6363
def parse_hosts(io)
6464
io.each do |line|
6565
line.sub!(/#.*/, '')
6666
address, hostname, *aliases = line.split(/\s+/)
67-
67+
6868
add(address, [hostname] + aliases)
6969
end
7070
end
71-
71+
7272
def self.local
7373
hosts = self.new
74-
74+
7575
path = System::hosts_path
76-
76+
7777
if path and File.exist?(path)
7878
File.open(path) do |file|
7979
hosts.parse_hosts(file)
8080
end
8181
end
82-
82+
8383
return hosts
8484
end
8585
end
86-
86+
8787
def self.parse_resolv_configuration(path)
8888
nameservers = []
8989
File.open(path) do |file|
9090
file.each do |line|
9191
# Remove any comments:
9292
line.sub!(/[#;].*/, '')
93-
93+
9494
# Extract resolv.conf command:
9595
keyword, *args = line.split(/\s+/)
96-
96+
9797
case keyword
9898
when 'nameserver'
9999
nameservers += args
100100
end
101101
end
102102
end
103-
103+
104104
return nameservers
105105
end
106-
106+
107107
def self.standard_connections(nameservers, **options)
108108
connections = []
109-
109+
110110
nameservers.each do |host|
111111
connections << IO::Endpoint.udp(host, 53, **options)
112112
connections << IO::Endpoint.tcp(host, 53, **options)
113113
end
114-
114+
115115
return IO::Endpoint.composite(connections)
116116
end
117-
117+
118118
# Get a list of standard nameserver connections which can be used for querying any standard servers that the system has been configured with. There is no equivalent facility to use the `hosts` file at present.
119119
def self.nameservers(**options)
120120
nameservers = []
121-
121+
122122
if File.exist? RESOLV_CONF
123123
nameservers = parse_resolv_configuration(RESOLV_CONF)
124124
elsif defined?(Win32::Resolv) and RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/
125125
search, nameservers = Win32::Resolv.get_resolv_info
126126
end
127-
127+
128128
return standard_connections(nameservers, **options)
129129
end
130130

test/async/dns/resolver/consistency.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ def before
8181
resolver = Async::DNS::Resolver.new
8282

8383
resolved_a = DOMAINS.to_h do |domain|
84-
[domain, resolver.addresses_for(domain)]
84+
[domain, resolver.addresses_for(domain).map(&:to_s)]
8585
end
8686
end
8787

8888
resolv_dns_performance = Benchmark.measure do
89-
resolver = Resolv::DNS.new
89+
resolver = Resolv.new(use_ipv6: true)
9090

9191
resolved_b = DOMAINS.to_h do |domain|
9292
[domain, resolver.getaddresses(domain)]

0 commit comments

Comments
 (0)