Repository navigation
Server: count an IPv6 /64 as one address for the per-address connection limit - #164
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
-max-conns-per-addrcounted each exact remote address. For IPv6 that is not one source: a single network (a /64) holds billions of addresses, so connections from different addresses of one network each got a full allowance. The UDP limit and the admin failure delay already treat an IPv6 /64 as one source; the TCP per-address limit did not.Change
server/server.go:addrLimitKeygives the key the limit counts by: an IPv4 address (an IPv4-mapped address counts as the IPv4 address), or an IPv6 address cut to its /64, with any zone dropped. The count is taken and released under that key. The address a player is known by (rooms, peers, logs, thepublic_ipsent to the client) is unchanged; only the counting key changes.-max-conns-per-addrif 32 is too tight for such a group.docs/running.md,README.md,docs/api.mdand the-helptext say that an IPv6 address counts as its /64. CHANGELOG Server: entry under Fixed;site/regenerated.Tests
server/conn_cap_key_test.go: a table for the key (IPv4, IPv4-mapped, two addresses of one /64, another /64, a zone); with a limit of 2 behind a trusted proxy, a third address of the same /64 is refused, another /64 is served, and IPv4 behaves as before; and a count is released under the same key, so the table empties when the connection closes and the allowance is free again.gofmt,go vet,go test ./server,python3 tools/repo_check.py,python3 tools/site.py --check,python3 tools/features.py --checkandscripts/check-deploy.shpass.mainthe new tests do not build, becauseaddrLimitKeydoes not exist there.Not in this change
No new flag, no change to the default of 32, and no change to the UDP limit or the admin delay.
Overlap
None open on
server/server.go. Other open work touchesCHANGELOG.mdand the generated site files, so whichever merges later needs a rebase. Based on main at 7fdd762.Developed with AI agent assistance.