fatedier / frp

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
Apache License 2.0
85.59k stars 13.26k forks source link

求帮忙,xtcp打洞失败,挂了很久也不行,其他配置可以 ,不知道是不是配置写错了还是啥问题 #4254

Closed mojerro closed 4 months ago

mojerro commented 4 months ago

Bug Description

p2p打洞失败

frpc Version

0.58.0

frps Version

0.58.0

System Architecture

ubuntu,不过frpc是在wsl2里

Configurations

frps

bindPort  = 27000
vhostHTTPPort = 27001
log.to = "./frps.log"

frpc-1 本地树莓派

serverAddr = "frp.xxx.xxx"
serverPort = 27000
[[proxies]]
name = "p2p_ssh"
type = "xtcp"
# 只有 secretKey 一致的用户才能访问到此服务
secretKey = "0327"
localIP = "127.0.0.1"
localPort = 22

frpc-visitor win10的wsl

serverAddr = "frp.xxx.xxx"
serverPort = 27000
log.level = "trace"

[[visitors]]
name = "p2p_ssh_visitor"
type = "xtcp"
protocol = "quic" # quic kcp 换kcp更不行
# 要访问的 P2P 代理的名称
serverName = "p2p_ssh"
secretKey = "0327"
maxRetriesAnHour = 6
minRetryInterval = 10
# 绑定本地端口以访问 SSH 服务
bindAddr = "127.0.0.1"
bindPort = 40000
# 如果需要自动保持隧道打开,将其设置为 true
keepTunnelOpen = true

Logs

xxx.xxx.xxx.xxx 是我本机的公网IP

2024-05-31 19:44:27 2024-05-31 11:44:27.638 [I] [sub/root.go:142] start frpc service for config file [/etc/frp/frpc.toml]
2024-05-31 19:44:27 2024-05-31 11:44:27.638 [I] [client/service.go:294] try to connect to server...
2024-05-31 19:44:27 2024-05-31 11:44:27.727 [I] [client/service.go:286] [d76149aaf41286e7] login to server success, get run id [d76149aaf41286e7]
2024-05-31 19:44:27 2024-05-31 11:44:27.727 [I] [visitor/visitor_manager.go:121] [d76149aaf41286e7] start visitor success
2024-05-31 19:44:27 2024-05-31 11:44:27.727 [I] [visitor/visitor_manager.go:172] [d76149aaf41286e7] visitor added: [p2p_ssh_visitor]
2024-05-31 19:44:27 2024-05-31 11:44:27.727 [I] [client/service.go:184] admin server listen on 127.0.0.1:7400
2024-05-31 19:44:27 2024-05-31 11:44:27.727 [T] [visitor/xtcp.go:271] [d76149aaf41286e7] [p2p_ssh_visitor] makeNatHole start
2024-05-31 19:44:27 2024-05-31 11:44:27.741 [T] [visitor/xtcp.go:277] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare start
2024-05-31 19:44:28 2024-05-31 11:44:28.205 [I] [visitor/xtcp.go:283] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare success, nat type: HardNAT, behavior: BehaviorPortChanged, addresses: [xxx.xxx.xxx.xxx:11871 xxx.xxx.xxx.xxx:11872], assistedAddresses: [192.168.65.6:48436 192.168.65.3:48436 172.18.0.1:48436 172.17.0.1:48436 172.19.0.1:48436]
2024-05-31 19:44:28 2024-05-31 11:44:28.207 [T] [visitor/xtcp.go:301] [d76149aaf41286e7] [p2p_ssh_visitor] nathole exchange info start
2024-05-31 19:44:29 2024-05-31 11:44:29.861 [I] [visitor/xtcp.go:309] [d76149aaf41286e7] [p2p_ssh_visitor] get natHoleRespMsg, sid [171715586802891f7c4c859937], protocol [quic], candidate address [xxx.xxx.xxx.xxx:11873], assisted address [192.168.3.199:44583 172.17.0.1:44583], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-05-31 19:44:29 2024-05-31 11:44:29.862 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:48436 to 192.168.3.199:44583
2024-05-31 19:44:29 2024-05-31 11:44:29.862 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:48436 to 172.17.0.1:44583
2024-05-31 19:44:29 2024-05-31 11:44:29.862 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:48436 to xxx.xxx.xxx.xxx:11873
2024-05-31 19:44:34 2024-05-31 11:44:34.864 [W] [visitor/xtcp.go:316] [d76149aaf41286e7] [p2p_ssh_visitor] make hole error: wait detect message error: read udp4 0.0.0.0:48436: i/o timeout
2024-05-31 19:44:37 2024-05-31 11:44:37.727 [D] [visitor/xtcp.go:143] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker try to check tunnel...
2024-05-31 19:44:37 2024-05-31 11:44:37.727 [W] [visitor/xtcp.go:146] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2024-05-31 19:44:37 2024-05-31 11:44:37.728 [T] [visitor/xtcp.go:271] [d76149aaf41286e7] [p2p_ssh_visitor] makeNatHole start
2024-05-31 19:44:37 2024-05-31 11:44:37.741 [T] [visitor/xtcp.go:277] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare start
2024-05-31 19:44:38 2024-05-31 11:44:38.280 [I] [visitor/xtcp.go:283] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare success, nat type: HardNAT, behavior: BehaviorPortChanged, addresses: [xxx.xxx.xxx.xxx:11888 xxx.xxx.xxx.xxx:11889], assistedAddresses: [192.168.65.6:56846 192.168.65.3:56846 172.18.0.1:56846 172.17.0.1:56846 172.19.0.1:56846]
2024-05-31 19:44:38 2024-05-31 11:44:38.280 [T] [visitor/xtcp.go:301] [d76149aaf41286e7] [p2p_ssh_visitor] nathole exchange info start
2024-05-31 19:44:39 2024-05-31 11:44:39.905 [I] [visitor/xtcp.go:309] [d76149aaf41286e7] [p2p_ssh_visitor] get natHoleRespMsg, sid [1717155878346b6b72cf6b40a1], protocol [quic], candidate address [xxx.xxx.xxx.xxx:11891], assisted address [192.168.3.199:49766 172.17.0.1:49766], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-05-31 19:44:39 2024-05-31 11:44:39.905 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:56846 to 192.168.3.199:49766
2024-05-31 19:44:39 2024-05-31 11:44:39.905 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:56846 to 172.17.0.1:49766
2024-05-31 19:44:39 2024-05-31 11:44:39.905 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:56846 to xxx.xxx.xxx.xxx:11891
2024-05-31 19:44:44 2024-05-31 11:44:44.906 [W] [visitor/xtcp.go:316] [d76149aaf41286e7] [p2p_ssh_visitor] make hole error: wait detect message error: read udp4 0.0.0.0:56846: i/o timeout
2024-05-31 19:44:47 2024-05-31 11:44:47.728 [D] [visitor/xtcp.go:143] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker try to check tunnel...
2024-05-31 19:44:47 2024-05-31 11:44:47.728 [W] [visitor/xtcp.go:146] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2024-05-31 19:44:47 2024-05-31 11:44:47.728 [T] [visitor/xtcp.go:271] [d76149aaf41286e7] [p2p_ssh_visitor] makeNatHole start
2024-05-31 19:44:47 2024-05-31 11:44:47.743 [T] [visitor/xtcp.go:277] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare start
2024-05-31 19:44:48 2024-05-31 11:44:48.225 [I] [visitor/xtcp.go:283] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare success, nat type: HardNAT, behavior: BehaviorPortChanged, addresses: [xxx.xxx.xxx.xxx:11908 xxx.xxx.xxx.xxx:11909], assistedAddresses: [192.168.65.6:46152 192.168.65.3:46152 172.18.0.1:46152 172.17.0.1:46152 172.19.0.1:46152]
2024-05-31 19:44:48 2024-05-31 11:44:48.225 [T] [visitor/xtcp.go:301] [d76149aaf41286e7] [p2p_ssh_visitor] nathole exchange info start
2024-05-31 19:44:49 2024-05-31 11:44:49.744 [I] [visitor/xtcp.go:309] [d76149aaf41286e7] [p2p_ssh_visitor] get natHoleRespMsg, sid [1717155888bef6c4ecf5c1b709], protocol [quic], candidate address [xxx.xxx.xxx.xxx:11911], assisted address [192.168.3.199:58436 172.17.0.1:58436], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-05-31 19:44:49 2024-05-31 11:44:49.744 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:46152 to 192.168.3.199:58436
2024-05-31 19:44:49 2024-05-31 11:44:49.744 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:46152 to 172.17.0.1:58436
2024-05-31 19:44:49 2024-05-31 11:44:49.744 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:46152 to xxx.xxx.xxx.xxx:11911
2024-05-31 19:44:54 2024-05-31 11:44:54.748 [W] [visitor/xtcp.go:316] [d76149aaf41286e7] [p2p_ssh_visitor] make hole error: wait detect message error: read udp4 0.0.0.0:46152: i/o timeout
2024-05-31 19:44:57 2024-05-31 11:44:57.729 [D] [visitor/xtcp.go:143] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker try to check tunnel...
2024-05-31 19:44:57 2024-05-31 11:44:57.729 [T] [visitor/xtcp.go:271] [d76149aaf41286e7] [p2p_ssh_visitor] makeNatHole start
2024-05-31 19:44:57 2024-05-31 11:44:57.729 [W] [visitor/xtcp.go:146] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2024-05-31 19:44:57 2024-05-31 11:44:57.742 [T] [visitor/xtcp.go:277] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare start
2024-05-31 19:44:58 2024-05-31 11:44:58.233 [I] [visitor/xtcp.go:283] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare success, nat type: HardNAT, behavior: BehaviorPortChanged, addresses: [xxx.xxx.xxx.xxx:11939 xxx.xxx.xxx.xxx:11940], assistedAddresses: [192.168.65.6:57844 192.168.65.3:57844 172.18.0.1:57844 172.17.0.1:57844 172.19.0.1:57844]
2024-05-31 19:44:58 2024-05-31 11:44:58.233 [T] [visitor/xtcp.go:301] [d76149aaf41286e7] [p2p_ssh_visitor] nathole exchange info start
2024-05-31 19:44:59 2024-05-31 11:44:59.923 [I] [visitor/xtcp.go:309] [d76149aaf41286e7] [p2p_ssh_visitor] get natHoleRespMsg, sid [1717155898c606044e1fc5145c], protocol [quic], candidate address [xxx.xxx.xxx.xxx:11941], assisted address [192.168.3.199:38164 172.17.0.1:38164], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-05-31 19:44:59 2024-05-31 11:44:59.924 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:57844 to 192.168.3.199:38164
2024-05-31 19:44:59 2024-05-31 11:44:59.924 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:57844 to 172.17.0.1:38164
2024-05-31 19:44:59 2024-05-31 11:44:59.924 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:57844 to xxx.xxx.xxx.xxx:11941
2024-05-31 19:45:04 2024-05-31 11:45:04.924 [W] [visitor/xtcp.go:316] [d76149aaf41286e7] [p2p_ssh_visitor] make hole error: wait detect message error: read udp4 0.0.0.0:57844: i/o timeout
2024-05-31 19:45:07 2024-05-31 11:45:07.725 [D] [visitor/xtcp.go:143] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker try to check tunnel...
2024-05-31 19:45:07 2024-05-31 11:45:07.726 [W] [visitor/xtcp.go:146] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2024-05-31 19:45:17 2024-05-31 11:45:17.733 [D] [visitor/xtcp.go:143] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker try to check tunnel...
2024-05-31 19:45:17 2024-05-31 11:45:17.733 [W] [visitor/xtcp.go:146] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2024-05-31 19:45:17 2024-05-31 11:45:17.733 [T] [visitor/xtcp.go:271] [d76149aaf41286e7] [p2p_ssh_visitor] makeNatHole start
2024-05-31 19:45:17 2024-05-31 11:45:17.746 [T] [visitor/xtcp.go:277] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare start
2024-05-31 19:45:18 2024-05-31 11:45:18.244 [I] [visitor/xtcp.go:283] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare success, nat type: HardNAT, behavior: BehaviorPortChanged, addresses: [xxx.xxx.xxx.xxx:11976 xxx.xxx.xxx.xxx:11977], assistedAddresses: [192.168.65.6:49678 192.168.65.3:49678 172.18.0.1:49678 172.17.0.1:49678 172.19.0.1:49678]
2024-05-31 19:45:18 2024-05-31 11:45:18.244 [T] [visitor/xtcp.go:301] [d76149aaf41286e7] [p2p_ssh_visitor] nathole exchange info start
2024-05-31 19:45:19 2024-05-31 11:45:19.856 [I] [visitor/xtcp.go:309] [d76149aaf41286e7] [p2p_ssh_visitor] get natHoleRespMsg, sid [17171559185baeeda4c90d936b], protocol [quic], candidate address [xxx.xxx.xxx.xxx:11979], assisted address [192.168.3.199:34204 172.17.0.1:34204], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-05-31 19:45:19 2024-05-31 11:45:19.856 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:49678 to 192.168.3.199:34204
2024-05-31 19:45:19 2024-05-31 11:45:19.856 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:49678 to 172.17.0.1:34204
2024-05-31 19:45:19 2024-05-31 11:45:19.856 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:49678 to xxx.xxx.xxx.xxx:11979
2024-05-31 19:45:24 2024-05-31 11:45:24.860 [W] [visitor/xtcp.go:316] [d76149aaf41286e7] [p2p_ssh_visitor] make hole error: wait detect message error: read udp4 0.0.0.0:49678: i/o timeout
2024-05-31 19:45:27 2024-05-31 11:45:27.726 [D] [visitor/xtcp.go:143] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker try to check tunnel...
2024-05-31 19:45:27 2024-05-31 11:45:27.726 [W] [visitor/xtcp.go:146] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2024-05-31 19:45:37 2024-05-31 11:45:37.725 [D] [visitor/xtcp.go:143] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker try to check tunnel...
2024-05-31 19:45:37 2024-05-31 11:45:37.725 [W] [visitor/xtcp.go:146] [d76149aaf41286e7] [p2p_ssh_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2024-05-31 19:45:37 2024-05-31 11:45:37.725 [T] [visitor/xtcp.go:271] [d76149aaf41286e7] [p2p_ssh_visitor] makeNatHole start
2024-05-31 19:45:37 2024-05-31 11:45:37.737 [T] [visitor/xtcp.go:277] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare start
2024-05-31 19:45:38 2024-05-31 11:45:38.265 [I] [visitor/xtcp.go:283] [d76149aaf41286e7] [p2p_ssh_visitor] nathole prepare success, nat type: HardNAT, behavior: BehaviorPortChanged, addresses: [xxx.xxx.xxx.xxx:11999 xxx.xxx.xxx.xxx:12000], assistedAddresses: [192.168.65.6:35757 192.168.65.3:35757 172.18.0.1:35757 172.17.0.1:35757 172.19.0.1:35757]
2024-05-31 19:45:38 2024-05-31 11:45:38.265 [T] [visitor/xtcp.go:301] [d76149aaf41286e7] [p2p_ssh_visitor] nathole exchange info start
2024-05-31 19:45:39 2024-05-31 11:45:39.793 [I] [visitor/xtcp.go:309] [d76149aaf41286e7] [p2p_ssh_visitor] get natHoleRespMsg, sid [1717155938cb15fbb4e7263127], protocol [quic], candidate address [xxx.xxx.xxx.xxx:12001], assisted address [192.168.3.199:52635 172.17.0.1:52635], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-05-31 19:45:39 2024-05-31 11:45:39.793 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:35757 to 192.168.3.199:52635
2024-05-31 19:45:39 2024-05-31 11:45:39.793 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:35757 to 172.17.0.1:52635
2024-05-31 19:45:39 2024-05-31 11:45:39.793 [T] [nathole/nathole.go:332] [d76149aaf41286e7] [p2p_ssh_visitor] send sid message from 0.0.0.0:35757 to xxx.xxx.xxx.xxx:12001
2024-05-31 19:45:44 2024-05-31 11:45:44.796 [W] [visitor/xtcp.go:316] [d76149aaf41286e7] [p2p_ssh_visitor] make hole error: wait detect message error: read udp4 0.0.0.0:35757: i/o timeout

Steps to reproduce

No response

Affected area

xqzr commented 4 months ago

nat type: HardNAT

mojerro commented 4 months ago

HardNAT是就无法打洞吗

xqzr commented 4 months ago

HardNAT是就无法打洞吗

困难

wuai1024 commented 4 months ago

先让 frpc-1NAT 类型变为 EasyNAT

fatedier commented 4 months ago

xtcp 不成功是正常的,本身只有一定成功率,不会100%成功。

这部分的调试也是很复杂的,不是简单的看下日志就能定位的。尽量提供到 frpc 两端和 frps 的日志也许会有一点帮助。