Skip to content

Commit

Permalink
Force resolution of soft AP address to IPv4 (#1)
Browse files Browse the repository at this point in the history
Seen this resolving to an IPv6 address and failing connection with latest firmware.
  • Loading branch information
stonehouse authored Oct 30, 2023
1 parent 5ddba5e commit 3996c41
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/GCD/GCDAsyncSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -8277,7 +8277,21 @@ + (NSMutableArray *)lookupHost:(NSString *)host port:(uint16_t)port error:(NSErr
NSMutableArray *addresses = nil;
NSError *error = nil;

if ([host isEqualToString:@"localhost"] || [host isEqualToString:@"loopback"])
if ([host isEqualToString:@"172.16.0.1"] && port == 56700)
{
struct sockaddr_in nativeAddr4;
nativeAddr4.sin_len = sizeof(struct sockaddr_in);
nativeAddr4.sin_family = AF_INET;
nativeAddr4.sin_port = htons(port);
nativeAddr4.sin_addr.s_addr = htonl(0xAC100001); // 172.16.0.1
memset(&(nativeAddr4.sin_zero), 0, sizeof(nativeAddr4.sin_zero));

NSData *address4 = [NSData dataWithBytes:&nativeAddr4 length:sizeof(nativeAddr4)];

addresses = [NSMutableArray arrayWithCapacity:1];
[addresses addObject:address4];
}
else if ([host isEqualToString:@"localhost"] || [host isEqualToString:@"loopback"])
{
// Use LOOPBACK address
struct sockaddr_in nativeAddr4;
Expand Down

0 comments on commit 3996c41

Please sign in to comment.