Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from

Conversation

0990
Copy link

@0990 0990 commented Mar 17, 2023

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

@xjasonlyu
Copy link
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
Copy link
Author

0990 commented Mar 20, 2023

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

@xjasonlyu
Copy link
Owner

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

@xjasonlyu
Copy link
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

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