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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4729288451e02d7b968dac5ef6bfd703383e3e7a759386ae6b74d82527e2dea6
4
- data.tar.gz: '085c16eba0b518c4be31609cfd8847788f8d0e0985ae9b167c41585c66a18182'
3
+ metadata.gz: fa4d72d84399a3545afdc8a93bae85c4b908c4241e9f6b81611525dd16bb60c6
4
+ data.tar.gz: 395a8c9a5f33fdc7560a1c77e9cf034dc71257001c6b83947e609e66c039289f
5
5
  SHA512:
6
- metadata.gz: 83b47a2b64ba1a6b436f38c7da2f546156076891cb73fae03a6b90f57b72119c4d6affd25bff7bac42523fd0e4abfcbf45eb9fb7363739cc9641a7992881fdad
7
- data.tar.gz: 365bd3f24ed79803b100ab0785c16a4257dadb18c25f9a8a6c0617eda4e4bba8786104000c559d24932bffc6cda95e428bf617b1c39b50db675b87a8170eabed
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
@@ -1,3 +1,7 @@
1
+ ## v2.16.1
2
+
3
+ * Fix airport deprecations' removal of listing all networks and disconnecting from a network by using Swift scripts.
4
+
1
5
  ## v2.16.0 (2024-04)
2
6
 
3
7
  * Handle deprecation of the `airport` command starting at Mac OS 14.4.
@@ -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
- # For some reason, the airport command very often returns nothing, so we need to try until
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
- run_os_command("sudo #{airport_command} -z")
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
@@ -1,3 +1,3 @@
1
1
  module WifiWand
2
- VERSION = '2.16.0' unless defined?(VERSION)
2
+ VERSION = '2.16.1' unless defined?(VERSION)
3
3
  end
@@ -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
+ }
@@ -0,0 +1,9 @@
1
+ import Foundation
2
+ import CoreWLAN
3
+
4
+ if let wifiInterface = CWWiFiClient.shared().interface() {
5
+ wifiInterface.disassociate()
6
+ print("ok")
7
+ } else {
8
+ print("error")
9
+ }
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.0
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