aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/Tunnel/InternetReachability.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-13 23:45:21 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-13 23:45:21 +0530
commit740ffd68b6c81fc251f6917b872d845002793463 (patch)
tree01878bbd8dff6d60b47e06431950bdee8f00758b /WireGuard/WireGuard/Tunnel/InternetReachability.swift
parentTunnelsManager: Remove unused variable (diff)
downloadwireguard-apple-740ffd68b6c81fc251f6917b872d845002793463.tar.xz
wireguard-apple-740ffd68b6c81fc251f6917b872d845002793463.zip
Remove unused code: InternetReachability
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/Tunnel/InternetReachability.swift51
1 files changed, 0 insertions, 51 deletions
diff --git a/WireGuard/WireGuard/Tunnel/InternetReachability.swift b/WireGuard/WireGuard/Tunnel/InternetReachability.swift
deleted file mode 100644
index 2e50852..0000000
--- a/WireGuard/WireGuard/Tunnel/InternetReachability.swift
+++ /dev/null
@@ -1,51 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright © 2018 WireGuard LLC. All Rights Reserved.
-
-import SystemConfiguration
-
-class InternetReachability {
-
- enum Status {
- case unknown
- case notReachable
- case reachableOverWiFi
- case reachableOverCellular
- }
-
- static func currentStatus() -> Status {
- var status: Status = .unknown
- if let reachabilityRef = InternetReachability.reachabilityRef() {
- var flags = SCNetworkReachabilityFlags(rawValue: 0)
- SCNetworkReachabilityGetFlags(reachabilityRef, &flags)
- status = Status(reachabilityFlags: flags)
- }
- return status
- }
-
- private static func reachabilityRef() -> SCNetworkReachability? {
- let addrIn = sockaddr_in(sin_len: UInt8(MemoryLayout<sockaddr_in>.size),
- sin_family: sa_family_t(AF_INET),
- sin_port: 0,
- sin_addr: in_addr(s_addr: 0),
- sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
- return withUnsafePointer(to: addrIn) { addrInPtr in
- addrInPtr.withMemoryRebound(to: sockaddr.self, capacity: 1) { addrPtr in
- return SCNetworkReachabilityCreateWithAddress(nil, addrPtr)
- }
- }
- }
-}
-
-extension InternetReachability.Status {
- init(reachabilityFlags flags: SCNetworkReachabilityFlags) {
- var status: InternetReachability.Status = .notReachable
- if flags.contains(.reachable) {
- if flags.contains(.isWWAN) {
- status = .reachableOverCellular
- } else {
- status = .reachableOverWiFi
- }
- }
- self = status
- }
-}