Browse Source

Merge pull request #236 from maeldur/master

Fixed GCDWebServerGetPrimaryIPAddress() on tvOS devices
Pierre-Olivier Latour 9 years ago
parent
commit
8a6a139687
1 changed files with 4 additions and 2 deletions
  1. 4 2
      GCDWebServer/Core/GCDWebServerFunctions.m

+ 4 - 2
GCDWebServer/Core/GCDWebServerFunctions.m

@@ -267,8 +267,10 @@ NSString* GCDWebServerGetPrimaryIPAddress(BOOL useIPv6) {
   struct ifaddrs* list;
   struct ifaddrs* list;
   if (getifaddrs(&list) >= 0) {
   if (getifaddrs(&list) >= 0) {
     for (struct ifaddrs* ifap = list; ifap; ifap = ifap->ifa_next) {
     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
 #else
       if (strcmp(ifap->ifa_name, primaryInterface))
       if (strcmp(ifap->ifa_name, primaryInterface))
 #endif
 #endif