wifi-wand 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -8
- data/RELEASE_NOTES.md +9 -0
- data/lib/wifi-wand/command_line_interface.rb +7 -8
- data/lib/wifi-wand/models/base_model.rb +40 -15
- data/lib/wifi-wand/models/mac_os_model.rb +13 -0
- data/lib/wifi-wand/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d5b1780753a271f9bc1d4da54530160de21c28760262fa959fd723589abbbdd
|
4
|
+
data.tar.gz: ee3094477cde57eed16ede10c2111b885986ee67340227284bb2882c45edd4c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4d9cd6476fbc3bdb06c02d906c0bcf1cceb99b0cd39c3bc0b84287477bcbd45e945cdfaeee7fd195f88cde5e87ea8a9bfbb24e38b5c31f6cedf512eb55911f2
|
7
|
+
data.tar.gz: b7d7626c4370420f6b971d82189f8b70d17fdca4e3ed34aab762d555800605e690f5507bf1ee702c60b5ae87e5cd6754d4ce81af3c2880bcf6a1f55478009c2e
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ output at the time of this writing:
|
|
28
28
|
```
|
29
29
|
$ wifi-wand -h
|
30
30
|
|
31
|
-
Command Line Switches: [wifi-wand version 2.
|
31
|
+
Command Line Switches: [wifi-wand version 2.9.0 at https://github.com/keithrbennett/wifiwand]
|
32
32
|
|
33
33
|
-o {i,j,k,p,y} - outputs data in inspect, JSON, pretty JSON, puts, or YAML format when not in shell mode
|
34
34
|
-p wifi_port_name - override automatic detection of port name with this name
|
@@ -52,12 +52,11 @@ of[f] - turns wifi off
|
|
52
52
|
pa[ssword] network-name - password for preferred network-name
|
53
53
|
pr[ef_nets] - preferred (not necessarily available) networks
|
54
54
|
q[uit] - exits this program (interactive shell mode only) (see also 'x')
|
55
|
-
r[m_pref_nets] network-name - removes network-name from the preferred networks list
|
56
|
-
|
57
|
-
ro[pen] - open resource ('ipc' (IP Chicken), 'ipw' (What is My IP), 'spe' (Speed Test), 'this' (wifi-wand Home Page))
|
55
|
+
r[m_pref_nets] network-name - removes network-name(s) from the preferred networks list
|
56
|
+
ro[pen] - open resource ('ipl' (IP Location), 'ipw' (What is My IP), 'spe' (Speed Test), 'this' (wifi-wand home page))
|
58
57
|
t[ill] - returns when the desired Internet connection state is true. Options:
|
59
|
-
|
60
|
-
|
58
|
+
1) 'on'/:on, 'off'/:off, 'conn'/:conn, or 'disc'/:disc
|
59
|
+
2) wait interval, in seconds (optional, defaults to 0.5 seconds)
|
61
60
|
w[ifion] - is the wifi on?
|
62
61
|
x[it] - exits this program (interactive shell mode only) (see also 'q')
|
63
62
|
|
@@ -345,8 +344,8 @@ return this:
|
|
345
344
|
`Rate limit exceeded. Subscribe to a paid plan to increase your usage limits`
|
346
345
|
|
347
346
|
If this happens, the public IP information will be silently omitted from the
|
348
|
-
information hash. In this case, the web site 'https://www.
|
349
|
-
recommended, and `ro
|
347
|
+
information hash. In this case, the web site 'https://www.iplocation.net/' is
|
348
|
+
recommended, and `ro ipl` on the command line or `ro 'ipl'` in the shell will
|
350
349
|
open that page in your browser for you.
|
351
350
|
|
352
351
|
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## v2.9.0
|
2
|
+
|
3
|
+
* Add duration of command to verbose output.
|
4
|
+
* Add MAC address to info hash.
|
5
|
+
* Reduce ping timeout to 3 seconds for faster return for `info`, `ci` commands.
|
6
|
+
* Replace ipchicken.com link with iplocation.net link for 'ropen'; iplocation aggregates several info sources.
|
7
|
+
* Fix bug where if there were no duplicate network names, result was nil, because uniq! returns nil if no changes!!!
|
8
|
+
* Suppress error throw on ping error when not connected; it was printing useless output.
|
9
|
+
|
1
10
|
## v2.8.0
|
2
11
|
|
3
12
|
* Substantial simplifications of model implementations of connected_to_internet?, available_network_names.
|
@@ -41,10 +41,10 @@ class CommandLineInterface
|
|
41
41
|
end
|
42
42
|
|
43
43
|
OPEN_RESOURCES = OpenResources.new([
|
44
|
-
OpenResource.new('
|
45
|
-
OpenResource.new('ipw', 'https://www.whatismyip.com',
|
46
|
-
OpenResource.new('spe', 'http://speedtest.net/',
|
47
|
-
OpenResource.new('this', 'https://github.com/keithrbennett/wifiwand', 'wifi-wand
|
44
|
+
OpenResource.new('ipl', 'https://www.iplocation.net/', 'IP Location'),
|
45
|
+
OpenResource.new('ipw', 'https://www.whatismyip.com', 'What is My IP'),
|
46
|
+
OpenResource.new('spe', 'http://speedtest.net/', 'Speed Test'),
|
47
|
+
OpenResource.new('this', 'https://github.com/keithrbennett/wifiwand', 'wifi-wand home page'),
|
48
48
|
])
|
49
49
|
|
50
50
|
|
@@ -74,12 +74,11 @@ of[f] - turns wifi off
|
|
74
74
|
pa[ssword] network-name - password for preferred network-name
|
75
75
|
pr[ef_nets] - preferred (not necessarily available) networks
|
76
76
|
q[uit] - exits this program (interactive shell mode only) (see also 'x')
|
77
|
-
r[m_pref_nets] network-name - removes network-name from the preferred networks list
|
78
|
-
(can provide multiple names separated by spaces)
|
77
|
+
r[m_pref_nets] network-name - removes network-name(s) from the preferred networks list
|
79
78
|
ro[pen] - open resource (#{OPEN_RESOURCES.help_string})
|
80
79
|
t[ill] - returns when the desired Internet connection state is true. Options:
|
81
|
-
|
82
|
-
|
80
|
+
1) 'on'/:on, 'off'/:off, 'conn'/:conn, or 'disc'/:disc
|
81
|
+
2) wait interval, in seconds (optional, defaults to 0.5 seconds)
|
83
82
|
w[ifion] - is the wifi on?
|
84
83
|
x[it] - exits this program (interactive shell mode only) (see also 'q')
|
85
84
|
|
@@ -59,9 +59,11 @@ class BaseModel
|
|
59
59
|
puts command_attempt_as_string(command)
|
60
60
|
end
|
61
61
|
|
62
|
+
start_time = Time.now
|
62
63
|
output = `#{command} 2>&1` # join stderr with stdout
|
63
64
|
|
64
65
|
if @verbose_mode
|
66
|
+
puts "Duration: #{'%.4f' % [Time.now - start_time]} seconds"
|
65
67
|
puts command_result_as_string(output)
|
66
68
|
end
|
67
69
|
|
@@ -77,28 +79,44 @@ class BaseModel
|
|
77
79
|
# which is defined as being able to get a successful response
|
78
80
|
# from google.com within 3 seconds..
|
79
81
|
def connected_to_internet?
|
80
|
-
test_site = 'https://www.google.com'
|
81
|
-
url = URI.parse(test_site)
|
82
|
-
success = true
|
83
82
|
|
84
|
-
|
85
|
-
|
83
|
+
# We test using ping first because that will allow us to fail faster
|
84
|
+
# if there is no network connection.
|
85
|
+
test_using_ping = -> do
|
86
|
+
run_os_command('ping -c 1 -t 3 google.com', false)
|
87
|
+
$?.exitstatus == 0
|
86
88
|
end
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
test_using_http_get = -> do
|
92
|
+
test_site = 'https://www.google.com'
|
93
|
+
url = URI.parse(test_site)
|
94
|
+
success = true
|
95
|
+
|
96
|
+
if @verbose_mode
|
97
|
+
puts command_attempt_as_string("[Calling Net:HTTP.start(#{url.host})]")
|
92
98
|
end
|
93
|
-
rescue
|
94
|
-
success = false
|
95
|
-
end
|
96
99
|
|
97
|
-
|
98
|
-
|
100
|
+
start_time = Time.now
|
101
|
+
|
102
|
+
begin
|
103
|
+
Net::HTTP.start(url.host) do |http|
|
104
|
+
http.read_timeout = 3 # seconds
|
105
|
+
http.get('.')
|
106
|
+
end
|
107
|
+
rescue
|
108
|
+
success = false
|
109
|
+
end
|
110
|
+
|
111
|
+
if @verbose_mode
|
112
|
+
puts "Duration: #{'%.4f' % [Time.now - start_time]} seconds"
|
113
|
+
puts command_result_as_string("#{success}\n")
|
114
|
+
end
|
115
|
+
|
116
|
+
success
|
99
117
|
end
|
100
118
|
|
101
|
-
|
119
|
+
test_using_ping.() && test_using_http_get.()
|
102
120
|
end
|
103
121
|
|
104
122
|
|
@@ -225,6 +243,13 @@ class BaseModel
|
|
225
243
|
end
|
226
244
|
|
227
245
|
|
246
|
+
def random_mac_address
|
247
|
+
bytes = Array.new(6) { rand(256) }
|
248
|
+
chars = bytes.map { |b| "%02x" % b }
|
249
|
+
chars.join(':')
|
250
|
+
end
|
251
|
+
|
252
|
+
|
228
253
|
def wifi_port
|
229
254
|
@wifi_port ||= detect_wifi_port
|
230
255
|
end
|
@@ -107,6 +107,7 @@ class MacOsModel < BaseModel
|
|
107
107
|
output.map! { |s| s.gsub(/<\/?string>/, '') }
|
108
108
|
output.sort! { |s1, s2| s1.casecmp(s2) } # sort alphabetically, case insensitively
|
109
109
|
output.uniq!
|
110
|
+
output
|
110
111
|
end
|
111
112
|
|
112
113
|
|
@@ -222,6 +223,17 @@ class MacOsModel < BaseModel
|
|
222
223
|
end
|
223
224
|
|
224
225
|
|
226
|
+
# TODO: Add capability to change the MAC address using a command in the form of:
|
227
|
+
# sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff
|
228
|
+
# However, the MAC address will be set to the real hardware address on restart.
|
229
|
+
# One way to implement this is to have an optional address argument,
|
230
|
+
# then this method returns the current address if none is provided,
|
231
|
+
# but sets to the specified address if it is.
|
232
|
+
def mac_address
|
233
|
+
run_os_command("ifconfig #{wifi_port} | awk '/ether/{print $2}'")
|
234
|
+
end
|
235
|
+
|
236
|
+
|
225
237
|
# Returns some useful wifi-related information.
|
226
238
|
def wifi_info
|
227
239
|
|
@@ -237,6 +249,7 @@ class MacOsModel < BaseModel
|
|
237
249
|
'port' => wifi_port,
|
238
250
|
'network' => connected_network_name,
|
239
251
|
'ip_address' => ip_address,
|
252
|
+
'mac_address' => mac_address,
|
240
253
|
'nameservers' => nameservers_using_scutil,
|
241
254
|
'timestamp' => Time.now,
|
242
255
|
}
|
data/lib/wifi-wand/version.rb
CHANGED
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.9.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-
|
11
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|