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

0 port #51

Closed
CMCDragonkai opened this issue Apr 15, 2017 · 6 comments
Closed

0 port #51

CMCDragonkai opened this issue Apr 15, 2017 · 6 comments

Comments

@CMCDragonkai
Copy link

CMCDragonkai commented Apr 15, 2017

In the test cases, 0 port is allowed for UDP, SCTP and TCP.

What's the reason for this? The 0 port is used for binding to a system allocated port, and it is also officially reserved by IANA and not be used for TCP or UDP messages.

If it this is allowed, then why does the onion test disallow a 0 port.

I'm writing a haskell version of this library, and seeing these 2 testcases means I would have to split the port logic to allow 0 for certain protocols and disallow 0 for other protocols.

In the broader case, why would 0 ever be used in a multiaddress? I would think it is intended for the binding on the server side, but never passed around as an actually addressable resource, since it doesn't make sense for the system to randomly allocate a connecting port on the client side.

@ghost
Copy link

ghost commented Apr 21, 2017

If it this is allowed, then why does the onion test disallow a 0 port.

I don't think 0-means-random-port works with Tor/Onion. Please correct me if I'm wrong.

In the broader case, why would 0 ever be used in a multiaddress? I would think it is intended for the binding on the server side, but never passed around as an actually addressable resource

Correct

@CMCDragonkai
Copy link
Author

@lgierth That's why I'm thinking that the 0 port should be disallowed in TCP and UDP. And this would unify the port parsing logic in my multiaddr library.

@ghost
Copy link

ghost commented Apr 22, 2017

port 0 is a legitimate use on the listening side. Not going to remove it :)

@CMCDragonkai
Copy link
Author

Are services allowed to bind to a multiaddr? If so, then yes it makes sense to have a 0 port.

If onion addresses is part of multiaddr, then why isn't it possible to bind to a 0 port onion address?

Where in the docs does it say that onion addresses cannot have a 0 port?

@ghost
Copy link

ghost commented May 2, 2017

Are services allowed to bind to a multiaddr? If so, then yes it makes sense to have a 0 port.

Correct

If onion addresses is part of multiaddr, then why isn't it possible to bind to a 0 port onion address?

Port 0 is part of the OS's TCP/IP stack, and I guess Tor hidden services just don't provide such a functionality. One could emulate it within go-multiaddr, but that would be hard to pull off without race conditions.

Where in the docs does it say that onion addresses cannot have a 0 port?

I don't know -- ping @david415 @ianopolous

@CMCDragonkai
Copy link
Author

Implemented in haskell

Stebalien pushed a commit that referenced this issue May 20, 2020
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

No branches or pull requests

1 participant