mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-26 06:39:20 +02:00
Add reality test
This commit is contained in:
parent
57ed75eb67
commit
772936906a
|
@ -1,8 +1,8 @@
|
||||||
package scenarios
|
package scenarios
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "encoding/base64"
|
"encoding/base64"
|
||||||
// "encoding/hex"
|
"encoding/hex"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import (
|
||||||
"github.com/xtls/xray-core/proxy/vless/outbound"
|
"github.com/xtls/xray-core/proxy/vless/outbound"
|
||||||
"github.com/xtls/xray-core/testing/servers/tcp"
|
"github.com/xtls/xray-core/testing/servers/tcp"
|
||||||
"github.com/xtls/xray-core/transport/internet"
|
"github.com/xtls/xray-core/transport/internet"
|
||||||
// "github.com/xtls/xray-core/transport/internet/reality"
|
"github.com/xtls/xray-core/transport/internet/reality"
|
||||||
transtcp "github.com/xtls/xray-core/transport/internet/tcp"
|
transtcp "github.com/xtls/xray-core/transport/internet/tcp"
|
||||||
"github.com/xtls/xray-core/transport/internet/tls"
|
"github.com/xtls/xray-core/transport/internet/tls"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
@ -377,142 +377,143 @@ func TestVlessXtlsVision(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func TestVlessXtlsVisionReality(t *testing.T) {
|
func TestVlessXtlsVisionReality(t *testing.T) {
|
||||||
// tcpServer := tcp.Server{
|
tcpServer := tcp.Server{
|
||||||
// MsgProcessor: xor,
|
MsgProcessor: xor,
|
||||||
// }
|
}
|
||||||
// dest, err := tcpServer.Start()
|
dest, err := tcpServer.Start()
|
||||||
// common.Must(err)
|
common.Must(err)
|
||||||
// defer tcpServer.Close()
|
defer tcpServer.Close()
|
||||||
|
|
||||||
// userID := protocol.NewID(uuid.New())
|
userID := protocol.NewID(uuid.New())
|
||||||
// serverPort := tcp.PickPort()
|
serverPort := tcp.PickPort()
|
||||||
// privateKey, _ := base64.RawURLEncoding.DecodeString("aGSYystUbf59_9_6LKRxD27rmSW_-2_nyd9YG_Gwbks")
|
privateKey, _ := base64.RawURLEncoding.DecodeString("aGSYystUbf59_9_6LKRxD27rmSW_-2_nyd9YG_Gwbks")
|
||||||
// publicKey, _ := base64.RawURLEncoding.DecodeString("E59WjnvZcQMu7tR7_BgyhycuEdBS-CtKxfImRCdAvFM")
|
publicKey, _ := base64.RawURLEncoding.DecodeString("E59WjnvZcQMu7tR7_BgyhycuEdBS-CtKxfImRCdAvFM")
|
||||||
// shortIds := make([][]byte, 1)
|
shortIds := make([][]byte, 1)
|
||||||
// shortIds[0] = make([]byte, 8)
|
shortIds[0] = make([]byte, 8)
|
||||||
// hex.Decode(shortIds[0], []byte("0123456789abcdef"))
|
hex.Decode(shortIds[0], []byte("0123456789abcdef"))
|
||||||
// serverConfig := &core.Config{
|
serverConfig := &core.Config{
|
||||||
// App: []*serial.TypedMessage{
|
App: []*serial.TypedMessage{
|
||||||
// serial.ToTypedMessage(&log.Config{
|
serial.ToTypedMessage(&log.Config{
|
||||||
// ErrorLogLevel: clog.Severity_Debug,
|
ErrorLogLevel: clog.Severity_Debug,
|
||||||
// ErrorLogType: log.LogType_Console,
|
ErrorLogType: log.LogType_Console,
|
||||||
// }),
|
}),
|
||||||
// },
|
},
|
||||||
// Inbound: []*core.InboundHandlerConfig{
|
Inbound: []*core.InboundHandlerConfig{
|
||||||
// {
|
{
|
||||||
// ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
||||||
// PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}},
|
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}},
|
||||||
// Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
// StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
// Protocol: internet.TransportProtocol_TCP,
|
Protocol: internet.TransportProtocol_TCP,
|
||||||
// SecurityType: serial.GetMessageType(&reality.Config{}),
|
SecurityType: serial.GetMessageType(&reality.Config{}),
|
||||||
// SecuritySettings: []*serial.TypedMessage{
|
SecuritySettings: []*serial.TypedMessage{
|
||||||
// serial.ToTypedMessage(&reality.Config{
|
serial.ToTypedMessage(&reality.Config{
|
||||||
// Show: true,
|
Show: true,
|
||||||
// Dest: "www.google.com:443", // use google for now, may fail in some region
|
Dest: "www.google.com:443", // use google for now, may fail in some region
|
||||||
// ServerNames: []string{"www.google.com"},
|
ServerNames: []string{"www.google.com"},
|
||||||
// PrivateKey: privateKey,
|
PrivateKey: privateKey,
|
||||||
// ShortIds: shortIds,
|
ShortIds: shortIds,
|
||||||
// }),
|
Type: "tcp",
|
||||||
// },
|
}),
|
||||||
// },
|
},
|
||||||
// }),
|
},
|
||||||
// ProxySettings: serial.ToTypedMessage(&inbound.Config{
|
}),
|
||||||
// Clients: []*protocol.User{
|
ProxySettings: serial.ToTypedMessage(&inbound.Config{
|
||||||
// {
|
Clients: []*protocol.User{
|
||||||
// Account: serial.ToTypedMessage(&vless.Account{
|
{
|
||||||
// Id: userID.String(),
|
Account: serial.ToTypedMessage(&vless.Account{
|
||||||
// Flow: vless.XRV,
|
Id: userID.String(),
|
||||||
// }),
|
Flow: vless.XRV,
|
||||||
// },
|
}),
|
||||||
// },
|
},
|
||||||
// }),
|
},
|
||||||
// },
|
}),
|
||||||
// },
|
},
|
||||||
// Outbound: []*core.OutboundHandlerConfig{
|
},
|
||||||
// {
|
Outbound: []*core.OutboundHandlerConfig{
|
||||||
// ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
|
{
|
||||||
// },
|
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
|
||||||
// },
|
},
|
||||||
// }
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// clientPort := tcp.PickPort()
|
clientPort := tcp.PickPort()
|
||||||
// clientConfig := &core.Config{
|
clientConfig := &core.Config{
|
||||||
// App: []*serial.TypedMessage{
|
App: []*serial.TypedMessage{
|
||||||
// serial.ToTypedMessage(&log.Config{
|
serial.ToTypedMessage(&log.Config{
|
||||||
// ErrorLogLevel: clog.Severity_Debug,
|
ErrorLogLevel: clog.Severity_Debug,
|
||||||
// ErrorLogType: log.LogType_Console,
|
ErrorLogType: log.LogType_Console,
|
||||||
// }),
|
}),
|
||||||
// },
|
},
|
||||||
// Inbound: []*core.InboundHandlerConfig{
|
Inbound: []*core.InboundHandlerConfig{
|
||||||
// {
|
{
|
||||||
// ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
||||||
// PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}},
|
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}},
|
||||||
// Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
// }),
|
}),
|
||||||
// ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
// Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
// Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
// NetworkList: &net.NetworkList{
|
NetworkList: &net.NetworkList{
|
||||||
// Network: []net.Network{net.Network_TCP},
|
Network: []net.Network{net.Network_TCP},
|
||||||
// },
|
},
|
||||||
// }),
|
}),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// Outbound: []*core.OutboundHandlerConfig{
|
Outbound: []*core.OutboundHandlerConfig{
|
||||||
// {
|
{
|
||||||
// ProxySettings: serial.ToTypedMessage(&outbound.Config{
|
ProxySettings: serial.ToTypedMessage(&outbound.Config{
|
||||||
// Vnext: []*protocol.ServerEndpoint{
|
Vnext: []*protocol.ServerEndpoint{
|
||||||
// {
|
{
|
||||||
// Address: net.NewIPOrDomain(net.LocalHostIP),
|
Address: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
// Port: uint32(serverPort),
|
Port: uint32(serverPort),
|
||||||
// User: []*protocol.User{
|
User: []*protocol.User{
|
||||||
// {
|
{
|
||||||
// Account: serial.ToTypedMessage(&vless.Account{
|
Account: serial.ToTypedMessage(&vless.Account{
|
||||||
// Id: userID.String(),
|
Id: userID.String(),
|
||||||
// Flow: vless.XRV,
|
Flow: vless.XRV,
|
||||||
// }),
|
}),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }),
|
}),
|
||||||
// SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
||||||
// StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
// Protocol: internet.TransportProtocol_TCP,
|
Protocol: internet.TransportProtocol_TCP,
|
||||||
// TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
// {
|
{
|
||||||
// Protocol: internet.TransportProtocol_TCP,
|
Protocol: internet.TransportProtocol_TCP,
|
||||||
// Settings: serial.ToTypedMessage(&transtcp.Config{}),
|
Settings: serial.ToTypedMessage(&transtcp.Config{}),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// SecurityType: serial.GetMessageType(&reality.Config{}),
|
SecurityType: serial.GetMessageType(&reality.Config{}),
|
||||||
// SecuritySettings: []*serial.TypedMessage{
|
SecuritySettings: []*serial.TypedMessage{
|
||||||
// serial.ToTypedMessage(&reality.Config{
|
serial.ToTypedMessage(&reality.Config{
|
||||||
// Show: true,
|
Show: true,
|
||||||
// Fingerprint: "chrome",
|
Fingerprint: "chrome",
|
||||||
// ServerName: "www.google.com",
|
ServerName: "www.google.com",
|
||||||
// PublicKey: publicKey,
|
PublicKey: publicKey,
|
||||||
// ShortId: shortIds[0],
|
ShortId: shortIds[0],
|
||||||
// SpiderX: "/",
|
SpiderX: "/",
|
||||||
// }),
|
}),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }),
|
}),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
|
|
||||||
// servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||||
// common.Must(err)
|
common.Must(err)
|
||||||
// defer CloseAllServers(servers)
|
defer CloseAllServers(servers)
|
||||||
|
|
||||||
// var errg errgroup.Group
|
var errg errgroup.Group
|
||||||
// for i := 0; i < 1; i++ {
|
for i := 0; i < 1; i++ {
|
||||||
// errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*30))
|
errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*30))
|
||||||
// }
|
}
|
||||||
// if err := errg.Wait(); err != nil {
|
if err := errg.Wait(); err != nil {
|
||||||
// t.Error(err)
|
t.Error(err)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
Loading…
Reference in New Issue