Repository navigation
fix: replaced port character sum with a cksum hash - #75
Merged
Merged
Conversation
The old sum ignored letter order (anagrams collided) and clustered short names around 49.5k-51.5k. Kept it as `port_legacy` since FraudCentral, Roboguard, Sockets and xeldex hardcode values it generated. Added `--check` to warn when the port is already taken, and scoped all variables with `local`.
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.
Problem
port <string>summed character codes, so:ab/ba,web-api/api-web)printfonce per characterword,sum,port, … leaked into the calling shellChanges
portnow hashes withcksum(POSIX CRC) into 49152–65535, useslocal, prints usage to stderr and returns 1 without an argumentport --check <string>warns on stderr when the port is listening locally, published by a running container, or written in adocker-compose*.yml/.envunder~/Code; it still prints the number and exits 0port_legacy, because these files hardcode values it generated (left untouched):docker-compose.yml→ 50427 (fraudcentral).env.example→ 50117 (roboguard), 49921 (control)docker-compose.yml→ 50117 in comments onlydocker-compose.yml→ 49802 (xeldex)Testing
_port_check 8080reports the local listener, thetraefikcontainer, and the compose/.env files that contain 8080port/port --checkwith no string → usage on stderr, exit 1