Files
sam3/SAMConn.go

67 lines
1.3 KiB
Go
Raw Permalink Normal View History

2015-10-15 17:21:11 -04:00
package sam3
import (
"net"
2016-02-10 17:54:17 -05:00
"time"
2021-10-04 21:00:03 -04:00
2024-11-09 11:54:54 -05:00
"github.com/go-i2p/i2pkeys"
2015-10-15 17:21:11 -04:00
)
2024-11-22 20:35:39 -05:00
// SAMConn sets up a SAM connection.
2015-10-15 17:21:11 -04:00
// Implements net.Conn
type SAMConn struct {
laddr i2pkeys.I2PAddr
raddr i2pkeys.I2PAddr
2024-11-22 20:35:39 -05:00
net.Conn
2015-10-15 17:21:11 -04:00
}
2024-11-22 20:35:39 -05:00
// Read implements net.Conn
2019-02-09 17:01:29 -05:00
func (sc *SAMConn) Read(buf []byte) (int, error) {
2024-11-22 20:35:39 -05:00
n, err := sc.Conn.Read(buf)
2015-10-15 17:21:11 -04:00
return n, err
}
2024-11-22 20:35:39 -05:00
// Write Implements net.Conn
2019-02-09 17:01:29 -05:00
func (sc *SAMConn) Write(buf []byte) (int, error) {
2024-11-22 20:35:39 -05:00
n, err := sc.Conn.Write(buf)
2015-10-15 17:21:11 -04:00
return n, err
}
2024-11-22 20:35:39 -05:00
// Close Implements net.Conn
2019-02-09 17:01:29 -05:00
func (sc *SAMConn) Close() error {
2024-11-22 20:35:39 -05:00
return sc.Conn.Close()
2015-10-15 17:21:11 -04:00
}
2024-11-22 20:35:39 -05:00
// LocalAddr Implements net.Conn
2019-02-09 17:01:29 -05:00
func (sc *SAMConn) LocalAddr() net.Addr {
2016-02-10 17:54:17 -05:00
return sc.localAddr()
}
func (sc *SAMConn) localAddr() i2pkeys.I2PAddr {
2015-10-15 17:21:11 -04:00
return sc.laddr
}
2024-11-22 20:35:39 -05:00
// RemoteAddr Implements net.Conn
2019-02-09 17:01:29 -05:00
func (sc *SAMConn) RemoteAddr() net.Addr {
2016-02-10 17:54:17 -05:00
return sc.remoteAddr()
}
func (sc *SAMConn) remoteAddr() i2pkeys.I2PAddr {
2015-10-15 17:21:11 -04:00
return sc.raddr
}
2024-11-22 20:35:39 -05:00
// SetDeadline Implements net.Conn
2019-02-09 17:01:29 -05:00
func (sc *SAMConn) SetDeadline(t time.Time) error {
2024-11-22 20:35:39 -05:00
return sc.Conn.SetDeadline(t)
2015-10-15 17:21:11 -04:00
}
2024-11-22 20:35:39 -05:00
// SetReadDeadline Implements net.Conn
2019-02-09 17:01:29 -05:00
func (sc *SAMConn) SetReadDeadline(t time.Time) error {
2024-11-22 20:35:39 -05:00
return sc.Conn.SetReadDeadline(t)
2015-10-15 17:21:11 -04:00
}
2024-11-22 20:35:39 -05:00
// SetWriteDeadline Implements net.Conn
2019-02-09 17:01:29 -05:00
func (sc *SAMConn) SetWriteDeadline(t time.Time) error {
2024-11-22 20:35:39 -05:00
return sc.Conn.SetWriteDeadline(t)
2015-10-15 17:21:11 -04:00
}