vagrant-dns 2.0.0 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/CHANGELOG.md +75 -16
- data/DEVELOPMENT.md +23 -0
- data/Gemfile +4 -4
- data/PLATFORM_SUPPORT.md +2 -2
- data/README.md +78 -8
- data/lib/vagrant-dns/command.rb +39 -16
- data/lib/vagrant-dns/config.rb +61 -9
- data/lib/vagrant-dns/configurator.rb +45 -12
- data/lib/vagrant-dns/middlewares/config_down.rb +20 -0
- data/lib/vagrant-dns/middlewares/config_up.rb +20 -0
- data/lib/vagrant-dns/middlewares/restart.rb +21 -0
- data/lib/vagrant-dns/registry.rb +60 -0
- data/lib/vagrant-dns/service.rb +21 -8
- data/lib/vagrant-dns/version.rb +2 -4
- data/lib/vagrant-dns.rb +33 -5
- data/tasks/acceptance.rake +12 -7
- data/vagrant-dns.gemspec +8 -1
- metadata +40 -9
- data/lib/vagrant-dns/restart_middleware.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: db8e26c490508c47ab65d7a9065e491cac6d97a00a5c6134198acd258445b72c
|
4
|
+
data.tar.gz: 61651738cc69c6d9992e13e61ee8d21c6f2c2a5018ab32adbc338e6bc2d3e10d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e2d081d253222942c755e9c8a65798d9225e2a6220a6317a092b37526cc354617e956c3255d0af078173fd458e1eb5826ac3769b1dfc20f2c77179b05359e53
|
7
|
+
data.tar.gz: 7b804c925ad00243d5643a6b9fe531dac654ded33456fb873bf6644f9e119faf99560838fb54a0285e7fe7e95e189688c2f67a0a3d5dff23f1101885464b0739
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,73 @@
|
|
1
|
-
|
1
|
+
## 2.2.2
|
2
|
+
|
3
|
+
### Fixes:
|
4
|
+
|
5
|
+
* Installation issue due to updated sub-dependency. [GH-69]
|
6
|
+
|
7
|
+
## 2.2.1
|
8
|
+
|
9
|
+
### Fixes:
|
10
|
+
|
11
|
+
* Prevent action hooks (restarting dns server) from running multiple times [GH-67]
|
12
|
+
|
13
|
+
## 2.2.0
|
14
|
+
|
15
|
+
### New Feautres:
|
16
|
+
|
17
|
+
* Add global config for time-to-live via `VagrantDNS::Config.ttl`
|
18
|
+
|
19
|
+
### Fixes:
|
20
|
+
|
21
|
+
* Fixes acceptance tests for macOS High Sierra (10.13) to cope with `scutil`s new output format
|
22
|
+
* Adds the log-time missing `license` gem config
|
23
|
+
|
24
|
+
### Breaking Changes:
|
25
|
+
|
26
|
+
* Removes the global and vm config `ipv4only`. It was nver been used.
|
27
|
+
|
28
|
+
### Changes:
|
29
|
+
|
30
|
+
* 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.
|
31
|
+
* Internal changes on how the dns pattern config is read and written. (Now using `YAML::Store`)
|
32
|
+
* Acceptance tests run against vagrant v2.1.4
|
33
|
+
* Acceptance tests run against Ubuntu 18.04
|
34
|
+
|
35
|
+
### New Feautres:
|
36
|
+
|
37
|
+
* Adds a check for the VMs configured TLDs to not be included in the [Public Suffix List](https://publicsuffix.org/)
|
38
|
+
|
39
|
+
## 2.1.0
|
40
|
+
|
41
|
+
### Breaking, internal changes:
|
42
|
+
|
43
|
+
* The version moved from `Vagrant::DNS::VERSION` to `VagrantDNS::VERSION`, removing an accidental highjack of the `Vagrant` namespace.
|
44
|
+
* The `VagrantDNS::RestartMiddleware` got split up into `VagrantDNS::Middlewares::ConfigUp`, `VagrantDNS::Middlewares::ConfigDown` and `VagrantDNS::Middlewares::Restart`
|
45
|
+
|
46
|
+
### Fixes:
|
47
|
+
|
48
|
+
* Fixes cli short argument `-S` for `--stop` (collided with `--start`'s `-s`)
|
49
|
+
|
50
|
+
### New Feautres:
|
51
|
+
|
52
|
+
* Adds new cli command `--status` to display process running status and PID
|
53
|
+
* Adds new cli command `--list` to display current (persisted) config
|
54
|
+
* 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.
|
55
|
+
|
56
|
+
### Changes:
|
57
|
+
|
58
|
+
* The cli command `--stop` no longer re-builds configuration.
|
59
|
+
|
60
|
+
## 2.0.0
|
2
61
|
|
3
62
|
* Upgrades RubyDNS to `2.0` release
|
4
63
|
|
5
|
-
|
64
|
+
## 2.0.0.rc1
|
6
65
|
|
7
66
|
* Upgrades RubyDNS to `2.0.0.pre.rc2`, which removes it's dependency on `celluloid`/`celluloid-dns` 🎉
|
8
67
|
* Requires Vagrant >= 1.9.6 which ships with ruby 2.3.4 (RubyDNS requires ruby >= 2.2.6)
|
9
68
|
* Development note: Upgraded to vagrant-share HEAD (d558861f)
|
10
69
|
|
11
|
-
|
70
|
+
## 1.1.0
|
12
71
|
|
13
72
|
* Fixes handling of networks without static IP, such as DHCP. [GH-37], [GH-39], [GH-50]
|
14
73
|
* Add support for boxes with `public_network` and static IP.
|
@@ -16,12 +75,12 @@
|
|
16
75
|
* Log messages will now be tagged with the related box (vm) and `[vagrant-dns]`
|
17
76
|
* Develepment targets Vagrant 1.9.3
|
18
77
|
|
19
|
-
|
78
|
+
## 1.0.0
|
20
79
|
|
21
80
|
* 🎉Release as 1.0 [GH-34]
|
22
81
|
* Fixes compatibility to Vagrant 1.7.4 by using RubyDNS ~> 1.0.2 [GH-38]
|
23
82
|
|
24
|
-
|
83
|
+
## 0.6.0
|
25
84
|
|
26
85
|
This is a intermediate release towards v1.0.0
|
27
86
|
|
@@ -32,16 +91,16 @@ This is a intermediate release towards v1.0.0
|
|
32
91
|
* Add acceptance test using vagrant-spec
|
33
92
|
* Moved sample `Vagrantfile` into `/testdrive` which also contains a small wrapper script `bin/vagrant` to move "vagrant home" into a sandbox.
|
34
93
|
|
35
|
-
|
94
|
+
## 0.5.0
|
36
95
|
|
37
96
|
* Use `osascript` to install system files, which require root privileges. [GH-18], [GH-22]
|
38
97
|
* internal cleanups (@ringods)
|
39
98
|
|
40
|
-
|
99
|
+
## v0.4.1
|
41
100
|
|
42
101
|
* Fixes an issue with not configured private networks [GH-21], [GH-19]
|
43
102
|
|
44
|
-
|
103
|
+
## v0.4.0
|
45
104
|
|
46
105
|
**This version is not compatible to vagrant < 1.2**
|
47
106
|
|
@@ -50,33 +109,33 @@ This is a intermediate release towards v1.0.0
|
|
50
109
|
* Fixes an issue where user-space files got created as root [GH-12]
|
51
110
|
* Adds command line option `--purge` which deletes the created config file (not only the system symlink to it) [GH-3]
|
52
111
|
|
53
|
-
|
112
|
+
## v0.3.0
|
54
113
|
|
55
114
|
* Using RubyDNS ~> 0.5.3
|
56
115
|
|
57
|
-
|
116
|
+
## v0.2.5
|
58
117
|
|
59
118
|
* Using RubyDNS 0.4.x
|
60
119
|
|
61
|
-
|
120
|
+
## v0.2.4
|
62
121
|
|
63
122
|
* Enable passthrough in DNS service. Helpful if you insist to hook a standard tld like .io.
|
64
123
|
|
65
|
-
|
124
|
+
## v0.2.3
|
66
125
|
|
67
126
|
* Remove unneeded iteraton in installers/mac.rb. (thanks to JonathanTron for reporting)
|
68
127
|
* Fix crash when no tld option was given.
|
69
128
|
|
70
|
-
|
129
|
+
## v0.2.2
|
71
130
|
|
72
131
|
* Default to 127.0.0.1 when no network option is given
|
73
132
|
* Warn if no default pattern is configured because TLD is given, but no host_name
|
74
133
|
|
75
|
-
|
134
|
+
## v0.2.1
|
76
135
|
|
77
136
|
* Fix a crash when /etc/resolver is not present
|
78
137
|
|
79
|
-
|
138
|
+
## v0.2.0
|
80
139
|
|
81
140
|
* Deactivate ipv6 support (was broken anyways)
|
82
141
|
* Add multiple patterns support
|
@@ -86,7 +145,7 @@ This is a intermediate release towards v1.0.0
|
|
86
145
|
* Uses one central server now
|
87
146
|
* The DNS server is now reconfigured on every run
|
88
147
|
|
89
|
-
|
148
|
+
## v0.1.0
|
90
149
|
|
91
150
|
* Initial Release
|
92
151
|
* Support for A and AAAA configuration
|
data/DEVELOPMENT.md
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Development Guidelines
|
2
|
+
|
3
|
+
TODO: Expand this section :)
|
4
|
+
|
5
|
+
The `Gemfile` uses two environment variables, `TEST_RUBY_VERSION` and `TEST_VAGRANT_VERSION` to control which version of ruby and vagrant are used during local development.
|
6
|
+
|
7
|
+
## Running Acceptance Tests
|
8
|
+
|
9
|
+
This project uses `vagrant-spec` to run acceptance tests.
|
10
|
+
See `test/acceptance/dns` for spec files and `test/acceptance/skeletons/*` for Vagrantfiles.
|
11
|
+
See `tasks/acceptance.rake` for the basic setup of vagrant-spec. This file also defines which base box is used.
|
12
|
+
Specs will take quite some time and run in GUI mode (due to some weirdness either in vagrant-spec and/or VirtualBox) which will render your machine basically unusable.
|
13
|
+
|
14
|
+
```bash
|
15
|
+
# List available tasks:
|
16
|
+
bundle exec rake -D acceptance
|
17
|
+
|
18
|
+
# Setup specs (download box artifacts)
|
19
|
+
bundle exec rake acceptance:setup:virtualbox
|
20
|
+
|
21
|
+
# Run tests
|
22
|
+
rake acceptance:virtualbox
|
23
|
+
```
|
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.
|
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
group :test, :development do
|
13
13
|
if ENV['TEST_VAGRANT_VERSION'] == 'HEAD'
|
14
|
-
gem 'vagrant', :git => 'https://github.com/hashicorp/vagrant', :branch => '
|
14
|
+
gem 'vagrant', :git => 'https://github.com/hashicorp/vagrant', :branch => 'main'
|
15
15
|
else
|
16
16
|
gem 'vagrant', :git => 'https://github.com/hashicorp/vagrant', :tag => ENV['TEST_VAGRANT_VERSION']
|
17
17
|
end
|
@@ -19,7 +19,7 @@ group :test, :development do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
group :test do
|
22
|
-
gem 'vagrant-spec', :git => 'https://github.com/hashicorp/vagrant-spec'
|
22
|
+
gem 'vagrant-spec', :git => 'https://github.com/hashicorp/vagrant-spec', :branch => 'main'
|
23
23
|
gem 'rake'
|
24
24
|
end
|
25
25
|
|
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
|
|
@@ -87,6 +87,47 @@ $ vagrant dns --stop
|
|
87
87
|
|
88
88
|
The DNS server will start automatically once the first VM is started.
|
89
89
|
|
90
|
+
You can list the currently configured dns patterns using:
|
91
|
+
|
92
|
+
```bash
|
93
|
+
$ vagrant dns --list
|
94
|
+
```
|
95
|
+
|
96
|
+
(Keep in mind, that it's not guaranteed that the running server uses exactly this configuration - for example, when manually editing it.)
|
97
|
+
The output looks somewhat like this:
|
98
|
+
|
99
|
+
```
|
100
|
+
/^.*mysite.test$/ => 33.33.33.60
|
101
|
+
/^.*myothersite.test$/ => 33.33.33.60
|
102
|
+
```
|
103
|
+
|
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
|
+
|
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
|
+
|
90
131
|
## VM options
|
91
132
|
|
92
133
|
* `vm.dns.tld`: Set the tld for the given virtual machine. No default.
|
@@ -96,7 +137,36 @@ The DNS server will start automatically once the first VM is started.
|
|
96
137
|
## Global Options
|
97
138
|
|
98
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).
|
99
141
|
* `VagrantDNS::Config.auto_run`: (re)start and reconfigure the server every time a machine is started. On by default.
|
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
|
+
|
147
|
+
## Using custom domains from inside the VM (VirtualBox only)
|
148
|
+
|
149
|
+
If you need to be able to resolve custom domains managed by this plugin from inside your virtual machine, add the following
|
150
|
+
setting to your `Vagrantfile`:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
Vagrant.configure(2) do |config|
|
154
|
+
# ...
|
155
|
+
config.vm.provider "virtualbox" do |vm_config, override|
|
156
|
+
vm_config.customize [
|
157
|
+
"modifyvm", :id,
|
158
|
+
"--natdnshostresolver1", "on",
|
159
|
+
# some systems also need this:
|
160
|
+
# "--natdnshostresolver2", "on"
|
161
|
+
]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
```
|
165
|
+
|
166
|
+
By default, the Virtualbox NAT engine offers the same DNS servers to the guest that are configured on the host. With the above
|
167
|
+
setting, however, the NAT engine will act as a DNS proxy
|
168
|
+
(see [Virtualbox docs](https://www.virtualbox.org/manual/ch09.html#nat-adv-dns)). That way, queries for your custom domains
|
169
|
+
from inside the guest will also be handled by the DNS server run by the plugin.
|
100
170
|
|
101
171
|
## Issues
|
102
172
|
|
@@ -104,4 +174,4 @@ The DNS server will start automatically once the first VM is started.
|
|
104
174
|
* No IPv6 support
|
105
175
|
* OS X only (please read: [Platform
|
106
176
|
Support](https://github.com/BerlinVagrant/vagrant-dns/blob/master/PLATFORM_SUPPORT.md) before ranting about this).
|
107
|
-
* Not visible inside the box
|
177
|
+
* Not automatically visible inside the box (special configuration of your guest system or provider needed)
|
data/lib/vagrant-dns/command.rb
CHANGED
@@ -11,35 +11,56 @@ module VagrantDNS
|
|
11
11
|
def execute
|
12
12
|
options = {}
|
13
13
|
opts = OptionParser.new do |opts|
|
14
|
-
opts.banner = "Usage: vagrant dns [vm-name] [-i|--install] [-u|--uninstall] [--with-sudo] [--pruge] [-s|--start] [-S|--stop] [-r|--restart] [-o|--ontop]"
|
14
|
+
opts.banner = "Usage: vagrant dns [vm-name] [-i|--install] [-u|--uninstall] [--with-sudo] [--pruge] [-s|--start] [-S|--stop] [-r|--restart] [--status] [-l|--list] [-o|--ontop]"
|
15
15
|
opts.separator ""
|
16
16
|
|
17
17
|
opts.on("--install", "-i", "Install DNS config for machine domain") do
|
18
18
|
options[:install] = true
|
19
|
+
options[:build_config] = true
|
20
|
+
options[:manage_installation] = true
|
19
21
|
end
|
20
22
|
|
21
23
|
opts.on("--uninstall", "-u", "Uninstall DNS config for machine domain") do
|
22
24
|
options[:uninstall] = true
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
options[:installer_opts] = { exec_style: :sudo }
|
25
|
+
options[:build_config] = false
|
26
|
+
options[:manage_installation] = true
|
27
|
+
options[:stop] = true
|
27
28
|
end
|
28
29
|
|
29
30
|
opts.on("--purge", "Uninstall DNS config and remove DNS configurations of all machines.") do
|
30
31
|
options[:purge] = true
|
32
|
+
options[:build_config] = false
|
33
|
+
options[:manage_installation] = true
|
34
|
+
options[:stop] = true
|
31
35
|
end
|
32
36
|
|
33
37
|
opts.on("--start", "-s", "Start the DNS service") do
|
34
38
|
options[:start] = true
|
39
|
+
options[:build_config] = true
|
35
40
|
end
|
36
41
|
|
37
|
-
opts.on("--stop", "-
|
42
|
+
opts.on("--stop", "-S", "Stop the DNS service") do
|
38
43
|
options[:stop] = true
|
44
|
+
options[:build_config] = false
|
39
45
|
end
|
40
46
|
|
41
47
|
opts.on("--restart", "-r", "Restart the DNS service") do
|
42
48
|
options[:restart] = true
|
49
|
+
options[:build_config] = true
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on("--status", "Show DNS service running status and PID.") do
|
53
|
+
options[:status] = true
|
54
|
+
options[:build_config] = false
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on("--list", "-l", "Show the current DNS service config. This works in conjunction with --start --stop --restart --status.") do
|
58
|
+
options[:show_config] = true
|
59
|
+
options[:build_config] = false
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on("--with-sudo", "In conjunction with `--install`, `--uninstall`, `--purge`: Run using `sudo` instead of `osascript`. Useful for automated scripts running as sudoer.") do
|
63
|
+
options[:installer_opts] = { exec_style: :sudo }
|
43
64
|
end
|
44
65
|
|
45
66
|
opts.on("--ontop", "-o", "Start the DNS service on top. Debugging only, this blocks Vagrant!") do
|
@@ -52,15 +73,10 @@ module VagrantDNS
|
|
52
73
|
|
53
74
|
vms = argv unless argv.empty?
|
54
75
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
build_config(vms, options)
|
60
|
-
manage_service(vms, options)
|
61
|
-
manage_installation(vms, options) if options[:install]
|
62
|
-
end
|
63
|
-
|
76
|
+
build_config(vms, options) if options[:build_config]
|
77
|
+
manage_service(vms, options)
|
78
|
+
manage_installation(vms, options) if options[:manage_installation]
|
79
|
+
show_config(vms, options) if options[:show_config]
|
64
80
|
end
|
65
81
|
|
66
82
|
protected
|
@@ -91,11 +107,18 @@ module VagrantDNS
|
|
91
107
|
service.stop!
|
92
108
|
elsif options[:restart]
|
93
109
|
service.restart! :ontop => options[:ontop]
|
110
|
+
elsif options[:status]
|
111
|
+
service.status!
|
94
112
|
end
|
95
113
|
end
|
96
114
|
|
115
|
+
def show_config(vms, options)
|
116
|
+
service = VagrantDNS::Service.new(tmp_path)
|
117
|
+
service.show_config
|
118
|
+
end
|
119
|
+
|
97
120
|
def build_config(vms, options)
|
98
|
-
with_target_vms(vms) { |vm| VagrantDNS::Configurator.new(vm, tmp_path).
|
121
|
+
with_target_vms(vms) { |vm| VagrantDNS::Configurator.new(vm, tmp_path).up! }
|
99
122
|
end
|
100
123
|
|
101
124
|
def tmp_path
|
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
|
@@ -10,13 +9,28 @@ module VagrantDNS
|
|
10
9
|
@tmp_path = tmp_path
|
11
10
|
end
|
12
11
|
|
13
|
-
def
|
12
|
+
def up!
|
13
|
+
return unless validate_tlds
|
14
14
|
regenerate_resolvers!
|
15
15
|
ensure_deamon_env!
|
16
16
|
register_patterns!
|
17
17
|
end
|
18
18
|
|
19
|
+
def down!
|
20
|
+
unregister_patterns!
|
21
|
+
end
|
22
|
+
|
19
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
|
+
|
20
34
|
def regenerate_resolvers!
|
21
35
|
FileUtils.mkdir_p(resolver_folder)
|
22
36
|
|
@@ -56,15 +70,38 @@ module VagrantDNS
|
|
56
70
|
|
57
71
|
ip = network.last[:ip]
|
58
72
|
|
59
|
-
registry =
|
60
|
-
registry
|
73
|
+
registry = Registry.new(tmp_path)
|
74
|
+
registry.transaction do
|
75
|
+
patterns.each do |pattern|
|
76
|
+
registry[pattern] = ip
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def unregister_patterns!
|
82
|
+
opts = dns_options(vm)
|
61
83
|
|
62
|
-
patterns
|
63
|
-
|
64
|
-
|
84
|
+
patterns = opts[:patterns] || default_patterns(opts)
|
85
|
+
if patterns.empty?
|
86
|
+
vm.ui.warn '[vagrant-dns] TLD but no host_name given. No patterns will be removed.'
|
87
|
+
return
|
65
88
|
end
|
66
89
|
|
67
|
-
|
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
|
96
|
+
|
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
|
103
|
+
end
|
104
|
+
end
|
68
105
|
end
|
69
106
|
|
70
107
|
def dns_options(vm)
|
@@ -97,9 +134,5 @@ FILE
|
|
97
134
|
def ensure_deamon_env!
|
98
135
|
FileUtils.mkdir_p(File.join(tmp_path, "daemon"))
|
99
136
|
end
|
100
|
-
|
101
|
-
def config_file
|
102
|
-
File.join(tmp_path, "config")
|
103
|
-
end
|
104
137
|
end
|
105
138
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantDNS
|
2
|
+
module Middlewares
|
3
|
+
class ConfigDown
|
4
|
+
def initialize(app, env)
|
5
|
+
@app = app
|
6
|
+
@env = env
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
@env = env
|
11
|
+
vm = env[:machine]
|
12
|
+
if VagrantDNS::Config.auto_run
|
13
|
+
tmp_path = File.join(vm.env.tmp_path, "dns")
|
14
|
+
VagrantDNS::Configurator.new(vm, tmp_path).down!
|
15
|
+
end
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantDNS
|
2
|
+
module Middlewares
|
3
|
+
class ConfigUp
|
4
|
+
def initialize(app, env)
|
5
|
+
@app = app
|
6
|
+
@env = env
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
@env = env
|
11
|
+
vm = env[:machine]
|
12
|
+
if VagrantDNS::Config.auto_run
|
13
|
+
tmp_path = File.join(vm.env.tmp_path, "dns")
|
14
|
+
VagrantDNS::Configurator.new(vm, tmp_path).up!
|
15
|
+
end
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module VagrantDNS
|
2
|
+
module Middlewares
|
3
|
+
class Restart
|
4
|
+
def initialize(app, env)
|
5
|
+
@app = app
|
6
|
+
@env = env
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
@env = env
|
11
|
+
vm = env[:machine]
|
12
|
+
if VagrantDNS::Config.auto_run
|
13
|
+
tmp_path = File.join(vm.env.tmp_path, "dns")
|
14
|
+
VagrantDNS::Service.new(tmp_path).restart!
|
15
|
+
env[:ui].info "Restarted DNS Service"
|
16
|
+
end
|
17
|
+
@app.call(env)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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
|
@@ -22,18 +21,24 @@ module VagrantDNS
|
|
22
21
|
run!(run_options)
|
23
22
|
end
|
24
23
|
|
24
|
+
def status!
|
25
|
+
run_options = {:ARGV => ["status"]}.merge(runopts)
|
26
|
+
run!(run_options)
|
27
|
+
end
|
28
|
+
|
25
29
|
def run!(run_options)
|
26
30
|
Daemons.run_proc("vagrant-dns", run_options) do
|
27
31
|
require 'rubydns'
|
28
32
|
require 'async/dns/system'
|
29
33
|
|
30
|
-
registry =
|
34
|
+
registry = Registry.new(tmp_path).to_hash
|
31
35
|
std_resolver = RubyDNS::Resolver.new(Async::DNS::System.nameservers)
|
36
|
+
ttl = VagrantDNS::Config.ttl
|
32
37
|
|
33
38
|
RubyDNS::run_server(VagrantDNS::Config.listen) do
|
34
39
|
registry.each do |pattern, ip|
|
35
|
-
match(
|
36
|
-
transaction.respond!(ip)
|
40
|
+
match(pattern, Resolv::DNS::Resource::IN::A) do |transaction, match_data|
|
41
|
+
transaction.respond!(ip, ttl: ttl)
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
@@ -52,6 +57,18 @@ module VagrantDNS
|
|
52
57
|
start!(start_opts)
|
53
58
|
end
|
54
59
|
|
60
|
+
def show_config
|
61
|
+
registry = Registry.new(tmp_path).to_hash
|
62
|
+
|
63
|
+
if registry.any?
|
64
|
+
registry.each do |pattern, ip|
|
65
|
+
puts format("%s => %s", pattern.inspect, ip)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
puts "Configuration missing or empty."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
55
72
|
def runopts
|
56
73
|
daemon_dir = File.join(tmp_path, "daemon")
|
57
74
|
{
|
@@ -61,9 +78,5 @@ module VagrantDNS
|
|
61
78
|
:log_dir => daemon_dir
|
62
79
|
}
|
63
80
|
end
|
64
|
-
|
65
|
-
def config_file
|
66
|
-
File.join(tmp_path, "config")
|
67
|
-
end
|
68
81
|
end
|
69
82
|
end
|
data/lib/vagrant-dns/version.rb
CHANGED
data/lib/vagrant-dns.rb
CHANGED
@@ -1,15 +1,32 @@
|
|
1
1
|
require "vagrant-dns/version"
|
2
2
|
require "vagrant-dns/config"
|
3
3
|
|
4
|
+
require "vagrant-dns/registry"
|
4
5
|
require "vagrant-dns/service"
|
5
6
|
require "vagrant-dns/installers/mac"
|
6
|
-
require "vagrant-dns/restart_middleware"
|
7
7
|
require "vagrant-dns/configurator"
|
8
|
+
require "vagrant-dns/middlewares/config_up"
|
9
|
+
require "vagrant-dns/middlewares/config_down"
|
10
|
+
require "vagrant-dns/middlewares/restart"
|
8
11
|
|
9
12
|
module VagrantDNS
|
10
13
|
|
11
|
-
|
14
|
+
# @private
|
15
|
+
def self.hooks
|
16
|
+
@hooks ||= []
|
17
|
+
end
|
12
18
|
|
19
|
+
# @private
|
20
|
+
def self.hooked(name)
|
21
|
+
hooks << name
|
22
|
+
end
|
23
|
+
|
24
|
+
# @private
|
25
|
+
def self.hooked?(name)
|
26
|
+
hooks.include?(name)
|
27
|
+
end
|
28
|
+
|
29
|
+
class Plugin < Vagrant.plugin("2")
|
13
30
|
name "vagrant-dns"
|
14
31
|
|
15
32
|
config "dns" do
|
@@ -21,12 +38,23 @@ module VagrantDNS
|
|
21
38
|
Command
|
22
39
|
end
|
23
40
|
|
24
|
-
%w{
|
25
|
-
action_hook(
|
26
|
-
|
41
|
+
%w{machine_action_up machine_action_reload}.each do |action|
|
42
|
+
action_hook("restart_vagarant_dns_on_#{action}", action) do |hook|
|
43
|
+
unless VagrantDNS.hooked?(action)
|
44
|
+
hook.append VagrantDNS::Middlewares::ConfigUp
|
45
|
+
hook.append VagrantDNS::Middlewares::Restart
|
46
|
+
VagrantDNS.hooked(action)
|
47
|
+
end
|
27
48
|
end
|
28
49
|
end
|
29
50
|
|
51
|
+
action_hook("remove_vagrant_dns_config", "machine_action_destroy") do |hook|
|
52
|
+
unless VagrantDNS.hooked?("remove_vagrant_dns_config")
|
53
|
+
hook.append VagrantDNS::Middlewares::ConfigDown
|
54
|
+
hook.append VagrantDNS::Middlewares::Restart
|
55
|
+
VagrantDNS.hooked("remove_vagrant_dns_config")
|
56
|
+
end
|
57
|
+
end
|
30
58
|
end
|
31
59
|
|
32
60
|
end
|
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,18 +7,25 @@ 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) }
|
13
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
15
|
gem.name = "vagrant-dns"
|
15
16
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version =
|
17
|
+
gem.version = VagrantDNS::VERSION
|
17
18
|
|
18
19
|
gem.required_ruby_version = '>= 2.2.6'
|
19
20
|
|
20
21
|
gem.add_dependency "daemons"
|
21
22
|
gem.add_dependency "rubydns", '~> 2.0.0'
|
23
|
+
gem.add_dependency "public_suffix"
|
24
|
+
|
25
|
+
# Pinning async gem to work around an issue in vagrant, where it does not
|
26
|
+
# honor "required_ruby_version" while resolving sub-dependencies.
|
27
|
+
# see: https://github.com/hashicorp/vagrant/issues/12640
|
28
|
+
gem.add_dependency 'async', '< 2'
|
22
29
|
|
23
30
|
gem.add_development_dependency 'rspec'
|
24
31
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Gilcher
|
8
8
|
- Robert Schulze
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: daemons
|
@@ -39,6 +39,34 @@ 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'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: async
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "<"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2'
|
42
70
|
- !ruby/object:Gem::Dependency
|
43
71
|
name: rspec
|
44
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,16 +103,20 @@ files:
|
|
75
103
|
- lib/vagrant-dns/config.rb
|
76
104
|
- lib/vagrant-dns/configurator.rb
|
77
105
|
- lib/vagrant-dns/installers/mac.rb
|
78
|
-
- lib/vagrant-dns/
|
106
|
+
- lib/vagrant-dns/middlewares/config_down.rb
|
107
|
+
- lib/vagrant-dns/middlewares/config_up.rb
|
108
|
+
- lib/vagrant-dns/middlewares/restart.rb
|
109
|
+
- lib/vagrant-dns/registry.rb
|
79
110
|
- lib/vagrant-dns/service.rb
|
80
111
|
- lib/vagrant-dns/version.rb
|
81
112
|
- tasks/acceptance.rake
|
82
113
|
- vagrant-dns.gemspec
|
83
114
|
- vagrant-spec.config.rb
|
84
115
|
homepage: ''
|
85
|
-
licenses:
|
116
|
+
licenses:
|
117
|
+
- MIT
|
86
118
|
metadata: {}
|
87
|
-
post_install_message:
|
119
|
+
post_install_message:
|
88
120
|
rdoc_options: []
|
89
121
|
require_paths:
|
90
122
|
- lib
|
@@ -99,9 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
131
|
- !ruby/object:Gem::Version
|
100
132
|
version: '0'
|
101
133
|
requirements: []
|
102
|
-
|
103
|
-
|
104
|
-
signing_key:
|
134
|
+
rubygems_version: 3.1.6
|
135
|
+
signing_key:
|
105
136
|
specification_version: 4
|
106
137
|
summary: vagrant-dns manages DNS records of vagrant machines
|
107
138
|
test_files: []
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module VagrantDNS
|
2
|
-
class RestartMiddleware
|
3
|
-
def initialize(app, env)
|
4
|
-
@app = app
|
5
|
-
@env = env
|
6
|
-
end
|
7
|
-
|
8
|
-
def call(env)
|
9
|
-
@env = env
|
10
|
-
vm = env[:machine]
|
11
|
-
if VagrantDNS::Config.auto_run
|
12
|
-
tmp_path = File.join(vm.env.tmp_path, "dns")
|
13
|
-
VagrantDNS::Configurator.new(vm, tmp_path).run!
|
14
|
-
VagrantDNS::Service.new(tmp_path).restart!
|
15
|
-
env[:ui].info "Restarted DNS Service"
|
16
|
-
end
|
17
|
-
|
18
|
-
@app.call(env)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|