handle public ip
This commit is contained in:
1 parent
a8b45851cc
commit
c7700904e0
3 files changed
+30
-6
No files matched your search
@@ -27,5 +27,6 @@
|
|||||||
- (void) pauseDiscoveryForHost:(TemporaryHost *)host;
|
- (void) pauseDiscoveryForHost:(TemporaryHost *)host;
|
||||||
- (void) resumeDiscoveryForHost:(TemporaryHost *)host;
|
- (void) resumeDiscoveryForHost:(TemporaryHost *)host;
|
||||||
- (void) discoverHost:(NSString*)hostAddress withCallback:(void (^)(TemporaryHost*, NSString*))callback;
|
- (void) discoverHost:(NSString*)hostAddress withCallback:(void (^)(TemporaryHost*, NSString*))callback;
|
||||||
|
+ (void) setBackdoorHostAddress: (NSString*)address;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
|
static NSString* backdoorHostAddress;
|
||||||
|
|
||||||
@implementation DiscoveryManager {
|
@implementation DiscoveryManager {
|
||||||
NSMutableArray* _hostQueue;
|
NSMutableArray* _hostQueue;
|
||||||
NSMutableSet* _pausedHosts;
|
NSMutableSet* _pausedHosts;
|
||||||
@@ -86,7 +88,7 @@
|
|||||||
// the Add PC dialog. This is required to comply with Apple App Store
|
// the Add PC dialog. This is required to comply with Apple App Store
|
||||||
// Guideline 4.2.7a.
|
// Guideline 4.2.7a.
|
||||||
+ (BOOL) isProhibitedAddress:(NSString*)address {
|
+ (BOOL) isProhibitedAddress:(NSString*)address {
|
||||||
#ifdef ENABLE_APP_STORE_RESTRICTIONS
|
//#ifdef ENABLE_APP_STORE_RESTRICTIONS
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
struct addrinfo* result;
|
struct addrinfo* result;
|
||||||
int err;
|
int err;
|
||||||
@@ -111,14 +113,25 @@
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOOL ret = ![DiscoveryManager isAddressLAN:((struct sockaddr_in*)result->ai_addr)->sin_addr.s_addr];
|
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 = NO;
|
||||||
freeaddrinfo(result);
|
freeaddrinfo(result);
|
||||||
|
|
||||||
|
NSLog(@"backDoorHostAddress: %@", backdoorHostAddress);
|
||||||
|
if(ret){
|
||||||
|
if([address isEqualToString:backdoorHostAddress]) ret = NO;
|
||||||
|
}
|
||||||
|
backdoorHostAddress = nil;
|
||||||
|
NSLog(@"IP Check, is prohibited: %d", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
//#else
|
||||||
return NO;
|
// return NO;
|
||||||
#endif
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)setBackdoorHostAddress: (NSString* )address{
|
||||||
|
backdoorHostAddress = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ServerInfoResponse*) getServerInfoResponseForAddress:(NSString*)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:@"Cancel"] style:UIAlertActionStyleCancel handler:nil]];
|
||||||
[alertController addAction:[UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Ok"] style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
[alertController addAction:[UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Ok"] style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
||||||
NSString* hostAddress = [((UITextField*)[[alertController textFields] objectAtIndex:0]).text trim];
|
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:^{
|
[self showLoadingFrame:^{
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
[self->_discMan discoverHost:hostAddress withCallback:^(TemporaryHost* host, NSString* error){
|
[self->_discMan discoverHost:hostAddress withCallback:^(TemporaryHost* host, NSString* error){
|
||||||
|
|||||||
Reference in new issue
Block a user