|
@@ -75,6 +75,7 @@ var (
|
|
|
MinTLSVersion: 12,
|
|
|
ForcePassiveIP: "",
|
|
|
PassiveIPOverrides: nil,
|
|
|
+ PassiveHost: "",
|
|
|
ClientAuthType: 0,
|
|
|
TLSCipherSuites: nil,
|
|
|
PassiveConnectionsSecurity: 0,
|
|
@@ -1116,85 +1117,97 @@ func getDefaultFTPDBinding(idx int) ftpd.Binding {
|
|
|
return binding
|
|
|
}
|
|
|
|
|
|
-func getFTPDBindingFromEnv(idx int) {
|
|
|
- binding := getDefaultFTPDBinding(idx)
|
|
|
+func getFTPDBindingSecurityFromEnv(idx int, binding *ftpd.Binding) bool {
|
|
|
isSet := false
|
|
|
|
|
|
- port, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__PORT", idx))
|
|
|
+ certificateFile, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__CERTIFICATE_FILE", idx))
|
|
|
if ok {
|
|
|
- binding.Port = int(port)
|
|
|
+ binding.CertificateFile = certificateFile
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- address, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__ADDRESS", idx))
|
|
|
+ certificateKeyFile, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__CERTIFICATE_KEY_FILE", idx))
|
|
|
if ok {
|
|
|
- binding.Address = address
|
|
|
+ binding.CertificateKeyFile = certificateKeyFile
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- applyProxyConfig, ok := lookupBoolFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__APPLY_PROXY_CONFIG", idx))
|
|
|
+ tlsMode, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__TLS_MODE", idx))
|
|
|
if ok {
|
|
|
- binding.ApplyProxyConfig = applyProxyConfig
|
|
|
+ binding.TLSMode = int(tlsMode)
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- certificateFile, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__CERTIFICATE_FILE", idx))
|
|
|
+ tlsVer, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__MIN_TLS_VERSION", idx))
|
|
|
if ok {
|
|
|
- binding.CertificateFile = certificateFile
|
|
|
+ binding.MinTLSVersion = int(tlsVer)
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- certificateKeyFile, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__CERTIFICATE_KEY_FILE", idx))
|
|
|
+ tlsCiphers, ok := lookupStringListFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__TLS_CIPHER_SUITES", idx))
|
|
|
if ok {
|
|
|
- binding.CertificateKeyFile = certificateKeyFile
|
|
|
+ binding.TLSCipherSuites = tlsCiphers
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- tlsMode, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__TLS_MODE", idx))
|
|
|
+ clientAuthType, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__CLIENT_AUTH_TYPE", idx))
|
|
|
if ok {
|
|
|
- binding.TLSMode = int(tlsMode)
|
|
|
+ binding.ClientAuthType = int(clientAuthType)
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- tlsVer, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__MIN_TLS_VERSION", idx))
|
|
|
+ pasvSecurity, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__PASSIVE_CONNECTIONS_SECURITY", idx))
|
|
|
if ok {
|
|
|
- binding.MinTLSVersion = int(tlsVer)
|
|
|
+ binding.PassiveConnectionsSecurity = int(pasvSecurity)
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- passiveIP, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__FORCE_PASSIVE_IP", idx))
|
|
|
+ activeSecurity, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__ACTIVE_CONNECTIONS_SECURITY", idx))
|
|
|
if ok {
|
|
|
- binding.ForcePassiveIP = passiveIP
|
|
|
+ binding.ActiveConnectionsSecurity = int(activeSecurity)
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- passiveIPOverrides := getFTPDPassiveIPOverridesFromEnv(idx)
|
|
|
- if len(passiveIPOverrides) > 0 {
|
|
|
- binding.PassiveIPOverrides = passiveIPOverrides
|
|
|
+ return isSet
|
|
|
+}
|
|
|
+
|
|
|
+func getFTPDBindingFromEnv(idx int) {
|
|
|
+ binding := getDefaultFTPDBinding(idx)
|
|
|
+ isSet := false
|
|
|
+
|
|
|
+ port, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__PORT", idx))
|
|
|
+ if ok {
|
|
|
+ binding.Port = int(port)
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- clientAuthType, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__CLIENT_AUTH_TYPE", idx))
|
|
|
+ address, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__ADDRESS", idx))
|
|
|
if ok {
|
|
|
- binding.ClientAuthType = int(clientAuthType)
|
|
|
+ binding.Address = address
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- tlsCiphers, ok := lookupStringListFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__TLS_CIPHER_SUITES", idx))
|
|
|
+ applyProxyConfig, ok := lookupBoolFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__APPLY_PROXY_CONFIG", idx))
|
|
|
if ok {
|
|
|
- binding.TLSCipherSuites = tlsCiphers
|
|
|
+ binding.ApplyProxyConfig = applyProxyConfig
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- pasvSecurity, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__PASSIVE_CONNECTIONS_SECURITY", idx))
|
|
|
+ passiveIP, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__FORCE_PASSIVE_IP", idx))
|
|
|
if ok {
|
|
|
- binding.PassiveConnectionsSecurity = int(pasvSecurity)
|
|
|
+ binding.ForcePassiveIP = passiveIP
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- activeSecurity, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__ACTIVE_CONNECTIONS_SECURITY", idx))
|
|
|
+ passiveIPOverrides := getFTPDPassiveIPOverridesFromEnv(idx)
|
|
|
+ if len(passiveIPOverrides) > 0 {
|
|
|
+ binding.PassiveIPOverrides = passiveIPOverrides
|
|
|
+ isSet = true
|
|
|
+ }
|
|
|
+
|
|
|
+ passiveHost, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__PASSIVE_HOST", idx))
|
|
|
if ok {
|
|
|
- binding.ActiveConnectionsSecurity = int(activeSecurity)
|
|
|
+ binding.PassiveHost = passiveHost
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
@@ -1204,6 +1217,10 @@ func getFTPDBindingFromEnv(idx int) {
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
+ if getFTPDBindingSecurityFromEnv(idx, &binding) {
|
|
|
+ isSet = true
|
|
|
+ }
|
|
|
+
|
|
|
applyFTPDBindingFromEnv(idx, isSet, binding)
|
|
|
}
|
|
|
|