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

Change server behavior when port by local is set to 0 #28

Closed
wants to merge 3 commits into from

Conversation

BxOxSxS
Copy link
Contributor

@BxOxSxS BxOxSxS commented Apr 15, 2022

Server will search for unused port within range of min_port and assign it to local
If there is no available port it will throw an error

Resolves #23 and gives easy way to implement max port which is my next plan

I tested it on linux and windows and everything seems to work great.
If the quality of the code needs to be tweaked feel free to tell me. I am quite new to rust. Unfortunately I'm going away for the weekend so most likely I will be able to do possible corrections on Monday or Tuesday

Server will search for unused port within range of min_port and assign it to local
If there is no available port it will throw an error
@ekzhang
Copy link
Owner

ekzhang commented Apr 17, 2022

Unfortunately I don't think it's desired to look through every port in the range and manually try to bind a TCP listener up to 65536 times. The current behavior is as intended, a safeguard to prevent users from requesting specific ports that are small (~1024).

@BxOxSxS
Copy link
Contributor Author

BxOxSxS commented Apr 18, 2022

I really find these changes useful in case of managing bore. The Only thing that came to my mind how it could be improved is storing ports is some kind of slice and doing faster checks by checking if it's inside. It would require more memory but search would be a bit faster. But in my current code it's still quite fast (1000 ports in about 20 ms)

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.

Minimum port is ignored if port on local is 0
2 participants