-
Notifications
You must be signed in to change notification settings - Fork 190
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
refactor: split out UDP association handling from serving #221
Conversation
56aa501
to
37414f9
Compare
This will allow us to re-use the handling of packets in the Caddy server where serving is handled separately.
37414f9
to
b2aa859
Compare
c830973
to
8d95309
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this needs a redesign. We can make the shared abstraction be an association handler, not a packet handler. It significantly simplifies things because the handler has the association context, rather than having the context of an individual packet only.
And it will likely use less memory, since the handler can call read directly to the buffer it uses.
We will need to extract a NAT component for outline-ss-server.
Note that the handler is still the one to dictate the lifetime of an association, by closing the writes. You can't do that with a packet handler.
Instead, make the connection an association by wrapping it with the client address and pass that to the `Handle()` function. Each connection will call `Handle()` only once.
50f739c
to
6c5c99f
Compare
6c5c99f
to
bcac22b
Compare
dd03e45
to
d81f128
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the changes to move from a PacketHandler
to an AssociationHandler
as we discussed earlier. PTAL.
dd6eb06
to
09e471f
Compare
c39d84f
to
2427670
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change. The code is definitely more reusable and composable now!
We should keep an eye on memory consumption. It's not super clear to me if this will have a significant impact on memory usage and allocations. Any ideas on how to ensure it's doing fine?
The benchmark analysis of the PR looks good. However, I too want to get more confident it performs well under real-world conditions. I'd like to see it deployed and tested in a production-like environment with significant traffic with one of our providers to see what it looks like. |
This allows us to re-use the association handling logic in the Caddy server, where the NAT is handled by Caddy.
The NAT handling for the legacy server is split out into its own
PacketServe
function (to handlePacketConn
types) that is similar to ourStreamServe
function (to handleStreamConn
types).