Display the prohibited address warning on failures too

This commit is contained in:
Cameron Gutman
2020-08-30 20:47:40 -07:00
parent 6bf643968b
commit b7b7a88ef7
+12 -11
View File
@@ -127,6 +127,14 @@
} }
- (void) discoverHost:(NSString *)hostAddress withCallback:(void (^)(TemporaryHost *, NSString*))callback { - (void) discoverHost:(NSString *)hostAddress withCallback:(void (^)(TemporaryHost *, NSString*))callback {
BOOL prohibitedAddress = [DiscoveryManager isProhibitedAddress:hostAddress];
NSString* prohibitedAddressMessage = [NSString stringWithFormat: @"Moonlight only supports adding PCs on your local network on %s.",
#if TARGET_OS_TV
"tvOS"
#else
"iOS"
#endif
];
ServerInfoResponse* serverInfoResponse = [self getServerInfoResponseForAddress:hostAddress]; ServerInfoResponse* serverInfoResponse = [self getServerInfoResponseForAddress:hostAddress];
TemporaryHost* host = nil; TemporaryHost* host = nil;
@@ -138,8 +146,6 @@
// Check if this is a new PC // Check if this is a new PC
if (![self getHostInDiscovery:host.uuid]) { if (![self getHostInDiscovery:host.uuid]) {
BOOL prohibitedAddress;
// Enforce LAN restriction for App Store Guideline 4.2.7a // Enforce LAN restriction for App Store Guideline 4.2.7a
if ([DiscoveryManager isProhibitedAddress:hostAddress]) { if ([DiscoveryManager isProhibitedAddress:hostAddress]) {
// We have a prohibited address. This might be because the user specified their WAN address // We have a prohibited address. This might be because the user specified their WAN address
@@ -170,13 +176,7 @@
} }
if (prohibitedAddress) { if (prohibitedAddress) {
callback(nil, [NSString stringWithFormat: @"Moonlight only supports adding PCs on your local network on %s.", callback(nil, prohibitedAddressMessage);
#if TARGET_OS_TV
"tvOS"
#else
"iOS"
#endif
]);
return; return;
} }
else if ([DiscoveryManager isAddressLAN:inet_addr([hostAddress UTF8String])]) { else if ([DiscoveryManager isAddressLAN:inet_addr([hostAddress UTF8String])]) {
@@ -201,10 +201,11 @@
} else { } else {
callback(host, nil); callback(host, nil);
} }
} else { } else if (!prohibitedAddress) {
callback(nil, @"Could not connect to host. Ensure GameStream is enabled in GeForce Experience on your PC."); callback(nil, @"Could not connect to host. Ensure GameStream is enabled in GeForce Experience on your PC.");
} else {
callback(nil, prohibitedAddressMessage);
} }
} }
- (void) resetDiscoveryState { - (void) resetDiscoveryState {