Fix: CounterConnection with ReadV/WriteV (#720)

Co-authored-by: JimhHan <50871214+JimhHan@users.noreply.github.com>
This commit is contained in:
Arthur Morgan 2021-09-20 20:11:21 +08:00 committed by GitHub
parent f2cb13a8ec
commit 24b637cd5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 247 additions and 128 deletions

View file

@ -5,6 +5,8 @@ import (
"sync"
"time"
"github.com/xtls/xray-core/transport/internet/stat"
"github.com/lucas-clemente/quic-go"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/net"
@ -114,7 +116,7 @@ func (s *clientSessions) cleanSessions() error {
return nil
}
func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsConfig *tls.Config, sockopt *internet.SocketConfig) (internet.Connection, error) {
func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsConfig *tls.Config, sockopt *internet.SocketConfig) (stat.Connection, error) {
s.access.Lock()
defer s.access.Unlock()
@ -182,7 +184,7 @@ func init() {
common.Must(client.cleanup.Start())
}
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) {
tlsConfig := tls.ConfigFromStreamSettings(streamSettings)
if tlsConfig == nil {
tlsConfig = &tls.Config{

View file

@ -6,6 +6,8 @@ import (
"testing"
"time"
"github.com/xtls/xray-core/transport/internet/stat"
"github.com/google/go-cmp/cmp"
"github.com/xtls/xray-core/common"
@ -37,7 +39,7 @@ func TestQuicConnection(t *testing.T) {
),
},
},
}, func(conn internet.Connection) {
}, func(conn stat.Connection) {
go func() {
defer conn.Close()
@ -100,7 +102,7 @@ func TestQuicConnectionWithoutTLS(t *testing.T) {
listener, err := quic.Listen(context.Background(), net.LocalHostIP, port, &internet.MemoryStreamConfig{
ProtocolName: "quic",
ProtocolSettings: &quic.Config{},
}, func(conn internet.Connection) {
}, func(conn stat.Connection) {
go func() {
defer conn.Close()
@ -164,7 +166,7 @@ func TestQuicConnectionAuthHeader(t *testing.T) {
Type: protocol.SecurityType_AES128_GCM,
},
},
}, func(conn internet.Connection) {
}, func(conn stat.Connection) {
go func() {
defer conn.Close()