yume-chan / ya-webadb

ADB in your browser
https://tangoapp.dev/
MIT License
2.32k stars 304 forks source link

strange \x00 ends in reverse tunnel name #642

Closed oott123 closed 4 months ago

oott123 commented 4 months ago

Issue Checklist

Library version

0.0.23

Environment

nodejs 20.14.0

Device

XiaoMi MI 5, Android 13 (lineage_gemini-userdebug 13 TQ3A.230901.001 0f600396c1)

Describe the bug

When using reverse tunnel, nothing happens when access the port forwarded on the device.

Steps to reproduce

  1. clone and run https://github.com/oott123/webadb-usb-reproduce
  2. try nc 127.0.0.1 8899 on the device
  3. see the bug

I have add a patch in the dispatcher:

diff --git a/esm/daemon/dispatcher.js b/esm/daemon/dispatcher.js
index 8bca8b8dc9b542e96cb529235a171fd5ca545ecf..417f7e797316d88d179368230ac9e7c3518768fe 100644
--- a/esm/daemon/dispatcher.js
+++ b/esm/daemon/dispatcher.js
@@ -170,6 +170,7 @@ export class AdbPacketDispatcher {
         }
         const handler = this.#incomingSocketHandlers.get(service);
         if (!handler) {
+            console.log(['incoming service', service]);
             await this.sendPacket(AdbCommand.Close, 0, remoteId);
             return;
         }

And when I access the reverse tunnel on the device, the following log appears in the terminal:

[ 'incoming service', 'localabstract:reverse_9404414318601646\x00' ]

As you can see, there are a strange "\x00" at the end of the tunnel service name.

yume-chan commented 4 months ago

This is the root cause of #628.

This is a regression caused by https://github.com/yume-chan/ya-webadb/commit/ac6dc1e57c179da4d04dc702bd56f739887850a0#diff-8f0811eceb54fac2e33a4fb5e9fe839c02dd3c9ed1614ea08c45c0cff13348b9L196-L198

A new version will be released soon.

yume-chan commented 4 months ago

image

My publish token expired, and NPM is broken, so can't publish packages now...