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
Listener only allows one session per client addr #166
Comments
|
Here is some background on my use case if you're curious: https://bugs.torproject.org/33519#comment:3. We are implementing a proxy and for us, creating a new The situation I am picturing is one |
|
could you make a PR to this and the other packetconn issue? |
|
I need to do some tests |
|
For this issue, I have doubts on the reliability on this So I chose to create a overlay, which was https://github.com/xtaci/smux. What's your thought? |
|
While I was working on a pull request (https://github.com/Eudi4H/kcp-go/tree/listener-multi-sessions), I realized that the approach I suggested (keying by (addr, conv)) won't work. It makes the sample program above work, but it doesn't work in the more detailed test I wrote. The reason is that both client So I think you are right. We will have to find a way to do it using multiple smux streams per |
Listeneronly supports one session per client address. (Let's say per IP:port tuple, though with customnet.PacketConnit could be something else.) TheListener.sessionsmap is keyed by address, and ifListener.packetInputsees a different conv than the one it knows about for an address, it closes the existing session and replaces it with a new one under the new conv.https://github.com/xtaci/kcp-go/blob/v5.5.9/sess.go#L810-L813
I think it should be possible to have multiple sessions for the same client address, as long as the sessions use different convs.
Here is a patch to show what I mean. It makes
Listener.sessionsbe keyed by (addr, conv), not just addr. I am not sure the patch is entirely correct, especially regarding FEC as I have never tried using that.https://gist.github.com/Eudi4H/5e5bc37f1277f124e01553753a9736d0
Here is a demonstration program. It creates a
net.PacketConnand starts aUDPSessionon it. It uses theUDPSessionfor five seconds, then creates a secondUDPSessionusing the samenet.PacketConn. When the secondUDPSessionconnects, the firstUDPSessionstops working with anio: read/write on closed pipeerror.Possibly related but I'm not sure: #54 .
go.mod
Without the patch, the output is
With the patch, the output is
The text was updated successfully, but these errors were encountered: