From cb61bf90b2959300d7cb2053aa642f200189ba1b Mon Sep 17 00:00:00 2001 From: Mix <32300164+mnixry@users.noreply.github.com> Date: Sun, 16 Jun 2024 20:41:27 +0800 Subject: [PATCH] feat: Add support for hysteria2 dialer and protocol (#533) Co-authored-by: mzz <2017@duck.com> --- .github/workflows/kernel-test.yml | 2 +- .github/workflows/prerelease.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/seed-build.yml | 2 +- Dockerfile | 2 +- cmd/run.go | 4 ++-- component/outbound/outbound.go | 2 ++ go.mod | 10 ++++++---- go.sum | 16 ++++++++++++++-- 9 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.github/workflows/kernel-test.yml b/.github/workflows/kernel-test.yml index e336911..b1181d9 100644 --- a/.github/workflows/kernel-test.yml +++ b/.github/workflows/kernel-test.yml @@ -23,7 +23,7 @@ jobs: cache-dependency-path: | go.mod go.sum - go-version: 1.21.0 + go-version: 1.22.4 - name: Generate and build run: | diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index fd63bf3..839b5a5 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -73,7 +73,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: '^1.21' + go-version: '^2' - name: Install Dependencies run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 929aaea..7e11160 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,7 +76,7 @@ jobs: cache-dependency-path: | go.mod go.sum - go-version: '^1.21' + go-version: '^1.22' - name: Install Dependencies run: | diff --git a/.github/workflows/seed-build.yml b/.github/workflows/seed-build.yml index 6e76c2f..eb7e867 100644 --- a/.github/workflows/seed-build.yml +++ b/.github/workflows/seed-build.yml @@ -102,7 +102,7 @@ jobs: cache-dependency-path: | go.mod go.sum - go-version: '^1.21' + go-version: '^1.22' - name: Install Dependencies run: | diff --git a/Dockerfile b/Dockerfile index ac59f36..9c45189 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-bookworm AS builder +FROM golang:1.22-bookworm AS builder RUN apt-get update && apt-get install -y llvm-15 clang-15 git make ENV CLANG=clang-15 WORKDIR /build/ diff --git a/cmd/run.go b/cmd/run.go index 01c6d70..c3be0d6 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -9,6 +9,7 @@ import ( "context" "errors" "fmt" + "math/rand/v2" "net" "net/http" "os" @@ -21,7 +22,6 @@ import ( "time" "github.com/daeuniverse/outbound/netproxy" - "github.com/daeuniverse/outbound/pkg/fastrand" "github.com/daeuniverse/outbound/protocol/direct" "gopkg.in/natefinch/lumberjack.v2" @@ -62,7 +62,7 @@ func init() { runCmd.PersistentFlags().BoolVarP(&disableTimestamp, "disable-timestamp", "", false, "Disable timestamp.") runCmd.PersistentFlags().BoolVarP(&disablePidFile, "disable-pidfile", "", false, "Not generate /var/run/dae.pid.") - fastrand.Rand().Shuffle(len(CheckNetworkLinks), func(i, j int) { + rand.Shuffle(len(CheckNetworkLinks), func(i, j int) { CheckNetworkLinks[i], CheckNetworkLinks[j] = CheckNetworkLinks[j], CheckNetworkLinks[i] }) } diff --git a/component/outbound/outbound.go b/component/outbound/outbound.go index 8a4dd71..32244cf 100644 --- a/component/outbound/outbound.go +++ b/component/outbound/outbound.go @@ -7,6 +7,7 @@ package outbound import ( _ "github.com/daeuniverse/outbound/dialer/http" + _ "github.com/daeuniverse/outbound/dialer/hysteria2" _ "github.com/daeuniverse/outbound/dialer/juicity" _ "github.com/daeuniverse/outbound/dialer/shadowsocks" _ "github.com/daeuniverse/outbound/dialer/shadowsocksr" @@ -14,6 +15,7 @@ import ( _ "github.com/daeuniverse/outbound/dialer/trojan" _ "github.com/daeuniverse/outbound/dialer/tuic" _ "github.com/daeuniverse/outbound/dialer/v2ray" + _ "github.com/daeuniverse/outbound/protocol/hysteria2" _ "github.com/daeuniverse/outbound/protocol/juicity" _ "github.com/daeuniverse/outbound/protocol/shadowsocks" _ "github.com/daeuniverse/outbound/protocol/trojanc" diff --git a/go.mod b/go.mod index 8dafc82..6a16b50 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/daeuniverse/dae -go 1.21.0 - -toolchain go1.21.3 +go 1.22 require ( github.com/adrg/xdg v0.4.0 @@ -10,7 +8,7 @@ require ( github.com/bits-and-blooms/bloom/v3 v3.5.0 github.com/cilium/ebpf v0.12.3 github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d - github.com/daeuniverse/outbound v0.0.0-20240423150318-97fdbb427e02 + github.com/daeuniverse/outbound v0.0.0-20240616090556-8df825695cc3 github.com/fsnotify/fsnotify v1.7.0 github.com/json-iterator/go v1.1.12 github.com/miekg/dns v1.1.55 @@ -32,6 +30,9 @@ require ( require ( github.com/andybalholm/brotli v1.0.6 // indirect + github.com/awnumar/fastrand v0.0.0-20210315215012-30ee0990fa2d // indirect + github.com/awnumar/memcall v0.0.0-20190816154910-db5ea08008a3 // indirect + github.com/awnumar/memguard v0.19.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/daeuniverse/quic-go v0.0.0-20240413031024-943f218e0810 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect @@ -39,6 +40,7 @@ require ( github.com/gorilla/websocket v1.5.0 // indirect github.com/klauspost/compress v1.17.4 // indirect github.com/onsi/ginkgo/v2 v2.11.0 // indirect + github.com/quic-go/qpack v0.4.0 // indirect github.com/stretchr/testify v1.8.1 // indirect go.uber.org/mock v0.4.0 // indirect golang.org/x/mod v0.12.0 // indirect diff --git a/go.sum b/go.sum index 2e28d3c..46f3868 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,13 @@ github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sx github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= +github.com/awnumar/fastrand v0.0.0-20210315215012-30ee0990fa2d h1:NkqtWyrOjr0QK1FSCmXS6Whbwh100Qt74SaRn92PemU= +github.com/awnumar/fastrand v0.0.0-20210315215012-30ee0990fa2d/go.mod h1:TO59kqNCiDBKS0qjRYUI8qJtkFL6SkP2EKqeOQ6xg/o= +github.com/awnumar/memcall v0.0.0-20190811121346-2affb857f00a/go.mod h1:sbEXyqNZZ3Cebk+6zOUmFNN8OuHHlugjiUmqn2tfiiM= +github.com/awnumar/memcall v0.0.0-20190816154910-db5ea08008a3 h1:pq6ZBJsmKeTOUOgeX3Ed6Td4loLrca4xIq6lstFN7AI= +github.com/awnumar/memcall v0.0.0-20190816154910-db5ea08008a3/go.mod h1:CszzLMKGwNr15cNA+0SuWkZLnPXGgUw+9kxRNbwUVnE= +github.com/awnumar/memguard v0.19.1 h1:y9k2r1XKaBeLWvB3kyQPNyxD/+qxwDjeZwX+4VZXzUk= +github.com/awnumar/memguard v0.19.1/go.mod h1:tewJ+MrJ12cFtR5gH5zNJs8A6BjBv8709binaV+1pws= github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/bits-and-blooms/bloom/v3 v3.5.0 h1:AKDvi1V3xJCmSR6QhcBfHbCN4Vf8FfxeWkMNQfmAGhY= @@ -15,8 +22,8 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d h1:hnC39MjR7xt5kZjrKlef7DXKFDkiX8MIcDXYC/6Jf9Q= github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d/go.mod h1:VGWGgv7pCP5WGyHGUyb9+nq/gW0yBm+i/GfCNATOJ1M= -github.com/daeuniverse/outbound v0.0.0-20240423150318-97fdbb427e02 h1:RvfDfy4c67zHoHos8OyxrpzUqGjnBf/EyfLt3AXehEg= -github.com/daeuniverse/outbound v0.0.0-20240423150318-97fdbb427e02/go.mod h1:UDGbEWJWcLVHanbq6NCK9kszBCBcIbrF4FT8v+XcU/I= +github.com/daeuniverse/outbound v0.0.0-20240616090556-8df825695cc3 h1:yQiWsSV+6MRVTLiq9r1GX4Xz1O1xODoNCcgMzw8KAB4= +github.com/daeuniverse/outbound v0.0.0-20240616090556-8df825695cc3/go.mod h1:z0vJ5ZlLErX8WTruVeOuGr+1KOhSFcaPzEhZMAYfPdA= github.com/daeuniverse/quic-go v0.0.0-20240413031024-943f218e0810 h1:YtEYouFaNrg9sV9vf3UabvKShKn6sD0QaCdOxCwaF3g= github.com/daeuniverse/quic-go v0.0.0-20240413031024-943f218e0810/go.mod h1:61o2uZUGLrlv1i+oO2rx9sVX0vbf8cHzdSHt7h6lMnM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -117,6 +124,8 @@ github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc= github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= +github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/refraction-networking/utls v1.6.4 h1:aeynTroaYn7y+mFtqv8D0bQ4bw0y9nJHneGxJ7lvRDM= github.com/refraction-networking/utls v1.6.4/go.mod h1:2VL2xfiqgFAZtJKeUTlf+PSYFs3Eu7km0gCtXJ3m8zs= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= @@ -161,6 +170,7 @@ gitlab.com/yawning/chacha20.git v0.0.0-20230427033715-7877545b1b37/go.mod h1:3x6 go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= @@ -186,6 +196,8 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190902133755-9109b7679e13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=