beordle / termtunnel

Cross-platform terminal tunnel tool
MIT License
357 stars 36 forks source link

wsl remote_listen 监听失败 #24

Closed ghost closed 2 years ago

ghost commented 2 years ago

场景为 A(wsl2) -> B(windows 192.168.0.107) -> B(wsl2)

$ ./termtunnel ssh slll@192.168.0.107
$ export TERMTUNNEL_VERBOSE=1
$ ./termtunnel -a
MAGIC!
termtunnel> remote_listen 127.0.0.1 8000 127.0.0.1  0
bind done (guess)
termtunnel> exit

B上的termtunnel.log

2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/entry.c:117: agent pid 1401
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/pipe.c:155: libuv_add_vnet_notify 0
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/vnet.c:279: agent init
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/pipe.c:139: add queue
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/vnet.c:116: do listen
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/vnet.c:116: do listen
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/vnet.c:116: do listen
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/vnet.c:116: do listen
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/vnet.c:116: do listen
2022-05-10 11:51:00 INFO (1401) /home/slll/workspace/termtunnel-master/src/agent.c:228: agent_handle_binary data (42)

2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/agent.c:228: agent_handle_binary data (62)

2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/pipe.c:139: add queue
2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/agent.c:228: agent_handle_binary data (54)

2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/agent.c:228: agent_handle_binary data (58)

2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/agent.c:228: agent_handle_binary data (81)

2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/pipe.c:139: add queue
2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/vnet.c:119: new tcp
2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/agentcall.c:41: sd: 5
2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/agentcall.c:60: agent will bind 127.0.0.1:8000, write to 127.0.0.1:0
2022-05-10 11:51:14 DEBUG(1401) /home/slll/workspace/termtunnel-master/src/portforward.c:292: listen 8000
2022-05-10 11:51:14 DEBUG(1401) /home/slll/workspace/termtunnel-master/src/portforward.c:318: portforward_static_start
2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/pipe.c:139: add queue
2022-05-10 11:51:14 INFO (1401) /home/slll/workspace/termtunnel-master/src/agent.c:228: agent_handle_binary data (54)

2022-05-10 11:51:28 INFO (1401) /home/slll/workspace/termtunnel-master/src/agent.c:195: exit

A上并无8000端口

$ sudo netstat -anop
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name     Timer
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      292/sshd: /usr/sbin  off (0.00/0/0)
tcp        0      0 172.24.142.34:39686     192.168.0.107:22        ESTABLISHED 1299/ssh             keepalive (6921.73/0/0)
tcp6       0      0 :::22                   :::*                    LISTEN      292/sshd: /usr/sbin  off (0.00/0/0)
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
unix  2      [ ACC ]     SEQPACKET  LISTENING     20575    206/init             /run/WSL/206_interop
unix  2      [ ACC ]     SEQPACKET  LISTENING     20652    1018/init            /run/WSL/1018_interop

$ ps -ef | grep term
sll       1297   207  0 11:49 pts/0    00:00:00 ./termtunnel ssh slll@192.168.0.107
sll       1298  1297  0 11:49 ?        00:00:00 ./termtunnel ssh slll@192.168.0.107
beordle commented 2 years ago

remote_listen 应该是在B上 listen 的,这个有点反直觉。 remote_listen就是监听在远程。 local_listen 就是监听在本地。

ghost commented 2 years ago

remote_listen 应该是在B上 listen 的,这个有点反直觉。 remote_listen就是监听在远程。 local_listen 就是监听在本地。

感谢答复 :frowning:

beordle commented 2 years ago

如果不稳定,可以更新到最新的代码哈~