chore: using new chan based deadline reader
This commit is contained in:
@ -100,7 +100,8 @@ func (l *Listener) AddrList() (addrList []net.Addr) {
|
||||
}
|
||||
|
||||
func (l *Listener) HandleConn(conn net.Conn, in chan<- C.ConnContext, additions ...inbound.Addition) {
|
||||
conn = N.NewDeadlineConn(l.pickCipher.StreamConn(conn))
|
||||
conn = l.pickCipher.StreamConn(conn)
|
||||
conn = N.NewDeadlineConn(conn) // embed ss can't handle readDeadline correctly
|
||||
|
||||
target, err := socks5.ReadAddr(conn, make([]byte, socks5.MaxAddrLen))
|
||||
if err != nil {
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/inbound"
|
||||
N "github.com/Dreamacro/clash/common/net"
|
||||
"github.com/Dreamacro/clash/common/pool"
|
||||
"github.com/Dreamacro/clash/common/sockopt"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
@ -30,7 +29,7 @@ func NewUDP(addr string, pickCipher core.Cipher, in chan<- C.PacketAdapter) (*UD
|
||||
}
|
||||
|
||||
sl := &UDPListener{l, false}
|
||||
conn := N.NewDeadlinePacketConn(pickCipher.PacketConn(l))
|
||||
conn := pickCipher.PacketConn(l)
|
||||
go func() {
|
||||
for {
|
||||
buf := pool.Get(pool.RelayBufferSize)
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
|
||||
vmess "github.com/sagernet/sing-vmess"
|
||||
"github.com/sagernet/sing/common/buf"
|
||||
"github.com/sagernet/sing/common/bufio/deadline"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
"github.com/sagernet/sing/common/network"
|
||||
@ -80,6 +81,9 @@ func (h *ListenerHandler) NewConnection(ctx context.Context, conn net.Conn, meta
|
||||
defer wg.Wait() // this goroutine must exit after conn.Close()
|
||||
wg.Add(1)
|
||||
|
||||
if deadline.NeedAdditionalReadDeadline(conn) {
|
||||
conn = N.NewDeadlineConn(conn) // conn from sing should check NeedAdditionalReadDeadline
|
||||
}
|
||||
h.TcpIn <- inbound.NewSocket(target, &waitCloseConn{ExtendedConn: N.NewExtendedConn(conn), wg: wg, rAddr: metadata.Source.TCPAddr()}, h.Type, additions...)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user