try to fix app crash caused by host discovery

This commit is contained in:
True Zhuanjia committed 2026-03-12 19:44:13 +08:00
1 parent 4dd1aad123
commit 92fca9bca1
4 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -89,7 +89,7 @@
NSError *error; NSError *error;
parentHost.activeAddressPool = [NSKeyedArchiver archivedDataWithRootObject:self.activeAddressPool requiringSecureCoding:YES error:&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); // NSLog(@"Persisting activeAddressPool, pool count %lu ... %f, host: %@", (unsigned long)self.activeAddressPool.count, CACurrentMediaTime(), self.name);
+2 -2
View File
@@ -142,7 +142,7 @@
host = [[TemporaryHost alloc] init]; host = [[TemporaryHost alloc] init];
host.activeAddress = host.address = hostAddress; host.activeAddress = host.address = hostAddress;
if(!host.activeAddressPool) host.activeAddressPool = [[NSMutableSet alloc] init]; if(!host.activeAddressPool) host.activeAddressPool = [[NSMutableSet alloc] init];
[host.activeAddressPool addObject:host.activeAddress]; if(host.activeAddress) [host.activeAddressPool addObject:host.activeAddress];
host.state = StateOnline; host.state = StateOnline;
[serverInfoResponse populateHost:host]; [serverInfoResponse populateHost:host];
@@ -288,7 +288,7 @@
existingHost.externalAddress = host.externalAddress; existingHost.externalAddress = host.externalAddress;
} }
existingHost.activeAddress = host.activeAddress; existingHost.activeAddress = host.activeAddress;
[existingHost.activeAddressPool addObject:host.activeAddress]; if(host.activeAddress) [existingHost.activeAddressPool addObject:host.activeAddress];
existingHost.state = host.state; existingHost.state = host.state;
return NO; // returning a "NO" here means Updating addresses of existing host return NO; // returning a "NO" here means Updating addresses of existing host
} }
+1 -1
View File
@@ -117,7 +117,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
if (receivedResponse) { if (receivedResponse) {
_host.activeAddress = address; _host.activeAddress = address;
if(!_host.activeAddressPool) _host.activeAddressPool = [[NSMutableSet alloc] init]; if(!_host.activeAddressPool) _host.activeAddressPool = [[NSMutableSet alloc] init];
[_host.activeAddressPool addObject:address]; if(address) [_host.activeAddressPool addObject:address];
[serverInfoResp populateHost:_host]; [serverInfoResp populateHost:_host];
// Update the database using the response // Update the database using the response
+2 -2
View File
@@ -46,7 +46,7 @@
// If we reached this host through this port, store our port there // If we reached this host through this port, store our port there
if (host.activeAddress && [lanAddr isEqualToString:[Utils addressPortStringToAddress:host.activeAddress]]) { if (host.activeAddress && [lanAddr isEqualToString:[Utils addressPortStringToAddress:host.activeAddress]]) {
localPort = [Utils addressPortStringToPort:host.activeAddress]; localPort = [Utils addressPortStringToPort:host.activeAddress];
[host.activeAddressPool addObject:host.activeAddress]; if(host.activeAddress) [host.activeAddressPool addObject:host.activeAddress];
} }
else if (host.localAddress) { else if (host.localAddress) {
// If there's an existing local address, use the port from that // If there's an existing local address, use the port from that
@@ -58,7 +58,7 @@
} }
host.localAddress = [Utils addressAndPortToAddressPortString:lanAddr port:localPort]; 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 // This is a Sunshine extension for WAN port remapping