landrush 0.15.4 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/landrush/action/setup.rb +2 -0
- data/lib/landrush/action/teardown.rb +1 -1
- data/lib/landrush/server.rb +9 -0
- data/lib/landrush/store.rb +4 -3
- data/lib/landrush/version.rb +1 -1
- data/test/landrush/server_test.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2213172e93bf054552fbdc803850ceb241ba4ecc
|
4
|
+
data.tar.gz: 7fd5229d7916bda4e6e66583fd6fcaf0cafc2095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/landrush/server.rb
CHANGED
@@ -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)
|
data/lib/landrush/store.rb
CHANGED
@@ -23,7 +23,7 @@ module Landrush
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def delete(key)
|
26
|
-
write(current_config.reject { |k,
|
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
|
data/lib/landrush/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubydns
|