eventmachine-dnsbl 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b769f5b225813cbc47239bbb19ffc340a0f65dd
4
- data.tar.gz: 4d68ffc2ddcdf8173817b9e668a4219b33a5bc0d
3
+ metadata.gz: 055d3633c5ab9e36ecbcfb2d1c1a4b5e1235c2c1
4
+ data.tar.gz: dc7d0ea98482377933a5902d1df430308377f4e1
5
5
  SHA512:
6
- metadata.gz: 879d99f241a220a447cb26e711438b0e96e0ac610755124eca90f1bc822c4494c619739ea7de1591d88f2b062d02764b0be1d65ccd314c36d449d7bcb96907fb
7
- data.tar.gz: 287aaab5c82b67ffd9911b9ecb165318be2ed5ce474ddb2194c44c4984a060179cab1ca0eb52e1f489b986f975bc4e5872b01927cada6c77dc949f9d7f741718
6
+ metadata.gz: 2bb8588e0d189807f46a0b8867c24436630cba9901753551c3053c48f9af9545d58ab6fca016670622f009be528167f6aa2e389307ee387d03c9e0a08c0eb23e
7
+ data.tar.gz: 0ce2a851cdae3cf498c547680d281e87e7bf45b710b0058cc56e6a711dad18ea30d84a68cb1857ec202b06652a02a8c41ecf06ad96d25e0feced9a390eb59929
@@ -1,5 +1,5 @@
1
1
  module EventMachine
2
2
  module DNSBL
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ module EventMachine
4
4
  class DNSBLResourceRecord < Struct.new(:zone, :label_regex, :ttl, :answer, :valid_until); end
5
5
 
6
6
  class AbstractZone
7
- def get_records(query, qtype)
7
+ def get_records(query, qtype = Resolv::DNS::Resource::IN::A)
8
8
  records = Array.new
9
9
  # A queries are all that I support right now
10
10
  if qtype != Resolv::DNS::Resource::IN::A
@@ -14,14 +14,16 @@ module EventMachine
14
14
  zone = label = nil
15
15
  @zones.each do |z|
16
16
  if query.end_with?(z)
17
- label = query[0, query.length - z.length]
17
+ label = query[0, query.length - z.length - 1]
18
18
  zone = z
19
19
  end
20
20
  end
21
21
 
22
22
  if zone
23
23
  get_all_records_for_zone(zone).each do |rec|
24
- if rec[:label_regex].match(label)
24
+ if rec[:valid_until] and rec[:valid_until] < Time.now.to_i
25
+ next
26
+ elsif rec[:label_regex].match(label)
25
27
  records << rec
26
28
  end
27
29
  end
@@ -42,6 +42,11 @@ module EventMachine
42
42
  rs.each do |row|
43
43
  row[1] = Regexp.new(row[1])
44
44
  row[3] = Resolv::DNS::Resource::IN::A.new(row[3])
45
+ if row[4] =~ /\d/
46
+ row[4] = row[4].to_i
47
+ else
48
+ row[4] = nil
49
+ end
45
50
  records << DNSBLResourceRecord.new(*row)
46
51
  end
47
52
  records
@@ -16,7 +16,6 @@ class TestDNSBLClient < Minitest::Test
16
16
  def run_test(item, expected_result)
17
17
  EM.run do
18
18
  EventMachine::DNSBL::Client.check(item) do |results|
19
- pp results
20
19
  assert_equal(expected_result, EventMachine::DNSBL::Client.blacklisted?(results))
21
20
  EM.stop
22
21
  end
@@ -42,14 +42,42 @@ class TestDNSBLServer < Minitest::Test
42
42
  Time.now.to_i + 3600
43
43
  )
44
44
  )
45
+ zone.add_dnsblresource(
46
+ EventMachine::DNSBL::Zone::DNSBLResourceRecord.new(
47
+ "example.com",
48
+ /\d+\.0\.0\.127$/,
49
+ 300,
50
+ Resolv::DNS::Resource::IN::A.new("127.0.0.4"),
51
+ Time.now.to_i + 3600
52
+ )
53
+ )
54
+ zone.add_dnsblresource(
55
+ EventMachine::DNSBL::Zone::DNSBLResourceRecord.new(
56
+ "example.com",
57
+ /\d+\.0\.168\.192$/,
58
+ 300,
59
+ Resolv::DNS::Resource::IN::A.new("127.0.0.5"),
60
+ Time.now.to_i - 10
61
+ )
62
+ )
45
63
  end
46
64
 
47
65
  def zone_test(zone)
48
66
  zone_add_test_resources(zone)
49
- recs = zone.get_records("viagrapillz.example.com", Resolv::DNS::Resource::IN::A)
50
- assert(2, recs.length)
51
- recs = zone.get_records("cialispillz.example.com", Resolv::DNS::Resource::IN::A)
52
- assert(1, recs.length)
67
+ recs = zone.get_records("viagrapillz.example.com")
68
+ assert_equal(2, recs.length)
69
+ assert_equal("127.0.0.2", recs[0].answer.address.to_s)
70
+ assert_equal("127.0.0.3", recs[1].answer.address.to_s)
71
+ recs = zone.get_records("cialispillz.example.com")
72
+ assert_equal(1, recs.length)
73
+ assert_equal("127.0.0.3", recs[0].answer.address.to_s)
74
+ recs = zone.get_records("www.example.com")
75
+ assert_equal(0, recs.length)
76
+ recs = zone.get_records("1.0.0.127.example.com")
77
+ assert_equal(1, recs.length)
78
+ assert_equal("127.0.0.4", recs[0].answer.address.to_s)
79
+ recs = zone.get_records("5.0.168.192.example.com")
80
+ assert_equal(0, recs.length)
53
81
  end
54
82
 
55
83
  def test_memory_zone
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine-dnsbl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-01 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine