From 832b9189f8b02bb2f7fe2e06f8c26851cf29e61b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 2 Sep 2017 19:47:47 -0700 Subject: [PATCH] Fix mDNS overriding manually specified addresses --- Limelight/Network/DiscoveryManager.m | 21 ++++++++++++++++++++- Limelight/Network/MDNSManager.m | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Limelight/Network/DiscoveryManager.m b/Limelight/Network/DiscoveryManager.m index 24dccfc..286fa34 100644 --- a/Limelight/Network/DiscoveryManager.m +++ b/Limelight/Network/DiscoveryManager.m @@ -102,10 +102,29 @@ TemporaryHost *existingHost = [self getHostInDiscovery:host.uuid]; if (existingHost != nil) { // Update address of existing host - existingHost.address = existingHost.activeAddress = host.address; + if (host.address != nil) { + existingHost.address = host.address; + } + if (host.localAddress != nil) { + existingHost.localAddress = host.localAddress; + } + if (host.externalAddress != nil) { + existingHost.externalAddress = host.externalAddress; + } + existingHost.activeAddress = host.activeAddress; return NO; } else { + // If we were added without an explicit address, + // populate it from our other available addresses + if (host.address == nil) { + if (host.externalAddress != nil) { + host.address = host.externalAddress; + } + else { + host.address = host.localAddress; + } + } [_hostQueue addObject:host]; if (shouldDiscover) { [_opQueue addOperation:[self createWorkerForHost:host]]; diff --git a/Limelight/Network/MDNSManager.m b/Limelight/Network/MDNSManager.m index c35a197..099c108 100644 --- a/Limelight/Network/MDNSManager.m +++ b/Limelight/Network/MDNSManager.m @@ -49,8 +49,8 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp"; for (NSNetService* service in services) { if (service.hostName != nil) { TemporaryHost* host = [[TemporaryHost alloc] init]; - host.activeAddress = host.address = service.hostName; - host.name = host.address; + host.activeAddress = host.localAddress = service.hostName; + host.name = service.hostName; [hosts addObject:host]; } }