wifi-wand 2.12.0 → 2.13.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/README.md +20 -30
- data/RELEASE_NOTES.md +5 -0
- data/lib/wifi-wand/models/base_model.rb +1 -0
- data/lib/wifi-wand/models/mac_os_model.rb +9 -3
- 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: e0669f48a732c950d64056cfdc853ac83b6afb31e35c30c514d026d05f757f80
|
4
|
+
data.tar.gz: 6117a6a8693b9d9730a159d049a2c442eb53cac6c92f2107c4d257ec7685513c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38d4beb5c03960e90d6e0e0f557f95fe10d319506e7543c83ab2e057e3f06718eb7f0a5ffe2239b8ccdae477b273ba39870ffa94365ef7b3e31c0992c099895a
|
7
|
+
data.tar.gz: dc747b5765528debc3874cdd7ea07dd5d1f4b2173c000f37854ced5a35b5ba74d5611c31c0114b3080ec3849760fa1eafedb78b6daa5bf9ae388900abc65b071
|
data/README.md
CHANGED
@@ -9,8 +9,8 @@ or, you may need to precede that command with `sudo`:
|
|
9
9
|
`sudo gem install wifi-wand`
|
10
10
|
|
11
11
|
The `wifi-wand` gem enables the query and management
|
12
|
-
of
|
13
|
-
The code encapsulates the Mac OS specific logic in
|
12
|
+
of WiFi configuration and environment on a Mac.
|
13
|
+
The code encapsulates the Mac OS specific logic in model classes
|
14
14
|
to more easily add support for other operating systems,
|
15
15
|
but as of now, only Mac OS is supported. (Feel free to add an OS!)
|
16
16
|
|
@@ -30,7 +30,7 @@ $ wifi-wand -h
|
|
30
30
|
|
31
31
|
Syntax is: exe/wifi-wand [options] command [command_options]
|
32
32
|
|
33
|
-
Command Line Switches: [wifi-wand version 2.
|
33
|
+
Command Line Switches: [wifi-wand version 2.13.0 at https://github.com/keithrbennett/wifiwand]
|
34
34
|
|
35
35
|
-o {i,j,k,p,y} - outputs data in inspect, JSON, pretty JSON, puts, or YAML format when not in shell mode
|
36
36
|
-p wifi_port_name - override automatic detection of port name with this name
|
@@ -44,7 +44,7 @@ ci - connected to Internet (not just wifi on)?
|
|
44
44
|
co[nnect] network-name - turns wifi on, connects to network-name
|
45
45
|
cy[cle] - turns wifi off, then on, preserving network selection
|
46
46
|
d[isconnect] - disconnects from current network, does not turn off wifi
|
47
|
-
f[orget]
|
47
|
+
f[orget] name1 [..name_n] - removes network-name(s) from the preferred networks list
|
48
48
|
h[elp] - prints this help
|
49
49
|
i[nfo] - a hash of wifi-related information
|
50
50
|
l[s_avail_nets] - details about available networks
|
@@ -59,17 +59,21 @@ ro[pen] - open resource ('ipl' (IP Location), 'ipw' (What is M
|
|
59
59
|
t[ill] - returns when the desired Internet connection state is true. Options:
|
60
60
|
1) 'on'/:on, 'off'/:off, 'conn'/:conn, or 'disc'/:disc
|
61
61
|
2) wait interval, in seconds (optional, defaults to 0.5 seconds)
|
62
|
-
w[
|
62
|
+
w[ifi_on] - is the wifi on?
|
63
63
|
x[it] - exits this program (interactive shell mode only) (see also 'q')
|
64
64
|
|
65
|
+
When in interactive shell mode:
|
66
|
+
* remember to quote string literals.
|
67
|
+
* for pry commands, use prefix `%`.
|
68
|
+
|
69
|
+
|
65
70
|
When in interactive shell mode:
|
66
71
|
* use quotes for string parameters such as method names.
|
67
72
|
* for pry commands, use prefix `%`.
|
68
73
|
```
|
69
74
|
|
70
|
-
Internally, it uses several Mac command line utilities
|
71
|
-
|
72
|
-
this script quickly and simply.
|
75
|
+
Internally, it uses several Mac command line utilities to interact with the
|
76
|
+
underlying operating system.
|
73
77
|
|
74
78
|
|
75
79
|
### Pretty Output
|
@@ -117,21 +121,6 @@ sudo gem install pry-coolline
|
|
117
121
|
```
|
118
122
|
|
119
123
|
|
120
|
-
### Using It in Scripts
|
121
|
-
|
122
|
-
Sometimes calling `wifi-wand` from a script is handy. I have this script that
|
123
|
-
connects to a commonly used wifi network, and then speaks a message when it's done:
|
124
|
-
|
125
|
-
```
|
126
|
-
wifi-wand connect my_network_name my_password && \
|
127
|
-
wifi-wand till conn && \
|
128
|
-
say -v Kyoko "Connected to my network."
|
129
|
-
```
|
130
|
-
|
131
|
-
(The Mac OS `say` command supports all kinds of accents that are fun to play around with.
|
132
|
-
You can get a list of all of them by running `say -v "?"`)
|
133
|
-
|
134
|
-
|
135
124
|
### Using the Shell
|
136
125
|
|
137
126
|
_If the program immediately exits when you try to run the shell, try upgrading `pry` and `pry-byebug`.
|
@@ -190,7 +179,7 @@ or constants, which will _not_ hide the methods:
|
|
190
179
|
```
|
191
180
|
|
192
181
|
2) If you accidentally refer to a nonexistent variable or method name,
|
193
|
-
the result may be mysterious. For example, if I were write the
|
182
|
+
the result may be mysterious. For example, if I were write the WiFi information
|
194
183
|
to a file, this would work:
|
195
184
|
|
196
185
|
```
|
@@ -284,7 +273,7 @@ puts model.available_network_names.to_yaml # etc...
|
|
284
273
|
but these commands could also each be specified on a line of its own.)
|
285
274
|
|
286
275
|
```
|
287
|
-
# Print out
|
276
|
+
# Print out WiFi info:
|
288
277
|
i
|
289
278
|
|
290
279
|
# Cycle (off/on) the network then connect to the specified network not requiring a password
|
@@ -303,11 +292,12 @@ You are connected on port en0 to .@ AIS SUPER WiFi on IP address 172.27.145.225.
|
|
303
292
|
There are 341 preferred networks.
|
304
293
|
|
305
294
|
# Delete all preferred networks whose names begin with "TOTTGUEST", the hard way:
|
306
|
-
> pr.grep(/^TOTTGUEST/).each { |n|
|
295
|
+
> pr.grep(/^TOTTGUEST/).each { |n| forget(n) }
|
307
296
|
|
308
297
|
# Delete all preferred networks whose names begin with "TOTTGUEST", the easy way.
|
309
|
-
#
|
310
|
-
|
298
|
+
# 'forget' can take multiple network names,
|
299
|
+
# but they must be specified as separate parameters; thus the '*'.
|
300
|
+
> forget(*pr.grep(/^TOTTGUEST/))
|
311
301
|
|
312
302
|
# Define a method to wait for the Internet connection to be active.
|
313
303
|
# (This functionality is included in the `till` command.)
|
@@ -347,14 +337,14 @@ return this:
|
|
347
337
|
|
348
338
|
If this happens, the public IP information will be silently omitted from the
|
349
339
|
information hash. In this case, the web site 'https://www.iplocation.net/' is
|
350
|
-
recommended, and `ro ipl` on the command line or `ro 'ipl'` in the shell will
|
340
|
+
recommended, and `wifi-wand ro ipl` on the command line or `ro 'ipl'` in the shell will
|
351
341
|
open that page in your browser for you.
|
352
342
|
|
353
343
|
|
354
344
|
### Password Lookup Oddity
|
355
345
|
|
356
346
|
You may find it odd (I did, anyway) that even if you issue the password command
|
357
|
-
(`mac_wifi
|
347
|
+
(`mac_wifi password a-network-name`) using sudo, you will still be prompted
|
358
348
|
with a graphical dialog for both a user id and password. This is no doubt
|
359
349
|
for better security, but it's unfortunate in that it makes it impossible to fully automate this task.
|
360
350
|
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## v2.13.0
|
2
|
+
|
3
|
+
* Fix: network names could not be displayed when one contained a nonstandard character (e.g. D5 for a special apostrophe in Mac Roman encoding).
|
4
|
+
* Fix: some operations that didn't make sense with WiFi off were attempted anyway; this was removed.
|
5
|
+
|
1
6
|
## v2.12.0
|
2
7
|
|
3
8
|
* 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.
|
@@ -70,6 +70,7 @@ class BaseModel
|
|
70
70
|
# Domains attempted are google.com and baidu.com. Success is either being successful.
|
71
71
|
# Commands for the multiple sites are run in parallel, in threads, to save time.
|
72
72
|
def connected_to_internet?
|
73
|
+
return nil unless wifi_on? # no need to try
|
73
74
|
|
74
75
|
# We cannot use run_os_command for the running of external processes here,
|
75
76
|
# because they are multithreaded, and the output will get mixed up.
|
@@ -73,7 +73,7 @@ class MacOsModel < BaseModel
|
|
73
73
|
# "DIRECT-sq-BRAVIA 02:71:cc:87:4a:8c -76 6 Y -- WPA2(PSK/AES/AES) ", #
|
74
74
|
def available_network_info
|
75
75
|
return nil unless wifi_on? # no need to try
|
76
|
-
command = "#{airport_command} -s"
|
76
|
+
command = "#{airport_command} -s | iconv -f macroman -t utf-8"
|
77
77
|
max_attempts = 50
|
78
78
|
|
79
79
|
|
@@ -145,10 +145,12 @@ class MacOsModel < BaseModel
|
|
145
145
|
#
|
146
146
|
# REXML is used here to avoid the need for the user to install Nokogiri.
|
147
147
|
def available_network_names
|
148
|
+
return nil unless wifi_on? # no need to try
|
149
|
+
|
148
150
|
# For some reason, the airport command very often returns nothing, so we need to try until
|
149
151
|
# we get data in the response:
|
150
152
|
|
151
|
-
command = "#{airport_command} -s -x"
|
153
|
+
command = "#{airport_command} -s -x | iconv -f macroman -t utf-8"
|
152
154
|
stop_condition = ->(response) { ! [nil, ''].include?(response) }
|
153
155
|
output = try_os_command_until(command, stop_condition)
|
154
156
|
doc = REXML::Document.new(output)
|
@@ -238,6 +240,7 @@ class MacOsModel < BaseModel
|
|
238
240
|
|
239
241
|
# Returns the IP address assigned to the wifi port, or nil if none.
|
240
242
|
def ip_address
|
243
|
+
return nil unless wifi_on? # no need to try
|
241
244
|
begin
|
242
245
|
run_os_command("ipconfig getifaddr #{wifi_port}").chomp
|
243
246
|
rescue OsCommandError => error
|
@@ -259,6 +262,7 @@ class MacOsModel < BaseModel
|
|
259
262
|
|
260
263
|
# Returns the network currently connected to, or nil if none.
|
261
264
|
def connected_network_name
|
265
|
+
return nil unless wifi_on? # no need to try
|
262
266
|
lines = run_os_command("#{airport_command} -I").split("\n")
|
263
267
|
ssid_lines = lines.grep(/ SSID:/)
|
264
268
|
ssid_lines.empty? ? nil : ssid_lines.first.split('SSID: ').last.lstrip
|
@@ -267,6 +271,7 @@ class MacOsModel < BaseModel
|
|
267
271
|
|
268
272
|
# Disconnects from the currently connected network. Does not turn off wifi.
|
269
273
|
def disconnect
|
274
|
+
return nil unless wifi_on? # no need to try
|
270
275
|
run_os_command("sudo #{airport_command} -z")
|
271
276
|
nil
|
272
277
|
end
|
@@ -337,7 +342,8 @@ class MacOsModel < BaseModel
|
|
337
342
|
raise Error.new("Bad IP addresses provided: #{bad_addresses.join(', ')}")
|
338
343
|
end
|
339
344
|
nameservers.join(' ')
|
340
|
-
end
|
345
|
+
end # end assignment to arg variable
|
346
|
+
|
341
347
|
run_os_command("networksetup -setdnsservers Wi-Fi #{arg}")
|
342
348
|
nameservers
|
343
349
|
end
|
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.13.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-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|