Skip to content

Commit feb3821

Browse files
flozanofclairambclaude
authored
feat(transfer): add passive port multiplexing by client IP (#623)
* Add passive port multiplexing by client IP * Run gofmt on passive listener multiplexing * style(transfer): fix lint issues in passive multiplexing * style(transfer): satisfy nlreturn in passive multiplexer * style(transfer): satisfy remaining nlreturn checks * style(transfer): fix remaining nlreturn findings * test(transfer): cover passive multiplexer error paths * test(transfer): lint coverage tests for passive multiplexer * fix(lint): extract repeated string literals to constants Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Florent Clairambault <florent.clairambault@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c73a72e commit feb3821

7 files changed

Lines changed: 828 additions & 89 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ type Settings struct {
126126
PublicHost string // Public IP to expose (only an IP address is accepted at this stage)
127127
PublicIPResolver PublicIPResolver // (Optional) To fetch a public IP lookup
128128
PassiveTransferPortRange PasvPortGetter // (Optional) Port Range for data connections. Random if not specified
129+
PassiveTransferPortMultiplexing bool // Allow different client IPs to share passive listener ports
129130
ActiveTransferPortNon20 bool // Do not impose the port 20 for active data transfer (#88, RFC 1579)
130131
IdleTimeout int // Maximum inactivity time before disconnecting (#58)
131132
ConnectionTimeout int // Maximum time to establish passive or active transfer connections

driver.go

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -303,28 +303,31 @@ const (
303303

304304
// Settings defines all the server settings
305305
type Settings struct {
306-
Listener net.Listener // (Optional) To provide an already initialized listener
307-
ListenAddr string // Listening address
308-
PublicHost string // Public IP to expose (only an IP address is accepted at this stage)
309-
Banner string // Banner to use in server status response
310-
PassiveTransferPortRange PasvPortGetter // (Optional) Port Mapping for data connections. Random if not specified
311-
PublicIPResolver PublicIPResolver // (Optional) To fetch a public IP lookup
312-
IdleTimeout int // Maximum inactivity time before disconnecting (#58)
313-
ConnectionTimeout int // Maximum time to establish passive or active transfer connections
314-
ActiveTransferPortNon20 bool // Do not impose the port 20 for active data transfer (#88, RFC 1579)
315-
DisableMLSD bool // Disable MLSD support
316-
DisableMLST bool // Disable MLST support
317-
DisableMFMT bool // Disable MFMT support (modify file mtime)
318-
TLSRequired TLSRequirement // defines the TLS mode
319-
DisableLISTArgs bool // Disable ls like options (-a,-la etc.) for directory listing
320-
DisableSite bool // Disable SITE command
321-
DisableActiveMode bool // Disable Active FTP
322-
EnableHASH bool // Enable support for calculating hash value of files
323-
DisableSTAT bool // Disable Server STATUS, STAT on files and directories will still work
324-
DisableSYST bool // Disable SYST
325-
EnableCOMB bool // Enable COMB support
326-
DeflateCompressionLevel int // Deflate compression level (0-9). 0 means disabled
327-
DefaultTransferType TransferType // Transfer type to use if the client don't send the TYPE command
306+
Listener net.Listener // (Optional) To provide an already initialized listener
307+
ListenAddr string // Listening address
308+
PublicHost string // Public IP to expose (only an IP address is accepted at this stage)
309+
Banner string // Banner to use in server status response
310+
// PassiveTransferPortRange is the optional port mapping for passive data connections.
311+
PassiveTransferPortRange PasvPortGetter
312+
PassiveTransferPortMultiplexing bool // Allow different client IPs to share passive listener ports
313+
PublicIPResolver PublicIPResolver // (Optional) To fetch a public IP lookup
314+
IdleTimeout int // Maximum inactivity time before disconnecting (#58)
315+
ConnectionTimeout int // Maximum time to establish passive or active transfer connections
316+
ActiveTransferPortNon20 bool // Do not impose the port 20 for active data transfer (#88, RFC 1579)
317+
DisableMLSD bool // Disable MLSD support
318+
DisableMLST bool // Disable MLST support
319+
DisableMFMT bool // Disable MFMT support (modify file mtime)
320+
TLSRequired TLSRequirement // defines the TLS mode
321+
DisableLISTArgs bool // Disable ls like options (-a,-la etc.) for directory listing
322+
DisableSite bool // Disable SITE command
323+
DisableActiveMode bool // Disable Active FTP
324+
EnableHASH bool // Enable support for calculating hash value of files
325+
// DisableSTAT disables Server STATUS. STAT on files and directories still works.
326+
DisableSTAT bool
327+
DisableSYST bool // Disable SYST
328+
EnableCOMB bool // Enable COMB support
329+
DeflateCompressionLevel int // Deflate compression level (0-9). 0 means disabled
330+
DefaultTransferType TransferType // Transfer type to use if the client don't send the TYPE command
328331
// ActiveConnectionsCheck defines the security requirements for active connections
329332
ActiveConnectionsCheck DataConnectionRequirement
330333
// PasvConnectionsCheck defines the security requirements for passive connections

0 commit comments

Comments
 (0)