Genymobile / gnirehtet

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

Using it wirelessly #23

Closed Zero3K closed 7 years ago

Zero3K commented 7 years ago

Is it possible to do so or not?

rom1v commented 7 years ago

Since adb can be used over TCP, it should in theory be possible. Unfortunately, this does not work.

First, connect your device to wifi, and get its IP:

adb shell netcfg

or

adb shell ifconfig

Then, switch its adb server to listen to port 5555:

adb tcpip 5555

Then, connect to it:

adb connect 5555

Unplug the device, you should be able to use a shell:

adb shell

Unfortunately, while adb forward works, adb reverse fails:

$ adb reverse tcp:31416 tcp:31416
error: more than one device/emulator

Even if this is the only device shown in adb devices, and all other adb commands work as expected. I tested with the very last adb (1.0.39).

Zero3K commented 7 years ago

Oh, here's something that should get it to work:

http://stackoverflow.com/questions/35269473/adb-error-more-than-one-device-android

rom1v commented 7 years ago

@Zero3K This is not the same problem. Here, adb device outputs exacly one device, and all adb commands work except adb reverse.

Zero3K commented 7 years ago

I'll try it out when my tablet is charged some more.

Zero3K commented 7 years ago

I can confirm that it doesn't work. Maybe its source could be modified to allow more than one device.

rom1v commented 7 years ago

Maybe its source could be modified to allow more than one device.

What do you mean?

Anyway, in that case, there is exactly one device, it's probably a bug in adb for the reverse command.

Zero3K commented 7 years ago

Could it be fixed?

rom1v commented 7 years ago

I have no fix for this. If you do, please suggest.

rom1v commented 7 years ago

A bug report exists: https://issuetracker.google.com/issues/37066218

Unfortunately, the problem occurs on the device side, so when it will be fixed, it will require to upgrade the device.

Zero3K commented 7 years ago

I am closing this issue since it is being taken care of by someone else.

xrisk commented 5 years ago

Hey, it seems this patch has been merged into Pi. adb reverse works successfully on my machine now.

When I try to ./gnirehtet run: the device successfully connects; I can see on my device that it's connected to the VPN; but no traffic is passed.

I can confirm that adb reverse is actually working: I tested with a file server on 31416 and I'm able to connect to it on localhost:31416 on my phone.

Output:

❯ ./gnirehtet run
2019-09-02 08:21:37.866 I Gnirehtet: Checking gnirehtet client...
2019-09-02 08:21:37.866 I Gnirehtet: Starting relay server...
2019-09-02 08:21:37.959 I Relay: Relay server started
2019-09-02 08:21:38.003 I Gnirehtet: Starting client...
Broadcasting: Intent { act=com.genymobile.gnirehtet.START flg=0x400000 cmp=com.genymobile.gnirehtet/.GnirehtetControlReceiver }
Broadcast completed: result=0
xrisk commented 5 years ago

Okay: so I am able to reliably get it working by:

  1. ./gnirehtet run
  2. Invariably, the adb reverse will break (adb reverse --list will be empty).
  3. Do ./gnirehtet tunnel
  4. Run ./gnirehtet start again.

I'm not sure if the reverse tunnel breaks because of a adb bug, or bug in the code.

However, starting a file server instead of the relay after the tunnel does not cause it to break; so I'm assuming it's a bug in the code.


Breaking it down further, if I:

  1. ./gnirehtet tunnel
  2. ./gnirehtet relay
  3. ./gnirehtet start <-- tunnel breaks here
  4. ./gnirehtet tunnel
  5. ./gnirehtet start <-- it begins to work here