diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f112e0a..3716ce1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,8 +21,12 @@ jobs: - run: git fetch --force --tags - uses: actions/setup-go@v5 with: - go-version: '1.24' + go-version: '1.25' cache: true + - name: Install UPX + uses: crazy-max/ghaction-upx@v3 + with: + install-only: true # More assembly might be required: Docker logins, GPG, etc. It all depends # on your needs. - uses: goreleaser/goreleaser-action@v6 diff --git a/.github/workflows/trigger-nightly.yml b/.github/workflows/trigger-nightly.yml index 0b7a6d3..53bde40 100644 --- a/.github/workflows/trigger-nightly.yml +++ b/.github/workflows/trigger-nightly.yml @@ -3,7 +3,7 @@ name: Trigger nightly build on: schedule: # * is a special character in YAML, so you have to quote this string - - cron: '30 15 * * *' + - cron: '00 15 * * *' workflow_dispatch: jobs: @@ -46,8 +46,9 @@ jobs: DESCRIBE=`git tag -l --sort=-v:refname | grep -v nightly | head -n 1` MAJOR_VERSION=`echo $DESCRIBE | awk '{split($0,a,"."); print a[1]}'` MINOR_VERSION=`echo $DESCRIBE | awk '{split($0,a,"."); print a[2]}'` - # MINOR_VERSION="$((${MINOR_VERSION} + 1))" - TAG="${MAJOR_VERSION}.${MINOR_VERSION}.0-nightly.$(date +'%Y%m%d')" + PATCH_VERSION=`echo $DESCRIBE | awk '{split($0,a,"."); print a[3]}'` + PATCH_VERSION="$((${PATCH_VERSION} + 1))" + TAG="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-nightly.$(date +'%Y%m%d')" git tag -a $TAG -m "$TAG: nightly build" git push origin $TAG - name: 'Clean up nightly releases' diff --git a/.goreleaser.yaml b/.goreleaser.yaml index ff657bc..f47074a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -38,6 +38,67 @@ builds: ldflags: - "-s -w -X 'main.version={{ .Tag }}'" +upx: + - # Whether to enable it or not. + # + # Templates: allowed. + enabled: true + + # Filter by build ID. + # ids: [build1, build2] + + # Filter by GOOS. + goos: [linux] + + # Filter by GOARCH. + goarch: [arm, arm64, amd64] + + # Filter by GOARM. + # goarm: [8] + + # Filter by GOAMD64. + # goamd64: [v1] + + # Compress argument. + # Valid options are from '1' (faster) to '9' (better), and 'best'. + compress: best + + # Whether to try LZMA (slower). + lzma: true + + # Whether to try all methods and filters (slow). + brute: true + + - # Whether to enable it or not. + # + # Templates: allowed. + enabled: true + + # Filter by build ID. + # ids: [build1, build2] + + # Filter by GOOS. + goos: [windows] + + # Filter by GOARCH. + goarch: [amd64] + + # Filter by GOARM. + # goarm: [8] + + # Filter by GOAMD64. + # goamd64: [v1] + + # Compress argument. + # Valid options are from '1' (faster) to '9' (better), and 'best'. + compress: best + + # Whether to try LZMA (slower). + lzma: true + + # Whether to try all methods and filters (slow). + brute: true + archives: - format: tar.gz # use zip for windows archives diff --git a/Dockerfile b/Dockerfile index 0e9aab3..4c7a43e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.6.1 AS xx -FROM --platform=$BUILDPLATFORM golang:1.24-alpine3.22 AS builder +FROM --platform=$BUILDPLATFORM golang:1.25-alpine3.22 AS builder + +# add upx for binary compression +RUN apk add --no-cache upx || echo "upx not found" COPY --from=xx / / @@ -17,8 +20,9 @@ WORKDIR /app COPY . . RUN cd cmd/gost && \ - xx-go build && \ - xx-verify gost + xx-go build -ldflags "-s -w" && \ + xx-verify gost && \ + { upx --best gost || true; } FROM alpine:3.22 diff --git a/README.md b/README.md index 437b86c..7691a17 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ - [x] [反向代理](https://gost.run/tutorials/reverse-proxy/)和[隧道](https://gost.run/tutorials/reverse-proxy-tunnel/) - [x] [TCP/UDP透明代理](https://gost.run/tutorials/redirect/) - [x] DNS[解析](https://gost.run/concepts/resolver/)和[代理](https://gost.run/tutorials/dns/) -- [x] [TUN/TAP设备](https://gost.run/tutorials/tuntap/) +- [x] [TUN/TAP设备](https://gost.run/tutorials/tuntap/)与[TUN2SOCKS](https://gost.run/tutorials/tungo/) - [x] [负载均衡](https://gost.run/concepts/selector/) - [x] [路由控制](https://gost.run/concepts/bypass/) - [x] [准入控制](https://gost.run/concepts/admission/) diff --git a/README_en.md b/README_en.md index 875e2fb..f5646af 100644 --- a/README_en.md +++ b/README_en.md @@ -13,7 +13,7 @@ - [x] [Reverse Proxy](https://gost.run/en/tutorials/reverse-proxy/) and [Tunnel](https://gost.run/en/tutorials/reverse-proxy-tunnel/) - [x] [TCP/UDP transparent proxy](https://gost.run/en/tutorials/redirect/) - [x] DNS [resolver](https://gost.run/en/concepts/resolver/) and [proxy](https://gost.run/en/tutorials/dns/) -- [x] [TUN/TAP device](https://gost.run/en/tutorials/tuntap/) +- [x] [TUN/TAP device](https://gost.run/en/tutorials/tuntap/) and [TUN2SOCKS](https://gost.run/en/tutorials/tungo/) - [x] [Load balancing](https://gost.run/en/concepts/selector/) - [x] [Routing control](https://gost.run/en/concepts/bypass/) - [x] [Admission control](https://gost.run/en/concepts/limiter/) diff --git a/cmd/gost/register.go b/cmd/gost/register.go index f7a861b..1297efd 100644 --- a/cmd/gost/register.go +++ b/cmd/gost/register.go @@ -70,6 +70,7 @@ import ( _ "github.com/go-gost/x/handler/sshd" _ "github.com/go-gost/x/handler/tap" _ "github.com/go-gost/x/handler/tun" + _ "github.com/go-gost/x/handler/tungo" _ "github.com/go-gost/x/handler/tunnel" _ "github.com/go-gost/x/handler/unix" @@ -103,6 +104,7 @@ import ( _ "github.com/go-gost/x/listener/tcp" _ "github.com/go-gost/x/listener/tls" _ "github.com/go-gost/x/listener/tun" + _ "github.com/go-gost/x/listener/tungo" _ "github.com/go-gost/x/listener/udp" _ "github.com/go-gost/x/listener/unix" _ "github.com/go-gost/x/listener/ws" diff --git a/cmd/gost/version.go b/cmd/gost/version.go index 91f48be..f46d4d0 100644 --- a/cmd/gost/version.go +++ b/cmd/gost/version.go @@ -1,5 +1,5 @@ package main var ( - version = "3.1.1" + version = "3.2.5" ) diff --git a/go.mod b/go.mod index 761734f..b3eaa26 100644 --- a/go.mod +++ b/go.mod @@ -41,6 +41,7 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.1.3 // indirect github.com/google/gopacket v1.1.19 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect @@ -95,6 +96,7 @@ require ( github.com/vishvananda/netlink v1.1.1-0.20211118161826-650dca95af54 // indirect github.com/vishvananda/netns v0.0.4 // indirect github.com/vulcand/predicate v1.2.0 // indirect + github.com/xjasonlyu/tun2socks/v2 v2.6.0 // indirect github.com/xtaci/kcp-go/v5 v5.6.5 // indirect github.com/xtaci/smux v1.5.31 // indirect github.com/xtaci/tcpraw v1.2.25 // indirect @@ -121,6 +123,7 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + gvisor.dev/gvisor v0.0.0-20250523182742-eede7a881b20 // indirect ) replace github.com/go-gost/x => ./x diff --git a/go.sum b/go.sum index 9aa8a5f..6c8d5c2 100644 --- a/go.sum +++ b/go.sum @@ -246,6 +246,8 @@ github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1Y github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/vulcand/predicate v1.2.0 h1:uFsW1gcnnR7R+QTID+FVcs0sSYlIGntoGOTb3rQJt50= github.com/vulcand/predicate v1.2.0/go.mod h1:VipoNYXny6c8N381zGUWkjuuNHiRbeAZhE7Qm9c+2GA= +github.com/xjasonlyu/tun2socks/v2 v2.6.0 h1:gI9saJT3XgH4e6v9jBuHRLwK7l3aN9YFWec/SsDTDx4= +github.com/xjasonlyu/tun2socks/v2 v2.6.0/go.mod h1:35AwqxIxnMkfBfT0UJ1Lku7PZm2ZiZJ8sxHyp0gt1yw= github.com/xtaci/kcp-go/v5 v5.6.5 h1:oxGZNobj3OddrLzwdJYnR/waNgwrL98u02u0DWNHE3k= github.com/xtaci/kcp-go/v5 v5.6.5/go.mod h1:Qy3Zf2tWTdFdEs0E8JvhrX+39r5UDZoYac8anvud7/Q= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM=