landrush 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.adoc +0 -20
- data/Gemfile +1 -1
- data/README.adoc +1 -0
- data/doc/Development.adoc +60 -18
- data/doc/Troubleshooting.adoc +27 -19
- data/features/commands.feature +2 -2
- data/features/dns_resolution.feature +5 -5
- data/features/docker_provider.feature +1 -1
- data/features/landrush_ip.feature +7 -0
- data/lib/landrush/action/redirect_dns.rb +0 -2
- data/lib/landrush/action/setup.rb +2 -2
- data/lib/landrush/action/teardown.rb +1 -1
- data/lib/landrush/cap/guest/all/read_host_visible_ip_address.rb +7 -5
- data/lib/landrush/cap/guest/linux/redirect_dns.rb +24 -10
- data/lib/landrush/cap/host/windows/configure_visibility_on_host.rb +35 -35
- data/lib/landrush/version.rb +1 -1
- data/scripts/changelog.sh +59 -0
- data/test/landrush/cap/host/windows/configure_visibility_on_host_test.rb +80 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d31f07ae3a474d9a5e399e15ce9bffa3cce616651a999437094d1aece8c617d2
|
4
|
+
data.tar.gz: 6e91547880229bdd51b4df747d8dde2fc9d48b167ff0a7acf3e83a56a0df1ce3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c01e67c9d8f55d8f0f4d9a42e959e4005840fce1d6f2d86f6060973a0313158beaa1bdfadec68ba7ef8da18da56824ebee27482a2498688f2f6b21f4bf00c3
|
7
|
+
data.tar.gz: dbf7d7cbc7ba989a89408468c567b1036ebaefa634422f93aeba540783fcf0b9851d450300de2dcbcf3b5e8366cbfac4f10a6c7e657363469af23bde19f6a1f8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [1.3.1] - 2018-12-04
|
2
|
+
|
3
|
+
- Issue [#11](https://github.com/vagrant-landrush/landrush/issues/11) - Landrush prevents the machine from reaching internet
|
4
|
+
- Issue [#165](https://github.com/vagrant-landrush/landrush/issues/165) - Unable to use with CentOS v5 boxes on vmware_fusion
|
5
|
+
- Issue [#314](https://github.com/vagrant-landrush/landrush/issues/314) - get_network_name fails on windows 10
|
6
|
+
- Issue [#319](https://github.com/vagrant-landrush/landrush/issues/319) - Installation error because can't build eventmachine gem
|
7
|
+
- Issue [#321](https://github.com/vagrant-landrush/landrush/issues/321) - iptables rule - move from OUTPUT => PREROUTING
|
8
|
+
|
1
9
|
## [1.3.0] - 2018-09-19
|
2
10
|
|
3
11
|
- Issue [#177](https://github.com/vagrant-landrush/landrush/issues/177) - Allow multiple TLD kind/feature priority/major
|
data/CONTRIBUTING.adoc
CHANGED
@@ -81,26 +81,6 @@ $ git merge fix-123
|
|
81
81
|
$ git push origin master
|
82
82
|
-------------------------------------------------------------------------
|
83
83
|
|
84
|
-
== Releasing
|
85
|
-
|
86
|
-
* Make sure the HEAD of development builds and passes all tests:
|
87
|
-
`bundle exec rake clean rubocop test features install`.
|
88
|
-
* Review https://github.com/vagrant-landrush/landrush/milestones[milestone] for the current release
|
89
|
-
** Make sure all issues are resolved
|
90
|
-
** Move unresolved issues into an upcoming release
|
91
|
-
** Close milestone
|
92
|
-
* Update the link:CHANGELOG.md[CHANGELOG]
|
93
|
-
* Update link:lib/landrush/version.rb[version.rb] with the correct
|
94
|
-
release version. Consider http://semver.org/:[Semantic Versioning] guidelines
|
95
|
-
when deciding on the release version
|
96
|
-
* Commit _CHANGELOG_ and _version.rb_ using commit message of the form:
|
97
|
-
`cut v<version>`
|
98
|
-
* Push commit to upstream
|
99
|
-
* Release the gem: `bundle exec rake release`
|
100
|
-
* Update link:lib/landrush/version.rb[version.rb] with the next anticipated release version, eg _1.4.0.dev_
|
101
|
-
* Commit with message: `setting dev version <version>.dev`
|
102
|
-
* Push upstream
|
103
|
-
|
104
84
|
== Maintainers
|
105
85
|
|
106
86
|
* Brian Exelbierd (@bexelbie)
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
https://travis-ci.org/vagrant-landrush/landrush[image:https://travis-ci.org/vagrant-landrush/landrush.png[Build Status]]
|
6
6
|
https://ci.appveyor.com/project/hferentschik/landrush-3agrx/branch/master[image:https://ci.appveyor.com/api/projects/status/3iv8sv5v73s15mt6/branch/master?svg=true[Build Status]]
|
7
|
+
image:https://badge.fury.io/rb/landrush.svg["Gem Version", link="https://badge.fury.io/rb/landrush"]
|
7
8
|
|
8
9
|
Landrush is a simple cross-platform DNS for Vagrant VMs that is visible
|
9
10
|
on both, the guest and the host.
|
data/doc/Development.adoc
CHANGED
@@ -21,41 +21,47 @@ The following sections list the most important commands you will need for develo
|
|
21
21
|
|
22
22
|
* Install http://bundler.io/[Bundler]:
|
23
23
|
+
|
24
|
-
|
24
|
+
[source,bash]
|
25
|
+
----
|
25
26
|
$ gem install bundler
|
26
|
-
|
27
|
+
----
|
27
28
|
|
28
29
|
* Install dependencies:
|
29
30
|
+
|
30
|
-
|
31
|
+
[source,bash]
|
32
|
+
----
|
31
33
|
$ bundle install
|
32
|
-
|
34
|
+
----
|
33
35
|
|
34
36
|
* Get a list of all available build tasks:
|
35
37
|
+
|
36
|
-
|
38
|
+
[source,bash]
|
39
|
+
----
|
37
40
|
$ bundle exec rake -T
|
38
|
-
|
41
|
+
----
|
39
42
|
|
40
43
|
* Build the Landrush gem:
|
41
44
|
+
|
42
|
-
|
45
|
+
[source,bash]
|
46
|
+
----
|
43
47
|
$ bundle exec rake build
|
44
|
-
|
48
|
+
----
|
45
49
|
|
46
50
|
* Clean all generated files:
|
47
51
|
+
|
48
|
-
|
52
|
+
[source,bash]
|
53
|
+
----
|
49
54
|
$ bundle exec rake clean clobber
|
50
|
-
|
55
|
+
----
|
51
56
|
|
52
57
|
== Tests
|
53
58
|
|
54
59
|
* Run the test suite:
|
55
60
|
+
|
56
|
-
|
61
|
+
[source,bash]
|
62
|
+
----
|
57
63
|
$ bundle exec rake test
|
58
|
-
|
64
|
+
----
|
59
65
|
|
60
66
|
TIP: The unit tests utilize https://github.com/seattlerb/minitest[minitest] as test harness.
|
61
67
|
Tests are mainly written in Spec style.
|
@@ -64,15 +70,17 @@ Refer to https://github.com/vagrant-landrush/landrush/blob/master/test/test_help
|
|
64
70
|
|
65
71
|
* Run a single test file:
|
66
72
|
+
|
67
|
-
|
73
|
+
[source,bash]
|
74
|
+
----
|
68
75
|
$ bundle exec rake test TEST=<path to test file>
|
69
|
-
|
76
|
+
----
|
70
77
|
|
71
78
|
* Run cucumber/aruba acceptance tests:
|
72
79
|
+
|
73
|
-
|
80
|
+
[source,bash]
|
81
|
+
----
|
74
82
|
$ bundle exec rake features
|
75
|
-
|
83
|
+
----
|
76
84
|
|
77
85
|
NOTE: The acceptance tests currently work only for OS X, out of the box.
|
78
86
|
On Linux, one has to manually configure the host visibility for the TLD _landrush-acceptance-test_.
|
@@ -81,9 +89,10 @@ On Windows, the acceptance tests won't work due to a bug in https://github.com/c
|
|
81
89
|
|
82
90
|
* Run a single cucumber/aruba acceptance tests:
|
83
91
|
+
|
84
|
-
|
92
|
+
[source,bash]
|
93
|
+
----
|
85
94
|
$ bundle exec rake features FEATURE=features/<feature-filename>.feature
|
86
|
-
|
95
|
+
----
|
87
96
|
|
88
97
|
== Documentation
|
89
98
|
|
@@ -92,6 +101,7 @@ refer to the http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/[AsciiD
|
|
92
101
|
|
93
102
|
To build the documentation you can execute:
|
94
103
|
|
104
|
+
[source,bash]
|
95
105
|
----
|
96
106
|
$ bundle exec rake html
|
97
107
|
----
|
@@ -101,12 +111,44 @@ which will build the HTML documentation into the folder _build/html_.
|
|
101
111
|
The source code also contains a link:../Guardfile[Guardfile] for the https://github.com/guard/guard[Guard] library.
|
102
112
|
You can execute:
|
103
113
|
|
114
|
+
[source,bash]
|
104
115
|
----
|
105
116
|
$ bundle exec guard
|
106
117
|
----
|
107
118
|
|
108
119
|
and your HTML documentation will be automatically updated on each change to an Asciidoc source file.
|
109
120
|
|
121
|
+
== Releasing
|
122
|
+
|
123
|
+
[NOTE]
|
124
|
+
====
|
125
|
+
In order to publish to RubyGems you need to have an account and you need to have an API key configured on your machine.
|
126
|
+
If you have an account you can setup the API key using:
|
127
|
+
|
128
|
+
[source,bash]
|
129
|
+
----
|
130
|
+
curl -u carlos https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
|
131
|
+
----
|
132
|
+
====
|
133
|
+
|
134
|
+
* Make sure the HEAD of development builds and passes all tests:
|
135
|
+
`bundle exec rake clean rubocop test features install`.
|
136
|
+
* Review https://github.com/vagrant-landrush/landrush/milestones[milestone] for the current release
|
137
|
+
** Make sure all issues are resolved
|
138
|
+
** Move unresolved issues into an upcoming release
|
139
|
+
** Close milestone
|
140
|
+
* Update the link:CHANGELOG.md[CHANGELOG] (you can use _scripts/changelog.sh to generate the content)
|
141
|
+
* Update link:lib/landrush/version.rb[version.rb] with the correct
|
142
|
+
release version. Consider http://semver.org/:[Semantic Versioning] guidelines
|
143
|
+
when deciding on the release version
|
144
|
+
* Commit _CHANGELOG_ and _version.rb_ using commit message of the form:
|
145
|
+
`cut v<version>`
|
146
|
+
* Push commit to upstream
|
147
|
+
* Release the gem: `bundle exec rake release`
|
148
|
+
* Update link:lib/landrush/version.rb[version.rb] with the next anticipated release version, eg _1.4.0.dev_
|
149
|
+
* Commit with message: `setting dev version <version>.dev`
|
150
|
+
* Push upstream
|
151
|
+
|
110
152
|
== Misc
|
111
153
|
|
112
154
|
* Run the vagrant binary with the Landrush plugin loaded from your local
|
data/doc/Troubleshooting.adoc
CHANGED
@@ -10,33 +10,41 @@ toc::[]
|
|
10
10
|
|
11
11
|
== How to avoid providing sudo password on OS X
|
12
12
|
|
13
|
-
When using Landrush on OS X, Landrush will try to create a file in
|
14
|
-
|
15
|
-
will ask you for your sudo password. +
|
13
|
+
When using Landrush on OS X, Landrush will try to create a file in `/etc/resolver` to make the guest VM visible via DNS on the host.
|
14
|
+
See *OS X* in the *Visibility on the Host* section of the link:Usage.adoc[Usage guide].
|
15
|
+
To create this file, sudo permissions are needed and Landrush will ask you for your sudo password. +
|
16
16
|
+
|
17
|
-
This can be avoided by adding the
|
18
|
-
|
19
|
-
to edit your `/etc/sudoers` configuration via `sudo visudo`:
|
17
|
+
This can be avoided by adding the following entries to the bottom of the sudoer configuration.
|
18
|
+
Make sure to edit your `/etc/sudoers` configuration via `sudo visudo`:
|
20
19
|
|
21
|
-
|
20
|
+
[source,bash]
|
21
|
+
----
|
22
22
|
# Begin Landrush config
|
23
23
|
Cmnd_Alias VAGRANT_LANDRUSH_HOST_MKDIR = /bin/mkdir /etc/resolver/*
|
24
24
|
Cmnd_Alias VAGRANT_LANDRUSH_HOST_CP = /bin/cp /*/vagrant_landrush_host_config* /etc/resolver/*
|
25
25
|
Cmnd_Alias VAGRANT_LANDRUSH_HOST_CHMOD = /bin/chmod 644 /etc/resolver/*
|
26
26
|
%admin ALL=(ALL) NOPASSWD: VAGRANT_LANDRUSH_HOST_MKDIR, VAGRANT_LANDRUSH_HOST_CP, VAGRANT_LANDRUSH_HOST_CHMOD
|
27
27
|
# End Landrush config
|
28
|
-
|
28
|
+
----
|
29
29
|
|
30
30
|
== Guest is unable to access the Internet
|
31
31
|
|
32
|
-
In some network configurations the access to outside DNS servers is
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
the
|
32
|
+
In some network configurations the access to outside DNS servers is restricted (firewalls, VPN, etc).
|
33
|
+
Since unmatched DNS queries are per default passed through to Google's DNS servers, this can lead to the fact that the guest cannot access anything in the outside world.
|
34
|
+
|
35
|
+
If you face problem with the guest's DNS, verify that you can access Google's DNS server under __8.8.8.8__.
|
36
|
+
If it does not work, you will need to set a custom upstream DNS server.
|
37
|
+
Check your network configuration on the host or ask your network administrator about the right DNS server address to use.
|
38
|
+
You can set the custom DNS server via the `config.landrush.upstream` option, see section on _Unmatched Queries_ in the link:Usage.adoc[Usage guide].
|
39
|
+
|
40
|
+
== ERROR: Failed to build gem native extension
|
41
|
+
|
42
|
+
Some of the Landrush dependencies use native extensions which get built during the plugin installation.
|
43
|
+
For that the required libraries and/or headers for the compilation must be installed on your machine.
|
44
|
+
How these required libraries need to be installed depends on the OS.
|
45
|
+
On link:https://en.wikipedia.org/wiki/APT_(Debian)[APT] based Linux distributions, it can for example be achieved via:
|
46
|
+
|
47
|
+
[source,bash]
|
48
|
+
----
|
49
|
+
$ sudo apt install build-essential
|
50
|
+
----
|
data/features/commands.feature
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Feature:
|
1
|
+
Feature: DNS resolution
|
2
2
|
Landrush should make a virtual machine's IP address DNS-resolvable.
|
3
3
|
|
4
4
|
Scenario Outline: booting a box
|
@@ -33,7 +33,7 @@ Feature: dns_resolution
|
|
33
33
|
Then Landrush is not running
|
34
34
|
|
35
35
|
Examples:
|
36
|
-
| box
|
37
|
-
| debian/jessie64
|
38
|
-
|
39
|
-
|
36
|
+
| box | provider |
|
37
|
+
| debian/jessie64 | virtualbox |
|
38
|
+
| ubuntu/xenial64 | virtualbox |
|
39
|
+
| ubuntu/bionic64 | virtualbox |
|
@@ -25,6 +25,9 @@ Feature: landrush-ip
|
|
25
25
|
When I successfully run `bundle exec vagrant up --provider <provider>`
|
26
26
|
Then the host visible IP address of the guest is the IP of interface "eth3"
|
27
27
|
|
28
|
+
When I successfully run `bundle exec vagrant landrush stop`
|
29
|
+
Then Landrush is not running
|
30
|
+
|
28
31
|
Examples:
|
29
32
|
| box | provider |
|
30
33
|
| debian/jessie64 | virtualbox |
|
@@ -52,6 +55,10 @@ Feature: landrush-ip
|
|
52
55
|
When I successfully run `bundle exec vagrant up --provider <provider>`
|
53
56
|
Then the host visible IP address of the guest is the IP of interface "eth4"
|
54
57
|
|
58
|
+
When I successfully run `bundle exec vagrant landrush stop`
|
59
|
+
Then Landrush is not running
|
60
|
+
|
55
61
|
Examples:
|
56
62
|
| box | provider |
|
57
63
|
| debian/jessie64 | virtualbox |
|
64
|
+
|
@@ -13,9 +13,7 @@ module Landrush
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def redirect_dns
|
16
|
-
info "setting up machine's DNS to point to our server"
|
17
16
|
machine.guest.capability(:redirect_dns, host: _target_host, port: Server.port)
|
18
|
-
|
19
17
|
machine.config.vm.networks.each do |type, options|
|
20
18
|
info "network: #{type.inspect}, #{options.inspect}"
|
21
19
|
end
|
@@ -50,7 +50,7 @@ module Landrush
|
|
50
50
|
def add_prerequisite_network_interface
|
51
51
|
return unless virtualbox? && !private_network_exists?
|
52
52
|
|
53
|
-
info '
|
53
|
+
info 'Virtualbox requires an additional private network; adding it'
|
54
54
|
machine.config.vm.network :private_network, type: :dhcp
|
55
55
|
end
|
56
56
|
|
@@ -93,7 +93,7 @@ module Landrush
|
|
93
93
|
end
|
94
94
|
|
95
95
|
unless Store.hosts.has?(machine_hostname, ip_address)
|
96
|
-
info "
|
96
|
+
info "Adding '#{machine_hostname} => #{ip_address}' to #{Store.hosts.backing_file}"
|
97
97
|
Store.hosts.set(machine_hostname, ip_address)
|
98
98
|
Store.hosts.set(IPAddr.new(ip_address).reverse, machine_hostname)
|
99
99
|
end
|
@@ -42,8 +42,7 @@ module Landrush
|
|
42
42
|
# This allows us to be more accurate, especially with logging what's going on.
|
43
43
|
unless machine.config.landrush.host_interface.nil?
|
44
44
|
addr = addresses.detect { |a| a['name'] == machine.config.landrush.host_interface }
|
45
|
-
|
46
|
-
machine.env.ui.warn "[landrush] Unable to find interface #{machine.config.landrush.host_interface}" if addr.nil?
|
45
|
+
log_with_prefix(:warn, "Unable to find interface #{machine.config.landrush.host_interface}", machine) if addr.nil?
|
47
46
|
end
|
48
47
|
|
49
48
|
if addr.nil?
|
@@ -64,11 +63,14 @@ module Landrush
|
|
64
63
|
end
|
65
64
|
|
66
65
|
ip = IPAddr.new(addr[key])
|
67
|
-
|
68
|
-
machine.env.ui.info "[landrush] Using #{addr['name']} (#{addr[key]})"
|
69
|
-
|
66
|
+
log_with_prefix(:info, "Using #{addr['name']} (#{addr[key]})", machine)
|
70
67
|
ip.to_s
|
71
68
|
end
|
69
|
+
|
70
|
+
def self.log_with_prefix(level, msg, machine)
|
71
|
+
@prefix_ui = Vagrant::UI::Prefixed.new(machine.env.ui, machine.name) if @prefix_ui.nil?
|
72
|
+
@prefix_ui.send level, "[landrush] #{msg}"
|
73
|
+
end
|
72
74
|
end
|
73
75
|
end
|
74
76
|
end
|
@@ -2,20 +2,34 @@ module Landrush
|
|
2
2
|
module Cap
|
3
3
|
module Linux
|
4
4
|
module RedirectDns
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
class << self
|
6
|
+
def redirect_dns(machine, target = {})
|
7
|
+
prefix_ui = Vagrant::UI::Prefixed.new(machine.env.ui, machine.name)
|
8
|
+
dns_servers = machine.guest.capability(:configured_dns_servers)
|
8
9
|
dns_servers.each do |dns_server|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
prefix_ui.info("[landrush] Setting up iptables rule on guest for DNS server #{dns_server}")
|
11
|
+
enable_route_localnet(machine) if dns_server =~ /127\.0\.0\.\d+/
|
12
|
+
%w[tcp udp].each do |proto|
|
13
|
+
machine.guest.capability(:add_iptables_rule, redirect_dns_rule(proto, dns_server, target.fetch(:host), target.fetch(:port)))
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
private
|
19
|
+
|
20
|
+
def redirect_dns_rule(protocol, original_server, target_server, target_port)
|
21
|
+
"OUTPUT -t nat -p #{protocol} -d #{original_server} --dport 53 -j DNAT --to-destination #{target_server}:#{target_port}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def enable_route_localnet(machine)
|
25
|
+
command = "sh -c 'echo 1 > /proc/sys/net/ipv4/conf/all/route_localnet'"
|
26
|
+
machine.communicate.sudo(command) do |data, type|
|
27
|
+
if %i[stderr stdout].include?(type)
|
28
|
+
color = type == :stdout ? :green : :red
|
29
|
+
machine.env.ui.info(data.chomp, color: color, prefix: false)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
19
33
|
end
|
20
34
|
end
|
21
35
|
end
|
@@ -23,6 +23,41 @@ module Landrush
|
|
23
23
|
(`reg query HKU\\S-1-5-19 2>&1` =~ /ERROR/).nil?
|
24
24
|
end
|
25
25
|
|
26
|
+
# Given an IP determines the network name, if any. Uses netsh which generates output like this:
|
27
|
+
#
|
28
|
+
# ...
|
29
|
+
# \n\n
|
30
|
+
# Configuration for interface "Ethernet 2"
|
31
|
+
# DHCP enabled: Yes
|
32
|
+
# IP Address: 10.10.10.1
|
33
|
+
# Subnet Prefix: 10.10.10.0/24 (mask 255.255.255.0)
|
34
|
+
# InterfaceMetric: 10
|
35
|
+
# DNS servers configured through DHCP: None
|
36
|
+
# Register with which suffix: Primary only
|
37
|
+
# WINS servers configured through DHCP: None
|
38
|
+
# \n\n
|
39
|
+
# ...
|
40
|
+
def get_network_name(ip)
|
41
|
+
cmd_out = `netsh interface ip show config`
|
42
|
+
network_details = cmd_out.split(/^$/).reject(&:empty?).select do |settings|
|
43
|
+
begin
|
44
|
+
lines = settings.split(/\n/).reject(&:empty?)
|
45
|
+
subnet = lines[3]
|
46
|
+
next false unless subnet =~ /Subnet Prefix/
|
47
|
+
|
48
|
+
mask = IPAddr.new(subnet.match(%r{.* (\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}/\d{1,3}).*}).captures[0])
|
49
|
+
address = IPAddr.new(ip)
|
50
|
+
|
51
|
+
mask.include?(address)
|
52
|
+
rescue StandardError
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
return nil if network_details[0].nil? || network_details[0].empty?
|
57
|
+
|
58
|
+
network_details[0].split(/\n/).reject(&:empty?)[0].match(/Configuration for interface "(.*)"/).captures[0].strip
|
59
|
+
end
|
60
|
+
|
26
61
|
private
|
27
62
|
|
28
63
|
# Checks that all required tools are on the PATH and that the Wired AutoConfig service is started
|
@@ -102,41 +137,6 @@ module Landrush
|
|
102
137
|
interface_details[0].split(/\n/)[2].match(/.*:(.*)/).captures[0].strip
|
103
138
|
end
|
104
139
|
|
105
|
-
# Given an IP determines the network name, if any. Uses netsh which generates output like this:
|
106
|
-
#
|
107
|
-
# ...
|
108
|
-
# \n\n
|
109
|
-
# Configuration for interface "Ethernet 2"
|
110
|
-
# DHCP enabled: Yes
|
111
|
-
# IP Address: 10.10.10.1
|
112
|
-
# Subnet Prefix: 10.10.10.0/24 (mask 255.255.255.0)
|
113
|
-
# InterfaceMetric: 10
|
114
|
-
# DNS servers configured through DHCP: None
|
115
|
-
# Register with which suffix: Primary only
|
116
|
-
# WINS servers configured through DHCP: None
|
117
|
-
# \n\n
|
118
|
-
# ...
|
119
|
-
def get_network_name(ip)
|
120
|
-
cmd_out = `netsh interface ip show config`
|
121
|
-
network_details = cmd_out.split(/\n\n/).select do |settings|
|
122
|
-
begin
|
123
|
-
lines = settings.split(/\n/).reject(&:empty?)
|
124
|
-
subnet = lines[3]
|
125
|
-
next false unless subnet =~ /Subnet Prefix/
|
126
|
-
|
127
|
-
mask = IPAddr.new(subnet.match(%r{.* (\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}/\d{1,3}).*}).captures[0])
|
128
|
-
address = IPAddr.new(ip)
|
129
|
-
|
130
|
-
mask.include?(address)
|
131
|
-
rescue StandardError
|
132
|
-
false
|
133
|
-
end
|
134
|
-
end
|
135
|
-
return nil if network_details[0].nil?
|
136
|
-
|
137
|
-
network_details[0].split(/\n/)[0].match(/Configuration for interface "(.*)"/).captures[0].strip
|
138
|
-
end
|
139
|
-
|
140
140
|
# Makes sure that we have admin privileges and if nor starts a new shell with the required
|
141
141
|
# privileges
|
142
142
|
def run_with_admin_privileges(file, *args)
|
data/lib/landrush/version.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
programname=$0
|
4
|
+
function usage()
|
5
|
+
{
|
6
|
+
echo "usage: $programname -m milestone"
|
7
|
+
echo " -m milestone id"
|
8
|
+
exit 1
|
9
|
+
}
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
# Given a milestone id, generates a sorted list of issues for this milestone.
|
14
|
+
# Can be used to generate content for CHANGELOG.md
|
15
|
+
function milestone_issues()
|
16
|
+
{
|
17
|
+
# get the raw data
|
18
|
+
milestone_data="`curl -s https://api.github.com/repos/vagrant-landrush/landrush/issues?per_page=100\&milestone=$milestone\&state=closed`"
|
19
|
+
|
20
|
+
issue_list=`echo $milestone_data | jq '.[] | "- Issue [#" + (.number|tostring) + "](" + .url + ") - " + .title'`
|
21
|
+
|
22
|
+
# sort first on issue type, then issue id
|
23
|
+
issue_list=`echo "$issue_list" | sort -k4,4 -k2n`
|
24
|
+
|
25
|
+
# Remove enclosing quotes on each line
|
26
|
+
issue_list=`echo "$issue_list" | tr -d \"`
|
27
|
+
|
28
|
+
# Replace \ which is left over from above command with "(double quote) and suppress warning
|
29
|
+
issue_list=`echo "$issue_list" | tr '\' '"' 2> /dev/null`
|
30
|
+
|
31
|
+
# Adjust the issue links
|
32
|
+
issue_list=`echo "$issue_list" | sed -e s/api.github.com.repos/github.com/g`
|
33
|
+
|
34
|
+
echo "$issue_list"
|
35
|
+
}
|
36
|
+
|
37
|
+
while getopts ":r:m:" opt; do
|
38
|
+
case $opt in
|
39
|
+
r)
|
40
|
+
repository=$OPTARG
|
41
|
+
;;
|
42
|
+
m)
|
43
|
+
milestone=$OPTARG
|
44
|
+
;;
|
45
|
+
*)
|
46
|
+
usage
|
47
|
+
exit 1
|
48
|
+
;;
|
49
|
+
esac
|
50
|
+
done
|
51
|
+
|
52
|
+
shift $((OPTIND-1))
|
53
|
+
|
54
|
+
if [ -z "${milestone}" ]; then
|
55
|
+
usage
|
56
|
+
exit 1
|
57
|
+
fi
|
58
|
+
|
59
|
+
milestone_issues
|
@@ -1,12 +1,8 @@
|
|
1
1
|
require_relative '../../../../test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
module Cap
|
5
|
-
module Windows
|
6
|
-
describe ConfigureVisibilityOnHost do
|
7
|
-
TEST_IP = '10.42.42.42'.freeze
|
3
|
+
TEST_IP = '10.42.42.42'.freeze
|
8
4
|
|
9
|
-
|
5
|
+
DOT_3_SVC_RUNNING = 'SERVICE_NAME: dot3svc
|
10
6
|
TYPE : 30 WIN32
|
11
7
|
STATE : 4 RUNNING
|
12
8
|
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
|
@@ -16,7 +12,7 @@ module Landrush
|
|
16
12
|
WAIT_HINT : 0x0
|
17
13
|
'.freeze
|
18
14
|
|
19
|
-
|
15
|
+
DOT_3_SVC_STOPPED = 'SERVICE_NAME: dot3svc
|
20
16
|
TYPE : 30 WIN32
|
21
17
|
STATE : 1 STOPPED
|
22
18
|
WIN32_EXIT_CODE : 0 (0x0)
|
@@ -25,6 +21,54 @@ module Landrush
|
|
25
21
|
WAIT_HINT : 0x0
|
26
22
|
'.freeze
|
27
23
|
|
24
|
+
NETSH_EXAMPLE = '
|
25
|
+
Configuration for interface "VirtualBox Host-Only Network #1"
|
26
|
+
DHCP enabled: No
|
27
|
+
IP Address: 192.168.99.1
|
28
|
+
Subnet Prefix: 192.168.99.0/24 (mask 255.255.255.0)
|
29
|
+
InterfaceMetric: 25
|
30
|
+
Statically Configured DNS Servers: None
|
31
|
+
Register with which suffix: Primary only
|
32
|
+
Statically Configured WINS Servers: None
|
33
|
+
|
34
|
+
Configuration for interface "Ethernet"
|
35
|
+
DHCP enabled: Yes
|
36
|
+
IP Address: 192.168.1.193
|
37
|
+
Subnet Prefix: 192.168.1.0/24 (mask 255.255.255.0)
|
38
|
+
Default Gateway: 192.168.1.1
|
39
|
+
Gateway Metric: 0
|
40
|
+
InterfaceMetric: 35
|
41
|
+
DNS servers configured through DHCP: 192.168.1.1
|
42
|
+
Register with which suffix: Primary only
|
43
|
+
WINS servers configured through DHCP: None
|
44
|
+
|
45
|
+
Configuration for interface "Loopback Pseudo-Interface 1"
|
46
|
+
DHCP enabled: No
|
47
|
+
IP Address: 127.0.0.1
|
48
|
+
Subnet Prefix: 127.0.0.0/8 (mask 255.0.0.0)
|
49
|
+
InterfaceMetric: 75
|
50
|
+
Statically Configured DNS Servers: None
|
51
|
+
Register with which suffix: Primary only
|
52
|
+
Statically Configured WINS Servers: None
|
53
|
+
'.freeze
|
54
|
+
|
55
|
+
NETSH_EXAMPLE_SINGLE_INTERFACE = '
|
56
|
+
Configuration for interface "Ethernet"
|
57
|
+
DHCP enabled: Yes
|
58
|
+
IP Address: 192.168.1.193
|
59
|
+
Subnet Prefix: 192.168.1.0/24 (mask 255.255.255.0)
|
60
|
+
Default Gateway: 192.168.1.1
|
61
|
+
Gateway Metric: 0
|
62
|
+
InterfaceMetric: 35
|
63
|
+
DNS servers configured through DHCP: 192.168.1.1
|
64
|
+
Register with which suffix: Primary only
|
65
|
+
WINS servers configured through DHCP: None
|
66
|
+
'.freeze
|
67
|
+
|
68
|
+
module Landrush
|
69
|
+
module Cap
|
70
|
+
module Windows
|
71
|
+
describe ConfigureVisibilityOnHost do
|
28
72
|
before do
|
29
73
|
@vboxmanage_found = !Vagrant::Util::Which.which('VBoxManage').nil?
|
30
74
|
@has_admin_privileges = Landrush::Cap::Windows::ConfigureVisibilityOnHost.admin_mode?
|
@@ -63,6 +107,35 @@ module Landrush
|
|
63
107
|
end
|
64
108
|
end
|
65
109
|
|
110
|
+
describe '#get_network_name' do
|
111
|
+
it 'returns network name for matching IP' do
|
112
|
+
ConfigureVisibilityOnHost.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE)
|
113
|
+
expect(ConfigureVisibilityOnHost.get_network_name('192.168.1.193')).must_equal('Ethernet')
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'returns nil for non matching IP' do
|
117
|
+
ConfigureVisibilityOnHost.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE)
|
118
|
+
expect(ConfigureVisibilityOnHost.get_network_name('42.42.42.42')).must_be_nil
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'returns nil for nil input' do
|
122
|
+
ConfigureVisibilityOnHost.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE)
|
123
|
+
expect(ConfigureVisibilityOnHost.get_network_name(nil)).must_be_nil
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'returns nil for empty input' do
|
127
|
+
ConfigureVisibilityOnHost.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE)
|
128
|
+
expect(ConfigureVisibilityOnHost.get_network_name('')).must_be_nil
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#get_network_name' do
|
132
|
+
it 'returns network name for single interface' do
|
133
|
+
ConfigureVisibilityOnHost.expects(:`).with('netsh interface ip show config').returns(NETSH_EXAMPLE_SINGLE_INTERFACE)
|
134
|
+
expect(ConfigureVisibilityOnHost.get_network_name('192.168.1.193')).must_equal('Ethernet')
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
66
139
|
def network_state
|
67
140
|
`netsh interface ip show config`.split(/\n/).reject(&:empty?)
|
68
141
|
end
|
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: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Hinze
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filelock
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/landrush/util/process_helper.rb
|
163
163
|
- lib/landrush/util/retry.rb
|
164
164
|
- lib/landrush/version.rb
|
165
|
+
- scripts/changelog.sh
|
165
166
|
- test/landrush/action/setup_test.rb
|
166
167
|
- test/landrush/action/teardown_test.rb
|
167
168
|
- test/landrush/cap/guest/all/read_host_visible_ip_address_test.rb
|