Skip to content
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

Choose client ports in a well-known range #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kaduk
Copy link

@kaduk kaduk commented Jul 2, 2017

Instead of letting the kernel assign us a port number, request
a specific port number and increment until one is available.
This makes writing firewall rules easier, when a known number
of clients will be in use.

Instead of letting the kernel assign us a port number, request
a specific port number and increment until one is available.
This makes writing firewall rules easier, when a known number
of clients will be in use.
@kaduk
Copy link
Author

kaduk commented Jul 2, 2017

I'm undecided if this should be a configure option (or at least the starting port number) vs. always-on.

@@ -38,17 +39,20 @@ ZOpenPort(u_short *port)
if (setsockopt(__Zephyr_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val) < 0)
return errno;
} else {
bindin.sin_port = 0;
bindin.sin_port = htons(60000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that Mosh uses almost the same port range, picking the first available port in 60001–60999.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mosh's range was prominent in shaping my initial choice here (though I find it amusing that I was off by one for the start port!). Probably I was thinking that a single hole in the firewall would cover both, but some amount of discussion is appropriate before a choice is made.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m a little worried it might break Mosh for users who only open one firewall port for it instead of a range. Only a little, since those users are probably smart enough to figure out what happened. Maybe that risk can be avoided by starting at 60500 or something.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a bit of discussion about this involving Keith from the mosh side and a few other folks. The conclusion (if there could be said to be one) was:

To the extent it matters, though, I guess it's probably better for
every random UDP app that needs a range of port numbers (instead of a
single port that can be multiplexed because each peer will use a
different IP address or port) to 'standardize' on 60000-61000 than for
us all to go separately. So, go for it if you want.

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