github.com/sagernet/sing@v0.2.6/common/bufio/copy_direct.go (about)

     1  package bufio
     2  
     3  import (
     4  	"syscall"
     5  
     6  	N "github.com/sagernet/sing/common/network"
     7  )
     8  
     9  func CopyDirect(source syscall.Conn, destination syscall.Conn, readCounters []N.CountFunc, writeCounters []N.CountFunc) (handed bool, n int64, err error) {
    10  	rawSource, err := source.SyscallConn()
    11  	if err != nil {
    12  		return
    13  	}
    14  	rawDestination, err := destination.SyscallConn()
    15  	if err != nil {
    16  		return
    17  	}
    18  	handed, n, err = splice(rawSource, rawDestination, readCounters, writeCounters)
    19  	return
    20  }