Skip to content

feat(ftpd): add passive port multiplexing by client IP - #2253

Open
flozano wants to merge 3 commits into
drakkan:mainfrom
flozano:feat/ftpd-passive-port-multiplexing
Open

feat(ftpd): add passive port multiplexing by client IP#2253
flozano wants to merge 3 commits into
drakkan:mainfrom
flozano:feat/ftpd-passive-port-multiplexing

Conversation

@flozano

@flozano flozano commented Jun 26, 2026

Copy link
Copy Markdown

Summary

ftpserverlib v0.31.0 added passive port multiplexing by client IP via fclairamb/ftpserverlib#623, exposed as the Settings.PassiveTransferPortMultiplexing flag. SFTPGo already depends on ftpserverlib v0.32.0 but does not surface the option, so this PR wires it through the FTP configuration.

When enabled, FTP clients with different IP addresses can share the same passive port concurrently, instead of requiring one listener per session. This increases the number of simultaneous passive transfers that can be served from a limited passive port range. Clients behind the same NAT / public egress IP are treated as a single client for multiplexing purposes, so the effective limit is based on the observed source IP.

The option is disabled by default, preserving the current behavior.

Changes

  • internal/ftpd/ftpd.go: new PassivePortMultiplexing field on Configuration (passive_port_multiplexing), placed next to the existing passive_port_range option.
  • internal/ftpd/server.go: map it to ftpserver.Settings.PassiveTransferPortMultiplexing when building the server settings.
  • internal/config/config.go: register the viper default, alongside the other ftpd.* defaults.
  • sftpgo.json: document the new key in the example configuration.

The naming mirrors SFTPGo's existing convention, which drops Transfer from the upstream names (PassiveTransferPortRangepassive_port_range), giving the parallel passive_port_multiplexing key. The exposure follows the exact same pattern as the sibling boolean flags such as disable_active_mode.

Testing

  • go build ./...
  • go vet ./internal/ftpd/... ./internal/config/...
  • gofmt clean

🤖 Generated with Claude Code

Expose the PassiveTransferPortMultiplexing setting added in ftpserverlib
v0.31.0 (fclairamb/ftpserverlib#623) through a new "passive_port_multiplexing"
FTP option. When enabled, clients with different IP addresses can share the
same passive port, increasing the number of concurrent passive transfers that
can be served with a limited passive port range. Clients behind the same NAT
or public IP are treated as a single client for multiplexing purposes.

Signed-off-by: Francisco A. Lozano <flozano@gmail.com>

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@flozano
flozano requested a review from drakkan as a code owner June 26, 2026 09:44
@CLAassistant

CLAassistant commented Jun 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Extend TestServerGetSettings to assert that the new PassivePortMultiplexing
configuration field is propagated to ftpserver.Settings, mirroring the existing
PassiveTransferPortRange assertion.

Signed-off-by: Francisco A. Lozano <flozano@gmail.com>

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@flozano
flozano force-pushed the feat/ftpd-passive-port-multiplexing branch from 7913613 to 70b7926 Compare June 26, 2026 10:13
… a port

Add a Linux-only integration test that starts an FTP server with a single-port
passive range and PassivePortMultiplexing enabled, then runs several overlapping
passive transfers from different loopback source IPs. The transfers are held
in-flight at the same time so they genuinely share the one passive port, which
is only possible with multiplexing (the test fails by port exhaustion when the
flag is off). Each client sends a distinct byte pattern that is read back to
verify the server delivered every data connection to the correct session.

Signed-off-by: Francisco A. Lozano <flozano@gmail.com>

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@flozano
flozano force-pushed the feat/ftpd-passive-port-multiplexing branch from 70b7926 to 70f879e Compare June 26, 2026 10:29
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.

2 participants