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

View File

@ -22,3 +22,27 @@ func NewClientConn(conn net.Conn, client *ssh.Client) net.Conn {
func (c *ClientConn) Client() *ssh.Client {
return c.client
}
type sshConn struct {
channel ssh.Channel
net.Conn
}
func NewConn(conn net.Conn, channel ssh.Channel) net.Conn {
return &sshConn{
Conn: conn,
channel: channel,
}
}
func (c *sshConn) Read(b []byte) (n int, err error) {
return c.channel.Read(b)
}
func (c *sshConn) Write(b []byte) (n int, err error) {
return c.channel.Write(b)
}
func (c *sshConn) Close() error {
return c.channel.Close()
}