forked from kpetku/sam3
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSAMConn.go
66 lines (53 loc) · 1.26 KB
/
SAMConn.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package sam3
import (
"net"
"time"
"github.com/go-i2p/i2pkeys"
)
// SAMConn sets up a SAM connection.
// Implements net.Conn
type SAMConn struct {
laddr i2pkeys.I2PAddr
raddr i2pkeys.I2PAddr
net.Conn
}
// Read implements net.Conn
func (sc *SAMConn) Read(buf []byte) (int, error) {
n, err := sc.Conn.Read(buf)
return n, err
}
// Write Implements net.Conn
func (sc *SAMConn) Write(buf []byte) (int, error) {
n, err := sc.Conn.Write(buf)
return n, err
}
// Close Implements net.Conn
func (sc *SAMConn) Close() error {
return sc.Conn.Close()
}
// LocalAddr Implements net.Conn
func (sc *SAMConn) LocalAddr() net.Addr {
return sc.localAddr()
}
func (sc *SAMConn) localAddr() i2pkeys.I2PAddr {
return sc.laddr
}
// RemoteAddr Implements net.Conn
func (sc *SAMConn) RemoteAddr() net.Addr {
return sc.remoteAddr()
}
func (sc *SAMConn) remoteAddr() i2pkeys.I2PAddr {
return sc.raddr
}
// SetDeadline Implements net.Conn
func (sc *SAMConn) SetDeadline(t time.Time) error {
return sc.Conn.SetDeadline(t)
}
// SetReadDeadline Implements net.Conn
func (sc *SAMConn) SetReadDeadline(t time.Time) error {
return sc.Conn.SetReadDeadline(t)
}
// SetWriteDeadline Implements net.Conn
func (sc *SAMConn) SetWriteDeadline(t time.Time) error {
return sc.Conn.SetWriteDeadline(t)
}