landrush 0.4.1 → 0.5.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.
- data/README.md +9 -13
- data/lib/landrush/server.rb +4 -4
- data/lib/landrush/store.rb +6 -0
- data/lib/landrush/version.rb +1 -1
- data/test/landrush/server_test.rb +29 -15
- data/test/landrush/store_test.rb +16 -0
- metadata +8 -3
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Simple DNS that's visible on both the guest and the host.
|
4
4
|
|
5
|
-
>
|
5
|
+
> Even a Vagrant needs a place to settle down once in a while.
|
6
6
|
|
7
7
|
Spins up a small DNS server and redirects DNS traffic from your VMs to use it,
|
8
8
|
automatically registers/deregisters IP addresseses of guests as they come up
|
@@ -14,6 +14,8 @@ Install under Vagrant (1.1 or later):
|
|
14
14
|
|
15
15
|
$ vagrant plugin install landrush
|
16
16
|
|
17
|
+
If you're on OS X, see **Visibility on the Host** below.
|
18
|
+
|
17
19
|
## Usage
|
18
20
|
|
19
21
|
### Get started
|
@@ -32,7 +34,6 @@ And you should be able to get your hostname from your host:
|
|
32
34
|
|
33
35
|
If you shut down your guest, the entries associated with it will be removed.
|
34
36
|
|
35
|
-
|
36
37
|
### Static entries
|
37
38
|
|
38
39
|
You can add static host entries to the DNS server in your `Vagrantfile` like so:
|
@@ -41,6 +42,10 @@ You can add static host entries to the DNS server in your `Vagrantfile` like so:
|
|
41
42
|
|
42
43
|
This is great for overriding production services for nodes you might be testing locally. For example, perhaps you might want to override the hostname of your puppetmaster to point to a local vagrant box instead.
|
43
44
|
|
45
|
+
### Wildcard Subdomains
|
46
|
+
|
47
|
+
For your convenience, any subdomain of a DNS entry known to landrush will resolve to the same IP address as the entry. For example: given `myhost.vagrant.dev -> 1.2.3.4`, both `foo.myhost.vagrant.dev` and `bar.myhost.vagrant.dev` will also resolve to `1.2.3.4`.
|
48
|
+
|
44
49
|
### Unmatched Queries
|
45
50
|
|
46
51
|
Any DNS queries that do not match will be passed through to an upstream DNS server, so this will be able to serve as the one-stop shop for your guests' DNS needs.
|
@@ -81,16 +86,7 @@ vagrant landrush install
|
|
81
86
|
|
82
87
|
Check out `vagrant landrush` for additional commands to monitor the DNS server daemon.
|
83
88
|
|
84
|
-
##
|
85
|
-
|
86
|
-
* The guest visibility strategy assumes iptables-based firewall.
|
87
|
-
* Lots of static values that need configurin' - config location, ports, etc.
|
88
|
-
* Tests tests tests.
|
89
|
+
## Help Out!
|
89
90
|
|
90
|
-
|
91
|
+
This project could use your feedback and help! Please don't hesitate to open issues or submit pull requests. NO HESITATION IS ALLOWED. NONE WHATSOEVER.
|
91
92
|
|
92
|
-
1. Fork it
|
93
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
94
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
95
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
96
|
-
5. Create new Pull Request
|
data/lib/landrush/server.rb
CHANGED
@@ -49,11 +49,11 @@ module Landrush
|
|
49
49
|
server = self
|
50
50
|
RubyDNS::run_server(:listen => interfaces) do
|
51
51
|
self.logger.level = Logger::INFO
|
52
|
-
|
52
|
+
|
53
53
|
match(/.*/, IN::A) do |transaction|
|
54
|
-
|
55
|
-
if
|
56
|
-
transaction.respond!(
|
54
|
+
host = Store.hosts.find(transaction.name)
|
55
|
+
if host
|
56
|
+
transaction.respond!(Store.hosts.get(host))
|
57
57
|
else
|
58
58
|
transaction.passthrough!(server.upstream)
|
59
59
|
end
|
data/lib/landrush/store.rb
CHANGED
data/lib/landrush/version.rb
CHANGED
@@ -2,34 +2,48 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Landrush
|
4
4
|
describe Server do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def query(host)
|
6
|
+
output = `dig -p #{Server.port} @127.0.0.1 #{host}`
|
7
|
+
answer_line = output.split("\n").grep(/^#{Regexp.escape(host)}/).first
|
8
|
+
answer_line.split.last
|
9
|
+
end
|
10
|
+
|
10
11
|
describe 'start/stop' do
|
11
12
|
it 'starts and stops a daemon' do
|
12
|
-
|
13
|
-
|
13
|
+
Server.start
|
14
14
|
Server.running?.must_equal true
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
Server.stop
|
18
17
|
Server.running?.must_equal false
|
19
18
|
end
|
20
19
|
|
21
20
|
it 'can be queried for upstream entries' do
|
22
|
-
|
21
|
+
Server.start
|
23
22
|
|
24
|
-
|
23
|
+
query("phinze.com").must_match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'responds properly to configured machine entries' do
|
27
|
+
Server.start
|
28
|
+
|
29
|
+
fake_host = 'boogers.vagrant.dev'
|
30
|
+
fake_ip = '99.98.97.96'
|
31
|
+
|
32
|
+
Store.hosts.set(fake_host, fake_ip)
|
33
|
+
|
34
|
+
query(fake_host).must_equal fake_ip
|
35
|
+
end
|
25
36
|
|
26
|
-
|
37
|
+
it 'also resolves wildcard subdomains to a given machine' do
|
38
|
+
Server.start
|
27
39
|
|
28
|
-
|
40
|
+
fake_host = 'boogers.vagrant.dev'
|
41
|
+
fake_ip = '99.98.97.96'
|
29
42
|
|
30
|
-
|
43
|
+
Store.hosts.set(fake_host, fake_ip)
|
31
44
|
|
32
|
-
|
45
|
+
query("green.#{fake_host}").must_match(fake_ip)
|
46
|
+
query("blue.#{fake_host}").must_match(fake_ip)
|
33
47
|
end
|
34
48
|
end
|
35
49
|
end
|
data/test/landrush/store_test.rb
CHANGED
@@ -51,5 +51,21 @@ module Landrush
|
|
51
51
|
@store.get('now').must_equal nil # you don't!
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
describe "find" do
|
56
|
+
it "returns the key that matches the end of the search term" do
|
57
|
+
@store.set('somehost.vagrant.dev', 'here')
|
58
|
+
|
59
|
+
@store.find('foo.somehost.vagrant.dev').must_equal 'somehost.vagrant.dev'
|
60
|
+
@store.find('bar.somehost.vagrant.dev').must_equal 'somehost.vagrant.dev'
|
61
|
+
@store.find('foo.otherhost.vagrant.dev').must_equal nil
|
62
|
+
@store.find('host.vagrant.dev').must_equal nil
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns exact matches too" do
|
66
|
+
@store.set('somehost.vagrant.dev', 'here')
|
67
|
+
@store.find('somehost.vagrant.dev').must_equal 'somehost.vagrant.dev'
|
68
|
+
end
|
69
|
+
end
|
54
70
|
end
|
55
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: landrush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubydns
|
@@ -134,12 +134,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- - ! '>='
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
hash: -227825973048311947
|
137
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
141
|
none: false
|
139
142
|
requirements:
|
140
143
|
- - ! '>='
|
141
144
|
- !ruby/object:Gem::Version
|
142
145
|
version: '0'
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
hash: -227825973048311947
|
143
149
|
requirements: []
|
144
150
|
rubyforge_project:
|
145
151
|
rubygems_version: 1.8.23
|
@@ -159,4 +165,3 @@ test_files:
|
|
159
165
|
- test/support/fake_working_dir.rb
|
160
166
|
- test/support/test_server_daemon.rb
|
161
167
|
- test/test_helper.rb
|
162
|
-
has_rdoc:
|