@@ -22,52 +22,6 @@ struct DNSServerEntry: Decodable {
22
22
23
23
/// Class with methods for verifying network connectivity
24
24
class Networking {
25
- /// Get IP address of the iOS device under test
26
- static func getIPAddress( ) throws -> String {
27
- var ipAddress : String
28
- // Get list of all interfaces on the local machine:
29
- var interfaceList : UnsafeMutablePointer < ifaddrs > ?
30
- guard getifaddrs ( & interfaceList) == 0 , let firstInterfaceAddress = interfaceList else {
31
- throw NetworkingError . internalError ( reason: " Failed to locate local networking interface " )
32
- }
33
-
34
- // For each interface
35
- for interfacePointer in sequence ( first: firstInterfaceAddress, next: { $0. pointee. ifa_next } ) {
36
- let flags = Int32 ( interfacePointer. pointee. ifa_flags)
37
- let interfaceAddress = interfacePointer. pointee. ifa_addr. pointee
38
-
39
- // Check for running IPv4 interfaces. Skip the loopback interface.
40
- if (
41
- flags &
42
- ( IFF_UP | IFF_RUNNING | IFF_LOOPBACK)
43
- ) == ( IFF_UP | IFF_RUNNING) ,
44
- interfaceAddress. sa_family == UInt8 ( AF_INET) {
45
- // Check if interface is en0 which is the WiFi connection on the iPhone
46
- let name = String ( cString: interfacePointer. pointee. ifa_name)
47
- // Convert interface address to a human readable string:
48
- var hostname = [ CChar] ( repeating: 0 , count: Int ( NI_MAXHOST) )
49
- if getnameinfo (
50
- interfacePointer. pointee. ifa_addr,
51
- socklen_t ( interfaceAddress. sa_len) ,
52
- & hostname,
53
- socklen_t ( hostname. count) ,
54
- nil ,
55
- socklen_t ( 0 ) ,
56
- NI_NUMERICHOST
57
- ) == 0 {
58
- ipAddress = String ( cString: hostname)
59
- if ipAddress. starts ( with: " 192.168 " ) {
60
- return ipAddress
61
- }
62
- }
63
- }
64
- }
65
-
66
- freeifaddrs ( interfaceList)
67
-
68
- throw NetworkingError . internalError ( reason: " No local IP found " )
69
- }
70
-
71
25
/// Get configured ad serving domain
72
26
private static func getAdServingDomain( ) throws -> String {
73
27
guard let adServingDomain = Bundle ( for: Networking . self)
0 commit comments