Repository navigation
feat(transfer): add passive port multiplexing by client IP - #623
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #623 +/- ##
==========================================
- Coverage 87.29% 87.22% -0.08%
==========================================
Files 12 13 +1
Lines 1842 2090 +248
==========================================
+ Hits 1608 1823 +215
- Misses 156 180 +24
- Partials 78 87 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I like this a lot! |
d0ef3d4 to
db6421c
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
db6421c to
d79dd42
Compare
|
@flozano thanks for this, but before adding this feature in SFTPGo I would like to check the following (potential) issues:
Let me know if I'm wrong a just did a quick look at the code. Thank you |
|
@drakkan you were right on both, thanks for checking. I reproduced them on v0.32.6:
I also found a third one: when sessions from different IPs use a port for the first time at the same moment, they race to bind it, and the loser skips a port it could have shared, or gets a 421 if there's no other port. #692 fixes all three, with regression tests and before/after numbers. Two limitations remain, and they matter for SFTPGo, because connections are matched by raw source IP before
I'm making drakkan/sftpgo#2253 warn about both. |
Description
This change adds passive port multiplexing so different client IPs can share a narrow passive port range without binding a fresh listener per PASV/EPSV session.
AI disclaimer
This implementation was coded with GPT/Codex assistance.
Why
I am trying to replace AWS Transfer. AWS Transfer's FTP server uses by default a very narrow port range for passive ports (8192-8200). The clients that connect to my server, unfortunately, have hard-coded in their firewalls this port range, and all of them upload at fixed periods (same hour). With current model, only 9 simultaneous passive transfers would be possible. This PR tries to move the limit from 9 simultaneous total to 9 per client IP.
Changes
What changed:
Settings.PassiveTransferPortMultiplexingBehavioral notes:
More on that protocol limit:
PASV/EPSVand before the incoming data connection is matched and the reservation is releasedExamples:
203.0.113.10sendsPASVand gets passive port8192; client B at198.51.100.20also sendsPASVand also gets8192; this works because the accepted data connections arrive from different source IPs and can be demultiplexed safely203.0.113.10sendsPASVand gets8192; before opening the data connection, another control session that is also seen by the server as203.0.113.10sendsPASV; that second session must get another passive port, for example81938192-8200and 10 workers are all behind the same NAT public IP203.0.113.10, then only 9 concurrent pending passive reservations are possible; the 10th cannot be distinguished on the same passive port and must wait or fail with no available passive port203.0.113.10gets8192, opens the data connection, and that reservation is consumed and released, a laterPASVfrom203.0.113.10can reuse8192againOther caveats / issues:
PassiveTransferPortMultiplexingis enabledValidation:
go test ./... -count=1 -timeout 90s