libimobiledevice / libusbmuxd

A client library to multiplex connections from and to iOS devices
https://libimobiledevice.org
GNU Lesser General Public License v2.1
581 stars 271 forks source link

Cannot find iPhone via network (idevice_id -n) #88

Open fosple opened 4 years ago

fosple commented 4 years ago

I saw in https://github.com/libimobiledevice/libusbmuxd/blob/master/NEWS that network support was added to libusbmuxd and I'm super happy about that fact 👍

However, I don't get it working. I've compiled and installed the latest version of all the needed libraries (libimobiledevice, libplist, libusbmuxd, usbmuxd) from source on my Raspberry Pi 4 (OS: Debian Buster).

Via USB the IPhone shows up. So I connected the iPhone via USB and paired it (idevicepair pair) before I tried to connect via network.

However, after unplugging the iPhone from USB and trying to connect to it via the network I didn't get any result:

sudo usbmuxd -s -v
[19:56:08.141][3] usbmuxd v1.1.1 starting up
[19:56:08.141][4] Creating socket
[19:56:08.142][4] Initializing USB
[19:56:08.159][4] Registering for libusb hotplug events
[19:56:08.159][4] 0 devices detected
[19:56:08.159][3] Initialization complete
[19:56:08.159][3] Enabled exit on SIGUSR1 if no devices are attached. Start a new instance with "--exit" to trigger.                                                      
[19:56:11.902][4] New client on fd 11 (pid 16768)
[19:56:11.904][4] Client 11 connection closed
[19:56:11.904][4] Disconnecting client fd 11
idevice_id -n
# no result

Further infos:

Would be super nice if you can help me :) Or could it be that the open source version of usbmuxd does not support network connections and only the proprietary one from Apple (on Windows and MacOS) supports it which is used by libusbmuxd when available?

leodeve commented 4 months ago

Firstly, I wanted to find my iPhone with the idevice_id -n command inside a docker container. I installed libimobiledevice with usbmuxd2 in my container. However, I couldn't find my iPhone. So, I installed it directly on my PC and it worked. Then, I tried again with my docker container. This time, it worked because the usbmuxd2 service was running on my PC. If I stop the service on my PC, I can't find my iPhone with the idevice_id -n command in my container.

mexmer commented 3 months ago

libusbmuxd (and tools build on top of it, which includes ideviceid) connect to usbmuxd trough socket, since you are running usbmuxd2 in container, you not only need to run docker container with usbmuxd in hostnetwork mode, but you also need to expose ubsmuxd2 listening port

normaly socket is /var/run/usbmuxd, but usbmuxd can be also built to listen to request on TCP port 27015 (this is port of apple service) you can "force" libusbmuxd based tools to use TCP by setting environment variable for example

USBMUXD_SOCKET_ADDRESS=127.0.0.1:27015

see https://github.com/libimobiledevice/libusbmuxd/blob/a7f0543fb1ecb20ac7121c0fd77297200e0e43fc/src/libusbmuxd.c#L161 how the value is processed, but i'm not sure, if you can build and run usbmuxd on linux that will listen to TCP socket.

on windows it's the only way, because that's how AMDservice on windows works.

for you it did work for you trough usbmuxd2 running on host, because ideviceid connected trough unix socket (read from /var/run)

what i would do is to run container with usbmuxd2, that have mapped /var/run to let's say /mydocker/sharedrun in host network mode run ideviceid in container that have mapped /var/run to same folder eg. /mydocker/sharedrun, it will use ubsmuxd socket file to communicate with other container, and see, what usbmuxd2 in container see

sharing socket between docker containers is working method that is commonly used, althought from security standpoint it's not best solution (since socket is also accessible from host, not just from containers)

leodeve commented 2 months ago

Sorry for taking so long to reply. I am not sure to understand your answer.

Here is what you suggest if I understood well:

Is that right?

Blackspell01 commented 2 days ago

I can see my iPhone with idevice_id -n but not connect to it. It says:

ERROR: [SRP] Invalid PIN
ERROR: Pairing with device 00008120-00**********0201E failed.

Does someone know what the problem could be?