diff --git a/Limelight/Network/DiscoveryManager.h b/Limelight/Network/DiscoveryManager.h index ba26549f..241f42a6 100644 --- a/Limelight/Network/DiscoveryManager.h +++ b/Limelight/Network/DiscoveryManager.h @@ -27,5 +27,6 @@ - (void) pauseDiscoveryForHost:(TemporaryHost *)host; - (void) resumeDiscoveryForHost:(TemporaryHost *)host; - (void) discoverHost:(NSString*)hostAddress withCallback:(void (^)(TemporaryHost*, NSString*))callback; ++ (void) setBackdoorHostAddress: (NSString*)address; @end diff --git a/Limelight/Network/DiscoveryManager.m b/Limelight/Network/DiscoveryManager.m index 3c053f0f..50ae1fc9 100644 --- a/Limelight/Network/DiscoveryManager.m +++ b/Limelight/Network/DiscoveryManager.m @@ -21,6 +21,8 @@ #include #include +static NSString* backdoorHostAddress; + @implementation DiscoveryManager { NSMutableArray* _hostQueue; NSMutableSet* _pausedHosts; @@ -86,7 +88,7 @@ // the Add PC dialog. This is required to comply with Apple App Store // Guideline 4.2.7a. + (BOOL) isProhibitedAddress:(NSString*)address { -#ifdef ENABLE_APP_STORE_RESTRICTIONS +//#ifdef ENABLE_APP_STORE_RESTRICTIONS struct addrinfo hints; struct addrinfo* result; int err; @@ -111,14 +113,25 @@ return NO; } - // BOOL ret = ![DiscoveryManager isAddressLAN:((struct sockaddr_in*)result->ai_addr)->sin_addr.s_addr]; - BOOL ret = NO; // Cancel LAN restriction for personnal use. + BOOL ret = ![DiscoveryManager isAddressLAN:((struct sockaddr_in*)result->ai_addr)->sin_addr.s_addr]; + //BOOL ret = NO; freeaddrinfo(result); + + NSLog(@"backDoorHostAddress: %@", backdoorHostAddress); + if(ret){ + if([address isEqualToString:backdoorHostAddress]) ret = NO; + } + backdoorHostAddress = nil; + NSLog(@"IP Check, is prohibited: %d", ret); return ret; -#else - return NO; -#endif +//#else +// return NO; +//#endif +} + ++ (void)setBackdoorHostAddress: (NSString* )address{ + backdoorHostAddress = address; } - (ServerInfoResponse*) getServerInfoResponseForAddress:(NSString*)address { diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index a8d69958..d8a313be 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -579,6 +579,16 @@ static NSMutableSet* hostList; [alertController addAction:[UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Cancel"] style:UIAlertActionStyleCancel handler:nil]]; [alertController addAction:[UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Ok"] style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){ NSString* hostAddress = [((UITextField*)[[alertController textFields] objectAtIndex:0]).text trim]; + + //handles public IP + NSString *publicIpBackdoor = @"-666"; + if ([hostAddress rangeOfString:publicIpBackdoor].location != NSNotFound) { + hostAddress = [hostAddress stringByReplacingOccurrencesOfString:publicIpBackdoor withString:@""]; + [DiscoveryManager setBackdoorHostAddress:hostAddress]; + } else { + [DiscoveryManager setBackdoorHostAddress:nil]; + } + [self showLoadingFrame:^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ [self->_discMan discoverHost:hostAddress withCallback:^(TemporaryHost* host, NSString* error){