add ssh tunnel

This commit is contained in:
ginuerzh
2021-12-19 17:24:51 +08:00
parent 10bcc59370
commit 34d6e393a1
12 changed files with 561 additions and 50 deletions

31
pkg/dialer/ssh/conn.go Normal file
View File

@ -0,0 +1,31 @@
package ssh
import (
"net"
"golang.org/x/crypto/ssh"
)
type sshSession struct {
addr string
conn net.Conn
client *ssh.Client
closed chan struct{}
dead chan struct{}
}
func (s *sshSession) IsClosed() bool {
select {
case <-s.dead:
return true
case <-s.closed:
return true
default:
}
return false
}
func (s *sshSession) wait() error {
defer close(s.closed)
return s.client.Wait()
}