go-gost / gost

GO Simple Tunnel - a simple tunnel written in golang
https://gost.run
MIT License
4.39k stars 528 forks source link

在网关实现网内udp透明代理,使用QUIC数据通道报错 #413

Open 123131513 opened 9 months ago

123131513 commented 9 months ago

linux A为 网关服务端,有公网IP linux B为 落地服务器,有公网IP,接收来自linux A转发过来的数据包并处理 linux C为全内网,可以访问A linux D为全内网,可以访问B,为最终的目标主机

linux C数据包通过linux A的透明代理转发到linux B,linux B处理后转发到linux D实现通信,其中只在linux A和linux B上运行gost服务

不使用QUIC数据通道而使用基于TCP的数据通道是可以通信成功,指令如下 linux A 启动命令: nohup ./gost -L redu://:12345?ttl=30s -D -F relay+tls://10.0.1.3:8888?so_mark=100 >> /dev/null 2>&1 &

linux B 启动命令: nohup ./gost -L "relay+tls://:8888?ttl=30s&so_mark=100" >> /dev/null 2>&1 &

此时实现了linux C和linux D之间的通信

使用QUIC数据通道时指令如下 linux A 启动命令: nohup ./gost -L redu://:12345?ttl=30s -F "relay+quic://10.0.1.3:8888?so_mark=100&keepalive=true&ttl=10000s" >> /dev/null 2>&1 &

linux B 启动命令: nohup ./gost -L "relay+quic://:8888?ttl=30s&so_mark=100&keepalive=true&ttl=10000s" >> /dev/null 2>&1 &

在开始运行后,linux C开始发送的几个udp包会在抓包软件中看到通过linux A后被代理并发送到linux B,但在linux D上并没有收到,并且之后的数据包也无法再通过linux A后被发送出去,下面是调试过程中在gost的日志文件中看到的内容

linux A日志出现报错 {"caller":"service/parse.go:145","handler":"redu","kind":"listener","level":"error","listener":"redu","msg":"init: listen udp :12345: bind: address already in use","service":"service-0","time":"2024-01-25T16:11:37.358+08:00"} {"caller":"gost/config.go:164","level":"fatal","msg":"listen udp :12345: bind: address already in use","time":"2024-01-25T16:11:37.358+08:00"} 之后出现 {"caller":"udp/listener_linux.go:62","handler":"redu","kind":"listener","level":"error","listener":"redu","msg":"dial: socket bind 10.0.2.3:57112: address already in use","service":"service-0","time":"2024-01-25T16:13:48.565+08:00"} {"caller":"service/service.go:143","handler":"redu","kind":"service","level":"error","listener":"redu","msg":"accept: dial: socket bind 10.0.2.3:57112: address already in use","service":"service-0","time":"2024-01-25T16:13:48.565+08:00"} {"caller":"quic/dialer.go:86","connector":"relay","dialer":"quic","hop":"hop-0","kind":"dialer","level":"error","msg":"timeout: no recent network activity","node":"node-0","time":"2024-01-25T16:13:53.565+08:00"} {"caller":"chain/router.go:191","handler":"redu","kind":"handler","level":"error","listener":"redu","msg":"route(retry=0) timeout: no recent network activity","service":"service-0","time":"2024-01-25T16:13:53.565+08:00"} {"caller":"udp/handler.go:85","dst":"10.0.1.4:1234/udp","handler":"redu","kind":"handler","level":"error","listener":"redu","local":"10.0.1.4:1234","msg":"timeout: no recent network activity","remote":"10.0.0.6:57608","service":"service-0","time":"2024-01-25T16:13:53.566+08:00"} {"caller":"udp/handler.go:63","dst":"10.0.1.4:1234/udp","duration":5023603697,"handler":"redu","kind":"handler","level":"info","listener":"redu","local":"10.0.1.4:1234","msg":"10.0.0.6:57608 >< 10.0.1.4:1234","remote":"10.0.0.6:57608","service":"service-0","time":"2024-01-25T16:13:53.566+08:00"} {"caller":"service/service.go:194","handler":"redu","kind":"service","level":"error","listener":"redu","msg":"timeout: no recent network activity","service":"service-0","time":"2024-01-25T16:13:53.566+08:00"} 并在这之后没有新的内容

而linux B日志出现报错 {"caller":"quic/listener.go:143","handler":"relay","kind":"listener","level":"error","listener":"quic","msg":"accept stream:timeout: no recent network activity","service":"service-0","time":"2024-01-25T16:13:57.763+08:00"} 同时这也是日志的最后一条,并且在日志文件中没有看到处理任何数据包

之后linux A和linux B就完全无法进行代理的通信了