Repository navigation
feat(portmapper): allow suggesting an external port - #251
Open
HeikoBornholdt wants to merge 1 commit into
Open
HeikoBornholdt wants to merge 1 commit into
HeikoBornholdt wants to merge 1 commit into
Conversation
PCP, NAT-PMP and UPnP all allow clients to suggest the external port they want. Expose this via Config::suggested_external_port so clients can request a static external port and stay connectable through known endpoints across program restarts. The suggestion is only used when creating a new mapping; an established mapping's external address keeps taking precedence on renewal and local port changes. Gateways may ignore the suggestion and assign a different port: UPnP and NAT-PMP already handle that, while PCP answers CANNOT_PROVIDE_EXTERNAL, so the PCP client retries the request once without a suggestion. The retry also covers renewal of a held mapping the gateway can no longer provide. Verified against a real PCP gateway (FRITZ!Box): the suggested port is granted when free, and when another mapping holds it the retry obtains a gateway-assigned port instead of failing. Closes n0-computer#232
This branch has not been deployed
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.
Description
Closes #232.
Adds
Config::suggested_external_portso clients can request a specific external port, e.g. to stay reachable at a known endpoint across restarts. The internals already supported this; it just wasn't exposed.API Changes
New public field
portmapper::Config::suggested_external_port: Option<NonZeroU16>, defaults toNone.Since
Configis notnon_exhaustive, struct-literal constructions must add the field (suggested_external_port: None). Code using..Default::default()is unaffected.Notes & open questions
Tested against a FRITZ!Box gateway: suggested port granted when free; when another mapping holds it, PCP refuses and the retry obtains a gateway-assigned port instead of failing.
Change checklist
proposed change and wrote an as clear and concise description as
they could.
intented effect.
cargo makepasses locally.