appium / WebDriverAgent

A WebDriver server for iOS and tvOS
Other
1.18k stars 368 forks source link

fix: Always assume en0 is the WiFi interface #864

Closed mykola-mokhnach closed 5 months ago

mykola-mokhnach commented 5 months ago

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

github-actions[bot] commented 5 months ago

:tada: This PR is included in version 7.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Jayxiang commented 5 months ago

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 commented 5 months ago

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

Jayxiang commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago
Jietu20240408@2x

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

KazuCocoa commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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.