@capgo/capacitor-wifi 8.3.4 → 8.3.6
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.
|
@@ -49,7 +49,7 @@ import java.util.List;
|
|
|
49
49
|
)
|
|
50
50
|
public class CapacitorWifiPlugin extends Plugin {
|
|
51
51
|
|
|
52
|
-
private final String pluginVersion = "8.3.
|
|
52
|
+
private final String pluginVersion = "8.3.6";
|
|
53
53
|
|
|
54
54
|
private WifiManager wifiManager;
|
|
55
55
|
private ConnectivityManager connectivityManager;
|
|
@@ -5,7 +5,7 @@ import CoreLocation
|
|
|
5
5
|
|
|
6
6
|
@objc(CapacitorWifiPlugin)
|
|
7
7
|
public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
|
|
8
|
-
private let pluginVersion: String = "8.3.
|
|
8
|
+
private let pluginVersion: String = "8.3.6"
|
|
9
9
|
public let identifier = "CapacitorWifiPlugin"
|
|
10
10
|
public let jsName = "CapacitorWifi"
|
|
11
11
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -109,7 +109,6 @@ public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManager
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
@objc func getIpAddress(_ call: CAPPluginCall) {
|
|
112
|
-
var address: String?
|
|
113
112
|
var ifaddr: UnsafeMutablePointer<ifaddrs>?
|
|
114
113
|
|
|
115
114
|
guard getifaddrs(&ifaddr) == 0, let firstAddr = ifaddr else {
|
|
@@ -119,24 +118,35 @@ public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManager
|
|
|
119
118
|
|
|
120
119
|
defer { freeifaddrs(ifaddr) }
|
|
121
120
|
|
|
121
|
+
var ipv4Address: String?
|
|
122
|
+
var routableIPv6Address: String?
|
|
123
|
+
var linkLocalIPv6Address: String?
|
|
124
|
+
|
|
122
125
|
for ptr in sequence(first: firstAddr, next: { $0.pointee.ifa_next }) {
|
|
123
126
|
let interface = ptr.pointee
|
|
124
127
|
let addrFamily = interface.ifa_addr.pointee.sa_family
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
let name = String(cString: interface.ifa_name)
|
|
129
|
+
|
|
130
|
+
guard name == "en0",
|
|
131
|
+
addrFamily == UInt8(AF_INET) || addrFamily == UInt8(AF_INET6) else { continue }
|
|
132
|
+
|
|
133
|
+
var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
|
|
134
|
+
getnameinfo(interface.ifa_addr, socklen_t(interface.ifa_addr.pointee.sa_len),
|
|
135
|
+
&hostname, socklen_t(hostname.count),
|
|
136
|
+
nil, socklen_t(0), NI_NUMERICHOST)
|
|
137
|
+
let resolved = String(cString: hostname)
|
|
138
|
+
|
|
139
|
+
if addrFamily == UInt8(AF_INET) {
|
|
140
|
+
ipv4Address = resolved
|
|
141
|
+
break
|
|
142
|
+
} else if resolved.hasPrefix("fe80") {
|
|
143
|
+
if linkLocalIPv6Address == nil { linkLocalIPv6Address = resolved }
|
|
144
|
+
} else {
|
|
145
|
+
if routableIPv6Address == nil { routableIPv6Address = resolved }
|
|
136
146
|
}
|
|
137
147
|
}
|
|
138
148
|
|
|
139
|
-
if let address =
|
|
149
|
+
if let address = ipv4Address ?? routableIPv6Address ?? linkLocalIPv6Address {
|
|
140
150
|
call.resolve(["ipAddress": address])
|
|
141
151
|
} else {
|
|
142
152
|
call.reject("No IP address found")
|
|
@@ -248,7 +258,6 @@ public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManager
|
|
|
248
258
|
}
|
|
249
259
|
|
|
250
260
|
private func getIPAddress() -> String? {
|
|
251
|
-
var address: String?
|
|
252
261
|
var ifaddr: UnsafeMutablePointer<ifaddrs>?
|
|
253
262
|
|
|
254
263
|
guard getifaddrs(&ifaddr) == 0, let firstAddr = ifaddr else {
|
|
@@ -257,24 +266,35 @@ public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManager
|
|
|
257
266
|
|
|
258
267
|
defer { freeifaddrs(ifaddr) }
|
|
259
268
|
|
|
269
|
+
var ipv4Address: String?
|
|
270
|
+
var routableIPv6Address: String?
|
|
271
|
+
var linkLocalIPv6Address: String?
|
|
272
|
+
|
|
260
273
|
for ptr in sequence(first: firstAddr, next: { $0.pointee.ifa_next }) {
|
|
261
274
|
let interface = ptr.pointee
|
|
262
275
|
let addrFamily = interface.ifa_addr.pointee.sa_family
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
276
|
+
let name = String(cString: interface.ifa_name)
|
|
277
|
+
|
|
278
|
+
guard name == "en0",
|
|
279
|
+
addrFamily == UInt8(AF_INET) || addrFamily == UInt8(AF_INET6) else { continue }
|
|
280
|
+
|
|
281
|
+
var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
|
|
282
|
+
getnameinfo(interface.ifa_addr, socklen_t(interface.ifa_addr.pointee.sa_len),
|
|
283
|
+
&hostname, socklen_t(hostname.count),
|
|
284
|
+
nil, socklen_t(0), NI_NUMERICHOST)
|
|
285
|
+
let resolved = String(cString: hostname)
|
|
286
|
+
|
|
287
|
+
if addrFamily == UInt8(AF_INET) {
|
|
288
|
+
ipv4Address = resolved
|
|
289
|
+
break
|
|
290
|
+
} else if resolved.hasPrefix("fe80") {
|
|
291
|
+
if linkLocalIPv6Address == nil { linkLocalIPv6Address = resolved }
|
|
292
|
+
} else {
|
|
293
|
+
if routableIPv6Address == nil { routableIPv6Address = resolved }
|
|
274
294
|
}
|
|
275
295
|
}
|
|
276
296
|
|
|
277
|
-
return
|
|
297
|
+
return ipv4Address ?? routableIPv6Address ?? linkLocalIPv6Address
|
|
278
298
|
}
|
|
279
299
|
|
|
280
300
|
private func getLocationPermissionStatus() -> String {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-wifi",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.6",
|
|
4
4
|
"description": "Manage WiFi connectivity for your Capacitor app",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -50,8 +50,7 @@
|
|
|
50
50
|
"prepublishOnly": "bun run build",
|
|
51
51
|
"check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs",
|
|
52
52
|
"example:install": "cd example-app && bun install --frozen-lockfile",
|
|
53
|
-
"example:build": "bun run build && cd example-app && bun install --frozen-lockfile && bun run build"
|
|
54
|
-
"example:capgo:deploy": "bun run example:build && bun scripts/deploy-example-capgo.mjs"
|
|
53
|
+
"example:build": "bun run build && cd example-app && bun install --frozen-lockfile && bun run build"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
57
56
|
"@capacitor/android": "^8.0.0",
|