Add deadline interface

This commit is contained in:
世界 2023-04-17 18:01:32 +08:00
parent 6489261191
commit f772573405
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
8 changed files with 36 additions and 22 deletions

View file

@ -13,7 +13,6 @@ import (
"github.com/sagernet/sing-shadowsocks"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/buf"
"github.com/sagernet/sing/common/bufio/deadline"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
@ -144,15 +143,15 @@ func (m *Method) DialConn(conn net.Conn, destination M.Socksaddr) (net.Conn, err
Conn: conn,
destination: destination,
}
return deadline.NewConn(shadowsocksConn), shadowsocksConn.writeRequest()
return shadowsocksConn, shadowsocksConn.writeRequest()
}
func (m *Method) DialEarlyConn(conn net.Conn, destination M.Socksaddr) net.Conn {
return deadline.NewConn(&clientConn{
return &clientConn{
Method: m,
Conn: conn,
destination: destination,
})
}
}
func (m *Method) DialPacketConn(conn net.Conn) N.NetPacketConn {
@ -239,6 +238,10 @@ func (c *clientConn) Write(p []byte) (n int, err error) {
return c.Conn.Write(p)
}
func (c *clientConn) NeedAdditionalReadDeadline() bool {
return true
}
func (c *clientConn) Upstream() any {
return c.Conn
}