-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix false success from SOCKS server when Dispatch() fails #3431
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
base: master
Are you sure you want to change the base?
fix false success from SOCKS server when Dispatch() fails #3431
Conversation
2676d11
to
e84d5c7
Compare
Thanks for your contribution. Would you mind making this behavior adjustable via a configuration flag? The reason socks inbound return an successful reply to the remote end before the link is actually setup is there to make sure that the initial content of traffic is available for 1. routing decisions, 2. bundling protocol handshake with first payload message to reduce rtt and fingerprint overhead-free. For those reasons, the current behavior is the default and expected action for a specific reasons, and cannot be changed without impacting existing use cases. I assume you wish to know whether a connection has been successfully created before sending traffic content that lacks reentrancy, and I am happy to discuss alternative solution of the issue you are interested. |
I got your point. Give me some time |
Not sure if it's easy to do in v2ray, but in my project shadowsocks-go, the behavior is determined by a config option Of course, in v2ray this would be further complicated by the potential use of sniffers, whereas in shadowsocks-go the router does not consume payload. |
Also you might want to implement the same thing for HTTP CONNECT requests. |
Thanks @database64128. In my opinion due to V2Ray's complexity, I don't recommend any contributor to implement such feature as it would require specialized knowledge and tools to implement it correctly, and significantly increase the difficulty to make application's behavior predictable.
If such thing does get implemented, please submit under a separate pull request. |
Postpone SOCKS server ok reply to a TCP Connect command until Dispatch() actually creates an upstream Link. Previously it was sent immediately inside Handshake(). UDP works as before.
e84d5c7
to
992d5d8
Compare
I added a flag to ServerConfig. |
Postpone SOCKS server ok reply to a TCP Connect command until Dispatch() actually creates an upstream Link. Previously it was sent immediately inside Handshake(). UDP works as before.
Tested in a standalone go program that only starts a V2Ray SOCKS server.
before:
Results(V5): Succeeded (0)
after:
_

Results(V5): Connection refused (5)