things-go / go-socks5

socks5 server in pure Golang with much custom optional. Full TCP/UDP and IPv4/IPv6 support.
MIT License
368 stars 59 forks source link

bugfix: 修复UDP转发功能 #33

Closed cxz66666 closed 9 months ago

cxz66666 commented 10 months ago

https://github.com/things-go/go-socks5/issues/29https://github.com/things-go/go-socks5/pull/1 中提到,RFC标准中的Associate function逻辑和当前实现的有出入,

https://github.com/things-go/go-socks5/pull/1#issuecomment-680734890 中提到

因为RFC文档里面规定UDP Associate请求所携带的地址应当是client欲发送数据的地址+端口,这一个值可以被服务器用来限制来自其余地址的数据包。 你所说的真实UDP地址是在UDP Associate请求协商完成之后,在client向socks5服务器发送的数据必须加上一个特殊的数据包头,包头中携带真实的目标udp地址,服务器解析后决定将client的请求发往何处

但目前实现逻辑恰好是相反的,因此本提交修复了这个问题,使其符合RFC1928标准

目前可以顺利通过 https://github.com/txthinking/testsocks5https://github.com/semigodking/socks5chk 的udp转发测试,同时正确处理了EOF和连接关闭的情况,可以正常退出协程。

thinkgos commented 10 months ago

你好, ci过不了, 把测试也改一下

cxz66666 commented 10 months ago

好的,我晚上修一下

codecov[bot] commented 10 months ago

Codecov Report

Merging #33 (a447d34) into master (ea3e2a0) will increase coverage by 0.23%. The diff coverage is 28.88%.

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   61.95%   62.19%   +0.23%     
==========================================
  Files          14       14              
  Lines         778      775       -3     
==========================================
  Hits          482      482              
+ Misses        236      233       -3     
  Partials       60       60              
Flag Coverage Δ
unittests 62.19% <28.88%> (+0.23%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
statute/auth.go 67.34% <ø> (ø)
statute/datagram.go 97.53% <ø> (ø)
handle.go 46.61% <28.88%> (+0.58%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

cxz66666 commented 10 months ago

已修复 @thinkgos

thinkgos commented 10 months ago

@cxz66666 好的, 找个时间我研究一下