From 740ffd68b6c81fc251f6917b872d845002793463 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 13 Dec 2018 23:45:21 +0530 Subject: Remove unused code: InternetReachability Signed-off-by: Roopesh Chander --- .../WireGuard/Tunnel/InternetReachability.swift | 51 ---------------------- 1 file changed, 51 deletions(-) delete mode 100644 WireGuard/WireGuard/Tunnel/InternetReachability.swift (limited to 'WireGuard/WireGuard/Tunnel/InternetReachability.swift') 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.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 - } -} -- cgit v1.2.3-59-g8ed1b