From 7d52a8932d8a929d742096c3a32a1e77fcd6192d Mon Sep 17 00:00:00 2001 From: wyx2685 Date: Wed, 13 Aug 2025 21:37:42 +0900 Subject: [PATCH] test: update go 1.25.0 --- .github/workflows/release.yml | 6 +++--- Dockerfile | 6 +++--- api/panel/node.go | 2 +- api/panel/user.go | 36 ++++++++++++++++++++++++++++------- conf/conf.go | 2 +- conf/node.go | 3 ++- core/sing/node.go | 3 ++- core/xray/dns.go | 3 ++- core/xray/inbound.go | 3 ++- core/xray/outbound.go | 3 ++- core/xray/xray.go | 3 ++- go.mod | 6 +++--- node/lego.go | 3 ++- 13 files changed, 54 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 06987c9..30a0079 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -109,7 +109,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.24.5' + go-version: '1.25.0' - name: Get project dependencies run: | @@ -126,13 +126,13 @@ jobs: run: | echo "version: $version" mkdir -p build_assets - go build -v -o build_assets/V2bX -tags "sing xray hysteria2 with_quic with_grpc with_utls with_wireguard with_acme with_gvisor" -trimpath -ldflags "-X 'github.com/InazumaV/V2bX/cmd.version=$version' -s -w -buildid=" + GOEXPERIMENT=jsonv2 go build -v -o build_assets/V2bX -tags "sing xray hysteria2 with_quic with_grpc with_utls with_wireguard with_acme with_gvisor" -trimpath -ldflags "-X 'github.com/InazumaV/V2bX/cmd.version=$version' -s -w -buildid=" - name: Build Mips softfloat V2bX if: matrix.goarch == 'mips' || matrix.goarch == 'mipsle' run: | echo "version: $version" - GOMIPS=softfloat go build -v -o build_assets/V2bX_softfloat -tags "sing xray hysteria2 with_quic with_grpc with_utls with_wireguard with_acme with_gvisor" -trimpath -ldflags "-X 'github.com/InazumaV/V2bX/cmd.version=$version' -s -w -buildid=" + GOEXPERIMENT=jsonv2 GOMIPS=softfloat go build -v -o build_assets/V2bX_softfloat -tags "sing xray hysteria2 with_quic with_grpc with_utls with_wireguard with_acme with_gvisor" -trimpath -ldflags "-X 'github.com/InazumaV/V2bX/cmd.version=$version' -s -w -buildid=" - name: Rename Windows V2bX if: matrix.goos == 'windows' run: | diff --git a/Dockerfile b/Dockerfile index 882756b..5d73a3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ # Build go -FROM golang:1.24.5-alpine AS builder +FROM golang:1.25.0-alpine AS builder WORKDIR /app COPY . . ENV CGO_ENABLED=0 -RUN go mod download -RUN go build -v -o V2bX -tags "sing xray hysteria2 with_quic with_grpc with_utls with_wireguard with_acme with_gvisor" +RUN GOEXPERIMENT=jsonv2 go mod download +RUN GOEXPERIMENT=jsonv2 go build -v -o V2bX -tags "sing xray hysteria2 with_quic with_grpc with_utls with_wireguard with_acme with_gvisor" # Release FROM alpine diff --git a/api/panel/node.go b/api/panel/node.go index 7efd750..eb5131f 100644 --- a/api/panel/node.go +++ b/api/panel/node.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/goccy/go-json" + "encoding/json" ) // Security type diff --git a/api/panel/user.go b/api/panel/user.go index 7407d6b..a799dbc 100644 --- a/api/panel/user.go +++ b/api/panel/user.go @@ -2,10 +2,11 @@ package panel import ( "fmt" - "io" "strings" - "github.com/goccy/go-json" + "encoding/json/jsontext" + "encoding/json/v2" + "github.com/vmihailenco/msgpack/v5" ) @@ -56,12 +57,33 @@ func (c *Client) GetUserList() ([]UserInfo, error) { return nil, fmt.Errorf("decode user list error: %w", err) } } else { - bodyBytes, err := io.ReadAll(r.RawResponse.Body) - if err != nil { - return nil, fmt.Errorf("read response body error: %w", err) + dec := jsontext.NewDecoder(r.RawResponse.Body) + for { + tok, err := dec.ReadToken() + if err != nil { + return nil, fmt.Errorf("decode user list error: %w", err) + } + if tok.Kind() == '"' && tok.String() == "users" { + break + } } - if err := json.Unmarshal(bodyBytes, userlist); err != nil { - return nil, fmt.Errorf("unmarshal user list error: %w", err) + tok, err := dec.ReadToken() + if err != nil { + return nil, fmt.Errorf("decode user list error: %w", err) + } + if tok.Kind() != '[' { + return nil, fmt.Errorf(`decode user list error: expected "users" array`) + } + for dec.PeekKind() != ']' { + val, err := dec.ReadValue() + if err != nil { + return nil, fmt.Errorf("decode user list error: read user object: %w", err) + } + var u UserInfo + if err := json.Unmarshal(val, &u); err != nil { + return nil, fmt.Errorf("decode user list error: unmarshal user error: %w", err) + } + userlist.Users = append(userlist.Users, u) } } c.userEtag = r.Header().Get("ETag") diff --git a/conf/conf.go b/conf/conf.go index 7ffa61a..afaf3ee 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -7,7 +7,7 @@ import ( "github.com/InazumaV/V2bX/common/json5" - "github.com/goccy/go-json" + "encoding/json/v2" ) type Conf struct { diff --git a/conf/node.go b/conf/node.go index a764703..1d7bd91 100644 --- a/conf/node.go +++ b/conf/node.go @@ -7,8 +7,9 @@ import ( "os" "strings" + "encoding/json" + "github.com/InazumaV/V2bX/common/json5" - "github.com/goccy/go-json" ) type NodeConfig struct { diff --git a/core/sing/node.go b/core/sing/node.go index 0d2abb3..3621657 100644 --- a/core/sing/node.go +++ b/core/sing/node.go @@ -10,9 +10,10 @@ import ( "strings" "time" + "encoding/json" + "github.com/InazumaV/V2bX/api/panel" "github.com/InazumaV/V2bX/conf" - "github.com/goccy/go-json" "github.com/sagernet/sing-box/option" F "github.com/sagernet/sing/common/format" "github.com/sagernet/sing/common/json/badoption" diff --git a/core/xray/dns.go b/core/xray/dns.go index db9af8c..681bf46 100644 --- a/core/xray/dns.go +++ b/core/xray/dns.go @@ -7,8 +7,9 @@ import ( "strconv" "strings" + "encoding/json" + "github.com/InazumaV/V2bX/api/panel" - "github.com/goccy/go-json" log "github.com/sirupsen/logrus" coreConf "github.com/xtls/xray-core/infra/conf" ) diff --git a/core/xray/inbound.go b/core/xray/inbound.go index 3c3312a..c654270 100644 --- a/core/xray/inbound.go +++ b/core/xray/inbound.go @@ -8,9 +8,10 @@ import ( "fmt" "time" + "encoding/json" + "github.com/InazumaV/V2bX/api/panel" "github.com/InazumaV/V2bX/conf" - "github.com/goccy/go-json" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/core" coreConf "github.com/xtls/xray-core/infra/conf" diff --git a/core/xray/outbound.go b/core/xray/outbound.go index 1e97b84..15b0a96 100644 --- a/core/xray/outbound.go +++ b/core/xray/outbound.go @@ -3,8 +3,9 @@ package xray import ( "fmt" + "encoding/json" + conf2 "github.com/InazumaV/V2bX/conf" - "github.com/goccy/go-json" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/infra/conf" ) diff --git a/core/xray/xray.go b/core/xray/xray.go index 2a5afa1..695048f 100644 --- a/core/xray/xray.go +++ b/core/xray/xray.go @@ -5,11 +5,12 @@ import ( "os" "sync" + "encoding/json/v2" + "github.com/InazumaV/V2bX/conf" vCore "github.com/InazumaV/V2bX/core" "github.com/InazumaV/V2bX/core/xray/app/dispatcher" _ "github.com/InazumaV/V2bX/core/xray/distro/all" - "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/stats" diff --git a/go.mod b/go.mod index 7907208..18132ae 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/InazumaV/V2bX -go 1.24 +go 1.25 -toolchain go1.24.5 +toolchain go1.25.0 require ( github.com/apernet/hysteria/core/v2 v2.6.2 @@ -12,7 +12,6 @@ require ( github.com/fsnotify/fsnotify v1.8.0 github.com/go-acme/lego/v4 v4.21.1-0.20241220151055-ee7a9e4fa04f github.com/go-resty/resty/v2 v2.16.2 - github.com/goccy/go-json v0.10.4 github.com/hashicorp/go-multierror v1.1.2-0.20241119060415-613124da9385 github.com/juju/ratelimit v1.0.2 github.com/sagernet/sing v0.7.0-beta.2 @@ -119,6 +118,7 @@ require ( github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gobwas/httphead v0.1.0 // indirect github.com/gobwas/pool v0.2.1 // indirect + github.com/goccy/go-json v0.10.4 // indirect github.com/godbus/dbus/v5 v5.1.1-0.20230522191255-76236955d466 // indirect github.com/gofrs/flock v0.12.1 // indirect github.com/gofrs/uuid/v5 v5.3.2 // indirect diff --git a/node/lego.go b/node/lego.go index 8d8af04..b75821a 100644 --- a/node/lego.go +++ b/node/lego.go @@ -13,11 +13,12 @@ import ( "strings" "time" + "encoding/json" + "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/challenge/http01" "github.com/go-acme/lego/v4/providers/dns" "github.com/go-acme/lego/v4/registration" - "github.com/goccy/go-json" "github.com/InazumaV/V2bX/common/file" "github.com/InazumaV/V2bX/conf"