mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-15 21:22:40 +00:00
Fix streaming over the external IP address when discovered via mDNS
This commit is contained in:
@@ -20,5 +20,6 @@
|
|||||||
@property (nonatomic, retain) NSString * mac;
|
@property (nonatomic, retain) NSString * mac;
|
||||||
@property (nonatomic) BOOL online;
|
@property (nonatomic) BOOL online;
|
||||||
@property (nonatomic) PairState pairState;
|
@property (nonatomic) PairState pairState;
|
||||||
|
@property (nonatomic) NSString * activeAddress;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -19,5 +19,6 @@
|
|||||||
@dynamic mac;
|
@dynamic mac;
|
||||||
@dynamic pairState;
|
@dynamic pairState;
|
||||||
@synthesize online;
|
@synthesize online;
|
||||||
|
@synthesize activeAddress;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ static const int MAX_ATTEMPTS = 5;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (appImage == nil) {
|
if (appImage == nil) {
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_host.address uniqueId:[CryptoManager getUniqueID] deviceName:deviceName cert:[CryptoManager readCertFromFile]];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:_host.activeAddress uniqueId:[CryptoManager getUniqueID] deviceName:deviceName cert:[CryptoManager readCertFromFile]];
|
||||||
AppAssetResponse* appAssetResp = [[AppAssetResponse alloc] init];
|
AppAssetResponse* appAssetResp = [[AppAssetResponse alloc] init];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appAssetResp withUrlRequest:[hMan newAppAssetRequestWithAppId:self.app.appId]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appAssetResp withUrlRequest:[hMan newAppAssetRequestWithAppId:self.app.appId]]];
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
if ([serverInfoResponse isStatusOk]) {
|
if ([serverInfoResponse isStatusOk]) {
|
||||||
DataManager* dataMan = [[DataManager alloc] init];
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
host = [dataMan createHost];
|
host = [dataMan createHost];
|
||||||
host.address = hostAddress;
|
host.activeAddress = host.address = hostAddress;
|
||||||
host.online = YES;
|
host.online = YES;
|
||||||
[serverInfoResponse populateHost:host];
|
[serverInfoResponse populateHost:host];
|
||||||
if (![self addHostToDiscovery:host]) {
|
if (![self addHostToDiscovery:host]) {
|
||||||
|
|||||||
@@ -46,18 +46,27 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
|||||||
if (!self.cancelled && _host.localAddress != nil) {
|
if (!self.cancelled && _host.localAddress != nil) {
|
||||||
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.localAddress];
|
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.localAddress];
|
||||||
receivedResponse = [self checkResponse:serverInfoResp];
|
receivedResponse = [self checkResponse:serverInfoResp];
|
||||||
|
if (receivedResponse) {
|
||||||
|
_host.activeAddress = _host.localAddress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!self.cancelled && !receivedResponse && _host.externalAddress != nil) {
|
if (!self.cancelled && !receivedResponse && _host.externalAddress != nil) {
|
||||||
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.externalAddress];
|
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.externalAddress];
|
||||||
receivedResponse = [self checkResponse:serverInfoResp];
|
receivedResponse = [self checkResponse:serverInfoResp];
|
||||||
|
if (receivedResponse) {
|
||||||
|
_host.activeAddress = _host.externalAddress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!self.cancelled && !receivedResponse && _host.address != nil) {
|
if (!self.cancelled && !receivedResponse && _host.address != nil) {
|
||||||
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.address];
|
ServerInfoResponse* serverInfoResp = [self requestInfoAtAddress:_host.address];
|
||||||
receivedResponse = [self checkResponse:serverInfoResp];
|
receivedResponse = [self checkResponse:serverInfoResp];
|
||||||
|
if (receivedResponse) {
|
||||||
|
_host.activeAddress = _host.address;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_host.online = receivedResponse;
|
_host.online = receivedResponse;
|
||||||
if (receivedResponse) {
|
if (receivedResponse) {
|
||||||
Log(LOG_D, @"Received response from: %@\n{\n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online);
|
Log(LOG_D, @"Received response from: %@\n{\n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n\t activeAddress:%@ \n}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online, _host.activeAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
|||||||
for (NSNetService* service in services) {
|
for (NSNetService* service in services) {
|
||||||
if (service.hostName != nil) {
|
if (service.hostName != nil) {
|
||||||
Host* host = [dataMan createHost];
|
Host* host = [dataMan createHost];
|
||||||
host.address = service.hostName;
|
host.activeAddress = host.address = service.hostName;
|
||||||
host.name = host.address;
|
host.name = host.address;
|
||||||
[hosts addObject:host];
|
[hosts addObject:host];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ static NSArray* appList;
|
|||||||
|
|
||||||
- (void)alreadyPaired {
|
- (void)alreadyPaired {
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.activeAddress uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||||
|
|
||||||
AppListResponse* appListResp = [[AppListResponse alloc] init];
|
AppListResponse* appListResp = [[AppListResponse alloc] init];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appListResp withUrlRequest:[hMan newAppListRequest]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appListResp withUrlRequest:[hMan newAppListRequest]]];
|
||||||
@@ -138,7 +138,7 @@ static NSArray* appList;
|
|||||||
[self showLoadingFrame];
|
[self showLoadingFrame];
|
||||||
_selectedHost = host;
|
_selectedHost = host;
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:host.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:host.activeAddress uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||||
ServerInfoResponse* serverInfoResp = [[ServerInfoResponse alloc] init];
|
ServerInfoResponse* serverInfoResp = [[ServerInfoResponse alloc] init];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:serverInfoResp withUrlRequest:[hMan newServerInfoRequest]
|
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:serverInfoResp withUrlRequest:[hMan newServerInfoRequest]
|
||||||
fallbackError:401 fallbackRequest:[hMan newHttpServerInfoRequest]]];
|
fallbackError:401 fallbackRequest:[hMan newHttpServerInfoRequest]]];
|
||||||
@@ -176,7 +176,7 @@ static NSArray* appList;
|
|||||||
if (host.online) {
|
if (host.online) {
|
||||||
[longClickAlert addAction:[UIAlertAction actionWithTitle:@"Unpair" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
[longClickAlert addAction:[UIAlertAction actionWithTitle:@"Unpair" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:host.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:host.activeAddress uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[hMan newUnpairRequest]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[hMan newUnpairRequest]]];
|
||||||
});
|
});
|
||||||
}]];
|
}]];
|
||||||
@@ -253,7 +253,7 @@ static NSArray* appList;
|
|||||||
- (void) appClicked:(App *)app {
|
- (void) appClicked:(App *)app {
|
||||||
Log(LOG_D, @"Clicked app: %@", app.appName);
|
Log(LOG_D, @"Clicked app: %@", app.appName);
|
||||||
_streamConfig = [[StreamConfiguration alloc] init];
|
_streamConfig = [[StreamConfiguration alloc] init];
|
||||||
_streamConfig.host = _selectedHost.address;
|
_streamConfig.host = _selectedHost.activeAddress;
|
||||||
_streamConfig.appID = app.appId;
|
_streamConfig.appID = app.appId;
|
||||||
|
|
||||||
DataManager* dataMan = [[DataManager alloc] init];
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
@@ -284,7 +284,7 @@ static NSArray* appList;
|
|||||||
[app.appId isEqualToString:currentApp.appId] ? @"Quit App" : @"Quit Running App and Start" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
|
[app.appId isEqualToString:currentApp.appId] ? @"Quit App" : @"Quit Running App and Start" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
|
||||||
Log(LOG_I, @"Quitting application: %@", currentApp.appName);
|
Log(LOG_I, @"Quitting application: %@", currentApp.appName);
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.activeAddress uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||||
HttpResponse* quitResponse = [[HttpResponse alloc] init];
|
HttpResponse* quitResponse = [[HttpResponse alloc] init];
|
||||||
HttpRequest* quitRequest = [HttpRequest requestForResponse: quitResponse withUrlRequest:[hMan newQuitAppRequest]];
|
HttpRequest* quitRequest = [HttpRequest requestForResponse: quitResponse withUrlRequest:[hMan newQuitAppRequest]];
|
||||||
[hMan executeRequestSynchronously:quitRequest];
|
[hMan executeRequestSynchronously:quitRequest];
|
||||||
@@ -442,6 +442,12 @@ static NSArray* appList;
|
|||||||
NSArray* hosts = [dataMan retrieveHosts];
|
NSArray* hosts = [dataMan retrieveHosts];
|
||||||
@synchronized(hostList) {
|
@synchronized(hostList) {
|
||||||
[hostList addObjectsFromArray:hosts];
|
[hostList addObjectsFromArray:hosts];
|
||||||
|
|
||||||
|
// Initialize the non-persistent host state
|
||||||
|
for (Host* host in hostList) {
|
||||||
|
host.online = NO;
|
||||||
|
host.activeAddress = host.address;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +455,7 @@ static NSArray* appList;
|
|||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
Log(LOG_D, @"New host list:");
|
Log(LOG_D, @"New host list:");
|
||||||
for (Host* host in hosts) {
|
for (Host* host in hosts) {
|
||||||
Log(LOG_D, @"Host: \n{\n\t name:%@ \n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", host.name, host.address, host.localAddress, host.externalAddress, host.uuid, host.mac, host.pairState, host.online);
|
Log(LOG_D, @"Host: \n{\n\t name:%@ \n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n\t activeAddress:%@ \n}", host.name, host.address, host.localAddress, host.externalAddress, host.uuid, host.mac, host.pairState, host.online, host.activeAddress);
|
||||||
}
|
}
|
||||||
@synchronized(hostList) {
|
@synchronized(hostList) {
|
||||||
[hostList removeAllObjects];
|
[hostList removeAllObjects];
|
||||||
|
|||||||
Reference in New Issue
Block a user