WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@thaJeztah
Copy link
Member

nat: improve some assertions

nat: add parsePortNumber utility

Add a utility for parsing and validating port-numbers to reduce
repetition and improve errors.

nat: ParsePortRange, ParsePortRangeToInt: reimplement with parsePortNumber

  • Split the implementations from the exported ParsePortRange function.
  • The implementation returns an int for ports (instead of an uint64),
    which we cast to the right type in ParsePortRange.
  • The parsePortNumber gives more informative errors.

nat: NewPort: reimplement with parsePortNumber

nat: ParsePortSpec: reimplement with parsePortNumber

nat: make Port methods more self-contained

  • Use strings.Cut directly instead of using SplitProtoPort
  • Use parsePortNumber instead of the SplitProtoPort wrapper

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Add a utility for parsing and validating port-numbers to reduce
repetition and improve errors.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
…umber

- Split the implementations from the exported ParsePortRange function.
- The implementation returns an int for ports (instead of an uint64),
  which we cast to the right type in ParsePortRange.
- The parsePortNumber gives more informative errors.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
- Use strings.Cut directly instead of using SplitProtoPort
- Use parsePortNumber instead of the SplitProtoPort wrapper

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@austinvazquez austinvazquez merged commit 9354edd into docker:main Aug 11, 2025
13 checks passed
@thaJeztah thaJeztah deleted the nat_cleanups branch August 11, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants