mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 22:23:52 +00:00
Force remote streaming mode when a VPN is connected
This commit is contained in:
@@ -163,20 +163,6 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isActiveNetworkVPN {
|
|
||||||
NSDictionary *dict = CFBridgingRelease(CFNetworkCopySystemProxySettings());
|
|
||||||
NSArray *keys = [dict[@"__SCOPED__"] allKeys];
|
|
||||||
for (NSString *key in keys) {
|
|
||||||
if ([key containsString:@"tap"] ||
|
|
||||||
[key containsString:@"tun"] ||
|
|
||||||
[key containsString:@"ppp"] ||
|
|
||||||
[key containsString:@"ipsec"]) {
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)netServiceDidResolveAddress:(NSNetService *)service {
|
- (void)netServiceDidResolveAddress:(NSNetService *)service {
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
NSArray<NSData*>* addresses = [service addresses];
|
NSArray<NSData*>* addresses = [service addresses];
|
||||||
@@ -196,7 +182,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
|
|
||||||
// Don't send a STUN request if we're connected to a VPN. We'll likely get the VPN
|
// Don't send a STUN request if we're connected to a VPN. We'll likely get the VPN
|
||||||
// gateway's external address rather than the external address of the LAN.
|
// gateway's external address rather than the external address of the LAN.
|
||||||
if (![self isActiveNetworkVPN]) {
|
if (![Utils isActiveNetworkVPN]) {
|
||||||
// Since we discovered this host over IPv4 mDNS, we know we're on the same network
|
// Since we discovered this host over IPv4 mDNS, we know we're on the same network
|
||||||
// as the PC and we can use our current WAN address as a likely candidate
|
// as the PC and we can use our current WAN address as a likely candidate
|
||||||
// for our PC's external address.
|
// for our PC's external address.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "Connection.h"
|
#import "Connection.h"
|
||||||
|
#import "Utils.h"
|
||||||
|
|
||||||
#import <AudioUnit/AudioUnit.h>
|
#import <AudioUnit/AudioUnit.h>
|
||||||
#import <AVFoundation/AVFoundation.h>
|
#import <AVFoundation/AVFoundation.h>
|
||||||
@@ -340,9 +341,16 @@ void ClConnectionStatusUpdate(int status)
|
|||||||
// quality improvement.
|
// quality improvement.
|
||||||
_streamConfig.hevcBitratePercentageMultiplier = 75;
|
_streamConfig.hevcBitratePercentageMultiplier = 75;
|
||||||
|
|
||||||
// Detect remote streaming automatically based on the IP address of the target
|
if ([Utils isActiveNetworkVPN]) {
|
||||||
_streamConfig.streamingRemotely = STREAM_CFG_AUTO;
|
// Force remote streaming mode when a VPN is connected
|
||||||
_streamConfig.packetSize = 1392;
|
_streamConfig.streamingRemotely = STREAM_CFG_REMOTE;
|
||||||
|
_streamConfig.packetSize = 1024;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Detect remote streaming automatically based on the IP address of the target
|
||||||
|
_streamConfig.streamingRemotely = STREAM_CFG_AUTO;
|
||||||
|
_streamConfig.packetSize = 1392;
|
||||||
|
}
|
||||||
|
|
||||||
switch (config.audioChannelCount) {
|
switch (config.audioChannelCount) {
|
||||||
case 2:
|
case 2:
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ FOUNDATION_EXPORT NSString *const deviceName;
|
|||||||
+ (NSData*) randomBytes:(NSInteger)length;
|
+ (NSData*) randomBytes:(NSInteger)length;
|
||||||
+ (NSString*) bytesToHex:(NSData*)data;
|
+ (NSString*) bytesToHex:(NSData*)data;
|
||||||
+ (NSData*) hexToBytes:(NSString*) hex;
|
+ (NSData*) hexToBytes:(NSString*) hex;
|
||||||
+ (int) resolveHost:(NSString*)host;
|
|
||||||
+ (void) addHelpOptionToDialog:(UIAlertController*)dialog;
|
+ (void) addHelpOptionToDialog:(UIAlertController*)dialog;
|
||||||
|
+ (BOOL) isActiveNetworkVPN;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
+10
-19
@@ -50,27 +50,18 @@ NSString *const deviceName = @"roth";
|
|||||||
return hex;
|
return hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (int) resolveHost:(NSString*)host {
|
+ (BOOL)isActiveNetworkVPN {
|
||||||
struct hostent *hostent;
|
NSDictionary *dict = CFBridgingRelease(CFNetworkCopySystemProxySettings());
|
||||||
|
NSArray *keys = [dict[@"__SCOPED__"] allKeys];
|
||||||
if (inet_addr([host UTF8String]) != INADDR_NONE) {
|
for (NSString *key in keys) {
|
||||||
// Already an IP address
|
if ([key containsString:@"tap"] ||
|
||||||
int addr = inet_addr([host UTF8String]);
|
[key containsString:@"tun"] ||
|
||||||
Log(LOG_I, @"host address: %d", addr);
|
[key containsString:@"ppp"] ||
|
||||||
return addr;
|
[key containsString:@"ipsec"]) {
|
||||||
} else {
|
return YES;
|
||||||
hostent = gethostbyname([host UTF8String]);
|
|
||||||
if (hostent != NULL) {
|
|
||||||
char* ipstr = inet_ntoa(*(struct in_addr*)hostent->h_addr_list[0]);
|
|
||||||
Log(LOG_I, @"Resolved %@ -> %s", host, ipstr);
|
|
||||||
int addr = inet_addr(ipstr);
|
|
||||||
Log(LOG_I, @"host address: %d", addr);
|
|
||||||
return addr;
|
|
||||||
} else {
|
|
||||||
Log(LOG_W, @"Failed to resolve host: %d", h_errno);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) addHelpOptionToDialog:(UIAlertController*)dialog {
|
+ (void) addHelpOptionToDialog:(UIAlertController*)dialog {
|
||||||
|
|||||||
Reference in New Issue
Block a user