-
Notifications
You must be signed in to change notification settings - Fork 100
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
active mode data connection: fix bind: address already in use #255
Conversation
This patch set the socket option to reuse the same port, before the patch, after connection in active mode and setting ActiveTransferPortNon20 to false we had something like this: ftp> ls 200 PORT command successful 425 could not establish active connection: dial tcp :20->127.0.0.1:36151: bind: address already in use ftp> ls 200 PORT command successful 425 could not establish active connection: dial tcp :20->127.0.0.1:55911: bind: address already in use
Codecov Report
@@ Coverage Diff @@
## main #255 +/- ##
==========================================
- Coverage 85.92% 85.20% -0.73%
==========================================
Files 10 11 +1
Lines 1528 1541 +13
==========================================
Hits 1313 1313
- Misses 144 157 +13
Partials 71 71
Continue to review full report at Codecov.
|
Interesting. I'm not sure I ever tested it like this. Does it even make sense to always make all active connections start from the In my opinion, adding a test wouldn't be an issue. We can skip it if the current user isn't root or if we detect we won't be able to open the port. |
Hello, this patch fixes the problem for me, thank you! |
@stevyn81 thanks for confirming @fclairamb The specs suggest/mandate that the data connection port must be adiacent to the control connection port
and
From my tests:
It seems that both ProFTPD and PureFTPD don't allow to configure a specific data port. The latest version of ProFTPD appears not to have the L-1 issue described here, see http://www.proftpd.org/docs/howto/ConfigurationTricks.html it always uses a random port (I tested the ArchLinux package). I will try to add a test case in the next few days. I'm not sure if we also want an option to use L-1 for the active data port. |
the test fails if we don't set the socket reuse options
Hi, I added a test case, it fails if you revert the socket reuse patch. As expected the test does not run in CI:
you can test locally executing the test as root. Please let me know if you also want an option to listen on L-1 for active data connection. I think this should be addresses in a separate PR, thanks |
@stevyn81 this patch is included in SFTPGo v2.2.0 and above, please let me know if you find any issues using the latest SFTPGo version, thanks |
This patch set the socket option to reuse the same port, before the
patch, after connecting in active mode and setting ActiveTransferPortNon20
to false we had something like this:
More details here
@fclairamb please let me know what do you think about. There is no automated test for now, binding to port 20 requires root privileges, I'm not sure CI allows it. Also, adding a test that requires root access is annoying when running tests locally