landrush 0.15.4 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daf7a71f8c1b732c73cba4f4188360fcf8cdb59c
4
- data.tar.gz: 236830e456bcac9109907a7e6bd81784da006032
3
+ metadata.gz: 2213172e93bf054552fbdc803850ceb241ba4ecc
4
+ data.tar.gz: 7fd5229d7916bda4e6e66583fd6fcaf0cafc2095
5
5
  SHA512:
6
- metadata.gz: 8e681085a1f4e19cbb57a9616dccaa3fad3da12809a0cdf3f83d1f4bea59207e1cbdeb49dcb55c2661ce31030d390a02d05861ffb8aed96fe7f9bdb7ac36f2ed
7
- data.tar.gz: 156d88a237850a3416505ffd6f382802aba54b696122af2c975ea13173c7f97413857620071875f87d0afddf4f2e0504bf8817151af3dfc53be12cd04d809248
6
+ metadata.gz: 13e7e08f3608ea7d0d3e58e51a56d5aafc40293b1308978ee0208f2bb8dd8f25ef28eb10976b710bb13b10969e6770528bfe0a84447f971f4f84fe8ebd880467
7
+ data.tar.gz: f1671a4162471abd9be73e6aefcd0903ed866ba4bd85cc491a4d9bce01f8621dbaad403741e7323e7ecec66ce6cecb85f17e246339aace6b2dd4e5b8f347ebac
@@ -55,6 +55,7 @@ module Landrush
55
55
  if !Store.hosts.has?(hostname, dns_value)
56
56
  info "adding static entry: #{hostname} => #{dns_value}"
57
57
  Store.hosts.set hostname, dns_value
58
+ Store.hosts.set(IPAddr.new(dns_value).reverse, hostname)
58
59
  end
59
60
  end
60
61
  end
@@ -71,6 +72,7 @@ module Landrush
71
72
  if !Store.hosts.has?(machine_hostname, ip_address)
72
73
  info "adding machine entry: #{machine_hostname} => #{ip_address}"
73
74
  Store.hosts.set(machine_hostname, ip_address)
75
+ Store.hosts.set(IPAddr.new(ip_address).reverse, machine_hostname)
74
76
  end
75
77
  end
76
78
 
@@ -27,7 +27,7 @@ module Landrush
27
27
  end
28
28
 
29
29
  def teardown_static_dns
30
- config.hosts.each do |static_hostname, _|
30
+ config.hosts.each do |static_hostname, dns_value|
31
31
  if Store.hosts.has? static_hostname
32
32
  info "removing static entry: #{static_hostname}"
33
33
  Store.hosts.delete static_hostname
@@ -61,6 +61,15 @@ module Landrush
61
61
  end
62
62
  end
63
63
 
64
+ match(/.*/, IN::PTR) do |transaction|
65
+ host = Store.hosts.find(transaction.name)
66
+ if host
67
+ transaction.respond!(Name.create(Store.hosts.get(host)))
68
+ else
69
+ transaction.passthrough!(server.upstream)
70
+ end
71
+ end
72
+
64
73
  # Default DNS handler
65
74
  otherwise do |transaction|
66
75
  transaction.passthrough!(server.upstream)
@@ -23,7 +23,7 @@ module Landrush
23
23
  end
24
24
 
25
25
  def delete(key)
26
- write(current_config.reject { |k, _| k == key })
26
+ write(current_config.reject { |k, v| k == key || v == key })
27
27
  end
28
28
 
29
29
  def has?(key, value = nil)
@@ -35,6 +35,7 @@ module Landrush
35
35
  end
36
36
 
37
37
  def find(search)
38
+ search = (IPAddr.new(search).reverse) if (IPAddr.new(search) rescue nil)
38
39
  current_config.keys.detect do |key|
39
40
  key.casecmp(search) == 0 ||
40
41
  search =~ /#{key}$/i ||
@@ -45,8 +46,8 @@ module Landrush
45
46
  def get(key)
46
47
  value = current_config[key]
47
48
  redirect = nil
48
- if value.is_a? String
49
- redirect = find(value)
49
+ if value.is_a? String and ! (IPAddr.new(value) rescue nil)
50
+ redirect = find(value) if not current_config[value]
50
51
  end
51
52
  if value
52
53
  if redirect
@@ -1,3 +1,3 @@
1
1
  module Landrush
2
- VERSION = "0.15.4"
2
+ VERSION = "0.16.0"
3
3
  end
@@ -8,6 +8,12 @@ module Landrush
8
8
  answer_line.split.last
9
9
  end
10
10
 
11
+ def query_ptr(host)
12
+ output = `dig ptr -p #{Server.port} @127.0.0.1 #{host}`
13
+ answer_line = output.split("\n").grep(/^#{Regexp.escape(host)}/).first
14
+ answer_line.split.last
15
+ end
16
+
11
17
  describe 'start/stop' do
12
18
  it 'starts and stops a daemon' do
13
19
  Server.start
@@ -35,6 +41,8 @@ module Landrush
35
41
  Store.hosts.set(fake_host, fake_ip)
36
42
 
37
43
  query(fake_host).must_equal fake_ip
44
+ query_ptr(fake_host).must_equal fake_ip+'.'
45
+
38
46
  end
39
47
 
40
48
  it 'also resolves wildcard subdomains to a given machine' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: landrush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.4
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Hinze
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubydns