mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 01:08:33 +00:00
Fix close pipe
This commit is contained in:
parent
f0b58d9ee0
commit
91ce752405
4 changed files with 17 additions and 30 deletions
|
@ -67,9 +67,6 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int
|
|||
if outbound == nil || !outbound.Target.IsValid() {
|
||||
return newError("target not specified")
|
||||
}
|
||||
/*if statConn, ok := inboundConn.(*internet.StatCounterConn); ok {
|
||||
inboundConn = statConn.Connection
|
||||
}*/
|
||||
destination := outbound.Target
|
||||
network := destination.Network
|
||||
|
||||
|
@ -92,6 +89,7 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int
|
|||
}
|
||||
_payload := B.StackNew()
|
||||
payload := C.Dup(_payload)
|
||||
defer payload.Release()
|
||||
for {
|
||||
payload.FullReset()
|
||||
nb, n := buf.SplitBytes(mb, payload.FreeBytes())
|
||||
|
@ -127,7 +125,7 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int
|
|||
conn.R = &buf.BufferedReader{Reader: link.Reader}
|
||||
}
|
||||
|
||||
return bufio.CopyConn(ctx, conn, serverConn)
|
||||
return returnError(bufio.CopyConn(ctx, conn, serverConn))
|
||||
} else {
|
||||
var packetConn N.PacketConn
|
||||
if pc, isPacketConn := inboundConn.(N.PacketConn); isPacketConn {
|
||||
|
@ -144,6 +142,6 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int
|
|||
}
|
||||
|
||||
serverConn := o.method.DialPacketConn(connection)
|
||||
return bufio.CopyPacketConn(ctx, packetConn, serverConn)
|
||||
return returnError(bufio.CopyPacketConn(ctx, packetConn, serverConn))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package shadowsocks_2022
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
B "github.com/sagernet/sing/common/buf"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/buf"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
)
|
||||
|
@ -47,9 +47,6 @@ type pipeConnWrapper struct {
|
|||
}
|
||||
|
||||
func (w *pipeConnWrapper) Close() error {
|
||||
common.Interrupt(w.R)
|
||||
common.Interrupt(w.W)
|
||||
common.Close(w.Conn)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -136,8 +133,13 @@ func (w *packetConnWrapper) WritePacket(buffer *B.Buffer, destination M.Socksadd
|
|||
}
|
||||
|
||||
func (w *packetConnWrapper) Close() error {
|
||||
common.Interrupt(w.Reader)
|
||||
common.Close(w.Conn)
|
||||
buf.ReleaseMulti(w.cached)
|
||||
return nil
|
||||
}
|
||||
|
||||
func returnError(err error) error {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue