elbping 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/elbping.gemspec +1 -1
- data/lib/elbping/resolver.rb +5 -3
- metadata +1 -2
- data/lib/elbping/tcp_dns.rb +0 -44
data/elbping.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'elbping'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.16'
|
4
4
|
s.date = '2013-08-13'
|
5
5
|
s.summary = "Small tool to 'ping' the nodes that make up an Amazon Elastic Load Balancer"
|
6
6
|
s.description = "elbping is a tool to ping all of the nodes behind an Amazon Elastic Load Balancer. It only works for ELBs in HTTP mode and works by triggering an HTTP 405 (METHOD NOT ALLOWED) error caused when the ELB receives a HTTP verb that is too long."
|
data/lib/elbping/resolver.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'resolv'
|
2
|
-
require 'elbping/tcp_dns.rb'
|
3
2
|
|
4
3
|
# TODO: Raise own exceptions
|
5
4
|
|
@@ -67,14 +66,17 @@ module ElbPing
|
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
|
-
|
69
|
+
# Resolv::DNS never completes queries successfully if you pass a list
|
70
|
+
# of nameservers to it
|
71
|
+
nameserver = find_elb_ns(target, timeout).sample
|
71
72
|
|
72
73
|
Timeout::timeout(timeout) do
|
73
|
-
|
74
|
+
Resolv::DNS.open :nameserver => nameserver do |dns|
|
74
75
|
# TODO: Exceptions
|
75
76
|
resp = dns.getresources "all.#{target}", Resolv::DNS::Resource::IN::A
|
76
77
|
end
|
77
78
|
end
|
79
|
+
|
78
80
|
if resp
|
79
81
|
resp.select { |r| r.respond_to? "address" and r.address }.map { |r| r.address.to_s }
|
80
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elbping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -52,7 +52,6 @@ files:
|
|
52
52
|
- lib/elbping/pinger.rb
|
53
53
|
- lib/elbping/resolver.rb
|
54
54
|
- lib/elbping/stats.rb
|
55
|
-
- lib/elbping/tcp_dns.rb
|
56
55
|
- test/test_latencybucket.rb
|
57
56
|
- test/test_pinger.rb
|
58
57
|
- test/test_resolver.rb
|
data/lib/elbping/tcp_dns.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'resolv'
|
3
|
-
|
4
|
-
# A TCP-only resolver built from `Resolv::DNS`. See the docs for what it's about.
|
5
|
-
# http://ruby-doc.org/stdlib-1.9.3/libdoc/resolv/rdoc/Resolv/DNS.html
|
6
|
-
class TcpDNS < Resolv::DNS
|
7
|
-
# Override fetch_resource to use a TCP requester instead of a UDP requester. This
|
8
|
-
# is mostly borrowed from `lib/resolv.rb` with the UDP->TCP fallback logic removed.
|
9
|
-
def each_resource(name, typeclass, &proc)
|
10
|
-
lazy_initialize
|
11
|
-
senders = {}
|
12
|
-
requester = nil
|
13
|
-
begin
|
14
|
-
@config.resolv(name) { |candidate, tout, nameserver, port|
|
15
|
-
requester = make_tcp_requester(nameserver, port)
|
16
|
-
msg = Message.new
|
17
|
-
msg.rd = 1
|
18
|
-
msg.add_question(candidate, typeclass)
|
19
|
-
unless sender = senders[[candidate, nameserver, port]]
|
20
|
-
sender = senders[[candidate, nameserver, port]] =
|
21
|
-
requester.sender(msg, candidate, nameserver, port)
|
22
|
-
end
|
23
|
-
|
24
|
-
begin # HACK
|
25
|
-
reply, reply_name = requester.request(sender, tout)
|
26
|
-
rescue
|
27
|
-
return
|
28
|
-
end
|
29
|
-
|
30
|
-
case reply.rcode
|
31
|
-
when RCode::NoError
|
32
|
-
extract_resources(reply, reply_name, typeclass, &proc)
|
33
|
-
return
|
34
|
-
when RCode::NXDomain
|
35
|
-
raise Config::NXDomain.new(reply_name.to_s)
|
36
|
-
else
|
37
|
-
raise Config::OtherResolvError.new(reply_name.to_s)
|
38
|
-
end
|
39
|
-
}
|
40
|
-
ensure
|
41
|
-
requester.close unless requester.nil?
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|