Skip to content

Commit

Permalink
Narrow down network interfaces to local wifi only
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalzawadzki authored Jan 27, 2023
1 parent 148e2de commit 4a27a0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ios/FPStaticServer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ - (NSDictionary*) constantsToExport {
// Check if the current interface is of type AF_INET (IPv4)
// and not the loopback interface (lo0)
if(temp_addr->ifa_addr->sa_family == AF_INET) {
if(!(temp_addr->ifa_flags & IFF_LOOPBACK)) {
NSLog(@"Found IPv4 & non-loopback interface. Retrieving IP address.");
if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
NSLog(@"Found IPv4 address of the local wifi connection. Returning address.");
NSString *ip = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
resolve(ip);
return;
Expand Down

0 comments on commit 4a27a0e

Please sign in to comment.