diff --git a/CHANGELOG.md b/CHANGELOG.md index 332f78b..93fb03d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.6.2] - 2021-02-12 ### Added -- Add config option to keep row focus on sort +- Config option to keep row focus on sort ## [1.6.1] - 2021-02-12 ### Fixed diff --git a/cmd/commands/server.go b/cmd/commands/server.go index 349b142..e5e0343 100644 --- a/cmd/commands/server.go +++ b/cmd/commands/server.go @@ -14,7 +14,8 @@ import ( func ServerCmd() *cobra.Command { var port uint = 22 var address string = "0.0.0.0" - var idleTimeout uint = 60 + var idleTimeout uint = 0 + var maxTimeout uint = 0 var executableBinary string = "cointop" var hostKeyFile string = cssh.DefaultHostKeyFile @@ -27,6 +28,7 @@ func ServerCmd() *cobra.Command { Address: address, Port: port, IdleTimeout: time.Duration(int(idleTimeout)) * time.Second, + MaxTimeout: time.Duration(int(maxTimeout)) * time.Second, ExecutableBinary: executableBinary, HostKeyFile: hostKeyFile, }) @@ -38,7 +40,8 @@ func ServerCmd() *cobra.Command { serverCmd.Flags().UintVarP(&port, "port", "p", port, "Port") serverCmd.Flags().StringVarP(&address, "address", "a", address, "Address") - serverCmd.Flags().UintVarP(&idleTimeout, "idle-timeout", "t", idleTimeout, "Idle timeout in seconds") + serverCmd.Flags().UintVarP(&idleTimeout, "idle-timeout", "t", idleTimeout, "Idle timeout in seconds. Default is 0 for no idle timeout") + serverCmd.Flags().UintVarP(&maxTimeout, "max-timeout", "m", maxTimeout, "Max timeout in seconds. Default is 0 for no max timeout") serverCmd.Flags().StringVarP(&executableBinary, "binary", "b", executableBinary, "Executable binary path") serverCmd.Flags().StringVarP(&hostKeyFile, "host-key-file", "k", hostKeyFile, "Host key file") diff --git a/pkg/ssh/server.go b/pkg/ssh/server.go index de35230..d84949d 100644 --- a/pkg/ssh/server.go +++ b/pkg/ssh/server.go @@ -29,6 +29,7 @@ type Config struct { Port uint Address string IdleTimeout time.Duration + MaxTimeout time.Duration ExecutableBinary string HostKeyFile string } @@ -38,6 +39,7 @@ type Server struct { port uint address string idleTimeout time.Duration + maxTimeout time.Duration executableBinary string sshServer *ssh.Server hostKeyFile string @@ -51,11 +53,11 @@ func NewServer(config *Config) *Server { } hostKeyFile = pathutil.NormalizePath(hostKeyFile) - return &Server{ port: config.Port, address: config.Address, idleTimeout: config.IdleTimeout, + maxTimeout: config.MaxTimeout, executableBinary: config.ExecutableBinary, hostKeyFile: hostKeyFile, } @@ -66,6 +68,7 @@ func (s *Server) ListenAndServe() error { s.sshServer = &ssh.Server{ Addr: fmt.Sprintf("%s:%v", s.address, s.port), IdleTimeout: s.idleTimeout, + MaxTimeout: s.maxTimeout, Handler: func(sshSession ssh.Session) { cmdUserArgs := sshSession.Command() ptyReq, winCh, isPty := sshSession.Pty()