vagrant-dns 2.2.3 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +16 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +17 -5
- data/DEVELOPMENT.md +18 -2
- data/Gemfile +4 -1
- data/PLATFORM_SUPPORT.md +20 -9
- data/README.md +76 -15
- data/lib/vagrant-dns/command.rb +19 -15
- data/lib/vagrant-dns/config.rb +15 -10
- data/lib/vagrant-dns/configurator.rb +151 -80
- data/lib/vagrant-dns/installers/linux.rb +73 -0
- data/lib/vagrant-dns/installers/mac.rb +16 -2
- data/lib/vagrant-dns/installers.rb +16 -0
- data/lib/vagrant-dns/registry.rb +7 -48
- data/lib/vagrant-dns/server.rb +82 -0
- data/lib/vagrant-dns/service.rb +31 -36
- data/lib/vagrant-dns/store.rb +59 -0
- data/lib/vagrant-dns/tld_registry.rb +19 -0
- data/lib/vagrant-dns/version.rb +1 -1
- data/lib/vagrant-dns.rb +3 -1
- data/tasks/acceptance.rake +3 -1
- data/vagrant-dns.gemspec +9 -2
- data/vagrant-spec.config.rb +1 -3
- metadata +26 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b96bd995237133ab779883dc28ed8ac0ed8b2cb15b71c81c755bef68f93fc6bb
|
4
|
+
data.tar.gz: 9ddc6a521a68af235a6626672e6d7089e330bfcc0445b2126e01f8f45f4ebf32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dee69e1a9fb66bdb817a310a2e2daf049bab4c032f907f7220825feffac480dbdeb4356c412c59dd7bd2369f40b030e8b21576e0c21d7bfd6dd6d3460fc69d74
|
7
|
+
data.tar.gz: d58f43351a8a12aa3f79e6bdb7c047f312b38714767a0c4d0e03c5e2e4a484c9bd11a57aec95d775f37e425ed6cda027af49b8c8cd66f38a84b5fb92bd8439bd
|
data/.editorconfig
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
end_of_line = lf
|
5
|
+
charset = utf-8
|
6
|
+
|
7
|
+
[{*.rb,Gemfile,Vagrantfile}]
|
8
|
+
indent_style = space
|
9
|
+
indent_size = 2
|
10
|
+
trim_trailing_whitespace = true
|
11
|
+
insert_final_newline = true
|
12
|
+
|
13
|
+
[*.md]
|
14
|
+
trim_trailing_whitespace = false
|
15
|
+
indent_style = space
|
16
|
+
indent_size = 2
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.7.7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 2.4.0 (2023-04-11)
|
2
|
+
|
3
|
+
* DHCP support. [GH-51]
|
4
|
+
* Non-A-queries (like IPv6 AAAA- or TXT records) matching a configured pattern will be answered with a `NOTIMP` error. [GH-76]
|
5
|
+
* Upstream / passthrough DNS servers are now configurable, defaulting to the system config (existing behavior). [GH-76]
|
6
|
+
* Passthrough behavior is now configurable (`true`/`false`/`:unknown`). [GH-77]
|
7
|
+
|
8
|
+
## 2.3.0 (2023-01-14)
|
9
|
+
|
10
|
+
* 🎉 Linux Support. Many thanks @mattiasb [GH-75]
|
11
|
+
* Managed TLDs are now stored in separate config file, which can be inspected via `vagrant dns --list-ltds`.
|
12
|
+
|
1
13
|
## 2.2.3
|
2
14
|
|
3
15
|
### Fixes:
|
@@ -18,7 +30,7 @@
|
|
18
30
|
|
19
31
|
## 2.2.0
|
20
32
|
|
21
|
-
### New
|
33
|
+
### New Features:
|
22
34
|
|
23
35
|
* Add global config for time-to-live via `VagrantDNS::Config.ttl`
|
24
36
|
|
@@ -29,16 +41,16 @@
|
|
29
41
|
|
30
42
|
### Breaking Changes:
|
31
43
|
|
32
|
-
* Removes the global and vm config `ipv4only`. It was
|
44
|
+
* Removes the global and vm config `ipv4only`. It was never used.
|
33
45
|
|
34
46
|
### Changes:
|
35
47
|
|
36
|
-
* 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
|
48
|
+
* 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 behavior.
|
37
49
|
* Internal changes on how the dns pattern config is read and written. (Now using `YAML::Store`)
|
38
50
|
* Acceptance tests run against vagrant v2.1.4
|
39
51
|
* Acceptance tests run against Ubuntu 18.04
|
40
52
|
|
41
|
-
### New
|
53
|
+
### New Features:
|
42
54
|
|
43
55
|
* Adds a check for the VMs configured TLDs to not be included in the [Public Suffix List](https://publicsuffix.org/)
|
44
56
|
|
@@ -79,7 +91,7 @@
|
|
79
91
|
* Add support for boxes with `public_network` and static IP.
|
80
92
|
* Breaking: No longer falls back to `127.0.0.1` when no IP could be found.
|
81
93
|
* Log messages will now be tagged with the related box (vm) and `[vagrant-dns]`
|
82
|
-
*
|
94
|
+
* Development targets Vagrant 1.9.3
|
83
95
|
|
84
96
|
## 1.0.0
|
85
97
|
|
data/DEVELOPMENT.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
TODO: Expand this section :)
|
4
4
|
|
5
|
-
The `Gemfile` uses
|
5
|
+
The `Gemfile` uses the `TEST_VAGRANT_VERSION` environment variable to control which version of vagrant is used during local development.
|
6
|
+
To adjust the ruby version used, change the contents of the `.ruby-version` file, even if you don't use a ruby version manager.
|
6
7
|
|
7
8
|
## Running Acceptance Tests
|
8
9
|
|
@@ -19,5 +20,20 @@ bundle exec rake -D acceptance
|
|
19
20
|
bundle exec rake acceptance:setup:virtualbox
|
20
21
|
|
21
22
|
# Run tests
|
22
|
-
rake acceptance:virtualbox
|
23
|
+
bundle exec rake acceptance:virtualbox
|
24
|
+
```
|
25
|
+
|
26
|
+
### On other providers
|
27
|
+
|
28
|
+
1. If it's not a default provider, add it to to `Gemfile` as a dependency and re-run `bundle install`.
|
29
|
+
2. Add a box provider name to box URL mapping to the `TEST_BOXES` hash in `tasks/acceptance.rake`
|
30
|
+
3. Run the `acceptance` rake task like above, replacing `virtualbox` with your provider.
|
31
|
+
|
32
|
+
|
33
|
+
### VMware IPs
|
34
|
+
|
35
|
+
VMware uses IPs from its bridges for DHCP and static private networks. Check IP and net masks using:
|
36
|
+
|
37
|
+
```console
|
38
|
+
ifconfig -X bridge | grep 'inet ' | grep -v '127.0.0.1' | awk '{ print $2 "\t" $4 }'
|
23
39
|
```
|
data/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
ruby(
|
2
|
+
ruby(File.read(File.expand_path('.ruby-version', __dir__))[/\d+\.\d+\.\d+.*/])
|
3
3
|
|
4
4
|
ENV['TEST_VAGRANT_VERSION'] ||= 'v2.3.4'
|
5
5
|
|
@@ -7,6 +7,9 @@ ENV['TEST_VAGRANT_VERSION'] ||= 'v2.3.4'
|
|
7
7
|
# during acceptance tests.
|
8
8
|
group :plugins do
|
9
9
|
gemspec
|
10
|
+
# source "https://gems.hashicorp.com/" do
|
11
|
+
# gem "vagrant-vmware-desktop"
|
12
|
+
# end
|
10
13
|
end
|
11
14
|
|
12
15
|
group :test, :development do
|
data/PLATFORM_SUPPORT.md
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
Platform Support
|
2
2
|
================
|
3
3
|
|
4
|
-
Vagrant-DNS
|
4
|
+
Vagrant-DNS was originally developed for macOS (or Mac OS X back in the time). This had 2 main reasons:
|
5
5
|
|
6
|
-
1) All main developers are on
|
6
|
+
1) All main developers are on macOS and have no good idea how to properly implement such a system for other OSes. Also, macOS makes it incredibly easy to do what vagrant-dns does.
|
7
7
|
|
8
8
|
2) We spoke to multiple Linux and Windows-Developers and found that a half-baked implementation of people not invested at the respective platform as a _convenient development_ platform is only harmful and might at worst mess with users systems in unintended ways. None of them have supplied us with a proper way to implement this.
|
9
9
|
|
10
|
-
|
10
|
+
Vagrant-DNS just recently gained support for Linux, more specificity systemd with resolved.
|
11
|
+
|
12
|
+
That said, we will happily accept any patches and want to encourage platform support beyond macOS, including ensuring further development of those solutions. Some of the groundwork for this has been layed. It might not be 100% finished, but we happily apply any changes necessary.
|
11
13
|
|
12
14
|
This document aims to be a guide to implementing support for other platforms.
|
13
15
|
|
@@ -23,10 +25,10 @@ Design Goals
|
|
23
25
|
|
24
26
|
Vagrant-DNS should not require superuser access for anything except reconfiguring the hosts DNS system. This is why there is a seperate "install" step that registers the Vagrant-DNS server to your system (for the configured TLDs). (Re)starts of the server (happening at startup of the machine) need to happen without superuser access.
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
macOS
|
29
|
+
=====
|
28
30
|
|
29
|
-
As a reference, here is how this works on
|
31
|
+
As a reference, here is how this works on macOS:
|
30
32
|
|
31
33
|
* `install` places a symlink in `/etc/resolver/{tld}` that links to a corresponding file in `.vagrant.d` with content similar to this one:
|
32
34
|
|
@@ -40,10 +42,19 @@ From then on, OS X will resolve all requests to that top level domain using the
|
|
40
42
|
Linux
|
41
43
|
=====
|
42
44
|
|
43
|
-
|
45
|
+
With `systemd-resolved`, we finally got a mechanism that resembles the macOS approach, with some subtile differences.
|
46
|
+
|
47
|
+
* `install` creates a single file `vagrant-dns.conf`, even when multiple top level domains are configured:
|
48
|
+
|
49
|
+
```
|
50
|
+
[Resolve]
|
51
|
+
DNS=127.0.0.1:5300
|
52
|
+
Domains=~test ~othertld
|
53
|
+
```
|
54
|
+
|
55
|
+
This file is then copied into `/etc/systemd/resolved.conf.d/`. The macOS strategy of adding symlinks from config files to a file within `/home/<user>/` doesn't work since the user that runs systemd-resolved doesn't have permission to read there.
|
44
56
|
|
45
|
-
|
46
|
-
* Setting up dnsmasq: this is certainly an option, but we couldn't find out how invasive this was, which Linux flavors might already come with dnsmasq configurations and how not to shoot other people in the foot with it. User help is needed.
|
57
|
+
This makes zombie configurations likely. For example when `vagrant-dns` is not correctly uninstalled using its `uninstall` command, its `resolved` configuration will point to a non-existing server, potentially causing troubles.
|
47
58
|
|
48
59
|
(Open)BSD
|
49
60
|
=========
|
data/README.md
CHANGED
@@ -12,11 +12,11 @@ Alternatively, you can install an older version of vagrant-dns like this: `vagra
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
In addition to your networking config, configure a
|
15
|
+
In addition to your networking config, configure a top-level domain and a `hostname` for your machine. Optionally, configure a set of free matching patterns. Global configuration options can be given through the `VagrantDNS::Config` object:
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
Vagrant.configure("2") do |config|
|
19
|
-
|
19
|
+
# ...
|
20
20
|
|
21
21
|
config.dns.tld = "test"
|
22
22
|
|
@@ -37,7 +37,9 @@ Then, register the DNS server as a resolver:
|
|
37
37
|
$ vagrant dns --install
|
38
38
|
```
|
39
39
|
|
40
|
-
|
40
|
+
This command will write out a configuration file that tells the operating system to resolve the `.test` TLD via the `vagrant-dns` DNS server. On OS X, this config file is located at `/etc/resolver/test` while on Linux it's at `/etc/systemd/resolved.conf.d/vagrant-dns.conf`.
|
41
|
+
|
42
|
+
You will have to rerun --install every time a tld is added.
|
41
43
|
|
42
44
|
You can delete this file by running:
|
43
45
|
|
@@ -45,7 +47,7 @@ You can delete this file by running:
|
|
45
47
|
$ vagrant dns --uninstall
|
46
48
|
```
|
47
49
|
|
48
|
-
To also delete the created config file for this TLD (`~/.vagrant.d/tmp/dns/resolver/test` in our example) run:
|
50
|
+
To also delete the created config file for this TLD (`~/.vagrant.d/tmp/dns/resolver/test` or `~/.vagrant.d/tmp/dns/resolver/vagrant-dns.conf` in our example) run:
|
49
51
|
|
50
52
|
|
51
53
|
```bash
|
@@ -60,26 +62,45 @@ $ vagrant dns --start
|
|
60
62
|
|
61
63
|
And test it:
|
62
64
|
|
65
|
+
**OS X:**
|
66
|
+
|
63
67
|
```bash
|
64
68
|
$ scutil --dns
|
65
|
-
|
69
|
+
[ … ]
|
66
70
|
resolver #8
|
67
71
|
domain : test
|
68
72
|
nameserver[0] : 127.0.0.1
|
69
73
|
port : 5300
|
70
|
-
|
74
|
+
[ … ]
|
75
|
+
|
71
76
|
$ dscacheutil -q host -a name test.machine.test
|
72
77
|
name: test.machine.test
|
73
78
|
ip_address: 33.33.33.10
|
74
79
|
```
|
75
80
|
|
76
|
-
|
81
|
+
**Linux**:
|
82
|
+
|
83
|
+
```bash
|
84
|
+
$ resolvectl status
|
85
|
+
Global
|
86
|
+
Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
|
87
|
+
resolv.conf mode: stub
|
88
|
+
DNS Domain: ~test
|
89
|
+
[ … ]
|
90
|
+
|
91
|
+
$ resolvectl query test.machine.test
|
92
|
+
test.machine.test: 33.33.33.10
|
93
|
+
|
94
|
+
-- Information acquired via protocol DNS in 10.1420s.
|
95
|
+
-- Data is authenticated: no; Data was acquired via local or encrypted transport: no
|
96
|
+
```
|
77
97
|
|
78
98
|
**Note:** Mac OS X is quite different from Linux regarding DNS resolution. As a result, do not use
|
79
99
|
`dig` or `nslookup`, but `dscacheutil` instead. Read [this article](http://apple.stackexchange.com/a/70583)
|
80
100
|
for more information.
|
81
101
|
|
82
|
-
|
102
|
+
|
103
|
+
You can now reach the server under the given domain.
|
83
104
|
|
84
105
|
```bash
|
85
106
|
$ vagrant dns --stop
|
@@ -127,12 +148,20 @@ We can use [multivm](https://www.vagrantup.com/docs/multi-machine/) configuratio
|
|
127
148
|
* Execute : `vagrant dns --install`
|
128
149
|
* Test via: `ping worker2.mysite.box` or `worker1.mysite.box`
|
129
150
|
|
130
|
-
|
131
151
|
## VM options
|
132
152
|
|
133
153
|
* `vm.dns.tld`: Set the tld for the given virtual machine. No default.
|
134
|
-
* `vm.dns.tlds`: Set multiple
|
154
|
+
* `vm.dns.tlds`: Set multiple TLDs. Default: `[tld]`
|
135
155
|
* `vm.dns.patterns`: A list of domain patterns to match. Defaults to `[/^.*{host_name}.{tld}$/]`
|
156
|
+
* `vm.dns.ip`: Optional, overwrite of the default static IP detection. Valid values are:
|
157
|
+
- `Proc`: A Proc which return value will get used as IP. Eg: `proc { |vm, opts| }` (See DHCP section for full sample)
|
158
|
+
- `Symbol`: Forces the use of the named static network:
|
159
|
+
+ `:private_network`: Use static ip of a configured private network (`config.vm.network "private_network", ip: "192.168.50.4"`)
|
160
|
+
+ `:public_network`: Use static ip of a configured public network (`config.vm.network "public_network", ip: "192.168.0.17"`)
|
161
|
+
+ `:dynamic`, `:dhcp`: Force reading the guest IP using vagrants build-in `read_ip_address` capability.
|
162
|
+
- Default:
|
163
|
+
If there is no network with a statically defined IP, and no `ip` override is given, use the build-in `read_ip_address` capability.
|
164
|
+
Else, check `:private_network`, if none found check `:public_network`
|
136
165
|
|
137
166
|
## Global Options
|
138
167
|
|
@@ -141,12 +170,19 @@ We can use [multivm](https://www.vagrantup.com/docs/multi-machine/) configuratio
|
|
141
170
|
* `VagrantDNS::Config.auto_run`: (re)start and reconfigure the server every time a machine is started. On by default.
|
142
171
|
* `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
172
|
- `false`: Disables the feature.
|
144
|
-
- `"warn"`: Check and print a warning. (Still creates a resolver config and
|
173
|
+
- `"warn"`: Check and print a warning. (Still creates a resolver config and potentially messes up your DNS) **At the moment, this is the default** because lots of projects used to use `"dev"` as a TLD, but this got registered by google and is now a public suffix.
|
145
174
|
- `"error"`: Check and prevent the box from starting. (Does not create the resolver config, it will also prevent the box from starting.)
|
146
|
-
|
175
|
+
* `VagrantDNS::Config.passthrough`: Configure how to deal with non-matching DNS queries. Will be set to `false` if no `passthrough_resolver` could be detected, or none is set.
|
176
|
+
- `true`: (default) Every non-matching query is passed through to the upstream DNS server (see `passthrough_resolver`)
|
177
|
+
- `false`: Disable passthrough. Every non-A-query to a matching pattern fails with `NotImp`. Every other query fails with `NXDomain`.
|
178
|
+
- `:unknown`: Only forward queries for which there's no matching pattern. Every non-A-query to a matching pattern fails with `NotImp`. Every other query will be passed through.
|
179
|
+
* `VagrantDNS::Config.passthrough_resolver`: By default, DNS queries not matching any patterns will be passed to an upstream DNS server.
|
180
|
+
- `:system`: (Default) pass through to the system configured default DNS server
|
181
|
+
- `[[:udp, "1.1.1.1", 53], [:tcp, "1.1.1.1", 53]]`: an Array of Arrays describing the DNS server(s) to use. (Protocol, IP, Port)
|
182
|
+
|
147
183
|
## Using custom domains from inside the VM (VirtualBox only)
|
148
184
|
|
149
|
-
If you need to be able to resolve custom domains managed by this plugin from inside your virtual machine, add the following
|
185
|
+
If you need to be able to resolve custom domains managed by this plugin from inside your virtual machine (and you're using VirtualBox), add the following
|
150
186
|
setting to your `Vagrantfile`:
|
151
187
|
|
152
188
|
```ruby
|
@@ -168,10 +204,35 @@ setting, however, the NAT engine will act as a DNS proxy
|
|
168
204
|
(see [Virtualbox docs](https://www.virtualbox.org/manual/ch09.html#nat-adv-dns)). That way, queries for your custom domains
|
169
205
|
from inside the guest will also be handled by the DNS server run by the plugin.
|
170
206
|
|
207
|
+
## DHCP / Dynamic IP
|
208
|
+
|
209
|
+
When configuring your VM with a DHCP network, vagrant-dns tries to identify the guest IP using vagrants build-in `read_ip_address` capability.
|
210
|
+
|
211
|
+
For more fine-grained control use the `ip` config.
|
212
|
+
Here is an example using the VM's default way of communication and using the `hostname` command on it:
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
Vagrant.configure("2") do |config|
|
216
|
+
# ...
|
217
|
+
|
218
|
+
# - `vm` is the vagrant virtual machine instance and can be used to communicate with it
|
219
|
+
# - `opts` is the vagrant-dns options hash (everything configured via `config.dns.*`)
|
220
|
+
config.dns.ip = -> (vm, opts) do
|
221
|
+
# note: the block handed to `execute` might get called multiple times, hence this closure
|
222
|
+
ip = nil
|
223
|
+
vm.communicate.execute("hostname -I | cut -d ' ' -f 1") do |type, data|
|
224
|
+
ip = data.strip if type == :stdout
|
225
|
+
end
|
226
|
+
ip
|
227
|
+
end
|
228
|
+
end
|
229
|
+
```
|
230
|
+
|
231
|
+
__NOTES__: In order to obtain the IP in this way, the vagrant box needs to be up and running. You will get a log output (`Postponing running user provided IP script until box has started.`) when you try to run `vagrant dns` on a non-running box.
|
232
|
+
|
171
233
|
## Issues
|
172
234
|
|
235
|
+
* macOS and systemd-resolved enabled Linux only (please read: [Platform Support](https://github.com/BerlinVagrant/vagrant-dns/blob/master/PLATFORM_SUPPORT.md) before ranting about this).
|
173
236
|
* `A` records only
|
174
237
|
* No IPv6 support
|
175
|
-
* OS X only (please read: [Platform
|
176
|
-
Support](https://github.com/BerlinVagrant/vagrant-dns/blob/master/PLATFORM_SUPPORT.md) before ranting about this).
|
177
238
|
* Not automatically visible inside the box (special configuration of your guest system or provider needed)
|
data/lib/vagrant-dns/command.rb
CHANGED
@@ -59,6 +59,11 @@ module VagrantDNS
|
|
59
59
|
options[:build_config] = false
|
60
60
|
end
|
61
61
|
|
62
|
+
opts.on("--list-tlds", "-L", "Show the current TopLevelDomains registered. This works in conjunction with --start --stop --restart --status.") do
|
63
|
+
options[:show_tld_config] = true
|
64
|
+
options[:build_config] = false
|
65
|
+
end
|
66
|
+
|
62
67
|
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
68
|
options[:installer_opts] = { exec_style: :sudo }
|
64
69
|
end
|
@@ -76,25 +81,23 @@ module VagrantDNS
|
|
76
81
|
build_config(vms, options) if options[:build_config]
|
77
82
|
manage_service(vms, options)
|
78
83
|
manage_installation(vms, options) if options[:manage_installation]
|
79
|
-
show_config(vms, options) if options[:show_config]
|
84
|
+
show_config(vms, options) if options[:show_config] || options[:show_tld_config]
|
80
85
|
end
|
81
86
|
|
82
87
|
protected
|
83
88
|
|
84
89
|
def manage_installation(vms, options)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
else
|
97
|
-
raise 'installing and uninstalling is only supported on Mac OS X at the moment.'
|
90
|
+
installer_class = VagrantDNS::Installers.resolve
|
91
|
+
|
92
|
+
installer_options = options.fetch(:installer_opts, {})
|
93
|
+
installer = installer_class.new(tmp_path, installer_options)
|
94
|
+
|
95
|
+
if options[:install]
|
96
|
+
installer.install!
|
97
|
+
elsif options[:uninstall]
|
98
|
+
installer.uninstall!
|
99
|
+
elsif options[:purge]
|
100
|
+
installer.purge!
|
98
101
|
end
|
99
102
|
end
|
100
103
|
|
@@ -114,7 +117,8 @@ module VagrantDNS
|
|
114
117
|
|
115
118
|
def show_config(vms, options)
|
116
119
|
service = VagrantDNS::Service.new(tmp_path)
|
117
|
-
service.
|
120
|
+
service.show_tld_config if options[:show_tld_config]
|
121
|
+
service.show_config if options[:show_config]
|
118
122
|
end
|
119
123
|
|
120
124
|
def build_config(vms, options)
|
data/lib/vagrant-dns/config.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "logger"
|
2
2
|
|
3
3
|
module VagrantDNS
|
4
4
|
class Config < Vagrant.plugin(2, :config)
|
5
5
|
class << self
|
6
|
-
|
6
|
+
attr_writer :listen, :ttl, :passthrough, :passthrough_resolver
|
7
|
+
attr_accessor :logger, :auto_run, :check_public_suffix
|
7
8
|
|
8
9
|
def listen
|
9
10
|
@listen ||= [[:udp, "127.0.0.1", 5300]]
|
@@ -13,6 +14,15 @@ module VagrantDNS
|
|
13
14
|
@ttl ||= 300
|
14
15
|
end
|
15
16
|
|
17
|
+
def passthrough
|
18
|
+
return true if @passthrough.nil?
|
19
|
+
@passthrough
|
20
|
+
end
|
21
|
+
|
22
|
+
def passthrough_resolver
|
23
|
+
@passthrough_resolver ||= :system
|
24
|
+
end
|
25
|
+
|
16
26
|
def auto_run
|
17
27
|
return true if @auto_run.nil?
|
18
28
|
@auto_run
|
@@ -37,7 +47,7 @@ module VagrantDNS
|
|
37
47
|
failed_tlds = vm.config.dns.tlds.select { |tld| list.find(tld, default: false) }
|
38
48
|
|
39
49
|
err = if failed_tlds.any?
|
40
|
-
"tlds include a public suffix: #{failed_tlds.join(
|
50
|
+
"tlds include a public suffix: #{failed_tlds.join(", ")}"
|
41
51
|
end
|
42
52
|
|
43
53
|
if err && check_public_suffix.to_s == "error"
|
@@ -50,7 +60,7 @@ module VagrantDNS
|
|
50
60
|
end
|
51
61
|
end
|
52
62
|
|
53
|
-
attr_accessor :records
|
63
|
+
attr_accessor :records, :ip
|
54
64
|
attr_reader :tlds, :patterns
|
55
65
|
|
56
66
|
def pattern=(pattern)
|
@@ -68,11 +78,7 @@ module VagrantDNS
|
|
68
78
|
|
69
79
|
# explicit hash, to get symbols in hash keys
|
70
80
|
def to_hash
|
71
|
-
{
|
72
|
-
:patterns => patterns,
|
73
|
-
:records => records,
|
74
|
-
:tlds => tlds
|
75
|
-
}
|
81
|
+
{ patterns: patterns, records: records, tlds: tlds, ip: ip }
|
76
82
|
end
|
77
83
|
|
78
84
|
def validate(machine)
|
@@ -96,4 +102,3 @@ module VagrantDNS
|
|
96
102
|
end
|
97
103
|
end
|
98
104
|
end
|
99
|
-
|