chore: support splice for direct outbound

This commit is contained in:
wwqgtxx
2023-04-25 23:01:05 +08:00
parent efcb278f61
commit 7bb5da3005
10 changed files with 76 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ package net
import (
"context"
"net"
"runtime"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/bufio"
@@ -33,7 +34,11 @@ func NeedHandshake(conn any) bool {
return false
}
type CountFunc = network.CountFunc
// Relay copies between left and right bidirectionally.
func Relay(leftConn, rightConn net.Conn) {
defer runtime.KeepAlive(leftConn)
defer runtime.KeepAlive(rightConn)
_ = bufio.CopyConn(context.TODO(), leftConn, rightConn)
}