Browse Source

Merge pull request #236 from maeldur/master

Fixed GCDWebServerGetPrimaryIPAddress() on tvOS devices
Pierre-Olivier Latour 9 năm trước cách đây
mục cha
commit
8a6a139687
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      GCDWebServer/Core/GCDWebServerFunctions.m

+ 4 - 2
GCDWebServer/Core/GCDWebServerFunctions.m

@@ -267,8 +267,10 @@ NSString* GCDWebServerGetPrimaryIPAddress(BOOL useIPv6) {
   struct ifaddrs* list;
   if (getifaddrs(&list) >= 0) {
     for (struct ifaddrs* ifap = list; ifap; ifap = ifap->ifa_next) {
-#if TARGET_IPHONE_SIMULATOR
-      if (strcmp(ifap->ifa_name, "en0") && strcmp(ifap->ifa_name, "en1"))  // Assume en0 is Ethernet and en1 is WiFi since there is no way to use SystemConfiguration framework in iOS Simulator
+#if TARGET_IPHONE_SIMULATOR  || TARGET_OS_TV
+        // Assume en0 is Ethernet and en1 is WiFi since there is no way to use SystemConfiguration framework in iOS Simulator
+        // Assumption holds for Apple TV running tvOS
+      if (strcmp(ifap->ifa_name, "en0") && strcmp(ifap->ifa_name, "en1"))
 #else
       if (strcmp(ifap->ifa_name, primaryInterface))
 #endif