|
@@ -11,8 +11,8 @@ import (
|
|
|
"github.com/stretchr/testify/require"
|
|
|
)
|
|
|
|
|
|
-func TestVMessGRPCSelf(t *testing.T) {
|
|
|
- testVMessWebscoketSelf(t, &option.V2RayTransportOptions{
|
|
|
+func TestV2RayGRPCSelf(t *testing.T) {
|
|
|
+ testV2RayTransportSelf(t, &option.V2RayTransportOptions{
|
|
|
Type: C.V2RayTransportTypeGRPC,
|
|
|
GRPCOptions: option.V2RayGRPCOptions{
|
|
|
ServiceName: "TunService",
|
|
@@ -20,14 +20,14 @@ func TestVMessGRPCSelf(t *testing.T) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-func TestVMessWebscoketSelf(t *testing.T) {
|
|
|
+func TestV2RayWebscoketSelf(t *testing.T) {
|
|
|
t.Run("basic", func(t *testing.T) {
|
|
|
- testVMessWebscoketSelf(t, &option.V2RayTransportOptions{
|
|
|
+ testV2RayTransportSelf(t, &option.V2RayTransportOptions{
|
|
|
Type: C.V2RayTransportTypeWebsocket,
|
|
|
})
|
|
|
})
|
|
|
t.Run("v2ray early data", func(t *testing.T) {
|
|
|
- testVMessWebscoketSelf(t, &option.V2RayTransportOptions{
|
|
|
+ testV2RayTransportSelf(t, &option.V2RayTransportOptions{
|
|
|
Type: C.V2RayTransportTypeWebsocket,
|
|
|
WebsocketOptions: option.V2RayWebsocketOptions{
|
|
|
MaxEarlyData: 2048,
|
|
@@ -35,7 +35,7 @@ func TestVMessWebscoketSelf(t *testing.T) {
|
|
|
})
|
|
|
})
|
|
|
t.Run("xray early data", func(t *testing.T) {
|
|
|
- testVMessWebscoketSelf(t, &option.V2RayTransportOptions{
|
|
|
+ testV2RayTransportSelf(t, &option.V2RayTransportOptions{
|
|
|
Type: C.V2RayTransportTypeWebsocket,
|
|
|
WebsocketOptions: option.V2RayWebsocketOptions{
|
|
|
MaxEarlyData: 2048,
|
|
@@ -45,13 +45,28 @@ func TestVMessWebscoketSelf(t *testing.T) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-func TestVMessHTTPSelf(t *testing.T) {
|
|
|
- testVMessWebscoketSelf(t, &option.V2RayTransportOptions{
|
|
|
+func TestV2RayHTTPSelf(t *testing.T) {
|
|
|
+ testV2RayTransportSelf(t, &option.V2RayTransportOptions{
|
|
|
Type: C.V2RayTransportTypeHTTP,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-func testVMessWebscoketSelf(t *testing.T, transport *option.V2RayTransportOptions) {
|
|
|
+func TestV2RayHTTPPlainSelf(t *testing.T) {
|
|
|
+ testV2RayTransportNOTLSSelf(t, &option.V2RayTransportOptions{
|
|
|
+ Type: C.V2RayTransportTypeHTTP,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func testV2RayTransportSelf(t *testing.T, transport *option.V2RayTransportOptions) {
|
|
|
+ t.Run("vmess", func(t *testing.T) {
|
|
|
+ testVMessTransportSelf(t, transport)
|
|
|
+ })
|
|
|
+ t.Run("trojan", func(t *testing.T) {
|
|
|
+ testTrojanTransportSelf(t, transport)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func testVMessTransportSelf(t *testing.T, transport *option.V2RayTransportOptions) {
|
|
|
user, err := uuid.DefaultGenerator.NewV4()
|
|
|
require.NoError(t, err)
|
|
|
_, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
|
|
@@ -130,6 +145,84 @@ func testVMessWebscoketSelf(t *testing.T, transport *option.V2RayTransportOption
|
|
|
testSuit(t, clientPort, testPort)
|
|
|
}
|
|
|
|
|
|
+func testTrojanTransportSelf(t *testing.T, transport *option.V2RayTransportOptions) {
|
|
|
+ user, err := uuid.DefaultGenerator.NewV4()
|
|
|
+ require.NoError(t, err)
|
|
|
+ _, certPem, keyPem := createSelfSignedCertificate(t, "example.org")
|
|
|
+ startInstance(t, option.Options{
|
|
|
+ Log: &option.LogOptions{
|
|
|
+ Level: "error",
|
|
|
+ },
|
|
|
+ Inbounds: []option.Inbound{
|
|
|
+ {
|
|
|
+ Type: C.TypeMixed,
|
|
|
+ Tag: "mixed-in",
|
|
|
+ MixedOptions: option.HTTPMixedInboundOptions{
|
|
|
+ ListenOptions: option.ListenOptions{
|
|
|
+ Listen: option.ListenAddress(netip.IPv4Unspecified()),
|
|
|
+ ListenPort: clientPort,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Type: C.TypeTrojan,
|
|
|
+ TrojanOptions: option.TrojanInboundOptions{
|
|
|
+ ListenOptions: option.ListenOptions{
|
|
|
+ Listen: option.ListenAddress(netip.IPv4Unspecified()),
|
|
|
+ ListenPort: serverPort,
|
|
|
+ },
|
|
|
+ Users: []option.TrojanUser{
|
|
|
+ {
|
|
|
+ Name: "sekai",
|
|
|
+ Password: user.String(),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ TLS: &option.InboundTLSOptions{
|
|
|
+ Enabled: true,
|
|
|
+ ServerName: "example.org",
|
|
|
+ CertificatePath: certPem,
|
|
|
+ KeyPath: keyPem,
|
|
|
+ },
|
|
|
+ Transport: transport,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Outbounds: []option.Outbound{
|
|
|
+ {
|
|
|
+ Type: C.TypeDirect,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Type: C.TypeTrojan,
|
|
|
+ Tag: "vmess-out",
|
|
|
+ TrojanOptions: option.TrojanOutboundOptions{
|
|
|
+ ServerOptions: option.ServerOptions{
|
|
|
+ Server: "127.0.0.1",
|
|
|
+ ServerPort: serverPort,
|
|
|
+ },
|
|
|
+ Password: user.String(),
|
|
|
+ TLS: &option.OutboundTLSOptions{
|
|
|
+ Enabled: true,
|
|
|
+ ServerName: "example.org",
|
|
|
+ CertificatePath: certPem,
|
|
|
+ },
|
|
|
+ Transport: transport,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Route: &option.RouteOptions{
|
|
|
+ Rules: []option.Rule{
|
|
|
+ {
|
|
|
+ DefaultOptions: option.DefaultRule{
|
|
|
+ Inbound: []string{"mixed-in"},
|
|
|
+ Outbound: "vmess-out",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ })
|
|
|
+ testSuit(t, clientPort, testPort)
|
|
|
+}
|
|
|
+
|
|
|
func TestVMessQUICSelf(t *testing.T) {
|
|
|
transport := &option.V2RayTransportOptions{
|
|
|
Type: C.V2RayTransportTypeQUIC,
|
|
@@ -212,10 +305,7 @@ func TestVMessQUICSelf(t *testing.T) {
|
|
|
testSuitQUIC(t, clientPort, testPort)
|
|
|
}
|
|
|
|
|
|
-func TestVMessHTTPNoTLSSelf(t *testing.T) {
|
|
|
- transport := &option.V2RayTransportOptions{
|
|
|
- Type: C.V2RayTransportTypeHTTP,
|
|
|
- }
|
|
|
+func testV2RayTransportNOTLSSelf(t *testing.T, transport *option.V2RayTransportOptions) {
|
|
|
user, err := uuid.DefaultGenerator.NewV4()
|
|
|
require.NoError(t, err)
|
|
|
startInstance(t, option.Options{
|