Expose the gossh.ServerConfig rather than specific values
This commit is contained in:
parent
cd0f9291c6
commit
4703ad4dc1
36
server.go
36
server.go
@ -33,18 +33,11 @@ type Server struct {
|
|||||||
IdleTimeout time.Duration // connection timeout when no activity, none if empty
|
IdleTimeout time.Duration // connection timeout when no activity, none if empty
|
||||||
MaxTimeout time.Duration // absolute connection timeout, none if empty
|
MaxTimeout time.Duration // absolute connection timeout, none if empty
|
||||||
|
|
||||||
// The allowed key exchanges algorithms. If unspecified then a
|
// Internal x/crypto/ssh config. Note that a number of values in this struct
|
||||||
// default set of algorithms is used. Most users should not need to set
|
// are overwritten every time a connection starts, so only use this if you
|
||||||
// this.
|
// know what you're doing and absolutely need to change the internal config
|
||||||
KeyExchanges []string
|
// values.
|
||||||
|
BaseConfig *gossh.ServerConfig
|
||||||
// The allowed cipher algorithms. If unspecified then a sensible
|
|
||||||
// default is used. Most users should not need to set this.
|
|
||||||
Ciphers []string
|
|
||||||
|
|
||||||
// The allowed MAC algorithms. If unspecified then a sensible default
|
|
||||||
// is used. Most users should not need to set this.
|
|
||||||
MACs []string
|
|
||||||
|
|
||||||
channelHandlers map[string]channelHandler
|
channelHandlers map[string]channelHandler
|
||||||
|
|
||||||
@ -71,19 +64,13 @@ func (srv *Server) ensureHostSigner() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) config(ctx Context) *gossh.ServerConfig {
|
func (srv *Server) config(ctx Context) *gossh.ServerConfig {
|
||||||
config := &gossh.ServerConfig{}
|
// Use the provided base config if set, otherwise default to an empty
|
||||||
if len(srv.KeyExchanges) > 0 {
|
// config.
|
||||||
config.KeyExchanges = make([]string, len(srv.KeyExchanges))
|
config := srv.BaseConfig
|
||||||
copy(srv.KeyExchanges, config.KeyExchanges)
|
if config == nil {
|
||||||
}
|
config = &gossh.ServerConfig{}
|
||||||
if len(srv.Ciphers) > 0 {
|
|
||||||
config.Ciphers = make([]string, len(srv.Ciphers))
|
|
||||||
copy(srv.Ciphers, config.Ciphers)
|
|
||||||
}
|
|
||||||
if len(srv.MACs) > 0 {
|
|
||||||
config.MACs = make([]string, len(srv.MACs))
|
|
||||||
copy(srv.MACs, config.MACs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, signer := range srv.HostSigners {
|
for _, signer := range srv.HostSigners {
|
||||||
config.AddHostKey(signer)
|
config.AddHostKey(signer)
|
||||||
}
|
}
|
||||||
@ -112,6 +99,7 @@ func (srv *Server) config(ctx Context) *gossh.ServerConfig {
|
|||||||
return ctx.Permissions().Permissions, nil
|
return ctx.Permissions().Permissions, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user