landrush 0.12.0 → 0.13.0

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: e7e55caad175c97da6a1f7d178c96bda82012444
4
- data.tar.gz: ada1f79f5d38f7b9ca4b28ddabb12277fc7cde2e
3
+ metadata.gz: c8a036c6758ecfa355d3763dd2df37cc8a699202
4
+ data.tar.gz: e8778c8cd9924ab4503fc2c3b4a1a8a5d4a7417f
5
5
  SHA512:
6
- metadata.gz: 247f383e81f21f58cb625aa698b64ba70430330347f84725cd5eb02485929385110563f3f24a91cce708ea187cc00b1a4a8285fbd9fc47161f63ad921753e61a
7
- data.tar.gz: 119d68e29a0bf5593e0c2734066f956458062faa2b0cb80d3dd66d1536ef2cc44fe01fc1981e5c7aab97e8986a8c52d6dcd319572c944460c009fa9bccc21cd1
6
+ metadata.gz: 5a1dd7d4800f0bced106a1792006d39d223bf57e7e22b363d6e66ca1cb3708adf65528d105963af6df7f95b03ab30c4cd20b3fe66859b3b5623d29f7b3dd95aa
7
+ data.tar.gz: 99f611d7fb8ac8368f643857b77b6ef283dc848d9b77a6889c4006d07076eae05c0037589b6bf0f9f9ca437797413877e50e55542995f8ca2744fb926f99bf8e
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+
6
+ before_install:
7
+ - sudo apt-get install dnsutils
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Landrush: DNS for Vagrant
1
+ # Landrush: DNS for Vagrant [![Build Status](https://travis-ci.org/phinze/landrush.png)](https://travis-ci.org/phinze/landrush)
2
2
 
3
3
  Simple DNS that's visible on both the guest and the host.
4
4
 
@@ -30,6 +30,16 @@ And you should be able to get your hostname from your host:
30
30
 
31
31
  If you shut down your guest, the entries associated with it will be removed.
32
32
 
33
+ ### Dynamic entries
34
+
35
+ Every time a VM is started, its IP address is automatically detected and a DNS record is created that maps the hostname to its IP.
36
+
37
+ If for any reason the auto-detection detects no IP address or the wrong IP address, or you want to override it, you can do like so:
38
+
39
+ config.landrush.host_ip_address = '1.2.3.4'
40
+
41
+ If you are using a multi-machine `Vagrantfile`, configure this inside each of your `config.vm.define` sections.
42
+
33
43
  ### Static entries
34
44
 
35
45
  You can add static host entries to the DNS server in your `Vagrantfile` like so:
@@ -64,6 +74,13 @@ If you would like to configure your own upstream servers, add upstream entries t
64
74
 
65
75
  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.
66
76
 
