-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
fix: Force closes bad connections #2033
Conversation
var firstBytes = new byte[5]; | ||
try | ||
{ | ||
await socket.ReceiveAsync(firstBytes, SocketFlags.Peek).WaitAsync(TimeSpan.FromMilliseconds(20)); |
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.
Timeout so short won't work
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.
After some testing, 30 second timeout (30000) seems better. You can work your way down from there.
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 would want the server to wait the least amount of time between accept and first packet to minimize threat surface from DDoS.
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.
You can close bad connections on the network/firewall side by changing the TCP timeouts there to a 1 to 2 second threshold. The thing with TCP, its error checking, so you want the network/firewalls layer to cut off bad connections so MUO isn't doing most of it.
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 agree that this should definitely be configured outside of the game server. I believe the time out is set by the socket options as well in the code. And by default it never times out. I'm not sure if this overrides the operating system though?
This code won't work the way I want it to. I have a version of this that uses another epoll instance (wepoll on Windows), but due to a bug in wepoll, I won't be able to do "clever' things the way I want to. I may come around to a deep dive into wepoll so I can fix the bug, but I am not set up (nor do I have the requisite knowledge at this time) to figure it out. cc @jaedan if you are interested in fixing the wepoll bug. Closing this for now and expect users that need to close bad connections to use a proxy in front of MUO. |
No description provided.