vagrant-dns 2.1.0 → 2.2.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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +27 -1
- data/Gemfile +2 -2
- data/PLATFORM_SUPPORT.md +2 -2
- data/README.md +40 -10
- data/lib/vagrant-dns.rb +1 -0
- data/lib/vagrant-dns/config.rb +61 -9
- data/lib/vagrant-dns/configurator.rb +28 -26
- data/lib/vagrant-dns/registry.rb +60 -0
- data/lib/vagrant-dns/service.rb +8 -11
- data/lib/vagrant-dns/version.rb +1 -1
- data/tasks/acceptance.rake +12 -7
- data/vagrant-dns.gemspec +2 -0
- metadata +20 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f20a43dd1e1d8a8fd560f86348319ad956f2a28e
|
|
4
|
+
data.tar.gz: d3411d5c4f66cadeb93aeec523a834341598a101
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2e561a70c62e88e222b5df72e84256a27552d0200fc6b041cbf634f3d7fd9b765d0d7668f6294c3967a158f44b22cd348d71f4a7ffb4d9f83e36021a9d06fee
|
|
7
|
+
data.tar.gz: e7ae3cacb4cbc579b5ddc9f8de00589bba5505d2050b654cf35bffb0763eb0f7a0e57dc5ab1107d40e8a9e0de70fa5fc29d7d4a0e9ec4e8ede58776acb78432e
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## 2.2.0
|
|
2
|
+
|
|
3
|
+
### New Feautres:
|
|
4
|
+
|
|
5
|
+
* Add global config for time-to-live via `VagrantDNS::Config.ttl`
|
|
6
|
+
|
|
7
|
+
### Fixes:
|
|
8
|
+
|
|
9
|
+
* Fixes acceptance tests for macOS High Sierra (10.13) to cope with `scutil`s new output format
|
|
10
|
+
* Adds the log-time missing `license` gem config
|
|
11
|
+
|
|
12
|
+
### Breaking Changes:
|
|
13
|
+
|
|
14
|
+
* Removes the global and vm config `ipv4only`. It was nver been used.
|
|
15
|
+
|
|
16
|
+
### Changes:
|
|
17
|
+
|
|
18
|
+
* Resources will now respond with a low TTL (time-to-live) of 5 minutes (300 seconds) instead of the old 24 hours by default. Use `VagrantDNS::Config.ttl = 86400` to reset to the old behaviour.
|
|
19
|
+
* Internal changes on how the dns pattern config is read and written. (Now using `YAML::Store`)
|
|
20
|
+
* Acceptance tests run against vagrant v2.1.4
|
|
21
|
+
* Acceptance tests run against Ubuntu 18.04
|
|
22
|
+
|
|
23
|
+
### New Feautres:
|
|
24
|
+
|
|
25
|
+
* Adds a check for the VMs configured TLDs to not be included in the [Public Suffix List](https://publicsuffix.org/)
|
|
26
|
+
|
|
1
27
|
## 2.1.0
|
|
2
28
|
|
|
3
29
|
### Breaking, internal changes:
|
|
@@ -13,7 +39,7 @@
|
|
|
13
39
|
|
|
14
40
|
* Adds new cli command `--status` to display process running status and PID
|
|
15
41
|
* Adds new cli command `--list` to display current (persisted) config
|
|
16
|
-
* Adds auto-cleanup: Removes registered dns pattern from config when destroying the box. It will, however, be re-created when some box in the project
|
|
42
|
+
* Adds auto-cleanup: Removes registered dns pattern from config when destroying the box. It will, however, be re-created when some box in the project gets re/started or one of vagrant dns `--install`, `--start` or `--restart` is executed.
|
|
17
43
|
|
|
18
44
|
### Changes:
|
|
19
45
|
|
data/Gemfile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
|
-
ruby(ENV['TEST_RUBY_VERSION'] || '~> 2.
|
|
2
|
+
ruby(ENV['TEST_RUBY_VERSION'] || '~> 2.4.4')
|
|
3
3
|
|
|
4
|
-
ENV['TEST_VAGRANT_VERSION'] ||= '
|
|
4
|
+
ENV['TEST_VAGRANT_VERSION'] ||= 'v2.1.4'
|
|
5
5
|
|
|
6
6
|
# Using the :plugins group causes Vagrant to automagially load auto_network
|
|
7
7
|
# during acceptance tests.
|
data/PLATFORM_SUPPORT.md
CHANGED
|
@@ -14,7 +14,7 @@ This document aims to be a guide to implementing support for other platforms.
|
|
|
14
14
|
How Vagrant-DNS currently works
|
|
15
15
|
===============================
|
|
16
16
|
|
|
17
|
-
In a nutshell, Vagrant-DNS starts a DNS server on a non-privileged port (5300 by default) and makes sure that the host operating system knows this server. If possible, it only does so for a specific, free, TLD (.
|
|
17
|
+
In a nutshell, Vagrant-DNS starts a DNS server on a non-privileged port (5300 by default) and makes sure that the host operating system knows this server. If possible, it only does so for a specific, free, TLD (.test). As a fallback, it also supports pass-through, if you really want to play with ICANN domains.
|
|
18
18
|
|
|
19
19
|
The DNS server runs on all platforms.
|
|
20
20
|
|
|
@@ -58,4 +58,4 @@ Quite frankly, I have not enough understanding on how to implement this properly
|
|
|
58
58
|
General Notes
|
|
59
59
|
=============
|
|
60
60
|
|
|
61
|
-
mDNS is not an option. It doesn't support subdomains and most implementations do not support multiple servers per machine. Thats sad, as all platforms come with good solutions for it.
|
|
61
|
+
mDNS is not an option. It doesn't support subdomains and most implementations do not support multiple servers per machine. Thats sad, as all platforms come with good solutions for it.
|
data/README.md
CHANGED
|
@@ -18,11 +18,11 @@ In addition to your networking config, configure a toplevel domain and a `hostna
|
|
|
18
18
|
Vagrant.configure("2") do |config|
|
|
19
19
|
#...
|
|
20
20
|
|
|
21
|
-
config.dns.tld = "
|
|
21
|
+
config.dns.tld = "test"
|
|
22
22
|
|
|
23
23
|
config.vm.hostname = "machine"
|
|
24
24
|
|
|
25
|
-
config.dns.patterns = [
|
|
25
|
+
config.dns.patterns = [/^(\w+\.)*mysite\.test$/, /^(\w+\.)*myothersite\.test$/]
|
|
26
26
|
|
|
27
27
|
config.vm.network :private_network, ip: "33.33.33.60"
|
|
28
28
|
end
|
|
@@ -37,7 +37,7 @@ Then, register the DNS server as a resolver:
|
|
|
37
37
|
$ vagrant dns --install
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
On OS X, this will create a file `/etc/resolver/
|
|
40
|
+
On OS X, this will create a file `/etc/resolver/test`, which tells OS X to resolve the TLD `.test` by using the nameserver given in this file. You will have to rerun --install every time a tld is added.
|
|
41
41
|
|
|
42
42
|
You can delete this file by running:
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ You can delete this file by running:
|
|
|
45
45
|
$ vagrant dns --uninstall
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
To also delete the created config file for this TLD (`~/.vagrant.d/tmp/dns/resolver/
|
|
48
|
+
To also delete the created config file for this TLD (`~/.vagrant.d/tmp/dns/resolver/test` in our example) run:
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
```bash
|
|
@@ -64,12 +64,12 @@ And test it:
|
|
|
64
64
|
$ scutil --dns
|
|
65
65
|
...
|
|
66
66
|
resolver #8
|
|
67
|
-
domain :
|
|
67
|
+
domain : test
|
|
68
68
|
nameserver[0] : 127.0.0.1
|
|
69
69
|
port : 5300
|
|
70
70
|
...
|
|
71
|
-
$ dscacheutil -q host -a name test.machine.
|
|
72
|
-
name: test.machine.
|
|
71
|
+
$ dscacheutil -q host -a name test.machine.test
|
|
72
|
+
name: test.machine.test
|
|
73
73
|
ip_address: 33.33.33.10
|
|
74
74
|
```
|
|
75
75
|
|
|
@@ -97,12 +97,37 @@ $ vagrant dns --list
|
|
|
97
97
|
The output looks somewhat like this:
|
|
98
98
|
|
|
99
99
|
```
|
|
100
|
-
/^.*mysite.
|
|
101
|
-
/^.*myothersite.
|
|
100
|
+
/^.*mysite.test$/ => 33.33.33.60
|
|
101
|
+
/^.*myothersite.test$/ => 33.33.33.60
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
Where the first part of each line is a [regular expression](https://ruby-doc.org/core-2.3.0/Regexp.html) and the second part is the mapped IPv4. (` => ` is just a separator)
|
|
105
105
|
|
|
106
|
+
## Multi VM config
|
|
107
|
+
|
|
108
|
+
We can use [multivm](https://www.vagrantup.com/docs/multi-machine/) configuration and have dns names for host.
|
|
109
|
+
|
|
110
|
+
* Use below given vagrant config
|
|
111
|
+
```ruby
|
|
112
|
+
BOX_IMAGE = "ubuntu/xenial64"
|
|
113
|
+
WORKER_COUNT = 2
|
|
114
|
+
Vagrant.configure("2") do |config|
|
|
115
|
+
(1..WORKER_COUNT).each do |i|
|
|
116
|
+
config.vm.define "worker#{i}" do |subconfig|
|
|
117
|
+
subconfig.dns.tld = "test"
|
|
118
|
+
subconfig.vm.hostname = "vagrant"
|
|
119
|
+
subconfig.dns.patterns = "worker#{i}.mysite.test"
|
|
120
|
+
subconfig.vm.box = BOX_IMAGE
|
|
121
|
+
subconfig.vm.network "private_network", ip: "10.240.0.#{i+15}"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
```
|
|
126
|
+
* `vagrant up`
|
|
127
|
+
* Execute : `vagrant dns --install`
|
|
128
|
+
* Test via: `ping worker2.mysite.box` or `worker1.mysite.box`
|
|
129
|
+
|
|
130
|
+
|
|
106
131
|
## VM options
|
|
107
132
|
|
|
108
133
|
* `vm.dns.tld`: Set the tld for the given virtual machine. No default.
|
|
@@ -112,8 +137,13 @@ Where the first part of each line is a [regular expression](https://ruby-doc.org
|
|
|
112
137
|
## Global Options
|
|
113
138
|
|
|
114
139
|
* `VagrantDNS::Config.listen`: an Array of Arrays describing interfaces to bind to. Defaults to `[[:udp, "127.0.0.1", 5300]]`.
|
|
140
|
+
* `VagrantDNS::Config.ttl`: The time-to-live in seconds for all resources. Defaults to `300` (5 minutes).
|
|
115
141
|
* `VagrantDNS::Config.auto_run`: (re)start and reconfigure the server every time a machine is started. On by default.
|
|
116
|
-
|
|
142
|
+
* `VagrantDNS::Config.check_public_suffix`: Check if you are going to configure a [Public Suffix](https://publicsuffix.org/) (like a Top Level Domain) in a VMs `tld(s)` config, which could mess up your local dev machines DNS config. Possible configuration values are:
|
|
143
|
+
- `false`: Disables the feature.
|
|
144
|
+
- `"warn"`: Check and print a warning. (Still creates a resolver config and potentionally messes up your DNS) **At the moment, this is the default** because lots of projetcs used to use `"dev"` as a TLD, but this got registered by google and is now a public suffix.
|
|
145
|
+
- `"error"`: Check and prevent the box from starting. (Does not create the resolver config, it will also prevent the box from starting.)
|
|
146
|
+
|
|
117
147
|
## Using custom domains from inside the VM (VirtualBox only)
|
|
118
148
|
|
|
119
149
|
If you need to be able to resolve custom domains managed by this plugin from inside your virtual machine, add the following
|
data/lib/vagrant-dns.rb
CHANGED
data/lib/vagrant-dns/config.rb
CHANGED
|
@@ -3,27 +3,60 @@ require 'logger'
|
|
|
3
3
|
module VagrantDNS
|
|
4
4
|
class Config < Vagrant.plugin(2, :config)
|
|
5
5
|
class << self
|
|
6
|
-
attr_accessor :listen, :logger, :
|
|
6
|
+
attr_accessor :listen, :ttl, :logger, :auto_run, :check_public_suffix
|
|
7
7
|
|
|
8
8
|
def listen
|
|
9
9
|
@listen ||= [[:udp, "127.0.0.1", 5300]]
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
@
|
|
12
|
+
def ttl
|
|
13
|
+
@ttl ||= 300
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
def auto_run
|
|
17
17
|
return true if @auto_run.nil?
|
|
18
18
|
@auto_run
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
def check_public_suffix
|
|
22
|
+
return "warn" if @check_public_suffix.nil?
|
|
23
|
+
@check_public_suffix
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def validate_tlds(vm)
|
|
27
|
+
return [true, nil] unless check_public_suffix
|
|
28
|
+
|
|
29
|
+
require "public_suffix"
|
|
30
|
+
|
|
31
|
+
# Don't include private domains in the list, we are only interested in TLDs and such
|
|
32
|
+
list = PublicSuffix::List.parse(
|
|
33
|
+
File.read(PublicSuffix::List::DEFAULT_LIST_PATH),
|
|
34
|
+
private_domains: false
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
failed_tlds = vm.config.dns.tlds.select { |tld| list.find(tld, default: false) }
|
|
38
|
+
|
|
39
|
+
err = if failed_tlds.any?
|
|
40
|
+
"tlds include a public suffix: #{failed_tlds.join(', ')}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if err && check_public_suffix.to_s == "error"
|
|
44
|
+
[false, err]
|
|
45
|
+
elsif err
|
|
46
|
+
[true, err]
|
|
47
|
+
else
|
|
48
|
+
[true, nil]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
20
51
|
end
|
|
21
52
|
|
|
22
|
-
attr_accessor :records
|
|
53
|
+
attr_accessor :records
|
|
54
|
+
attr_reader :tlds, :patterns
|
|
23
55
|
|
|
24
56
|
def pattern=(pattern)
|
|
25
|
-
|
|
57
|
+
@patterns = (pattern ? Array(pattern) : pattern)
|
|
26
58
|
end
|
|
59
|
+
alias_method :patterns=, :pattern=
|
|
27
60
|
|
|
28
61
|
def tld=(tld)
|
|
29
62
|
@tlds = Array(tld)
|
|
@@ -36,12 +69,31 @@ module VagrantDNS
|
|
|
36
69
|
# explicit hash, to get symbols in hash keys
|
|
37
70
|
def to_hash
|
|
38
71
|
{
|
|
39
|
-
:patterns =>
|
|
72
|
+
:patterns => patterns,
|
|
40
73
|
:records => records,
|
|
41
|
-
:tlds => tlds
|
|
42
|
-
:ipv4only => ipv4only
|
|
74
|
+
:tlds => tlds
|
|
43
75
|
}
|
|
44
76
|
end
|
|
77
|
+
|
|
78
|
+
def validate(machine)
|
|
79
|
+
errors = _detected_errors
|
|
80
|
+
|
|
81
|
+
errors = validate_check_public_suffix(errors, machine)
|
|
82
|
+
|
|
83
|
+
{ "vagrant_dns" => errors }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def validate_check_public_suffix(errors, machine)
|
|
87
|
+
valid, err = self.class.validate_tlds(machine)
|
|
88
|
+
|
|
89
|
+
if !valid
|
|
90
|
+
errors << err
|
|
91
|
+
elsif err
|
|
92
|
+
machine.ui.warn(err)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
errors
|
|
96
|
+
end
|
|
45
97
|
end
|
|
46
98
|
end
|
|
47
99
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
|
-
require 'yaml'
|
|
3
2
|
|
|
4
3
|
module VagrantDNS
|
|
5
4
|
class Configurator
|
|
@@ -11,6 +10,7 @@ module VagrantDNS
|
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
def up!
|
|
13
|
+
return unless validate_tlds
|
|
14
14
|
regenerate_resolvers!
|
|
15
15
|
ensure_deamon_env!
|
|
16
16
|
register_patterns!
|
|
@@ -21,6 +21,16 @@ module VagrantDNS
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
private
|
|
24
|
+
def validate_tlds
|
|
25
|
+
valid, err = VagrantDNS::Config.validate_tlds(vm)
|
|
26
|
+
if !valid
|
|
27
|
+
vm.ui.error(err)
|
|
28
|
+
elsif err
|
|
29
|
+
vm.ui.warn(err)
|
|
30
|
+
end
|
|
31
|
+
valid
|
|
32
|
+
end
|
|
33
|
+
|
|
24
34
|
def regenerate_resolvers!
|
|
25
35
|
FileUtils.mkdir_p(resolver_folder)
|
|
26
36
|
|
|
@@ -60,15 +70,12 @@ module VagrantDNS
|
|
|
60
70
|
|
|
61
71
|
ip = network.last[:ip]
|
|
62
72
|
|
|
63
|
-
registry =
|
|
64
|
-
registry
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
registry[p] = ip
|
|
73
|
+
registry = Registry.new(tmp_path)
|
|
74
|
+
registry.transaction do
|
|
75
|
+
patterns.each do |pattern|
|
|
76
|
+
registry[pattern] = ip
|
|
77
|
+
end
|
|
69
78
|
end
|
|
70
|
-
|
|
71
|
-
File.open(config_file, "w") { |f| f << YAML.dump(registry) }
|
|
72
79
|
end
|
|
73
80
|
|
|
74
81
|
def unregister_patterns!
|
|
@@ -80,22 +87,21 @@ module VagrantDNS
|
|
|
80
87
|
return
|
|
81
88
|
end
|
|
82
89
|
|
|
83
|
-
registry =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
registry = Registry.new(tmp_path)
|
|
91
|
+
registry.transaction do
|
|
92
|
+
unless registry.any?
|
|
93
|
+
vm.ui.warn '[vagrant-dns] Configuration missing or empty. No patterns will be removed.'
|
|
94
|
+
registry.abort
|
|
95
|
+
end
|
|
88
96
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
patterns.each do |pattern|
|
|
98
|
+
if (ip = registry.delete(pattern))
|
|
99
|
+
vm.ui.info "[vagrant-dns] Removing pattern: #{pattern} for ip: #{ip}"
|
|
100
|
+
else
|
|
101
|
+
vm.ui.info "[vagrant-dns] Pattern: #{pattern} was not in config."
|
|
102
|
+
end
|
|
95
103
|
end
|
|
96
104
|
end
|
|
97
|
-
|
|
98
|
-
File.open(config_file, "w") { |f| f << YAML.dump(registry) }
|
|
99
105
|
end
|
|
100
106
|
|
|
101
107
|
def dns_options(vm)
|
|
@@ -128,9 +134,5 @@ FILE
|
|
|
128
134
|
def ensure_deamon_env!
|
|
129
135
|
FileUtils.mkdir_p(File.join(tmp_path, "daemon"))
|
|
130
136
|
end
|
|
131
|
-
|
|
132
|
-
def config_file
|
|
133
|
-
File.join(tmp_path, "config")
|
|
134
|
-
end
|
|
135
137
|
end
|
|
136
138
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'yaml/store'
|
|
2
|
+
require 'forwardable'
|
|
3
|
+
|
|
4
|
+
module VagrantDNS
|
|
5
|
+
# This is the dns pattern registry (aka "config")
|
|
6
|
+
# It basically delegates everything to a YAML::Store but handles the conversion
|
|
7
|
+
# of Regexp dns-patterns into YAML string keys and reverse.
|
|
8
|
+
class Registry
|
|
9
|
+
extend Forwardable
|
|
10
|
+
|
|
11
|
+
def initialize(tmp_path)
|
|
12
|
+
@store = YAML::Store.new(File.join(tmp_path, "config"), true)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def_delegators :@store, :transaction, :abort, :commit
|
|
16
|
+
|
|
17
|
+
# This method is only valid in a #transaction and it cannot be read-only. It will raise PStore::Error if called at any other time.
|
|
18
|
+
def [](name)
|
|
19
|
+
name = name.source if name.respond_to? :source
|
|
20
|
+
@store[name]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# This method is only valid in a #transaction and it cannot be read-only. It will raise PStore::Error if called at any other time.
|
|
24
|
+
def []=(name, value)
|
|
25
|
+
name = name.source if name.respond_to? :source
|
|
26
|
+
@store[name] = value
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def delete(name)
|
|
30
|
+
name = name.source if name.respond_to? :source
|
|
31
|
+
@store.delete(name)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# This method is only valid in a #transaction and it cannot be read-only. It will raise PStore::Error if called at any other time.
|
|
35
|
+
def root?(name)
|
|
36
|
+
name = name.source if name.respond_to? :source
|
|
37
|
+
@store.root?(name)
|
|
38
|
+
end
|
|
39
|
+
alias_method :key?, :root?
|
|
40
|
+
|
|
41
|
+
# This method is only valid in a #transaction and it cannot be read-only. It will raise PStore::Error if called at any other time.
|
|
42
|
+
def roots
|
|
43
|
+
@store.roots.map { |name| Regexp.new(name) }
|
|
44
|
+
end
|
|
45
|
+
alias_method :keys, :roots
|
|
46
|
+
|
|
47
|
+
# This method is only valid in a #transaction and it cannot be read-only. It will raise PStore::Error if called at any other time.
|
|
48
|
+
def any?
|
|
49
|
+
@store.roots.any?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def to_hash
|
|
53
|
+
@store.transaction(true) do
|
|
54
|
+
@store.roots.each_with_object({}) do |name, a|
|
|
55
|
+
a[Regexp.new(name)] = @store[name]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
data/lib/vagrant-dns/service.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require 'daemons'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
module VagrantDNS
|
|
5
4
|
class Service
|
|
6
5
|
attr_accessor :tmp_path
|
|
@@ -32,13 +31,14 @@ module VagrantDNS
|
|
|
32
31
|
require 'rubydns'
|
|
33
32
|
require 'async/dns/system'
|
|
34
33
|
|
|
35
|
-
registry =
|
|
34
|
+
registry = Registry.new(tmp_path).to_hash
|
|
36
35
|
std_resolver = RubyDNS::Resolver.new(Async::DNS::System.nameservers)
|
|
36
|
+
ttl = VagrantDNS::Config.ttl
|
|
37
37
|
|
|
38
38
|
RubyDNS::run_server(VagrantDNS::Config.listen) do
|
|
39
39
|
registry.each do |pattern, ip|
|
|
40
|
-
match(
|
|
41
|
-
transaction.respond!(ip)
|
|
40
|
+
match(pattern, Resolv::DNS::Resource::IN::A) do |transaction, match_data|
|
|
41
|
+
transaction.respond!(ip, ttl: ttl)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -58,10 +58,11 @@ module VagrantDNS
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def show_config
|
|
61
|
-
registry =
|
|
62
|
-
|
|
61
|
+
registry = Registry.new(tmp_path).to_hash
|
|
62
|
+
|
|
63
|
+
if registry.any?
|
|
63
64
|
registry.each do |pattern, ip|
|
|
64
|
-
puts format("%s => %s",
|
|
65
|
+
puts format("%s => %s", pattern.inspect, ip)
|
|
65
66
|
end
|
|
66
67
|
else
|
|
67
68
|
puts "Configuration missing or empty."
|
|
@@ -77,9 +78,5 @@ module VagrantDNS
|
|
|
77
78
|
:log_dir => daemon_dir
|
|
78
79
|
}
|
|
79
80
|
end
|
|
80
|
-
|
|
81
|
-
def config_file
|
|
82
|
-
File.join(tmp_path, "config")
|
|
83
|
-
end
|
|
84
81
|
end
|
|
85
82
|
end
|
data/lib/vagrant-dns/version.rb
CHANGED
data/tasks/acceptance.rake
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
1
3
|
namespace :acceptance do
|
|
2
4
|
def tmp_dir_path
|
|
3
5
|
@tmp_dir_path ||= ENV["VS_TEMP"] || Dir.mktmpdir('vagrant-dns-spec')
|
|
@@ -6,22 +8,25 @@ namespace :acceptance do
|
|
|
6
8
|
ARTIFACT_DIR = File.join('test', 'acceptance', 'artifacts')
|
|
7
9
|
|
|
8
10
|
TEST_BOXES = {
|
|
9
|
-
|
|
11
|
+
# Ubuntu 16.04 https://app.vagrantup.com/ubuntu/boxes/xenial64.json
|
|
12
|
+
# :virtualbox => "https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20180511.0.0/providers/virtualbox.box"
|
|
13
|
+
# Ubuntu 18.04 https://app.vagrantup.com/ubuntu/boxes/bionic64.json
|
|
14
|
+
:virtualbox => "https://vagrantcloud.com/ubuntu/boxes/bionic64/versions/20180709.0.0/providers/virtualbox.box"
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
TEST_BOXES.each do |provider, box_url|
|
|
13
18
|
# Declare file download tasks
|
|
14
|
-
directory ARTIFACT_DIR
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
directory ARTIFACT_DIR
|
|
20
|
+
|
|
21
|
+
file File.join(ARTIFACT_DIR, "#{provider}.box") => ARTIFACT_DIR do |path|
|
|
22
|
+
puts 'Downloading: ' + box_url
|
|
23
|
+
Kernel.system 'curl', '-L', '-o', path.to_s, box_url
|
|
19
24
|
end
|
|
20
25
|
|
|
21
26
|
desc "Run acceptance tests for #{provider}"
|
|
22
27
|
task provider => :"setup:#{provider}" do |task|
|
|
23
28
|
box_path = File.expand_path(File.join('..', '..', ARTIFACT_DIR, "#{provider}.box"), __FILE__)
|
|
24
|
-
puts "TMPDIR: "
|
|
29
|
+
puts "TMPDIR: #{tmp_dir_path}"
|
|
25
30
|
Kernel.system(
|
|
26
31
|
{
|
|
27
32
|
"VS_PROVIDER" => provider.to_s,
|
data/vagrant-dns.gemspec
CHANGED
|
@@ -7,6 +7,7 @@ Gem::Specification.new do |gem|
|
|
|
7
7
|
gem.description = %q{vagrant-dns is a vagrant plugin that manages DNS records associated with local machines.}
|
|
8
8
|
gem.summary = %q{vagrant-dns manages DNS records of vagrant machines}
|
|
9
9
|
gem.homepage = ""
|
|
10
|
+
gem.license = "MIT"
|
|
10
11
|
|
|
11
12
|
gem.files = `git ls-files`.split($\).reject { |f| f.match(%r{^(test|testdrive)/}) }
|
|
12
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
@@ -19,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
|
19
20
|
|
|
20
21
|
gem.add_dependency "daemons"
|
|
21
22
|
gem.add_dependency "rubydns", '~> 2.0.0'
|
|
23
|
+
gem.add_dependency "public_suffix"
|
|
22
24
|
|
|
23
25
|
gem.add_development_dependency 'rspec'
|
|
24
26
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vagrant-dns
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Gilcher
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-
|
|
12
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: daemons
|
|
@@ -39,6 +39,20 @@ dependencies:
|
|
|
39
39
|
- - "~>"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
41
|
version: 2.0.0
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: public_suffix
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
type: :runtime
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
42
56
|
- !ruby/object:Gem::Dependency
|
|
43
57
|
name: rspec
|
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -78,13 +92,15 @@ files:
|
|
|
78
92
|
- lib/vagrant-dns/middlewares/config_down.rb
|
|
79
93
|
- lib/vagrant-dns/middlewares/config_up.rb
|
|
80
94
|
- lib/vagrant-dns/middlewares/restart.rb
|
|
95
|
+
- lib/vagrant-dns/registry.rb
|
|
81
96
|
- lib/vagrant-dns/service.rb
|
|
82
97
|
- lib/vagrant-dns/version.rb
|
|
83
98
|
- tasks/acceptance.rake
|
|
84
99
|
- vagrant-dns.gemspec
|
|
85
100
|
- vagrant-spec.config.rb
|
|
86
101
|
homepage: ''
|
|
87
|
-
licenses:
|
|
102
|
+
licenses:
|
|
103
|
+
- MIT
|
|
88
104
|
metadata: {}
|
|
89
105
|
post_install_message:
|
|
90
106
|
rdoc_options: []
|
|
@@ -102,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
102
118
|
version: '0'
|
|
103
119
|
requirements: []
|
|
104
120
|
rubyforge_project:
|
|
105
|
-
rubygems_version: 2.
|
|
121
|
+
rubygems_version: 2.6.14.1
|
|
106
122
|
signing_key:
|
|
107
123
|
specification_version: 4
|
|
108
124
|
summary: vagrant-dns manages DNS records of vagrant machines
|