move server version setting to common section

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-05-01 19:42:09 +02:00
parent 7b5ad6c38d
commit d3f42e39db
22 changed files with 86 additions and 91 deletions

View File

@@ -107,8 +107,6 @@ func (b *Binding) HasProxy() bool {
// Configuration for the SFTP server
type Configuration struct {
// Identification string used by the server
Banner string `json:"banner" mapstructure:"banner"`
// Addresses and ports to bind to
Bindings []Binding `json:"bindings" mapstructure:"bindings"`
// Maximum number of authentication attempts permitted per connection.
@@ -227,13 +225,6 @@ func (c *Configuration) ShouldBind() bool {
return false
}
func (c *Configuration) getServerVersion() string {
if c.Banner == "short" {
return "SSH-2.0-SFTPGo"
}
return fmt.Sprintf("SSH-2.0-SFTPGo_%v", version.Get().Version)
}
func (c *Configuration) getServerConfig() *ssh.ServerConfig {
serverConfig := &ssh.ServerConfig{
NoClientAuth: false,
@@ -251,7 +242,7 @@ func (c *Configuration) getServerConfig() *ssh.ServerConfig {
return sp, nil
},
ServerVersion: c.getServerVersion(),
ServerVersion: fmt.Sprintf("SSH-2.0-%s", version.GetServerVersion("_", false)),
}
if c.PasswordAuthentication {