net-dns-rbl 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +16 -0
- data/lib/net-dns-rbl.rb +1 -1
- data/lib/net-dns-rbl/netcheck.rb +48 -14
- data/lib/net-dns-rbl/version.rb +1 -1
- data/test/test_netdnsrbl.rb +20 -0
- metadata +4 -2
data/README
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
To use:
|
2
|
+
|
3
|
+
require 'net-dns-rbl'
|
4
|
+
|
5
|
+
ipCheck = Net::Dns::Rbl::Netchecker.new('ip_address_here')
|
6
|
+
listings = ipCheck.performLookups
|
7
|
+
- Returns nil if not listed
|
8
|
+
|
9
|
+
To add more lists:
|
10
|
+
ipCheck.addToLists('list_address_here')
|
11
|
+
|
12
|
+
To remove lists:
|
13
|
+
ipCheck.removeFromLists('list_address_here')
|
14
|
+
|
15
|
+
To see current lists you are checking against:
|
16
|
+
ipCheck.showCurrentLists
|
data/lib/net-dns-rbl.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Dir.chdir(File.dirname(__FILE__)) { Dir['
|
1
|
+
Dir.chdir(File.dirname(__FILE__)) { Dir['net-dns-rbl/*.rb'] }.each {|f| require f }
|
data/lib/net-dns-rbl/netcheck.rb
CHANGED
@@ -1,22 +1,56 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module
|
4
|
-
|
1
|
+
module Net
|
2
|
+
module Dns
|
3
|
+
module Rbl
|
4
|
+
|
5
|
+
require 'resolv'
|
6
|
+
|
7
|
+
class Netcheck
|
5
8
|
|
6
|
-
|
7
|
-
|
9
|
+
def initialize(ip)
|
10
|
+
raise ArgumentError, "Invalid IP specified" if !ip.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
|
11
|
+
@reverseip = ip.split('.').reverse.join('.')
|
12
|
+
@lists = LISTS
|
13
|
+
end
|
8
14
|
|
9
|
-
|
10
|
-
|
11
|
-
|
15
|
+
# Add additional dnsbl lookup lists
|
16
|
+
def addToLists(list)
|
17
|
+
@lists.push(list)
|
18
|
+
end
|
12
19
|
|
13
|
-
|
20
|
+
# Remove an existing dnsbl list from the existing hash
|
21
|
+
def removeFromLists(list)
|
22
|
+
@lists.delete(list)
|
23
|
+
end
|
24
|
+
|
25
|
+
def showCurrentLists
|
26
|
+
@lists
|
27
|
+
end
|
14
28
|
|
15
|
-
|
29
|
+
def performLookups
|
30
|
+
@lists.each do |l|
|
31
|
+
begin
|
32
|
+
host = @reverseip+'.'+l
|
33
|
+
resip = Resolv::getaddress(host)
|
34
|
+
if resip.match(/(127)\.\d{1}\.\d{1,3}\.\d{1,3}/)
|
35
|
+
@listed << l
|
36
|
+
end
|
37
|
+
|
38
|
+
rescue Exception => e
|
39
|
+
case e
|
40
|
+
when Resolv::ResolvError
|
41
|
+
nil
|
42
|
+
when Interrupt
|
43
|
+
puts "\nCaught signal SIGINT. Exiting..."
|
44
|
+
exit 1
|
45
|
+
else
|
46
|
+
puts ": \e[0;47mTIMEOUT\e[0m\n"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
return @listed
|
51
|
+
end
|
16
52
|
|
17
|
-
|
18
|
-
|
53
|
+
end
|
19
54
|
end
|
20
|
-
|
21
55
|
end
|
22
56
|
end
|
data/lib/net-dns-rbl/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'net-dns-rbl'
|
3
|
+
|
4
|
+
class TestNetDnsRbl < Test::Unit::TestCase
|
5
|
+
def test_initialization_and_list_array
|
6
|
+
assert_equal Net::Dns::Rbl::Netcheck.new('127.0.0.1').showCurrentLists.count, 16
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_remove_list
|
10
|
+
netCheckObj = Net::Dns::Rbl::Netcheck.new('127.0.0.1')
|
11
|
+
netCheckObj.removeFromLists('xbl.spamhaus.org')
|
12
|
+
assert(!netCheckObj.showCurrentLists.include?('xbl.spamhaus.org'),"List was not removed from array")
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_add_list
|
16
|
+
netCheckObj = Net::Dns::Rbl::Netcheck.new('127.0.0.1')
|
17
|
+
netCheckObj.addToLists('testlist.org')
|
18
|
+
assert(netCheckObj.showCurrentLists.include?('testlist.org'),"List was not added to array")
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-dns-rbl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- lib/net-dns-rbl/version.rb
|
26
26
|
- lib/net-dns-rbl.rb
|
27
27
|
- README
|
28
|
+
- test/test_netdnsrbl.rb
|
28
29
|
homepage: http://rubygems.org/gems/net-dns-rbl
|
29
30
|
licenses: []
|
30
31
|
post_install_message:
|
@@ -49,4 +50,5 @@ rubygems_version: 1.8.10
|
|
49
50
|
signing_key:
|
50
51
|
specification_version: 3
|
51
52
|
summary: Utility gem to perform lookups against dns blacklists
|
52
|
-
test_files:
|
53
|
+
test_files:
|
54
|
+
- test/test_netdnsrbl.rb
|