Skip to content

Commit

Permalink
-conn.setdeadline
Browse files Browse the repository at this point in the history
  • Loading branch information
shoce committed Aug 27, 2023
1 parent 9211a18 commit 319e4cf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions hs.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,22 @@ func connectssh() (err error) {
// https://github.com/golang/go/issues/21478
// https://github.com/golang/go/issues/19338
// https://pkg.go.dev/golang.org/x/crypto/ssh
func keepalive(cl *ssh.Client, conn net.Conn, done <-chan bool) error {
func keepalive(cl *ssh.Client, conn net.Conn, done <-chan bool) (err error) {
if Verbose {
log("keepalive start")
}
t := time.NewTicker(SshKeepAliveInterval)
defer t.Stop()
for {
err := conn.SetDeadline(time.Now().Add(2 * SshKeepAliveInterval))
if err != nil {
if Verbose {
log("keepalive failed to set deadline: %v", err)
/*
err = conn.SetDeadline(time.Now().Add(2 * SshKeepAliveInterval))
if err != nil {
if Verbose {
log("keepalive failed to set deadline: %v", err)
}
return fmt.Errorf("failed to set deadline: %w", err)
}
return fmt.Errorf("failed to set deadline: %w", err)
}
*/
select {
case <-t.C:
_, _, err = cl.SendRequest("keepalive@github.com/shoce/hs", true, nil)
Expand Down

0 comments on commit 319e4cf

Please sign in to comment.