77
+ To disable this functionality:
78
+
79
+ config.landrush.guest_redirect_dns = false
80
+
81
+ You may want to do this if you are already proxying all your DNS requests through your host (e.g. using VirtualBox's natdnshostresolver1 option) and you
82
+ have DNS servers that you can easily set as upstreams in the daemon (e.g. DNS requests that go through the host's VPN connection).
83
+
67
84
  ### Visibility on the Host
68
85
 
69
86
  If you're on an OS X host, we use a nice trick to unobtrusively add a secondary DNS server only for specific domains.
@@ -8,10 +8,6 @@
8
8
  # VAGRANT_CWD=examples bundle exce vagrant halt
9
9
  #
10
10
 
11
- # This line is unnecessary when the plugin is installed normally; it's just
12
- # here for the development / testing use case.
13
- Vagrant.require_plugin "landrush"
14
-
15
11
  Vagrant.configure("2") do |config|
16
12
  config.vm.box = "precise64"
17
13
 
@@ -31,7 +31,7 @@ module Landrush
31
31
  def vmware?
32
32
  provider == :vmware_fusion
33
33
  end
34
-
34
+
35
35
  def parallels?
36
36
  provider == :parallels
37
37
  end
@@ -41,7 +41,7 @@ module Landrush
41
41
  raise "The landrush plugin does not support the #{key} provider yet!"
42
42
  }
43
43
 
44
- if provider_name == :parallels and VagrantPlugins::Parallels::VERSION < "1.0.3"
44
+ if provider_name == :parallels and Gem::Version.new(VagrantPlugins::Parallels::VERSION) < Gem::Version.new("1.0.3")
45
45
  raise "The landrush plugin supports the Parallels provider v1.0.3 and later. Please, update your 'vagrant-parallels' plugin."
46
46
  end
47
47
 
@@ -70,6 +70,10 @@ module Landrush
70
70
  config.enabled?
71
71
  end
72
72
 
73
+ def guest_redirect_dns?
74
+ config.guest_redirect_dns?
75
+ end
76
+
73
77
  def info(msg)
74
78
  env[:ui].info "[landrush] #{msg}"
75
79
  end
@@ -5,13 +5,13 @@ module Landrush
5
5
 
6
6
  def call(env)
7
7
  handle_action_stack(env) do
8
- redirect_dns if enabled?
8
+ redirect_dns if enabled? and guest_redirect_dns?
9
9
  end
10
10
  end
11
11
 
12
12
  def redirect_dns
13
13
  info "setting up machine's DNS to point to our server"
14
- machine.guest.capability(:redirect_dns, host: _target_host, port: 10053)
14
+ machine.guest.capability(:redirect_dns, host: _target_host, port: Server.port)
15
15
 
16
16
  machine.config.vm.networks.each do |type, options|
17
17
  info "network: #{type.inspect}, #{options.inspect}"
@@ -36,4 +36,3 @@ module Landrush
36
36
  end
37
37
  end
38
38
  end
39
-
@@ -58,7 +58,8 @@ module Landrush
58
58
  end
59
59
 
60
60
  def record_machine_dns_entry
61
- ip_address = machine.guest.capability(:read_host_visible_ip_address)
61
+ ip_address = machine.config.landrush.host_ip_address ||
62
+ machine.guest.capability(:read_host_visible_ip_address)
62
63
 
63
64
  info "adding machine entry: #{machine_hostname} => #{ip_address}"
64
65
 
@@ -22,7 +22,6 @@ module Landrush
22
22
  # TODO: Find a better heuristic for this implementation.
23
23
  #
24
24
  def self.read_host_visible_ip_address(machine)
25
- command = "ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'"
26
25
  result = ""
27
26
  machine.communicate.execute(command) do |type, data|
28
27
  result << data if type == :stdout
@@ -30,6 +29,10 @@ module Landrush
30
29
 
31
30
  result.chomp.split("\n").last
32
31
  end
32
+
33
+ def self.command
34
+ %Q(hostname -I | awk -F' ' '{print $NF}')
35
+ end
33
36
  end
34
37
  end
35
38
  end
@@ -2,6 +2,7 @@ module Landrush
2
2
  class Config < Vagrant.plugin('2', :config)
3
3
  attr_accessor :hosts
4
4
  attr_accessor :upstream_servers
5
+ attr_accessor :host_ip_address
5
6
 
6
7
  def initialize
7
8
  @hosts = {}
@@ -9,6 +10,7 @@ module Landrush
9
10
  @default_upstream = [[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]]
10
11
  @default_tld = 'vagrant.dev'
11
12
  @upstream_servers = @default_upstream
13
+ @guest_redirect_dns = true
12
14
  end
13
15
 
14
16
  def enable(enabled=true)
@@ -23,6 +25,14 @@ module Landrush
23
25
  @enabled
24
26
  end
25
27
 
28
+ def guest_redirect_dns=(guest_redirect_dns=true)
29
+ @guest_redirect_dns=guest_redirect_dns
30
+ end
31
+
32
+ def guest_redirect_dns?
33
+ @guest_redirect_dns
34
+ end
35
+
26
36
  def host(hostname, ip_address=nil)
27
37
  @hosts[hostname] = ip_address
28
38
  end
@@ -45,7 +55,7 @@ module Landrush
45
55
  @upstream_servers.push [:tcp, ip, port]
46
56
  else
47
57
  @upstream_servers.push [protocol, ip, port]
48
- end
58
+ end
49
59
  end
50
60
 
51
61
  def merge(other)
@@ -29,7 +29,7 @@ module Landrush
29
29
  def desired_contents; <<-EOS.gsub(/^ /, '')
30
30
  # Generated by landrush, a vagrant plugin
31
31
  nameserver 127.0.0.1
32
- port 10053
32
+ port #{Server.port}
33
33
  EOS
34
34
  end
35
35
 
@@ -28,15 +28,18 @@ module Landrush
28
28
 
29
29
  def find(search)
30
30
  current_config.keys.detect do |key|
31
- key == search ||
32
- search =~ /#{key}$/ ||
33
- key =~ /^#{search}\./
31
+ key.casecmp(search) == 0 ||
32
+ search =~ /#{key}$/i ||
33
+ key =~ /^#{search}\./i
34
34
  end
35
35
  end
36
36
 
37
37
  def get(key)
38
38
  value = current_config[key]
39
- redirect = find(value)
39
+ redirect = nil
40
+ if value.is_a? String
41
+ redirect = find(value)
42
+ end
40
43
  if value
41
44
  if redirect
42
45
  get(redirect)
@@ -1,3 +1,3 @@
1
1
  module Landrush
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
@@ -5,13 +5,15 @@ module Landrush
5
5
  describe 'ensure_config_exists' do
6
6
  it 'writes a resolver config on the host if one is not already there' do
7
7
  resolver_config = ResolverConfig.new(fake_environment)
8
+ skip("Only supported on OSX") unless resolver_config.osx?
9
+
8
10
  resolver_config.config_file.exist?.must_equal false
9
11
  resolver_config.ensure_config_exists!
10
12
  resolver_config.config_file.exist?.must_equal true
11
13
  resolver_config.config_file.read.must_equal <<-EOF.gsub(/^ +/, '')
12
14
  # Generated by landrush, a vagrant plugin
13
15
  nameserver 127.0.0.1
14
- port 10053
16
+ port #{Server.port}
15
17
  EOF
16
18
  end
17
19
 
@@ -4,6 +4,7 @@ require 'bundler/setup'
4
4
  require 'minitest/spec'
5
5
 
6
6
  require 'landrush'
7
+ require 'landrush/cap/linux/read_host_visible_ip_address'
7
8
 
8
9
  require 'minitest/autorun'
9
10
 
@@ -84,7 +85,7 @@ def fake_machine(options={})
84
85
 
85
86
  machine.instance_variable_set("@communicator", RecordingCommunicator.new)
86
87
  machine.communicate.stub_command(
87
- "ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'",
88
+ Landrush::Cap::Linux::ReadHostVisibleIpAddress.command,
88
89
  "#{options.fetch(:ip, '1.2.3.4')}\n"
89
90
  )
90
91
 
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.12.0
4
+ version: 0.13.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: 2014-03-24 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubydns
@@ -41,6 +41,7 @@ extensions: []
41
41
  extra_rdoc_files: []
42
42
  files:
43
43
  - ".gitignore"
44
+ - ".travis.yml"
44
45
  - Gemfile
45
46
  - LICENSE.txt
46
47
  - README.md