Skip to content

Feature: TCP handshake (RST) response when proxy fails - #235

Closed
0990 wants to merge 2 commits into
xjasonlyu:mainfrom
0990:main
Closed

0990 wants to merge 2 commits into
xjasonlyu:mainfrom
0990:main

Conversation

@0990

@0990 0990 commented Mar 17, 2023

Copy link
Copy Markdown

Feature:#234
目前粗略处理,只要dial sock5代理失败,就返回客户端握手失败RST,由于对gvisor还不熟悉,这部分代码您参考用

@xjasonlyu

Copy link
Copy Markdown
Owner

Hello!

这个问题之前也有人提过,但我一直没空去解决,很高兴你愿意贡献修改。

我觉得目前的代码处理方式不够优雅,有进一步优化修改的空间。你可以参考这个 issue #83 然后在这里有讨论怎么在握手前处理发送RST等 #222

我个人认为这部分处理逻辑应该在core模块里解决,并提供是否需要开启这个功能的选项。

另外,麻烦你把 issue 和 PR 的标题改成英文的,谢谢 :-P

@0990 0990 changed the title feat:dial sock5代理返回remoteAddr connect refuse(0x05)时,应该给客户端返回tcp握手失败(RST) Feature: the client should be given a TCP handshake failure (RST) response when socks5 proxy returns "remoteAddr connection refuse" (0x05) Mar 20, 2023
@0990

0990 commented Mar 20, 2023 •

Copy link
Copy Markdown
Author

我目前使用的是透明代理(TPROXY),ipt2socks等将普通流量转成socks流量,由于工作应用层,无法控制握手流程,而想解决我遇到的问题#234,tun2socks是“有能力”解决的,也应该这样去做,你的提议我再看看代码,看怎么处理严谨些,主要是sock proxy返回RepNetworkUnreachable(0x03)RepHostUnreachable(0x04)RepConnectionRefused(0x05)的处理方式

@xjasonlyu

Copy link
Copy Markdown
Owner

是的,tun2socks在网络层是可以直接响应这些问题。

@xjasonlyu

Copy link
Copy Markdown
Owner

不过我现在的想法是,把所有RST这类逻辑放在core里做掉,tunnel照样还是处理TCPConn这种。

@xjasonlyu
xjasonlyu marked this pull request as draft April 24, 2023 10:17
@xjasonlyu xjasonlyu changed the title Feature: the client should be given a TCP handshake failure (RST) response when socks5 proxy returns "remoteAddr connection refuse" (0x05) Feature: TCP handshake (RST) response when proxy fails May 17, 2023
@m2abrams15

Copy link
Copy Markdown

Did some testing with this, and it seems to fix the issues for handling connections properly with scanning as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants