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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making use of multiple relay ports #178

Closed
maximbaz opened this issue Nov 19, 2019 · 4 comments
Closed

Making use of multiple relay ports #178

maximbaz opened this issue Nov 19, 2019 · 4 comments

Comments

@maximbaz
Copy link
Contributor

maximbaz commented Nov 19, 2019

I might be misunderstanding something here, let me know 馃檪

I noticed that relay is listening on 5 different ports, namely 9009-9013.

When I do croc send file1, I also see that croc opens all 4 ports on my local machine.

Question 1: Why are 4 ports being opened locally? Isn't it enough for the local croc to use a single port to access the relay? I imagine it would easily be possible to let local croc:9009 connect to relay:9012 if necessary.

Question 2: Why does relay open 4 ports? Is it to load balance connections? But then it doesn't seem so, if someone sends me a file via 9009 port, I cannot receive it via the same relay but via 9010 port, I get securing channel...unexpected end of JSON input.

Question 3: Why does receiver need to specify port at all? If they run croc --relay myrelay.com my-code, the app will crash with missing port in address - I think given that ports are known, croc should in this case try all 4 ports by itself (and iterate via RelayPorts in config), and figure out which one works.

@schollz
Copy link
Owner

schollz commented Nov 19, 2019

  1. One port is used for communication (9009). The other ports are used for sending the data in parallel.

  2. Separating the data transfer and the communication made programming easier, although its not strictly necessary I think. I used multiple ports for the data channel because it can improve transfer rates. (You can test this by adding --no-multi to the sender. On my computer, on local connections I'm seeing sending rates of 13.9 +/- 3.6 MB/s with multi ports, and 7.0 +/- 2.0 MB/s wihtout).

  3. If you use a DNS you are right, you don't need the port. The internals aren't configured to work with names yet though, but that can be added.

@maximbaz
Copy link
Contributor Author

maximbaz commented Nov 19, 2019

Wow, this is very interesting, thanks for explaining!

  1. Yeah I think it would be nice to let croc try communication port 9009 by default if no port was specified, after all croc --relay myrelay.com send file1 actually works and tells me to share croc --relay myrelay.com my-code with receiver (notice it doesn't add the port), but if receiver runs this command as is it will fail for them.

Same happens with IP btw, with regard to copy-pasting the command as is:

$ croc --relay 142.93.177.120 send PKGBUILD
Sending 'PKGBUILD' (1.2 kB)
Code is: bombay-prime-visible
On the other computer run

croc --relay 142.93.177.120 bombay-prime-visible
$ croc --relay 142.93.177.120 bombay-prime-visible
connecting...could not connect to 142.93.177.120: dial tcp: address 142.93.177.120: missing port in address

@schollz
Copy link
Owner

schollz commented Nov 19, 2019

Yeah, this is a easy fix, will try 9009 before it complains 馃憤

schollz added a commit that referenced this issue Nov 19, 2019
@maximbaz
Copy link
Contributor Author

Questions got answered, improvements got implemented, closing 馃槃

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

2 participants