-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsshchannelconn.go
45 lines (36 loc) · 1.27 KB
/
sshchannelconn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package revssh
import (
"net"
"time"
"golang.org/x/crypto/ssh"
)
// SSHChannelConn wraps an ssh.Channel to make it compatible with a net.Conn interface.
type SSHChannelConn struct {
ssh.Channel
}
// NewSSHChannelConn returns a new SSHChannelConn instanced from an ssh.Channel.
func NewSSHChannelConn(schan ssh.Channel) *SSHChannelConn {
return &SSHChannelConn{schan}
}
// LocalAddr always returns 'reverse-channel', as this is an ssh.Channel wrapper.
func (cc *SSHChannelConn) LocalAddr() net.Addr {
return &net.UnixAddr{Name: "reverse-channel", Net: "ssh"}
// return &net.TCPAddr{IP: net.ParseIP("::1"), Port: 22}
}
// RemoteAddr always returns 'reverse-channel', as this is an ssh.Channel wrapper.
func (cc *SSHChannelConn) RemoteAddr() net.Addr {
return &net.UnixAddr{Name: "reverse-channel", Net: "ssh"}
// return &net.TCPAddr{IP: net.ParseIP("::1"), Port: 22}
}
// SetDeadline does nothing, as this is an ssh.Channel wrapper.
func (cc *SSHChannelConn) SetDeadline(t time.Time) error {
return nil
}
// SetReadDeadline wrapper, as this is an ssh.Channel wrapper.
func (cc *SSHChannelConn) SetReadDeadline(t time.Time) error {
return nil
}
// SetWriteDeadline wrappes, as this is an ssh.Channel wrapper.
func (cc *SSHChannelConn) SetWriteDeadline(t time.Time) error {
return nil
}