From b3f95098103bb50f845131f70b23d31dbe7b805e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 6 Sep 2023 21:59:52 +0800 Subject: [PATCH] documentation: Add notes for hysteria2 compatibility issues --- docs/configuration/inbound/hysteria2.md | 4 + docs/configuration/inbound/hysteria2.zh.md | 4 + docs/configuration/outbound/hysteria2.md | 4 + docs/configuration/outbound/hysteria2.zh.md | 4 + test/clash_test.go | 6 +- test/config/hysteria2-client.yml | 12 +++ test/config/hysteria2-server.yml | 13 +++ test/hysteria2_test.go | 89 +++++++++++++++++++++ 8 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 test/config/hysteria2-client.yml create mode 100644 test/config/hysteria2-server.yml diff --git a/docs/configuration/inbound/hysteria2.md b/docs/configuration/inbound/hysteria2.md index b65304e24..f4b5973c8 100644 --- a/docs/configuration/inbound/hysteria2.md +++ b/docs/configuration/inbound/hysteria2.md @@ -25,6 +25,10 @@ } ``` +!!! warning "Compatibility issues with original client" + + When using the original client, the use case with `fastOpen=false` or UDP MTU >= 1200 is not supported. + !!! warning "" QUIC, which is required by Hysteria2 is not included by default, see [Installation](/#installation). diff --git a/docs/configuration/inbound/hysteria2.zh.md b/docs/configuration/inbound/hysteria2.zh.md index 49d2258a3..d5e3c5337 100644 --- a/docs/configuration/inbound/hysteria2.zh.md +++ b/docs/configuration/inbound/hysteria2.zh.md @@ -25,6 +25,10 @@ } ``` +!!! warning "与原始客户端的兼容性问题" + + 当使用原始客户端时,不支持 `fastOpen=false` 或者 UDP MTU >= 1200 的用例。 + !!! warning "" 默认安装不包含被 Hysteria2 依赖的 QUIC,参阅 [安装](/zh/#_2)。 diff --git a/docs/configuration/outbound/hysteria2.md b/docs/configuration/outbound/hysteria2.md index 115c1f251..6d04161d4 100644 --- a/docs/configuration/outbound/hysteria2.md +++ b/docs/configuration/outbound/hysteria2.md @@ -21,6 +21,10 @@ } ``` +!!! warning "Compatibility issues with original server" + + When using the original server, the use case with `fastOpen=false` or UDP MTU >= 1200 is not supported. + !!! warning "" QUIC, which is required by Hysteria2 is not included by default, see [Installation](/#installation). diff --git a/docs/configuration/outbound/hysteria2.zh.md b/docs/configuration/outbound/hysteria2.zh.md index ba699b584..64ee5538d 100644 --- a/docs/configuration/outbound/hysteria2.zh.md +++ b/docs/configuration/outbound/hysteria2.zh.md @@ -21,6 +21,10 @@ } ``` +!!! warning "与原始服务器的兼容性问题" + + 当使用原始服务器时,不支持 `fastOpen=false` 或者 UDP MTU >= 1200 的用例。 + !!! warning "" 默认安装不包含被 Hysteria2 依赖的 QUIC,参阅 [安装](/zh/#_2)。 diff --git a/test/clash_test.go b/test/clash_test.go index af9e80b40..4ade42f10 100644 --- a/test/clash_test.go +++ b/test/clash_test.go @@ -32,7 +32,8 @@ const ( ImageTrojan = "trojangfw/trojan:latest" ImageNaive = "pocat/naiveproxy:client" ImageBoringTun = "ghcr.io/ntkme/boringtun:edge" - ImageHysteria = "tobyxdd/hysteria:latest" + ImageHysteria = "teddysun/hysteria:1.3.5" + ImageHysteria2 = "teddysun/hysteria:latest" ImageNginx = "nginx:stable" ImageShadowTLS = "ghcr.io/ihciah/shadow-tls:latest" ImageShadowsocksR = "teddysun/shadowsocks-r:latest" @@ -50,6 +51,7 @@ var allImages = []string{ ImageNaive, ImageBoringTun, ImageHysteria, + ImageHysteria2, ImageNginx, ImageShadowTLS, ImageShadowsocksR, @@ -376,7 +378,7 @@ func testLargeDataWithPacketConnSize(t *testing.T, port uint16, chunkSize int, p rAddr := &net.UDPAddr{IP: localIP.AsSlice(), Port: int(port)} - times := 50 + times := 2 pingCh, pongCh, test := newLargeDataPair() writeRandData := func(pc net.PacketConn, addr net.Addr) (map[int][]byte, error) { diff --git a/test/config/hysteria2-client.yml b/test/config/hysteria2-client.yml new file mode 100644 index 000000000..403451a06 --- /dev/null +++ b/test/config/hysteria2-client.yml @@ -0,0 +1,12 @@ +server: 127.0.0.1:10000 +auth: password +fastOpen: true +socks5: + listen: 127.0.0.1:10001 +tls: + sni: example.org + ca: /etc/hysteria/ca.pem +obfs: + type: salamander + salamander: + password: cry_me_a_r1ver \ No newline at end of file diff --git a/test/config/hysteria2-server.yml b/test/config/hysteria2-server.yml new file mode 100644 index 000000000..9b4b1b130 --- /dev/null +++ b/test/config/hysteria2-server.yml @@ -0,0 +1,13 @@ +listen: 127.0.0.1:10000 +auth: + type: password + password: password +fastOpen: true +tls: + sni: example.org + cert: /etc/hysteria/cert.pem + key: /etc/hysteria/key.pem +obfs: + type: salamander + salamander: + password: cry_me_a_r1ver \ No newline at end of file diff --git a/test/hysteria2_test.go b/test/hysteria2_test.go index 22e9c1640..06284d1e9 100644 --- a/test/hysteria2_test.go +++ b/test/hysteria2_test.go @@ -95,3 +95,92 @@ func testHysteria2Self(t *testing.T, salamanderPassword string) { }) testSuit(t, clientPort, testPort) } + +func TestHysteria2Inbound(t *testing.T) { + caPem, certPem, keyPem := createSelfSignedCertificate(t, "example.org") + startInstance(t, option.Options{ + Inbounds: []option.Inbound{ + { + Type: C.TypeHysteria2, + Hysteria2Options: option.Hysteria2InboundOptions{ + ListenOptions: option.ListenOptions{ + Listen: option.NewListenAddress(netip.IPv4Unspecified()), + ListenPort: serverPort, + }, + Obfs: &option.Hysteria2Obfs{ + Type: hysteria2.ObfsTypeSalamander, + Password: "cry_me_a_r1ver", + }, + Users: []option.Hysteria2User{{ + Password: "password", + }}, + TLS: &option.InboundTLSOptions{ + Enabled: true, + ServerName: "example.org", + CertificatePath: certPem, + KeyPath: keyPem, + }, + }, + }, + }, + }) + startDockerContainer(t, DockerOptions{ + Image: ImageHysteria2, + Ports: []uint16{serverPort, clientPort}, + Cmd: []string{"hysteria", "client", "-c", "/etc/hysteria/config.yml", "--disable-update-check", "--log-level", "debug"}, + Bind: map[string]string{ + "hysteria2-client.yml": "/etc/hysteria/config.yml", + caPem: "/etc/hysteria/ca.pem", + }, + }) + testSuit(t, clientPort, testPort) +} + +func TestHysteria2Outbound(t *testing.T) { + _, certPem, keyPem := createSelfSignedCertificate(t, "example.org") + startDockerContainer(t, DockerOptions{ + Image: ImageHysteria2, + Ports: []uint16{testPort}, + Cmd: []string{"hysteria", "server", "-c", "/etc/hysteria/config.yml", "--disable-update-check", "--log-level", "debug"}, + Bind: map[string]string{ + "hysteria2-server.yml": "/etc/hysteria/config.yml", + certPem: "/etc/hysteria/cert.pem", + keyPem: "/etc/hysteria/key.pem", + }, + }) + startInstance(t, option.Options{ + Inbounds: []option.Inbound{ + { + Type: C.TypeMixed, + MixedOptions: option.HTTPMixedInboundOptions{ + ListenOptions: option.ListenOptions{ + Listen: option.NewListenAddress(netip.IPv4Unspecified()), + ListenPort: clientPort, + }, + }, + }, + }, + Outbounds: []option.Outbound{ + { + Type: C.TypeHysteria2, + Hysteria2Options: option.Hysteria2OutboundOptions{ + ServerOptions: option.ServerOptions{ + Server: "127.0.0.1", + ServerPort: serverPort, + }, + Obfs: &option.Hysteria2Obfs{ + Type: hysteria2.ObfsTypeSalamander, + Password: "cry_me_a_r1ver", + }, + Password: "password", + TLS: &option.OutboundTLSOptions{ + Enabled: true, + ServerName: "example.org", + CertificatePath: certPem, + }, + }, + }, + }, + }) + testSuitSimple1(t, clientPort, testPort) +}