Skip to content

Commit

Permalink
support ServerAliveInterval=0 #150
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnywong committed Oct 19, 2024
1 parent ab8cc44 commit 0823d9b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tssh/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (

"github.com/alessio/shellescape"
"github.com/skeema/knownhosts"
"github.com/trzsz/ssh_config"
"golang.org/x/crypto/ssh"
"golang.org/x/term"
)
Expand Down Expand Up @@ -1090,15 +1091,23 @@ func sshConnect(args *sshArgs, client SshClient, proxy string) (SshClient, *sshP

func keepAlive(client SshClient, args *sshArgs) {
getOptionValue := func(option string) int {
if value, err := strconv.Atoi(getOptionConfig(args, option)); err == nil {
return value
config := getOptionConfig(args, option)
if config == "" {
return 0
}
return 0
value, err := strconv.Atoi(config)
if err != nil {
warning("%s [%s] invalid: %v", option, config, err)
return 0
}
return value
}

ssh_config.SetDefault("ServerAliveInterval", "10")
serverAliveInterval := getOptionValue("ServerAliveInterval")
if serverAliveInterval <= 0 {
serverAliveInterval = 10
debug("no keep alive")
return
}
serverAliveCountMax := getOptionValue("ServerAliveCountMax")
if serverAliveCountMax <= 0 {
Expand Down

0 comments on commit 0823d9b

Please sign in to comment.