sing/common/bufio/deadline/conn.go
2023-04-09 15:02:29 +08:00

47 lines
881 B
Go

package deadline
import (
"net"
"time"
"github.com/sagernet/sing/common/buf"
"github.com/sagernet/sing/common/bufio"
N "github.com/sagernet/sing/common/network"
)
type Conn struct {
N.ExtendedConn
reader *Reader
}
func NewConn(conn net.Conn) *Conn {
return &Conn{ExtendedConn: bufio.NewExtendedConn(conn), reader: NewReader(conn)}
}
func (c *Conn) Read(p []byte) (n int, err error) {
return c.reader.Read(p)
}
func (c *Conn) ReadBuffer(buffer *buf.Buffer) error {
return c.reader.ReadBuffer(buffer)
}
func (c *Conn) SetReadDeadline(t time.Time) error {
return c.reader.SetReadDeadline(t)
}
func (c *Conn) ReaderReplaceable() bool {
return c.reader.ReaderReplaceable()
}
func (c *Conn) UpstreamReader() any {
return c.reader.UpstreamReader()
}
func (c *Conn) WriterReplaceable() bool {
return true
}
func (c *Conn) Upstream() any {
return c.ExtendedConn
}