proxy protocol: added an option to make the proxy header required

now we can configure SFTPGo to accept or reject requests without the proxy
header when the proxy protocol is enabled
This commit is contained in:
Nicola Murino
2020-02-29 00:02:06 +01:00
parent 830e3d1f64
commit 7163fde724
7 changed files with 94 additions and 16 deletions

View File

@@ -216,6 +216,17 @@ func TestMain(m *testing.M) {
waitTCPListening(fmt.Sprintf("%s:%d", sftpdConf.BindAddress, sftpdConf.BindPort))
sftpdConf.BindPort = 2224
sftpdConf.ProxyProtocol = 2
go func() {
logger.Debug(logSender, "", "initializing SFTP server with config %+v", sftpdConf)
if err := sftpdConf.Initialize(configDir); err != nil {
logger.Error(logSender, "", "could not start SFTP server: %v", err)
}
}()
waitTCPListening(fmt.Sprintf("%s:%d", sftpdConf.BindAddress, sftpdConf.BindPort))
exitCode := m.Run()
os.Remove(logFilePath)
os.Remove(loginBannerFile)
@@ -341,6 +352,10 @@ func TestProxyProtocol(t *testing.T) {
t.Errorf("error mkdir: %v", err)
}
}
client, err = getSftpClientWithAddr(user, usePubKey, "127.0.0.1:2224")
if err == nil {
t.Error("request without a proxy header must be rejected")
}
httpd.RemoveUser(user, http.StatusOK)
os.RemoveAll(user.GetHomeDir())
}