2024-05-17 17:43:28 +02:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Conn struct {
|
2024-05-23 13:24:02 +02:00
|
|
|
client *Client
|
|
|
|
dstID []byte
|
|
|
|
readerFn func(b []byte) (n int, err error)
|
2024-05-17 17:43:28 +02:00
|
|
|
}
|
|
|
|
|
2024-05-23 13:24:02 +02:00
|
|
|
func NewConn(client *Client, dstID []byte, readerFn func(b []byte) (n int, err error)) *Conn {
|
2024-05-17 17:43:28 +02:00
|
|
|
c := &Conn{
|
2024-05-23 13:24:02 +02:00
|
|
|
client: client,
|
|
|
|
dstID: dstID,
|
|
|
|
readerFn: readerFn,
|
2024-05-17 17:43:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) Write(p []byte) (n int, err error) {
|
2024-05-23 13:24:02 +02:00
|
|
|
return c.client.writeTo(c.dstID, p)
|
2024-05-17 17:43:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) Read(b []byte) (n int, err error) {
|
|
|
|
return c.readerFn(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) LocalAddr() net.Addr {
|
2024-05-19 12:41:06 +02:00
|
|
|
return c.client.relayConn.LocalAddr()
|
2024-05-17 17:43:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) RemoteAddr() net.Addr {
|
2024-05-19 12:41:06 +02:00
|
|
|
return c.client.relayConn.RemoteAddr()
|
2024-05-17 17:43:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) SetDeadline(t time.Time) error {
|
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) SetReadDeadline(t time.Time) error {
|
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Conn) SetWriteDeadline(t time.Time) error {
|
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|