handle public ip
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
||||
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 {
|
||||
|
||||
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user