Genymobile / gnirehtet

Gnirehtet provides reverse tethering for Android
Apache License 2.0
6.23k stars 571 forks source link

doesn't work on linux using adb -L localfilesystem:/tmp/sockfile #305

Open manoflinux opened 4 years ago

manoflinux commented 4 years ago

doesn't work on linux using adb -L localfilesystem:/tmp/sockfile I know alot of people probably don't know about the -L option as it seems to be only added with newer versions of adb, but it allows you to specify the server by using a sock specification, which is by default tcp:ip:port, but by looking at the code I was able to find out the format localfilesystem:/pathto/sockfile worked as well. My problem is I am using adb on a machine with two active ethernet connections under linux and adb doesn't work at all as far as I can tell in that situation(it runs but nothing is able to contact it which causes adb to spawn another which fails because the first one still has the socket, if someone has some advice please tell me) except with a sock file. If I use -a it tries to listen on only localhost and not all interfaces, which has the same problem. but with a sockfile it works fine, I am able to run a shell, list devices, do all the commands you list in the manual section with no errors, but gnirehtet still doesn't work. I have reinstalled the apk using adb and gnirehtet same effect. I have tried using it on both a windows and linux box with only one active network connection and it works fine, both adp on an ip and gnirehtet.

So to stop gnirehtet from trying to spawn adp instances not using a sockfile I wrote a wrapper which appends the socket command to the beginning of every command line. That got gnirehtet running, but it still doesn't seem to work. When I run it with autorun I get

2020-06-02 07:04:20.668 INFO AdbMonitor: Restarting adb daemon
2020-06-02 07:06:31.740 ERROR AdbMonitor: Failed to monitor adb devices: Connection timed out (os error 110)
2020-06-02 07:06:31.740 INFO AdbMonitor: Restarting adb daemon
2020-06-02 07:08:42.812 ERROR AdbMonitor: Failed to monitor adb devices: Connection timed out (os error 110)
2020-06-02 07:08:42.812 INFO AdbMonitor: Restarting adb daemon
2020-06-02 07:10:53.884 ERROR AdbMonitor: Failed to monitor adb devices: Connection timed out (os error 110)
2020-06-02 07:10:53.884 INFO AdbMonitor: Restarting adb daemon

over and over again. I have tried run as well and it doesn't work, if you need more info I can provide that.

This makes me think that gnirehtet or some library it uses is trying to connect via tcp without trying the sockfile. Am I right? It would be nice to pass the -L socket to gnirehtet through a command line option as well.

Here is the wrapper I wrote, I renamed the original adb to adb.orig and put this shell script in its place, just vi adb and cut and paste this in it to get farther.

!/bin/bash

./adb.orig -L localfilesystem:/tmp/sockfile "$@"

rom1v commented 4 years ago

You could use the env variable ADB_SERVER_SOCKET, which should have the same effect as -L.

https://github.com/Genymobile/scrcpy/issues/144#issue-321600201

manoflinux commented 4 years ago

nice! thanks. I will try that when I get a chance. If that will change the behavior of gnirehtet as well then that is probably the solution.

manoflinux commented 4 years ago

that does eliminate the need for the wrapper, thanks! But it seems to do the same. run does the same, and running adb devices while its running takes forever.
./gnirehtet run 2020-06-02 13:53:22.472 INFO Main: Starting relay server on port 31416... 2020-06-02 13:53:22.472 INFO Relay: Relay server started 2020-06-02 13:53:22.473 INFO Main: Checking gnirehtet client... 2020-06-02 13:53:22.603 INFO Main: Starting client... Starting: Intent { act=com.genymobile.gnirehtet.START cmp=com.genymobile.gnirehtet/.GnirehtetActivity }

and no internet on the device till I reboot it.