Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Always assume en0 is the WiFi interface #864

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

mykola-mokhnach
Copy link

We must only assume that the en0 is the device's Wi-Fi interface instead of any interface whose name starts with en. See https://stackoverflow.com/questions/30748480/swift-get-devices-wifi-ip-address for more details

@mykola-mokhnach mykola-mokhnach merged commit 6dbfb3f into master Mar 14, 2024
46 checks passed
@mykola-mokhnach mykola-mokhnach deleted the wifi_ip branch March 14, 2024 06:31
github-actions bot pushed a commit that referenced this pull request Mar 14, 2024
## [7.1.2](v7.1.1...v7.1.2) (2024-03-14)

### Bug Fixes

* Always assume en0 is the WiFi interface ([#864](#864)) ([6dbfb3f](6dbfb3f))
Copy link

🎉 This PR is included in version 7.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Jayxiang
Copy link

Jayxiang commented Apr 7, 2024

After the change, the obtained IP address cannot be directly opened in the browser anymore, while previously, the IP address could be directly opened on ports 8100 or 9100. @mykola-mokhnach @KazuCocoa

@KazuCocoa
Copy link
Member

My a couple of real devices had no issue with this. What kind of ip addresses were assigned to your en interfaces?

@Jayxiang
Copy link

Jayxiang commented Apr 8, 2024

My en interfaces were assigned an IP address corresponding to "phone.local-169.254.9.200" instead of the IPv4 address of the device.

@KazuCocoa
Copy link
Member

KazuCocoa commented Apr 8, 2024

How did you configure the ip address?

Could you share the list of assigned IP addresses like the below?
https://stackoverflow.com/questions/7072989/how-to-get-my-ip-address-programmatically-on-ios-macos

e.g. addresses:
Screenshot 2024-04-07 at 8 41 18 PM

I assume in the previous implementation, if(![interfaceName containsString:@"en"]) {, your env returned ipv4 accidentally. The result could also be the phone.local-169.254.9.200 but the order was fortunately not en0 as the beginning.

@Jayxiang
Copy link

Jayxiang commented Apr 8, 2024

Jietu20240408@2x

if(![interfaceName containsString:@"en"]) {return en2

@KazuCocoa
Copy link
Member

So, en0, which was expected to be WiFi's primary IP address, was 10.18.10???, but your env also had an accessibble 169.254.9.200? Perhaps we could show possible IP v4 addresses as the device as another method then

@Jayxiang
Copy link

Jayxiang commented Apr 8, 2024

Yes, 10.18 is the IP address of WiFi, but I cannot open the corresponding ports 8100 or 9100 in the browser. However, the 169.254 returned by en2 can directly open port 9100. Can you directly open port 9100 using the IP returned by en0?

@KazuCocoa
Copy link
Member

Yes. my env's primary local ip address which is available via the device's Settings app is the en0.
My device had another IP address, 169.254.119.165, also worked as same as en0, but it was not exposed to users via the Settings app. Perhaps it was for https://stackoverflow.com/questions/21464364/how-does-the-ios-reachability-class-work-and-why-the-ip-address-169-254-0-0#:~:text=When%20you%20fail%20to%20get%20an%20IP%20address,unable%20to%20obtain%20an%20IP%20address%20from%20DHCP. so in this method's intention, the address is not expected.

@KazuCocoa
Copy link
Member

KazuCocoa commented Apr 8, 2024

Btw, I guess 10.18.... could be your own private network. Could it block some network requests? What IP address is available via your device's Settings -> WiFi config?

@Jayxiang
Copy link

Jayxiang commented Apr 8, 2024

Btw, I guess 10.18.... could be your own private network. Could it block some network requests?

It is possible, as I am using the company's network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants