mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Fix: CounterConnection with ReadV/WriteV (#720)
Co-authored-by: JimhHan <50871214+JimhHan@users.noreply.github.com>
This commit is contained in:
parent
f2cb13a8ec
commit
24b637cd5e
53 changed files with 247 additions and 128 deletions
|
@ -3,6 +3,8 @@ package tcp
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/xtls/xray-core/transport/internet/stat"
|
||||
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/common/session"
|
||||
|
@ -12,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
// Dial dials a new TCP connection to the given destination.
|
||||
func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (internet.Connection, error) {
|
||||
func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) {
|
||||
newError("dialing TCP to ", dest).WriteToLog(session.ExportIDToError(ctx))
|
||||
conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings)
|
||||
if err != nil {
|
||||
|
@ -46,7 +48,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
|||
}
|
||||
conn = auth.Client(conn)
|
||||
}
|
||||
return internet.Connection(conn), nil
|
||||
return stat.Connection(conn), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/xtls/xray-core/transport/internet/stat"
|
||||
|
||||
goxtls "github.com/xtls/go"
|
||||
|
||||
"github.com/xtls/xray-core/common"
|
||||
|
@ -120,7 +122,7 @@ func (v *Listener) keepAccepting() {
|
|||
conn = v.authConfig.Server(conn)
|
||||
}
|
||||
|
||||
v.addConn(internet.Connection(conn))
|
||||
v.addConn(stat.Connection(conn))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@ package tcp
|
|||
import (
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/transport/internet"
|
||||
"github.com/xtls/xray-core/transport/internet/stat"
|
||||
)
|
||||
|
||||
// GetOriginalDestination from tcp conn
|
||||
func GetOriginalDestination(conn internet.Connection) (net.Destination, error) {
|
||||
func GetOriginalDestination(conn stat.Connection) (net.Destination, error) {
|
||||
la := conn.LocalAddr()
|
||||
ra := conn.RemoteAddr()
|
||||
ip, port, err := internet.OriginalDst(la, ra)
|
||||
|
|
|
@ -6,13 +6,14 @@ import (
|
|||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/xtls/xray-core/transport/internet/stat"
|
||||
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/transport/internet"
|
||||
)
|
||||
|
||||
const SO_ORIGINAL_DST = 80
|
||||
|
||||
func GetOriginalDestination(conn internet.Connection) (net.Destination, error) {
|
||||
func GetOriginalDestination(conn stat.Connection) (net.Destination, error) {
|
||||
sysrawconn, f := conn.(syscall.Conn)
|
||||
if !f {
|
||||
return net.Destination{}, newError("unable to get syscall.Conn")
|
||||
|
|
|
@ -4,9 +4,9 @@ package tcp
|
|||
|
||||
import (
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/transport/internet"
|
||||
"github.com/xtls/xray-core/transport/internet/stat"
|
||||
)
|
||||
|
||||
func GetOriginalDestination(conn internet.Connection) (net.Destination, error) {
|
||||
func GetOriginalDestination(conn stat.Connection) (net.Destination, error) {
|
||||
return net.Destination{}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue