dnsbl-client 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dnsbl-client +1 -0
- data/data/dnsbl.yaml +0 -0
- data/data/three-level-tlds +0 -0
- data/data/two-level-tlds +0 -0
- data/lib/dnsbl/client.rb +26 -4
- data/lib/dnsbl/client/version.rb +1 -1
- data/test/helper.rb +0 -0
- data/test/test_dnsbl-client.rb +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8782496924ce9d3fcf9231060e3182203a8e8886a7a4195d75eacb7abed9463c
|
4
|
+
data.tar.gz: 7c95c6bcd94468c2ac7a58c4db8d4c21c2bff33b8d5afff7d07c0bb2afb08f02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0954fde62af63a2216af0e6107e2bb162604eeb703d70cc9b91f861373c101f35c95e350102343db62667efd000171bb680c0b9d73b538aee52e979b7dc343fa'
|
7
|
+
data.tar.gz: '01490c656455fd58c20f2e407f543c89cc2c7687d6581095b6bb0438e2e1c8ffa35535bd685a46277deeef3efb51bd4bc8f34885866cedcfa36b984caf797a6d'
|
data/bin/dnsbl-client
CHANGED
data/data/dnsbl.yaml
CHANGED
File without changes
|
data/data/three-level-tlds
CHANGED
File without changes
|
data/data/two-level-tlds
CHANGED
File without changes
|
data/lib/dnsbl/client.rb
CHANGED
@@ -5,12 +5,13 @@ require 'resolv'
|
|
5
5
|
require 'socket'
|
6
6
|
require 'thread'
|
7
7
|
require 'yaml'
|
8
|
+
require 'ipaddr'
|
8
9
|
|
9
10
|
# This is a monkeypatch for the built-in Ruby DNS resolver to specify nameservers
|
10
11
|
class Resolv::DNS::Config
|
11
12
|
# Monkeypatch the nameservers to set a default if there are no defined nameservers
|
12
13
|
def nameservers
|
13
|
-
return @nameservers if @nameservers
|
14
|
+
return @nameservers if defined?(@nameservers)
|
14
15
|
|
15
16
|
lazy_initialize
|
16
17
|
if self.respond_to? :nameserver_port
|
@@ -41,6 +42,8 @@ module DNSBL # :nodoc:
|
|
41
42
|
two_level_tldfile = File.expand_path('../../../data', __FILE__)+"/two-level-tlds",
|
42
43
|
three_level_tldfile = File.expand_path('../../../data', __FILE__)+"/three-level-tlds")
|
43
44
|
@dnsbls = config
|
45
|
+
@timeout = 1.5
|
46
|
+
@first_only = false
|
44
47
|
@two_level_tld = []
|
45
48
|
@three_level_tld = []
|
46
49
|
File.open(two_level_tldfile).readlines.each do |l|
|
@@ -60,6 +63,14 @@ module DNSBL # :nodoc:
|
|
60
63
|
@socket_index = 0
|
61
64
|
end
|
62
65
|
|
66
|
+
def timeout=(timeout_seconds)
|
67
|
+
@timeout = timeout_seconds
|
68
|
+
end
|
69
|
+
|
70
|
+
def first_only=(first_only_boolean)
|
71
|
+
@first_only = first_only_boolean
|
72
|
+
end
|
73
|
+
|
63
74
|
# sets the nameservers used for performing DNS lookups in round-robin fashion
|
64
75
|
def nameservers=(ns=Resolv::DNS::Config.new.nameservers)
|
65
76
|
@sockets.each do |s|
|
@@ -108,7 +119,8 @@ module DNSBL # :nodoc:
|
|
108
119
|
def _encode_query(item,itemtype,domain,apikey=nil)
|
109
120
|
label = nil
|
110
121
|
if itemtype == 'ip'
|
111
|
-
|
122
|
+
ip = IPAddr.new(item)
|
123
|
+
label = ip.reverse.gsub('.ip6.arpa', '').gsub('.in-addr.arpa', '')
|
112
124
|
elsif itemtype == 'domain'
|
113
125
|
label = normalize(item)
|
114
126
|
end
|
@@ -142,6 +154,8 @@ module DNSBL # :nodoc:
|
|
142
154
|
@starttime = Time.now.to_f
|
143
155
|
# determine the type of query
|
144
156
|
itemtype = (item =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) ? 'ip' : 'domain'
|
157
|
+
itemtype = (item =~ /^\s*((([0-9A-Fa-f]{1,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for each dnsbl that supports our type, create the DNS query packet and send it
|
146
160
|
# rotate across our configured name servers and increment sent
|
147
161
|
@dnsbls.each do |name,config|
|
@@ -160,11 +174,12 @@ module DNSBL # :nodoc:
|
|
160
174
|
end
|
161
175
|
# while we still expect answers
|
162
176
|
while sent > 0
|
163
|
-
# wait on the socket for maximally
|
164
|
-
r,_,_ = IO.select(@sockets,nil,nil
|
177
|
+
# wait on the socket for maximally @timeout seconds
|
178
|
+
r,_,_ = IO.select(@sockets,nil,nil,@timeout)
|
165
179
|
# if we time out, break out of the loop
|
166
180
|
break unless r
|
167
181
|
# for each reply, decode it and receive results, decrement the pending answers
|
182
|
+
first_only = false
|
168
183
|
r.each do |s|
|
169
184
|
begin
|
170
185
|
response = _decode_response(s.recv(4096))
|
@@ -174,7 +189,14 @@ module DNSBL # :nodoc:
|
|
174
189
|
puts e.backtrace.join("\n")
|
175
190
|
end
|
176
191
|
sent -= 1
|
192
|
+
if @first_only
|
193
|
+
first_only = true
|
194
|
+
break
|
195
|
+
end
|
177
196
|
end
|
197
|
+
if first_only
|
198
|
+
break
|
199
|
+
end
|
178
200
|
end
|
179
201
|
end
|
180
202
|
results
|
data/lib/dnsbl/client/version.rb
CHANGED
data/test/helper.rb
CHANGED
File without changes
|
data/test/test_dnsbl-client.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsbl-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chrislee35
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|