wifi-wand 2.16.0 → 2.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -10
- data/RELEASE_NOTES.md +4 -0
- data/lib/wifi-wand/models/mac_os_model.rb +11 -37
- data/lib/wifi-wand/version.rb +1 -1
- data/swift/AvailableWifiNetworkLister.swift +32 -0
- data/swift/WifiNetworkDisconecter.swift +9 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa4d72d84399a3545afdc8a93bae85c4b908c4241e9f6b81611525dd16bb60c6
|
4
|
+
data.tar.gz: 395a8c9a5f33fdc7560a1c77e9cf034dc71257001c6b83947e609e66c039289f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b22b21c170675dc09b88d0e27602f36c6d347202222cc89f26fec49527f72b4aa30788ae88234a5d03d0bbd98de024f3999c6b1f5898cdc77d538ea1f9003976
|
7
|
+
data.tar.gz: 6bd48d2bf96327d2b330f88bc9cf48136535ae787a49bf9ebccfe53b0023e1e5699a55e16dabd7c16227f5c056e7ab6674529b736246faae3e0158370fb65190
|
data/README.md
CHANGED
@@ -69,16 +69,6 @@ When in interactive shell mode:
|
|
69
69
|
Internally, it uses several Mac command line utilities to interact with the
|
70
70
|
underlying operating system.
|
71
71
|
|
72
|
-
> [!WARNING]
|
73
|
-
> Starting in Mac OS version 14.4, the `airport` utility on which some of this project's
|
74
|
-
> functionality relies has been disabled and will presumably eventually be removed.
|
75
|
-
>
|
76
|
-
> The following commands will result in a runtime error if `airport` is no longer available:
|
77
|
-
>
|
78
|
-
> * listing names of available wifi networks
|
79
|
-
> * listing detailed information about available wifi networks
|
80
|
-
> * disconnecting from a wifi network
|
81
|
-
|
82
72
|
### Pretty Output
|
83
73
|
|
84
74
|
For nicely formatted output of the `info` command in non-interactive mode,
|
@@ -363,6 +353,21 @@ to create a script for your most commonly used networks containing something lik
|
|
363
353
|
wifi-wand connect my-usual-network its-password
|
364
354
|
```
|
365
355
|
|
356
|
+
### Airport Utility Deprecation (April 2024)
|
357
|
+
|
358
|
+
Starting in Mac OS version 14.4, the `airport` utility on which some of this project's
|
359
|
+
functionality relies has been disabled and will presumably eventually be removed.
|
360
|
+
|
361
|
+
The following tasks were restored by using Swift scripts:
|
362
|
+
* listing names of all available networks
|
363
|
+
* disconnecting from a network (with the added benefit that sudo access is no longer required)
|
364
|
+
|
365
|
+
The following tasks were restored by using `networksetup`:
|
366
|
+
* determining whether or not wifi is on
|
367
|
+
* the name of the currently connected network
|
368
|
+
|
369
|
+
The only remaining issue is that we were getting some extended information from airport for each available network.
|
370
|
+
|
366
371
|
|
367
372
|
### License
|
368
373
|
|
data/RELEASE_NOTES.md
CHANGED
@@ -6,26 +6,6 @@ require 'shellwords'
|
|
6
6
|
require_relative 'base_model'
|
7
7
|
require_relative '../error'
|
8
8
|
|
9
|
-
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
10
|
-
# 2024-04-18:
|
11
|
-
#
|
12
|
-
# Apple has deprecated the 'airport' utility and has already disabled its
|
13
|
-
# functionality. This utility is used for the following wifi-wand commands:
|
14
|
-
|
15
|
-
# 1) cmd: info, fn: wifi_info - adds information to the info output
|
16
|
-
# 2) cmd: avail_nets, fn: available_network_names - available wifi network names
|
17
|
-
# 3) cmd: ls_avail_nets, fn: available_network_info - available wifi networks details
|
18
|
-
# 4) cmd: wifi_on, fn: wifi_on?
|
19
|
-
# 5) cmd: network_name, fn: connected_network_name
|
20
|
-
# 6) cmd: disconnect, fn: disconnect
|
21
|
-
|
22
|
-
# Functions 4 and 5 have been fixed to use `networksetup` instead of `airport`.
|
23
|
-
# The others are not yet fixed.
|
24
|
-
|
25
|
-
# An AskDifferent (Mac StackExchange site) question has been posted to
|
26
|
-
# https://apple.stackexchange.com/questions/471886/how-to-replace-functionality-of-deprecated-airport-command-line-application.
|
27
|
-
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
28
|
-
|
29
9
|
module WifiWand
|
30
10
|
|
31
11
|
class MacOsModel < BaseModel
|
@@ -190,22 +170,9 @@ class MacOsModel < BaseModel
|
|
190
170
|
#
|
191
171
|
# REXML is used here to avoid the need for the user to install Nokogiri.
|
192
172
|
def available_network_names
|
193
|
-
raise RuntimeError, airport_deprecated_message if airport_deprecated
|
194
|
-
|
195
173
|
return nil unless wifi_on? # no need to try
|
196
174
|
|
197
|
-
|
198
|
-
# we get data in the response:
|
199
|
-
|
200
|
-
command = "#{airport_command} -s -x | iconv -f macroman -t utf-8"
|
201
|
-
stop_condition = ->(response) { ! [nil, ''].include?(response) }
|
202
|
-
output = try_os_command_until(command, stop_condition)
|
203
|
-
doc = REXML::Document.new(output)
|
204
|
-
xpath = '//key[text() = "SSID_STR"][1]/following-sibling::*[1]' # provided by @ScreenStaring on Twitter
|
205
|
-
REXML::XPath.match(doc, xpath) \
|
206
|
-
.map(&:text) \
|
207
|
-
.sort { |x,y| x.casecmp(y) } \
|
208
|
-
.uniq
|
175
|
+
run_swift_command('AvailableWifiNetworkLister').split("\n")
|
209
176
|
end
|
210
177
|
|
211
178
|
|
@@ -323,10 +290,9 @@ class MacOsModel < BaseModel
|
|
323
290
|
|
324
291
|
# Disconnects from the currently connected network. Does not turn off wifi.
|
325
292
|
def disconnect
|
326
|
-
raise RuntimeError, airport_deprecated_message if airport_deprecated
|
327
|
-
|
328
293
|
return nil unless wifi_on? # no need to try
|
329
|
-
|
294
|
+
|
295
|
+
run_swift_command('WifiNetworkDisconecter')
|
330
296
|
nil
|
331
297
|
end
|
332
298
|
|
@@ -463,5 +429,13 @@ class MacOsModel < BaseModel
|
|
463
429
|
end
|
464
430
|
output.split("\n")
|
465
431
|
end
|
432
|
+
|
433
|
+
def run_swift_command(basename)
|
434
|
+
swift_filespec = File.join(
|
435
|
+
File.dirname(__FILE__), "../../../swift/#{basename}.swift"
|
436
|
+
)
|
437
|
+
command = "swift #{swift_filespec}"
|
438
|
+
`#{command}`
|
439
|
+
end
|
466
440
|
end
|
467
441
|
end
|
data/lib/wifi-wand/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
import Foundation
|
2
|
+
import CoreWLAN
|
3
|
+
|
4
|
+
class NetworkScanner {
|
5
|
+
var currentInterface: CWInterface
|
6
|
+
|
7
|
+
init?() {
|
8
|
+
// Initialize with the default Wi-Fi interface
|
9
|
+
guard let defaultInterface = CWWiFiClient.shared().interface(),
|
10
|
+
defaultInterface.interfaceName != nil else {
|
11
|
+
return nil
|
12
|
+
}
|
13
|
+
self.currentInterface = defaultInterface
|
14
|
+
self.scanForNetworks()
|
15
|
+
}
|
16
|
+
|
17
|
+
func scanForNetworks() {
|
18
|
+
do {
|
19
|
+
let networks = try currentInterface.scanForNetworks(withName: nil)
|
20
|
+
for network in networks {
|
21
|
+
print("\(network.ssid ?? "Unknown")")
|
22
|
+
}
|
23
|
+
} catch let error as NSError {
|
24
|
+
print("Error: \(error.localizedDescription)")
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
// Usage
|
30
|
+
if NetworkScanner() != nil {
|
31
|
+
// The list of available networks will be printed
|
32
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wifi-wand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.16.
|
4
|
+
version: 2.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Bennett
|
@@ -155,6 +155,8 @@ files:
|
|
155
155
|
- sample-available-networks.json
|
156
156
|
- sample-available-networks.yaml
|
157
157
|
- spec/wifi-wand/models/base_model_spec.rb
|
158
|
+
- swift/AvailableWifiNetworkLister.swift
|
159
|
+
- swift/WifiNetworkDisconecter.swift
|
158
160
|
- test-data/invalid-byte-sequence-network-names.txt
|
159
161
|
- wifi-wand.gemspec
|
160
162
|
homepage: https://github.com/keithrbennett/wifiwand
|