landrush 0.9.0 → 0.10.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 +13 -1
- data/lib/landrush/action/common.rb +11 -0
- data/lib/landrush/action/setup.rb +10 -0
- data/lib/landrush/config.rb +25 -0
- data/lib/landrush/resolver_config.rb +1 -1
- data/lib/landrush/server.rb +2 -1
- data/lib/landrush/store.rb +4 -0
- data/lib/landrush/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -42,12 +42,24 @@ This is great for overriding production services for nodes you might be testing
|
|
42
42
|
|
43
43
|
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`.
|
44
44
|
|
45
|
-
|
45
|
+
If you would like to configure your guests to be accessible from the host as subdomains of something other than the default `vagrant.dev`, you can use the `config.landrush.tld` option in your Vagrantfile like so:
|
46
|
+
|
47
|
+
config.landrush.tld = 'vm'
|
48
|
+
|
49
|
+
Note that from the __host__, you will only be able to access subdomains of your configured TLD by default- so wildcard subdomains only apply to that space. For the __guest__, wildcard subdomains work for anything.
|
46
50
|
|
47
51
|
### Unmatched Queries
|
48
52
|
|
49
53
|
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.
|
50
54
|
|
55
|
+
If you would like to configure your own upstream servers, add upstream entries to your `Vagrantfile` like so:
|
56
|
+
|
57
|
+
config.landrush.upstream '10.1.1.10'
|
58
|
+
# Set the port to 1001
|
59
|
+
config.landrush.upstream '10.1.2.10', 1001
|
60
|
+
# If your upstream is TCP only for some strange reason
|
61
|
+
config.landrush.upstream '10.1.3.10', 1001, :tcp
|
62
|
+
|
51
63
|
### Visibility on the Guest
|
52
64
|
|
53
65
|
Linux guests should automatically have their DNS traffic redirected via `iptables` rules to the Landrush DNS server. File an issue if this does not work for you.
|
@@ -56,6 +56,17 @@ module Landrush
|
|
56
56
|
def info(msg)
|
57
57
|
env[:ui].info "[landrush] #{msg}"
|
58
58
|
end
|
59
|
+
|
60
|
+
def log(level, msg)
|
61
|
+
# Levels from github.com/mitchellh/vagrant/blob/master/lib/vagrant/ui.rb
|
62
|
+
valid_levels = [:ask, :detail, :warn, :error, :info, :output, :success]
|
63
|
+
|
64
|
+
if valid_levels.include? level
|
65
|
+
env[:ui].send level, "[landrush] #{msg}"
|
66
|
+
else
|
67
|
+
env[:ui].error "[landrush] (Invalid logging level #{level}) #{msg}"
|
68
|
+
end
|
69
|
+
end
|
59
70
|
end
|
60
71
|
end
|
61
72
|
end
|
@@ -18,6 +18,7 @@ module Landrush
|
|
18
18
|
record_dependent_vm
|
19
19
|
add_prerequisite_network_interface
|
20
20
|
setup_host_resolver
|
21
|
+
configure_server
|
21
22
|
start_server
|
22
23
|
setup_static_dns
|
23
24
|
end
|
@@ -37,6 +38,10 @@ module Landrush
|
|
37
38
|
machine.config.vm.network :private_network, type: :dhcp
|
38
39
|
end
|
39
40
|
|
41
|
+
def configure_server
|
42
|
+
Store.config.set('upstream', global_config.landrush.upstream_servers)
|
43
|
+
end
|
44
|
+
|
40
45
|
def start_server
|
41
46
|
return if Server.running?
|
42
47
|
|
@@ -56,6 +61,11 @@ module Landrush
|
|
56
61
|
|
57
62
|
info "adding machine entry: #{machine_hostname} => #{ip_address}"
|
58
63
|
|
64
|
+
if not machine_hostname.match(global_config.landrush.tld)
|
65
|
+
log :error, "hostname #{machine_hostname} does not match the configured TLD: #{global_config.landrush.tld}"
|
66
|
+
log :error, "You will not be able to access #{machine_hostname} from the host"
|
67
|
+
end
|
68
|
+
|
59
69
|
Store.hosts.set(machine_hostname, ip_address)
|
60
70
|
end
|
61
71
|
|
data/lib/landrush/config.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
module Landrush
|
2
2
|
class Config < Vagrant.plugin('2', :config)
|
3
3
|
attr_accessor :hosts
|
4
|
+
attr_accessor :upstream_servers
|
4
5
|
|
5
6
|
def initialize
|
6
7
|
@hosts = {}
|
7
8
|
@enabled = false
|
9
|
+
@default_upstream = [[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]]
|
10
|
+
@default_tld = 'vagrant.dev'
|
11
|
+
@upstream_servers = @default_upstream
|
8
12
|
end
|
9
13
|
|
10
14
|
def enable(enabled=true)
|
@@ -23,6 +27,27 @@ module Landrush
|
|
23
27
|
@hosts[hostname] = ip_address
|
24
28
|
end
|
25
29
|
|
30
|
+
def tld
|
31
|
+
@tld ||= @default_tld
|
32
|
+
end
|
33
|
+
|
34
|
+
def tld=(tld)
|
35
|
+
@tld = tld
|
36
|
+
end
|
37
|
+
|
38
|
+
def upstream(ip, port=53, protocol=nil)
|
39
|
+
if @upstream_servers == @default_upstream
|
40
|
+
@upstream_servers = []
|
41
|
+
end
|
42
|
+
|
43
|
+
if !protocol
|
44
|
+
@upstream_servers.push [:udp, ip, port]
|
45
|
+
@upstream_servers.push [:tcp, ip, port]
|
46
|
+
else
|
47
|
+
@upstream_servers.push [protocol, ip, port]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
26
51
|
def merge(other)
|
27
52
|
super.tap do |result|
|
28
53
|
result.hosts = @hosts.merge(other.hosts)
|
data/lib/landrush/server.rb
CHANGED
@@ -14,7 +14,8 @@ module Landrush
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.upstream_servers
|
17
|
-
|
17
|
+
# Doing collect to cast protocol to symbol because JSON store doesn't know about symbols
|
18
|
+
@upstream_servers ||= Store.config.get('upstream').collect {|i| [i[0].to_sym, i[1], i[2]]}
|
18
19
|
end
|
19
20
|
|
20
21
|
def self.interfaces
|
data/lib/landrush/store.rb
CHANGED
data/lib/landrush/version.rb
CHANGED
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.10.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: 2014-01-
|
12
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubydns
|