Skip to content

Clarify port ranges in mosh-server(1) man page.#1378

Open
magical wants to merge 1 commit intomobile-shell:masterfrom
magical:port-ranges
Open

Clarify port ranges in mosh-server(1) man page.#1378
magical wants to merge 1 commit intomobile-shell:masterfrom
magical:port-ranges

Conversation

@magical
Copy link
Copy Markdown

@magical magical commented Mar 23, 2026

The man page for mosh-server says that -p says it takes a "port or port-range" without specifying whether the range is exclusive or inclusive. It is inclusive.

The man page also says that mosh-server binds to a port "between 60000 and 61000" by default without stating whether the endpoints are included. They are not; the range is exclusive.

That is, the default is equivalent to -p 60001:60999, not -p 60000:61000 as one might reasonably suppose.

Clarify the manual by sticking to inclusive ranges in both cases and stating explicitly that they are inclusive instead of leaving it up to the reader to guess.

The man page for mosh-server says that -p says it takes a "port or
port-range" without specifying whether the range is exclusive or
inclusive. It is inclusive.

The man page also says that mosh-server binds to a port "between 60000
and 61000" by default without stating whether the endpoints are
included. They are not; the range is exclusive.

That is, the default is equivalent to -p 60001:60999, not -p 60000:61000
as one might reasonably suppose.

Clarify the manual by sticking to inclusive ranges in both cases and
stating explicitly that they are inclusive instead of leaving it up to
the reader to guess.
@magical
Copy link
Copy Markdown
Author

magical commented Mar 23, 2026

The default port range was set by Keith Winstein, in this commit from 2012:

commit df3eec13973ab22301bdd0bedaadce46343b5109
Author: Keith Winstein <keithw@mit.edu>
Date:   Sat Mar 10 03:34:47 2012 -0500

    Allow explicit UDP port option, confine ports to range 60000..61000

diff --git a/src/network/network.h b/src/network/network.h
index 2959e89..dd9d79b 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -74,6 +74,11 @@ namespace Network {
     static const uint64_t MIN_RTO = 50; /* ms */
     static const uint64_t MAX_RTO = 1000; /* ms */
 
+    static const int PORT_RANGE_LOW  = 60001;
+    static const int PORT_RANGE_HIGH = 60999;
+
+    static bool try_bind( int socket, uint32_t s_addr, int port );
+
     int sock;
     bool has_remote_addr;
     struct sockaddr_in remote_addr;
[snip]

I could expand the range to match the documentation instead of changing the documentation to match the implementation, but it's been that way for so long it's probably best not to mess with it.

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.

1 participant