wifi-wand 2.11.0 → 2.12.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/RELEASE_NOTES.md +8 -0
- data/lib/wifi-wand/models/base_model.rb +44 -27
- data/lib/wifi-wand/models/mac_os_model.rb +4 -1
- data/lib/wifi-wand/version.rb +1 -1
- data/wifi-wand.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f241f14959069b1206de6183dc072605c5af1c65b1dbfc0f855366194bc3c68
|
4
|
+
data.tar.gz: 8bd1250fe4fc050b5810d1c67bd279ce6022974fc9facb236088057966712ec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3e3b3a1da083d30ba3289046d35506c43a6a0a56c443da10e5dc50566ada6e9c5aae829967eb5ac5c0d1a59d49063280397c1a05e5461440945c0415329c5a
|
7
|
+
data.tar.gz: d4791602539759a83b8d88f5dd801279559537dc5401fd003bdf2b9cd96083a5ffce957487122ed704e69a13458ef0659b7f7c52b19a74f4a4c9d1ca386d8d42
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## v2.12.0
|
2
|
+
|
3
|
+
* Change connected_to_internet?. Use 'dig' to test name resolution first, then HTTP get. Also, add baidu.com for China where google.com is blocked.
|
4
|
+
* Remove ping test from connected_to_internet?. It was failing on a network that had connectivity (Syma in France).
|
5
|
+
* Remove trailing newline from MAC address.
|
6
|
+
* Fix nameservers command to return empty array instead of ["There aren't any DNS Servers set on Wi-Fi."] (output of underlying command)when no nameservers.
|
7
|
+
|
8
|
+
|
1
9
|
## v2.11.0
|
2
10
|
|
3
11
|
* Various fixes and clarifications.
|
@@ -66,47 +66,64 @@ class BaseModel
|
|
66
66
|
|
67
67
|
|
68
68
|
# This method returns whether or not there is a working Internet connection,
|
69
|
-
# which is defined as
|
70
|
-
#
|
69
|
+
# which is defined as name resolution and HTTP get being successful.
|
70
|
+
# Domains attempted are google.com and baidu.com. Success is either being successful.
|
71
|
+
# Commands for the multiple sites are run in parallel, in threads, to save time.
|
71
72
|
def connected_to_internet?
|
72
73
|
|
73
|
-
# We
|
74
|
-
#
|
75
|
-
test_using_ping = -> do
|
76
|
-
run_os_command('ping -c 1 -t 3 google.com', false)
|
77
|
-
$?.exitstatus == 0
|
78
|
-
end
|
79
|
-
|
74
|
+
# We cannot use run_os_command for the running of external processes here,
|
75
|
+
# because they are multithreaded, and the output will get mixed up.
|
80
76
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
# First pass to fail quickly if name resolving does not work.
|
78
|
+
test_using_dig = -> do
|
79
|
+
domains = %w(google.com baidu.com)
|
80
|
+
puts "Calling dig on domains #{domains}..." if @verbose_mode
|
85
81
|
|
86
|
-
|
87
|
-
|
82
|
+
threads = domains.map do |domain|
|
83
|
+
Thread.new do
|
84
|
+
output = `dig +short #{domain}`
|
85
|
+
output.length > 0
|
86
|
+
end
|
88
87
|
end
|
89
88
|
|
90
|
-
|
89
|
+
threads.each(&:join)
|
90
|
+
values = threads.map(&:value)
|
91
|
+
success = values.include?(true)
|
92
|
+
puts "Results of dig: success == #{success}, values were #{values}." if @verbose_mode
|
93
|
+
success
|
94
|
+
end
|
91
95
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
+
test_using_http_get = -> do
|
97
|
+
test_sites = %w{https://www.google.com http://baidu.com}
|
98
|
+
puts "Calling HTTP.get on sites #{test_sites}..." if @verbose_mode
|
99
|
+
|
100
|
+
threads = test_sites.map do |site|
|
101
|
+
Thread.new do
|
102
|
+
url = URI.parse(site)
|
103
|
+
success = true
|
104
|
+
|
105
|
+
begin
|
106
|
+
Net::HTTP.start(url.host) do |http|
|
107
|
+
http.read_timeout = 3 # seconds
|
108
|
+
http.get('.')
|
109
|
+
end
|
110
|
+
rescue
|
111
|
+
success = false
|
112
|
+
end
|
113
|
+
|
114
|
+
success
|
96
115
|
end
|
97
|
-
rescue
|
98
|
-
success = false
|
99
116
|
end
|
100
117
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
118
|
+
threads.each(&:join)
|
119
|
+
values = threads.map(&:value)
|
120
|
+
success = values.include?(true)
|
105
121
|
|
122
|
+
puts "Results of HTTP.get: success == #{success}, values were #{values}." if @verbose_mode
|
106
123
|
success
|
107
124
|
end
|
108
125
|
|
109
|
-
|
126
|
+
test_using_dig.() && test_using_http_get.()
|
110
127
|
end
|
111
128
|
|
112
129
|
|
@@ -279,7 +279,7 @@ class MacOsModel < BaseModel
|
|
279
279
|
# then this method returns the current address if none is provided,
|
280
280
|
# but sets to the specified address if it is.
|
281
281
|
def mac_address
|
282
|
-
run_os_command("ifconfig #{wifi_port} | awk '/ether/{print $2}'")
|
282
|
+
run_os_command("ifconfig #{wifi_port} | awk '/ether/{print $2}'").chomp
|
283
283
|
end
|
284
284
|
|
285
285
|
|
@@ -387,6 +387,9 @@ class MacOsModel < BaseModel
|
|
387
387
|
|
388
388
|
def nameservers_using_networksetup
|
389
389
|
output = run_os_command("networksetup -getdnsservers Wi-Fi")
|
390
|
+
if output == "There aren't any DNS Servers set on Wi-Fi.\n"
|
391
|
+
output = ''
|
392
|
+
end
|
390
393
|
output.split("\n")
|
391
394
|
end
|
392
395
|
end
|
data/lib/wifi-wand/version.rb
CHANGED
data/wifi-wand.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["keithrbennett@gmail.com"]
|
10
10
|
spec.description = %q{A command line interface for managing WiFi on a Mac.}
|
11
11
|
spec.summary = %q{Mac WiFi utility}
|
12
|
-
spec.homepage = "https://github.com/keithrbennett/
|
12
|
+
spec.homepage = "https://github.com/keithrbennett/wifiwand"
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
15
15
|
spec.files = `git ls-files`.split($/)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wifi-wand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Bennett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,7 +85,7 @@ files:
|
|
85
85
|
- spec/wifi-wand/models/mac_os_model_spec.rb
|
86
86
|
- test-data/invalid-byte-sequence-network-names.txt
|
87
87
|
- wifi-wand.gemspec
|
88
|
-
homepage: https://github.com/keithrbennett/
|
88
|
+
homepage: https://github.com/keithrbennett/wifiwand
|
89
89
|
licenses:
|
90
90
|
- MIT
|
91
91
|
metadata: {}
|