Add DefaultServerConfigCallback option for create custom default (#95)
ServerConfigs
This commit is contained in:
parent
bed87f398c
commit
4b72c663cf
10
server.go
10
server.go
@ -30,7 +30,8 @@ type Server struct {
|
||||
PtyCallback PtyCallback // callback for allowing PTY sessions, allows all if nil
|
||||
ConnCallback ConnCallback // optional callback for wrapping net.Conn before handling
|
||||
LocalPortForwardingCallback LocalPortForwardingCallback // callback for allowing local port forwarding, denies all if nil
|
||||
ReversePortForwardingCallback ReversePortForwardingCallback //callback for allowing reverse port forwarding, denies all if nil
|
||||
ReversePortForwardingCallback ReversePortForwardingCallback // callback for allowing reverse port forwarding, denies all if nil
|
||||
DefaultServerConfigCallback DefaultServerConfigCallback // callback for configuring detailed SSH options
|
||||
|
||||
IdleTimeout time.Duration // connection timeout when no activity, none if empty
|
||||
MaxTimeout time.Duration // absolute connection timeout, none if empty
|
||||
@ -77,7 +78,12 @@ func (srv *Server) ensureHandlers() {
|
||||
}
|
||||
|
||||
func (srv *Server) config(ctx Context) *gossh.ServerConfig {
|
||||
config := &gossh.ServerConfig{}
|
||||
var config *gossh.ServerConfig
|
||||
if srv.DefaultServerConfigCallback == nil {
|
||||
config = &gossh.ServerConfig{}
|
||||
} else {
|
||||
config = srv.DefaultServerConfigCallback(ctx)
|
||||
}
|
||||
for _, signer := range srv.HostSigners {
|
||||
config.AddHostKey(signer)
|
||||
}
|
||||
|
3
ssh.go
3
ssh.go
@ -57,6 +57,9 @@ type LocalPortForwardingCallback func(ctx Context, destinationHost string, desti
|
||||
// ReversePortForwardingCallback is a hook for allowing reverse port forwarding
|
||||
type ReversePortForwardingCallback func(ctx Context, bindHost string, bindPort uint32) bool
|
||||
|
||||
// DefaultServerConfigCallback is a hook for creating custom default server configs
|
||||
type DefaultServerConfigCallback func(ctx Context) *gossh.ServerConfig
|
||||
|
||||
// Window represents the size of a PTY window.
|
||||
type Window struct {
|
||||
Width int
|
||||
|
Loading…
Reference in New Issue
Block a user