-
Notifications
You must be signed in to change notification settings - Fork 263
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
Support Ephemeral ports #5126
Draft
fishface60
wants to merge
7
commits into
RPTools:develop
Choose a base branch
from
fishface60:ephemeral-ports
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Support Ephemeral ports #5126
Conversation
This file contains 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
fishface60
force-pushed
the
ephemeral-ports
branch
3 times, most recently
from
December 28, 2024 18:37
2db5327
to
0b3b2b9
Compare
Sealed interfaces are useful in switch exprs to enumerate possible values so that it becomes a compile error to introduce a new server type without implementing an appropriate arm for the switch block.
ServiceAnnouncer requires a non-null String, but an empty server ID is not well-formed so a ServiceAnnouncer shouldn't be created. This was previously handled by MapToolServer being passed null config and the absence of a port to give was sufficient to prevent creating a ServiceAnnouncer with an empty ID, but we can be more defensive about this and check for a null pointer.
This adds extra complexity from the ServiceAnnouncer not always existing but enables later flexibility in supporting binding to an emphemeral port instead of having to preconfigure it.
It is neater to stop announcement, deregister and close UPnP before stopping the server so that discovering clients can't try to connect to an already stopped server though this is mostly just being picky because the human interaction time scales dominate and shut down and deregister are nearly the same time.
If a port number of 0 is chosen then bind() will open a random port in an ephemeral range instead of the provided port number and this port can then be retrieved using getLocalPort(). This enables starting servers on arbitrary ports instead of preconfigured ones. Since only direct connections need to know the port number connections using the registry or LAN can use an ephemeral port number and the connection information tab can display the port direct connections should use. This requires a router with functioning UPnP instead of port forwarding though so is not univerally useful.
fishface60
force-pushed
the
ephemeral-ports
branch
from
January 5, 2025 16:46
0b3b2b9
to
9cd4255
Compare
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.
Identify the Bug or Feature request
Closes #5125
Depends on #5124 or #5131
Description of the Change
This relaxes the validation of the server port field to allow 0, changes code that used the configured port for sending to the registry or advertising with service discovery to use the value from the bound socket, and ensures they are configured after the socket has been bound so the port can be correctly determined.
Possible Drawbacks
If a user specifies it as 0 without using UPnP then connections will probably fail and those error messages are less informative than having picked an invalid port.
Release Notes
This change is