diff --git a/VoidLink/Database/TemporaryHost.m b/VoidLink/Database/TemporaryHost.m index c9ba2fa3..58df6e55 100644 --- a/VoidLink/Database/TemporaryHost.m +++ b/VoidLink/Database/TemporaryHost.m @@ -89,7 +89,7 @@ NSError *error; parentHost.activeAddressPool = [NSKeyedArchiver archivedDataWithRootObject:self.activeAddressPool requiringSecureCoding:YES error:&error]; } - else [self.activeAddressPool addObject:self.activeAddress]; + else if(self.activeAddress) [self.activeAddressPool addObject:self.activeAddress]; // NSLog(@"Persisting activeAddressPool, pool count %lu ... %f, host: %@", (unsigned long)self.activeAddressPool.count, CACurrentMediaTime(), self.name); diff --git a/VoidLink/Network/DiscoveryManager.m b/VoidLink/Network/DiscoveryManager.m index 360e758e..7d63f5a2 100644 --- a/VoidLink/Network/DiscoveryManager.m +++ b/VoidLink/Network/DiscoveryManager.m @@ -142,7 +142,7 @@ host = [[TemporaryHost alloc] init]; host.activeAddress = host.address = hostAddress; if(!host.activeAddressPool) host.activeAddressPool = [[NSMutableSet alloc] init]; - [host.activeAddressPool addObject:host.activeAddress]; + if(host.activeAddress) [host.activeAddressPool addObject:host.activeAddress]; host.state = StateOnline; [serverInfoResponse populateHost:host]; @@ -288,7 +288,7 @@ existingHost.externalAddress = host.externalAddress; } existingHost.activeAddress = host.activeAddress; - [existingHost.activeAddressPool addObject:host.activeAddress]; + if(host.activeAddress) [existingHost.activeAddressPool addObject:host.activeAddress]; existingHost.state = host.state; return NO; // returning a "NO" here means Updating addresses of existing host } diff --git a/VoidLink/Network/DiscoveryWorker.m b/VoidLink/Network/DiscoveryWorker.m index 8a8c315f..ae454020 100644 --- a/VoidLink/Network/DiscoveryWorker.m +++ b/VoidLink/Network/DiscoveryWorker.m @@ -117,7 +117,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds if (receivedResponse) { _host.activeAddress = address; if(!_host.activeAddressPool) _host.activeAddressPool = [[NSMutableSet alloc] init]; - [_host.activeAddressPool addObject:address]; + if(address) [_host.activeAddressPool addObject:address]; [serverInfoResp populateHost:_host]; // Update the database using the response diff --git a/VoidLink/Network/ServerInfoResponse.m b/VoidLink/Network/ServerInfoResponse.m index 212598a3..67effdc1 100644 --- a/VoidLink/Network/ServerInfoResponse.m +++ b/VoidLink/Network/ServerInfoResponse.m @@ -46,7 +46,7 @@ // If we reached this host through this port, store our port there if (host.activeAddress && [lanAddr isEqualToString:[Utils addressPortStringToAddress:host.activeAddress]]) { localPort = [Utils addressPortStringToPort:host.activeAddress]; - [host.activeAddressPool addObject:host.activeAddress]; + if(host.activeAddress) [host.activeAddressPool addObject:host.activeAddress]; } else if (host.localAddress) { // If there's an existing local address, use the port from that @@ -58,7 +58,7 @@ } host.localAddress = [Utils addressAndPortToAddressPortString:lanAddr port:localPort]; - [host.activeAddressPool addObject:lanAddr]; + if(lanAddr) [host.activeAddressPool addObject:lanAddr]; } // This is a Sunshine extension for WAN port remapping