diff --git a/Dockerfile b/Dockerfile index d6d33258..9e9bf9ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: go-base -FROM golang:1.26.5-alpine AS go-base +FROM golang:1.27.0-alpine AS go-base HEALTHCHECK NONE # package version does not matter diff --git a/agent/go.mod b/agent/go.mod index 217438c8..6f45fe10 100644 --- a/agent/go.mod +++ b/agent/go.mod @@ -1,6 +1,6 @@ module github.com/yusing/godoxy/agent -go 1.26.5 +go 1.27.0 replace ( github.com/shirou/gopsutil/v4 => ../internal/gopsutil @@ -92,7 +92,7 @@ require ( github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.73.0 // indirect github.com/yusing/ds v0.4.1 // indirect - github.com/yusing/gointernals v0.2.0 // indirect + github.com/yusing/gointernals v0.2.1 // indirect github.com/yusing/goutils/http/websocket v0.0.0-20260729070603-e4c7e978cbc2 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.mongodb.org/mongo-driver/v2 v2.8.0 // indirect diff --git a/agent/go.sum b/agent/go.sum index 38bcaf16..691acca7 100644 --- a/agent/go.sum +++ b/agent/go.sum @@ -196,8 +196,8 @@ github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZ github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yusing/ds v0.4.1 h1:syMCh7hO6Yw8xfcFkEaln3W+lVeWB/U/meYv6Wf2/Ig= github.com/yusing/ds v0.4.1/go.mod h1:XhKV4l7cZwBbbl7lRzNC9zX27zvCM0frIwiuD40ULRk= -github.com/yusing/gointernals v0.2.0 h1:jyWB3kdUPkuU6s0r8QY/sS5h2WNBF4Kfisly8dtSVvg= -github.com/yusing/gointernals v0.2.0/go.mod h1:xGzNbPGMm5Z8kG0t4JYISMscw+gMQlgghkLxlgRZv5Y= +github.com/yusing/gointernals v0.2.1 h1:QlajBlRG6qbqfzjHmRq774pi+CUW/DILjFM6GjveHuM= +github.com/yusing/gointernals v0.2.1/go.mod h1:xGzNbPGMm5Z8kG0t4JYISMscw+gMQlgghkLxlgRZv5Y= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.mongodb.org/mongo-driver/v2 v2.8.0 h1:CxWDGQYY8QQwNjAl/aq2sfWakdnWZynnqJ9F4DhHbP8= diff --git a/cmd/bench_server/Dockerfile b/cmd/bench_server/Dockerfile index 8eb80202..9b859636 100644 --- a/cmd/bench_server/Dockerfile +++ b/cmd/bench_server/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.26.5-alpine AS builder +FROM golang:1.27.0-alpine AS builder HEALTHCHECK NONE diff --git a/cmd/bench_server/go.mod b/cmd/bench_server/go.mod index e5ca0c3d..f08031b4 100644 --- a/cmd/bench_server/go.mod +++ b/cmd/bench_server/go.mod @@ -1,6 +1,6 @@ module github.com/yusing/godoxy/cmd/bench_server -go 1.26.5 +go 1.27.0 require ( github.com/gorilla/websocket v1.5.3 diff --git a/cmd/cli/go.mod b/cmd/cli/go.mod index 6833189e..d431f45c 100644 --- a/cmd/cli/go.mod +++ b/cmd/cli/go.mod @@ -1,6 +1,6 @@ module github.com/yusing/godoxy/cli -go 1.26.5 +go 1.27.0 require ( github.com/gorilla/websocket v1.5.3 diff --git a/cmd/h2c_test_server/Dockerfile b/cmd/h2c_test_server/Dockerfile index 2513629c..3b99ef56 100644 --- a/cmd/h2c_test_server/Dockerfile +++ b/cmd/h2c_test_server/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.26.5-alpine AS builder +FROM golang:1.27.0-alpine AS builder HEALTHCHECK NONE diff --git a/cmd/h2c_test_server/go.mod b/cmd/h2c_test_server/go.mod index 514fff49..1ef0b8bd 100644 --- a/cmd/h2c_test_server/go.mod +++ b/cmd/h2c_test_server/go.mod @@ -1,6 +1,6 @@ module github.com/yusing/godoxy/cmd/h2c_test_server -go 1.26.5 +go 1.27.0 require golang.org/x/net v0.58.0 diff --git a/cmd/h3bench/go.mod b/cmd/h3bench/go.mod index 47258c91..f51a9d49 100644 --- a/cmd/h3bench/go.mod +++ b/cmd/h3bench/go.mod @@ -1,6 +1,6 @@ module h3bench -go 1.26.5 +go 1.27.0 require github.com/quic-go/quic-go v0.61.0 diff --git a/cmd/tcp_echo_server/Dockerfile b/cmd/tcp_echo_server/Dockerfile index 4e6054f0..bc2f35eb 100644 --- a/cmd/tcp_echo_server/Dockerfile +++ b/cmd/tcp_echo_server/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.26.5-alpine AS builder +FROM golang:1.27.0-alpine AS builder HEALTHCHECK NONE diff --git a/go.mod b/go.mod index 34cece01..23cfca61 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/yusing/godoxy -go 1.26.5 +go 1.27.0 replace ( github.com/coreos/go-oidc/v3 => ./internal/go-oidc @@ -16,48 +16,49 @@ replace ( require ( github.com/PuerkitoBio/goquery v1.12.0 // parsing HTML for extract fav icon; modify_html middleware + github.com/bytedance/gopkg v0.1.4 // xxhash64 for fast hash + github.com/bytedance/sonic v1.15.2 // fast json parsing github.com/cenkalti/backoff/v5 v5.0.3 // backoff for retrying operations github.com/coreos/go-oidc/v3 v3.20.0 // oidc authentication + github.com/docker/cli v29.7.2+incompatible // needs docker/cli/cli/connhelper connection helper for docker client + github.com/docker/docker v28.5.2+incompatible + github.com/docker/go-connections v0.8.1 github.com/fsnotify/fsnotify v1.10.1 // file watcher github.com/gin-gonic/gin v1.12.0 // api server github.com/go-acme/lego/v5 v5.3.1 // acme client github.com/go-playground/validator/v10 v10.30.3 // validator github.com/gobwas/glob v0.2.3 // glob matcher for route rules + github.com/goccy/go-yaml v1.19.2 // yaml parsing for different config files + github.com/golang-jwt/jwt/v5 v5.3.1 // jwt authentication github.com/gorilla/websocket v1.5.3 // websocket for API and agent github.com/gotify/server/v2 v2.9.1 // reference the Message struct for json response github.com/lithammer/fuzzysearch v1.1.8 // fuzzy search for searching icons and filtering metrics + github.com/luthermonson/go-proxmox v0.8.1 // proxmox API client + github.com/oschwald/maxminddb-golang v1.13.1 // maxminddb for geoip database github.com/pires/go-proxyproto v0.15.0 // proxy protocol support github.com/puzpuzpuz/xsync/v4 v4.5.0 // lock free map for concurrent operations github.com/rs/zerolog v1.35.1 // logging - github.com/vincent-petithory/dataurl v1.0.0 // data url for fav icon - golang.org/x/crypto v0.55.0 // encrypting password with bcrypt - golang.org/x/net v0.58.0 // HTTP header utilities - golang.org/x/oauth2 v0.36.0 // oauth2 authentication - golang.org/x/sync v0.22.0 // errgroup and singleflight for concurrent operations - golang.org/x/time v0.15.0 // time utilities -) - -require ( - github.com/bytedance/gopkg v0.1.4 // xxhash64 for fast hash - github.com/bytedance/sonic v1.15.2 // fast json parsing - github.com/docker/cli v29.7.2+incompatible // needs docker/cli/cli/connhelper connection helper for docker client - github.com/goccy/go-yaml v1.19.2 // yaml parsing for different config files - github.com/golang-jwt/jwt/v5 v5.3.1 // jwt authentication - github.com/luthermonson/go-proxmox v0.8.1 // proxmox API client - github.com/oschwald/maxminddb-golang v1.13.1 // maxminddb for geoip database - github.com/quic-go/quic-go v0.61.0 // indirect; http3 support github.com/shirou/gopsutil/v4 v4.26.7 // system information - github.com/spf13/afero v1.15.0 // indirect github.com/stretchr/testify v1.11.1 // testing framework github.com/valyala/fasthttp v1.73.0 // fast http for health check + github.com/vincent-petithory/dataurl v1.0.0 // data url for fav icon github.com/yusing/ds v0.4.1 // data structures and algorithms github.com/yusing/godoxy/agent v0.0.0-20260815090440-878444888e37 github.com/yusing/godoxy/internal/dnsproviders v0.0.0-20260815090440-878444888e37 - github.com/yusing/gointernals v0.2.0 + github.com/yusing/gointernals v0.2.1 github.com/yusing/goutils v0.7.0 + github.com/yusing/goutils/cache v0.0.0-20260729070603-e4c7e978cbc2 github.com/yusing/goutils/http/reverseproxy v0.0.0-20260729070603-e4c7e978cbc2 github.com/yusing/goutils/http/websocket v0.0.0-20260729070603-e4c7e978cbc2 github.com/yusing/goutils/server v0.0.0-20260729070603-e4c7e978cbc2 + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 + go.uber.org/atomic v1.11.0 + golang.org/x/crypto v0.55.0 // encrypting password with bcrypt + golang.org/x/net v0.58.0 // HTTP header utilities + golang.org/x/oauth2 v0.36.0 // oauth2 authentication + golang.org/x/sync v0.22.0 // errgroup and singleflight for concurrent operations + golang.org/x/sys v0.47.0 + golang.org/x/time v0.15.0 // time utilities ) require ( @@ -70,68 +71,126 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.3.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.10.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.8.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/akamai/AkamaiOPEN-edgegrid-golang/v13 v13.4.0 // indirect + github.com/alexbrainman/sspi v0.0.0-20250919150558-7d374ff0d59e // indirect + github.com/andybalholm/brotli v1.2.2 // indirect github.com/andybalholm/cascadia v1.3.4 // indirect github.com/benbjohnson/clock v1.3.5 // indirect + github.com/bodgit/gssapi v0.0.4 // indirect + github.com/bodgit/tsig v1.3.1 // indirect + github.com/boombuler/barcode v1.1.0 // indirect github.com/buger/goterm v1.0.4 // indirect + github.com/bytedance/sonic/loader v0.5.2 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cloudwego/base64x v0.1.7 // indirect + github.com/containerd/errdefs v1.0.0 // indirect + github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/diskfs/go-diskfs v1.9.4 // indirect github.com/distribution/reference v0.6.0 // indirect github.com/djherbis/times v1.6.0 // indirect - github.com/docker/go-connections v0.8.1 github.com/docker/go-units v0.5.0 // indirect github.com/ebitengine/purego v0.10.2 // indirect + github.com/fatih/structs v1.1.0 // indirect github.com/felixge/httpsnoop v1.1.0 // indirect github.com/gabriel-vasile/mimetype v1.4.15 // indirect + github.com/gin-contrib/sse v1.1.1 // indirect github.com/go-jose/go-jose/v4 v4.1.4 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect + github.com/go-ozzo/ozzo-validation/v4 v4.4.1 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-resty/resty/v2 v2.17.2 // indirect + github.com/go-viper/mapstructure/v2 v2.5.0 // indirect + github.com/goccy/go-json v0.10.6 // indirect github.com/gofrs/flock v0.13.0 // indirect + github.com/google/go-querystring v1.2.0 // indirect github.com/google/s2a-go v0.1.9 // indirect github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.21 // indirect github.com/googleapis/gax-go/v2 v2.23.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-retryablehttp v0.7.8 // indirect + github.com/hashicorp/go-uuid v1.0.3 // indirect + github.com/jcmturner/aescts/v2 v2.0.0 // indirect + github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect + github.com/jcmturner/gofork v1.7.6 // indirect + github.com/jcmturner/goidentity/v6 v6.0.1 // indirect + github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect + github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/jinzhu/copier v0.4.0 // indirect github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect + github.com/klauspost/compress v1.19.2 // indirect + github.com/klauspost/cpuid/v2 v2.4.0 // indirect + github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/leodido/go-urn v1.5.0 // indirect + github.com/linode/linodego v1.69.1 // indirect + github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 // indirect github.com/magefile/mage v1.17.2 // indirect github.com/mattn/go-colorable v0.1.15 // indirect github.com/mattn/go-isatty v0.0.24 // indirect github.com/miekg/dns v1.1.72 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/moby/sys/sequential v0.6.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect + github.com/nrdcg/desec v0.11.2 // indirect github.com/nrdcg/goacmedns v0.2.0 // indirect + github.com/nrdcg/goinwx v0.12.0 // indirect + github.com/nrdcg/oci-go-sdk/common/v1065 v1065.123.1 // indirect + github.com/nrdcg/oci-go-sdk/dns/v1065 v1065.123.1 // indirect github.com/nrdcg/porkbun v0.4.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect + github.com/openshift/gssapi v0.0.0-20161010215902-5fb4217df13b // indirect github.com/ovh/go-ovh v1.9.0 // indirect github.com/pelletier/go-toml/v2 v2.4.3 // indirect + github.com/peterhellberg/link v1.2.0 // indirect + github.com/pion/dtls/v3 v3.1.5 // indirect + github.com/pion/logging v0.2.4 // indirect + github.com/pion/transport/v4 v4.1.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/power-devops/perfstat v0.0.0-20260805114148-88456608a4f6 // indirect + github.com/pquerna/otp v1.5.0 // indirect github.com/quic-go/qpack v0.6.0 // indirect + github.com/quic-go/quic-go v0.61.0 // indirect; http3 support github.com/samber/lo v1.53.0 // indirect github.com/samber/slog-common v0.22.0 // indirect github.com/samber/slog-zerolog/v2 v2.9.2 // indirect github.com/scaleway/scaleway-sdk-go v1.0.0-beta.37 // indirect github.com/sirupsen/logrus v1.10.0 // indirect + github.com/sony/gobreaker/v2 v2.4.0 // indirect + github.com/spf13/afero v1.15.0 // indirect + github.com/stretchr/objx v0.5.3 // indirect + github.com/tklauser/go-sysconf v0.4.0 // indirect + github.com/tklauser/numcpus v0.12.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.3.2 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/vultr/govultr/v3 v3.32.0 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + go.mongodb.org/mongo-driver/v2 v2.8.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 go.opentelemetry.io/otel v1.45.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect go.opentelemetry.io/otel/metric v1.45.0 // indirect go.opentelemetry.io/otel/trace v1.45.0 // indirect - go.uber.org/atomic v1.11.0 + go.opentelemetry.io/proto/otlp v1.10.0 // indirect go.uber.org/ratelimit v0.3.1 // indirect + golang.org/x/arch v0.30.0 // indirect golang.org/x/mod v0.40.0 // indirect - golang.org/x/sys v0.47.0 golang.org/x/text v0.41.0 // indirect golang.org/x/tools v0.49.0 // indirect google.golang.org/api v0.293.0 // indirect @@ -141,73 +200,5 @@ require ( gopkg.in/ini.v1 v1.67.3 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect -) - -require ( - github.com/docker/docker v28.5.2+incompatible - github.com/yusing/goutils/cache v0.0.0-20260729070603-e4c7e978cbc2 -) - -require ( - github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect - github.com/akamai/AkamaiOPEN-edgegrid-golang/v13 v13.4.0 // indirect - github.com/alexbrainman/sspi v0.0.0-20250919150558-7d374ff0d59e // indirect - github.com/andybalholm/brotli v1.2.2 // indirect - github.com/bodgit/gssapi v0.0.4 // indirect - github.com/bodgit/tsig v1.3.1 // indirect - github.com/boombuler/barcode v1.1.0 // indirect - github.com/bytedance/sonic/loader v0.5.2 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/cloudwego/base64x v0.1.7 // indirect - github.com/containerd/errdefs v1.0.0 // indirect - github.com/containerd/errdefs/pkg v0.3.0 // indirect - github.com/fatih/structs v1.1.0 // indirect - github.com/gin-contrib/sse v1.1.1 // indirect - github.com/go-ole/go-ole v1.3.0 // indirect - github.com/go-ozzo/ozzo-validation/v4 v4.4.1 // indirect - github.com/go-resty/resty/v2 v2.17.2 // indirect - github.com/go-viper/mapstructure/v2 v2.5.0 // indirect - github.com/goccy/go-json v0.10.6 // indirect - github.com/google/go-querystring v1.2.0 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/jcmturner/aescts/v2 v2.0.0 // indirect - github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect - github.com/jcmturner/gofork v1.7.6 // indirect - github.com/jcmturner/goidentity/v6 v6.0.1 // indirect - github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect - github.com/jcmturner/rpc/v2 v2.0.3 // indirect - github.com/klauspost/compress v1.19.2 // indirect - github.com/klauspost/cpuid/v2 v2.4.0 // indirect - github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b // indirect - github.com/linode/linodego v1.69.1 // indirect - github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 // indirect - github.com/moby/sys/sequential v0.6.0 // indirect - github.com/nrdcg/desec v0.11.2 // indirect - github.com/nrdcg/goinwx v0.12.0 // indirect - github.com/nrdcg/oci-go-sdk/common/v1065 v1065.123.1 // indirect - github.com/nrdcg/oci-go-sdk/dns/v1065 v1065.123.1 // indirect - github.com/openshift/gssapi v0.0.0-20161010215902-5fb4217df13b // indirect - github.com/peterhellberg/link v1.2.0 // indirect - github.com/pion/dtls/v3 v3.1.5 // indirect - github.com/pion/logging v0.2.4 // indirect - github.com/pion/transport/v4 v4.1.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/power-devops/perfstat v0.0.0-20260805114148-88456608a4f6 // indirect - github.com/pquerna/otp v1.5.0 // indirect - github.com/sony/gobreaker/v2 v2.4.0 // indirect - github.com/stretchr/objx v0.5.3 // indirect - github.com/tklauser/go-sysconf v0.4.0 // indirect - github.com/tklauser/numcpus v0.12.0 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.3.2 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/vultr/govultr/v3 v3.32.0 // indirect - github.com/yusufpapurcu/wmi v1.2.4 // indirect - go.mongodb.org/mongo-driver/v2 v2.8.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect - go.opentelemetry.io/proto/otlp v1.10.0 // indirect - golang.org/x/arch v0.30.0 // indirect software.sslmate.com/src/go-pkcs12 v0.7.3 // indirect ) diff --git a/go.sum b/go.sum index 48b61a89..f7683649 100644 --- a/go.sum +++ b/go.sum @@ -377,8 +377,8 @@ github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfS github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusing/ds v0.4.1 h1:syMCh7hO6Yw8xfcFkEaln3W+lVeWB/U/meYv6Wf2/Ig= github.com/yusing/ds v0.4.1/go.mod h1:XhKV4l7cZwBbbl7lRzNC9zX27zvCM0frIwiuD40ULRk= -github.com/yusing/gointernals v0.2.0 h1:jyWB3kdUPkuU6s0r8QY/sS5h2WNBF4Kfisly8dtSVvg= -github.com/yusing/gointernals v0.2.0/go.mod h1:xGzNbPGMm5Z8kG0t4JYISMscw+gMQlgghkLxlgRZv5Y= +github.com/yusing/gointernals v0.2.1 h1:QlajBlRG6qbqfzjHmRq774pi+CUW/DILjFM6GjveHuM= +github.com/yusing/gointernals v0.2.1/go.mod h1:xGzNbPGMm5Z8kG0t4JYISMscw+gMQlgghkLxlgRZv5Y= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.mongodb.org/mongo-driver/v2 v2.8.0 h1:CxWDGQYY8QQwNjAl/aq2sfWakdnWZynnqJ9F4DhHbP8= diff --git a/goutils b/goutils index fb9193e4..fb8566d3 160000 --- a/goutils +++ b/goutils @@ -1 +1 @@ -Subproject commit fb9193e494e9b12698084a25f9f0070f22ad4dd0 +Subproject commit fb8566d3f3e3347dd6939f9215ab7890f12272a3 diff --git a/internal/api/v1/agent/verify_test.go b/internal/api/v1/agent/verify_test.go index c1202f19..ca8c6249 100644 --- a/internal/api/v1/agent/verify_test.go +++ b/internal/api/v1/agent/verify_test.go @@ -137,11 +137,9 @@ func TestVerifyReturnsManagedResponseAndSkipsConfigPersistence(t *testing.T) { listAgentsFunc = func(context.Context) []*agent.AgentConfig { return []*agent.AgentConfig{ { - AgentInfo: agent.AgentInfo{ - Name: "agent-1", - Runtime: agent.ContainerRuntimeDocker, - }, - Addr: "10.0.0.1:8890", + Name: "agent-1", + Runtime: agent.ContainerRuntimeDocker, + Addr: "10.0.0.1:8890", }, } } diff --git a/internal/auth/oauth_refresh.go b/internal/auth/oauth_refresh.go index 66620fd0..22e565f5 100644 --- a/internal/auth/oauth_refresh.go +++ b/internal/auth/oauth_refresh.go @@ -112,11 +112,9 @@ func invalidateOAuthRefreshToken(sessionID sessionID) { func (auth *OIDCProvider) setSessionTokenCookie(w http.ResponseWriter, r *http.Request, session Session) { claims := &sessionClaims{ - Session: session, - RegisteredClaims: jwt.RegisteredClaims{ - Issuer: sessionTokenIssuer, - ExpiresAt: jwt.NewNumericDate(time.Now().Add(common.APIJWTTokenTTL)), - }, + Session: session, + Issuer: sessionTokenIssuer, + ExpiresAt: jwt.NewNumericDate(time.Now().Add(common.APIJWTTokenTTL)), } jwtToken := jwt.NewWithClaims(jwt.SigningMethodHS512, claims) signed, err := jwtToken.SignedString(common.APIJWTSecret) diff --git a/internal/auth/userpass.go b/internal/auth/userpass.go index 2e92ef57..fb31ee37 100644 --- a/internal/auth/userpass.go +++ b/internal/auth/userpass.go @@ -59,10 +59,8 @@ func (auth *UserPassAuth) TokenCookieName() string { func (auth *UserPassAuth) NewToken() (token string, err error) { claim := &UserPassClaims{ - Username: auth.username, - RegisteredClaims: jwt.RegisteredClaims{ - ExpiresAt: jwt.NewNumericDate(time.Now().Add(auth.tokenTTL)), - }, + Username: auth.username, + ExpiresAt: jwt.NewNumericDate(time.Now().Add(auth.tokenTTL)), } tok := jwt.NewWithClaims(jwt.SigningMethodHS512, claim) token, err = tok.SignedString(auth.secret) diff --git a/internal/autocert/sni_matcher.go b/internal/autocert/sni_matcher.go index 022a0ddf..57af6a93 100644 --- a/internal/autocert/sni_matcher.go +++ b/internal/autocert/sni_matcher.go @@ -2,6 +2,7 @@ package autocert import ( "crypto/x509" + "slices" "strings" ) @@ -36,11 +37,11 @@ func (m *sniMatcher) matchSuffixTree(serverName string) *Provider { labels := strings.Split(serverName, ".") var best *Provider - for i := len(labels) - 1; i >= 0; i-- { + for i, label := range slices.Backward(labels) { if n.children == nil { break } - next := n.children[labels[i]] + next := n.children[label] if next == nil { break } @@ -116,14 +117,14 @@ func (m *sniMatcher) insertWildcardSuffix(suffix string, p *Provider) { } n := &m.root labels := strings.Split(suffix, ".") - for i := len(labels) - 1; i >= 0; i-- { + for _, label := range slices.Backward(labels) { if n.children == nil { n.children = make(map[string]*sniTreeNode) } - next := n.children[labels[i]] + next := n.children[label] if next == nil { next = &sniTreeNode{} - n.children[labels[i]] = next + n.children[label] = next } n = next } diff --git a/internal/config/events_test.go b/internal/config/events_test.go index 58dfafda..18ba23df 100644 --- a/internal/config/events_test.go +++ b/internal/config/events_test.go @@ -127,11 +127,9 @@ func newNotificationTestState(t *testing.T, url string) *state { { ProviderName: notif.ProviderWebhook, Provider: ¬if.Webhook{ - ProviderBase: notif.ProviderBase{ - Name: "test", - URL: url, - Format: notif.LogFormatPlain, - }, + Name: "test", + URL: url, + Format: notif.LogFormatPlain, Payload: "$message", Method: http.MethodPost, MIMEType: notif.MimeTypeText, diff --git a/internal/config/state.go b/internal/config/state.go index 0d28b0dd..badf07fe 100644 --- a/internal/config/state.go +++ b/internal/config/state.go @@ -874,11 +874,9 @@ func (state *state) newWebUIRoute() (*routeimpl.Route, error) { Homepage: &homepage.ItemConfig{ Show: false, }, - Metadata: routeimpl.Metadata{ - Provider: "webui", - RootFS: webui.Dist(), - ForceConflictWin: true, - }, + Provider: "webui", + RootFS: webui.Dist(), + ForceConflictWin: true, InboundMTLSProfile: state.WebUI.InboundMTLSProfile, Middlewares: state.WebUI.Middlewares, AccessLog: state.WebUI.AccessLog, diff --git a/internal/config/state_diagnostics_test.go b/internal/config/state_diagnostics_test.go index ba062a89..d03930b1 100644 --- a/internal/config/state_diagnostics_test.go +++ b/internal/config/state_diagnostics_test.go @@ -133,11 +133,10 @@ func TestStartupDiagnosticsAllowlist(t *testing.T) { } state.Config.Providers.Notification = []*notif.NotificationConfig{{ ProviderName: notif.ProviderWebhook, - Provider: ¬if.Webhook{ProviderBase: notif.ProviderBase{ + Provider: ¬if.Webhook{ Name: "operations", URL: "https://notifications.example.com", - Token: notificationToken, - }}, + Token: notificationToken}, }} const providerName = "password-reset-token-service" diff --git a/internal/config/types/lifecycle_test.go b/internal/config/types/lifecycle_test.go index 0b233266..4352f2f9 100644 --- a/internal/config/types/lifecycle_test.go +++ b/internal/config/types/lifecycle_test.go @@ -25,11 +25,9 @@ func TestLifecycleErrorsNeedNoCustomJSONMarshalers(t *testing.T) { Severity: IssueDegraded, Err: gperr.Wrap(sentinel), }}, - ActivationReport: ActivationReport{ - Metrics: ComponentActivation{ - Configured: true, - Err: gperr.Wrap(sentinel), - }, + Metrics: ComponentActivation{ + Configured: true, + Err: gperr.Wrap(sentinel), }, } diff --git a/internal/dnsproviders/go.mod b/internal/dnsproviders/go.mod index 26e71a65..774e5678 100644 --- a/internal/dnsproviders/go.mod +++ b/internal/dnsproviders/go.mod @@ -1,6 +1,6 @@ module github.com/yusing/godoxy/internal/dnsproviders -go 1.26.5 +go 1.27.0 replace github.com/yusing/godoxy => ../.. @@ -99,7 +99,7 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/vultr/govultr/v3 v3.32.0 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect - github.com/yusing/gointernals v0.2.0 // indirect + github.com/yusing/gointernals v0.2.1 // indirect github.com/yusing/goutils v0.7.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 // indirect diff --git a/internal/dnsproviders/go.sum b/internal/dnsproviders/go.sum index 21750424..608e8a03 100644 --- a/internal/dnsproviders/go.sum +++ b/internal/dnsproviders/go.sum @@ -229,8 +229,8 @@ github.com/vultr/govultr/v3 v3.32.0/go.mod h1:2zyUw9yADQaGwKnwDesmIOlBNLrm7edsCf github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yusing/gointernals v0.2.0 h1:jyWB3kdUPkuU6s0r8QY/sS5h2WNBF4Kfisly8dtSVvg= -github.com/yusing/gointernals v0.2.0/go.mod h1:xGzNbPGMm5Z8kG0t4JYISMscw+gMQlgghkLxlgRZv5Y= +github.com/yusing/gointernals v0.2.1 h1:QlajBlRG6qbqfzjHmRq774pi+CUW/DILjFM6GjveHuM= +github.com/yusing/gointernals v0.2.1/go.mod h1:xGzNbPGMm5Z8kG0t4JYISMscw+gMQlgghkLxlgRZv5Y= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.67.0 h1:yI1/OhfEPy7J9eoa6Sj051C7n5dvpj0QX8g4sRchg04= diff --git a/internal/entrypoint/query.go b/internal/entrypoint/query.go index 86accc36..7f43cea5 100644 --- a/internal/entrypoint/query.go +++ b/internal/entrypoint/query.go @@ -56,20 +56,16 @@ func getHealthInfo(r routing.Route) health.HealthInfo { mon := r.HealthMonitor() if mon == nil { return health.HealthInfo{ - HealthInfoWithoutDetail: health.HealthInfoWithoutDetail{ - Status: health.StatusUnknown, - }, + Status: health.StatusUnknown, Detail: "n/a", } } return health.HealthInfo{ - HealthInfoWithoutDetail: health.HealthInfoWithoutDetail{ - Status: mon.Status(), - Uptime: mon.Uptime(), - Latency: mon.Latency(), - SleepIn: sleepIn(mon), - }, - Detail: mon.Detail(), + Status: mon.Status(), + Uptime: mon.Uptime(), + Latency: mon.Latency(), + SleepIn: sleepIn(mon), + Detail: mon.Detail(), } } diff --git a/internal/health/monitor/docker_test.go b/internal/health/monitor/docker_test.go index 2a1b631d..40ea2d76 100644 --- a/internal/health/monitor/docker_test.go +++ b/internal/health/monitor/docker_test.go @@ -161,16 +161,14 @@ func TestNewMonitorDoesNotProbeWhenDockerClientInitializationFails(t *testing.T) Alias: "test", Scheme: route.SchemeHTTP, HealthCheck: testHealthConfig(disabled), - Metadata: route.Metadata{ - ProxyURL: targetURL, - Container: &docker.Container{ - ContainerID: "test", - HealthCheckEnabled: true, - DockerCfg: types.DockerProviderConfig{ - URL: "https://127.0.0.1:2376", - }, - Running: true, + ProxyURL: targetURL, + Container: &docker.Container{ + ContainerID: "test", + HealthCheckEnabled: true, + DockerCfg: types.DockerProviderConfig{ + URL: "https://127.0.0.1:2376", }, + Running: true, }, } reverseProxyRoute, err := routeimpl.NewReverseProxyRoute(base) @@ -199,15 +197,13 @@ func TestNewMonitorSkipsDockerWhenHealthCheckWasNotEnabledAtLoad(t *testing.T) { Alias: "test", Scheme: route.SchemeHTTP, HealthCheck: testHealthConfig(false), - Metadata: route.Metadata{ - ProxyURL: targetURL, - Container: &docker.Container{ - ContainerID: "test", - DockerCfg: types.DockerProviderConfig{ - URL: "https://127.0.0.1:2376", - }, - Running: true, + ProxyURL: targetURL, + Container: &docker.Container{ + ContainerID: "test", + DockerCfg: types.DockerProviderConfig{ + URL: "https://127.0.0.1:2376", }, + Running: true, }, } reverseProxyRoute, err := routeimpl.NewReverseProxyRoute(base) diff --git a/internal/homepage/homepage_test.go b/internal/homepage/homepage_test.go index fc762885..c38ac397 100644 --- a/internal/homepage/homepage_test.go +++ b/internal/homepage/homepage_test.go @@ -12,15 +12,13 @@ import ( func TestOverrideItem(t *testing.T) { a := &Item{ Alias: "foo", - ItemConfig: ItemConfig{ - Show: false, - Name: "Foo", - Icon: &icons.URL{ - FullURL: new("/favicon.ico"), - Source: icons.SourceRelative, - }, - Category: "App", + Show: false, + Name: "Foo", + Icon: &icons.URL{ + FullURL: new("/favicon.ico"), + Source: icons.SourceRelative, }, + Category: "App", } want := ItemConfig{ Show: true, @@ -44,11 +42,9 @@ func TestOverrideItem(t *testing.T) { func TestOverrideItem_PreservesURL(t *testing.T) { a := &Item{ Alias: "svc", - ItemConfig: ItemConfig{ - Show: true, - Name: "Service", - URL: "http://origin.local", - }, + Show: true, + Name: "Service", + URL: "http://origin.local", } wantCfg := ItemConfig{ Show: true, @@ -66,13 +62,11 @@ func TestOverrideItem_PreservesURL(t *testing.T) { func TestVisibilityFavoriteAndSortOrders(t *testing.T) { a := &Item{ - Alias: "alpha", - ItemConfig: ItemConfig{ - Show: true, - Name: "Alpha", - Category: "Apps", - Favorite: false, - }, + Alias: "alpha", + Show: true, + Name: "Alpha", + Category: "Apps", + Favorite: false, } overrides := GetOverrideConfig() overrides.Initialize() @@ -93,10 +87,8 @@ func TestVisibilityFavoriteAndSortOrders(t *testing.T) { func TestCategoryDefaultedWhenEmpty(t *testing.T) { a := &Item{ Alias: "no-cat", - ItemConfig: ItemConfig{ - Show: true, - Name: "NoCat", - }, + Show: true, + Name: "NoCat", } got := a.GetOverride() expect.Equal(t, got.Category, CategoryOthers) @@ -104,20 +96,16 @@ func TestCategoryDefaultedWhenEmpty(t *testing.T) { func TestOverrideItems_Bulk(t *testing.T) { a := &Item{ - Alias: "bulk-1", - ItemConfig: ItemConfig{ - Show: true, - Name: "Bulk1", - Category: "X", - }, + Alias: "bulk-1", + Show: true, + Name: "Bulk1", + Category: "X", } b := &Item{ - Alias: "bulk-2", - ItemConfig: ItemConfig{ - Show: true, - Name: "Bulk2", - Category: "Y", - }, + Alias: "bulk-2", + Show: true, + Name: "Bulk2", + Category: "Y", } overrides := GetOverrideConfig() diff --git a/internal/homepage/icons/fetch/fetch.go b/internal/homepage/icons/fetch/fetch.go index b09feef3..e6dfa929 100644 --- a/internal/homepage/icons/fetch/fetch.go +++ b/internal/homepage/icons/fetch/fetch.go @@ -131,8 +131,8 @@ var FetchIconAbsolute = cache.NewKeyFunc(func(ctx context.Context, url string) ( } } - res := Result{Icon: icon} - res.contentType = ct + res := Result{Icon: icon, + contentType: ct} // else leave it empty return res, nil }).WithMaxEntries(200).WithRetriesExponentialBackoff(3).WithTTL(4 * time.Hour).Build() diff --git a/internal/homepage/icons/list/list_icons.go b/internal/homepage/icons/list/list_icons.go index 9d1f546f..ace96153 100644 --- a/internal/homepage/icons/list/list_icons.go +++ b/internal/homepage/icons/list/list_icons.go @@ -153,8 +153,8 @@ func parseKeyword(keyword string) (icons.Source, string) { default: return "", keyword } - if dot := strings.LastIndexByte(ref, '.'); dot != -1 && isExtensionPrefix(ref[dot+1:]) { - ref = ref[:dot] + if name, extension, ok := strings.CutLast(ref, "."); ok && isExtensionPrefix(extension) { + ref = name } for _, variant := range []string{"-light", "-dark"} { if strutils.HasSuffixFold(ref, variant) { diff --git a/internal/homepage/icons/list/list_icons_test.go b/internal/homepage/icons/list/list_icons_test.go index 58085ac6..dcc185c1 100644 --- a/internal/homepage/icons/list/list_icons_test.go +++ b/internal/homepage/icons/list/list_icons_test.go @@ -109,29 +109,23 @@ func TestListWalkxCodeIcons(t *testing.T) { } test := []testCases{ { - Key: NewKey(SourceWalkXCode, "app1"), - Meta: Meta{ - SVG: true, - PNG: true, - WebP: true, - Light: true, - }, + Key: NewKey(SourceWalkXCode, "app1"), + SVG: true, + PNG: true, + WebP: true, + Light: true, }, { - Key: NewKey(SourceWalkXCode, "app2"), - Meta: Meta{ - PNG: true, - WebP: true, - }, + Key: NewKey(SourceWalkXCode, "app2"), + PNG: true, + WebP: true, }, { - Key: NewKey(SourceWalkXCode, "karakeep"), - Meta: Meta{ - SVG: true, - PNG: true, - WebP: true, - Dark: true, - }, + Key: NewKey(SourceWalkXCode, "karakeep"), + SVG: true, + PNG: true, + WebP: true, + Dark: true, }, } runTests(t, m, test) @@ -148,35 +142,29 @@ func TestListSelfhstIcons(t *testing.T) { } test := []testCases{ { - Key: NewKey(SourceSelfhSt, "2fauth"), - Meta: Meta{ - SVG: true, - PNG: true, - WebP: true, - Light: true, - Dark: true, - DisplayName: "2FAuth", - }, + Key: NewKey(SourceSelfhSt, "2fauth"), + SVG: true, + PNG: true, + WebP: true, + Light: true, + Dark: true, + DisplayName: "2FAuth", }, { - Key: NewKey(SourceSelfhSt, "dittofeed"), - Meta: Meta{ - PNG: true, - WebP: true, - DisplayName: "Dittofeed", - }, + Key: NewKey(SourceSelfhSt, "dittofeed"), + PNG: true, + WebP: true, + DisplayName: "Dittofeed", }, { - Key: NewKey(SourceSelfhSt, "ars-technica"), - Meta: Meta{ - SVG: true, - PNG: true, - WebP: true, - Light: true, - Dark: true, - DisplayName: "Ars Technica", - Tag: "News", - }, + Key: NewKey(SourceSelfhSt, "ars-technica"), + SVG: true, + PNG: true, + WebP: true, + Light: true, + Dark: true, + DisplayName: "Ars Technica", + Tag: "News", }, } runTests(t, m, test) diff --git a/internal/homepage/icons/list/resolve.go b/internal/homepage/icons/list/resolve.go index d8b71504..0e542860 100644 --- a/internal/homepage/icons/list/resolve.go +++ b/internal/homepage/icons/list/resolve.go @@ -38,11 +38,11 @@ func ExpandRefs(refs []string) []string { ref = sanitizeRef(ref) add(ref) for { - dash := strings.LastIndexByte(ref, '-') - if dash <= 0 { + prefix, _, ok := strings.CutLast(ref, "-") + if !ok || prefix == "" { break } - ref = ref[:dash] + ref = prefix add(ref) } } diff --git a/internal/idlewatcher/handle_http_debug.go b/internal/idlewatcher/handle_http_debug.go index 1603aeba..8f7c2b41 100644 --- a/internal/idlewatcher/handle_http_debug.go +++ b/internal/idlewatcher/handle_http_debug.go @@ -15,10 +15,8 @@ func DebugHandler(rw http.ResponseWriter, r *http.Request) { w := &Watcher{ events: gevents.NewHistory(), cfg: &idlewatcher.Config{ - IdlewatcherProviderConfig: idlewatcher.ProviderConfig{ - Docker: &idlewatcher.DockerConfig{ - ContainerName: "test", - }, + Docker: &idlewatcher.DockerConfig{ + ContainerName: "test", }, }, } diff --git a/internal/idlewatcher/handle_http_test.go b/internal/idlewatcher/handle_http_test.go index 511ebd79..6c0629df 100644 --- a/internal/idlewatcher/handle_http_test.go +++ b/internal/idlewatcher/handle_http_test.go @@ -817,16 +817,12 @@ func newTestWatcher(t *testing.T) *Watcher { w := &Watcher{ cfg: &idlewatchertypes.Config{ - IdlewatcherProviderConfig: idlewatchertypes.ProviderConfig{ - Docker: &idlewatchertypes.DockerConfig{ - ContainerID: containerName, - ContainerName: containerName, - }, - }, - IdlewatcherConfigBase: idlewatchertypes.ConfigBase{ - IdleTimeout: time.Hour, - WakeTimeout: time.Second, + Docker: &idlewatchertypes.DockerConfig{ + ContainerID: containerName, + ContainerName: containerName, }, + IdleTimeout: time.Hour, + WakeTimeout: time.Second, }, idleTicker: idleTicker, healthTicker: healthTicker, diff --git a/internal/idlewatcher/health_test.go b/internal/idlewatcher/health_test.go index 4d808656..b28d1f80 100644 --- a/internal/idlewatcher/health_test.go +++ b/internal/idlewatcher/health_test.go @@ -12,9 +12,7 @@ import ( func TestSleepIn(t *testing.T) { w := &Watcher{ cfg: &Config{ - IdlewatcherConfigBase: idlewatchertypes.ConfigBase{ - IdleTimeout: time.Minute, - }, + IdleTimeout: time.Minute, }, } w.state.Store(&containerState{ @@ -31,9 +29,7 @@ func TestSleepIn(t *testing.T) { func TestSleepInHiddenWhenNotReadyOrExpired(t *testing.T) { w := &Watcher{ cfg: &Config{ - IdlewatcherConfigBase: idlewatchertypes.ConfigBase{ - IdleTimeout: time.Minute, - }, + IdleTimeout: time.Minute, }, } w.state.Store(&containerState{ diff --git a/internal/idlewatcher/watcher.go b/internal/idlewatcher/watcher.go index b48c598a..6d6cce81 100644 --- a/internal/idlewatcher/watcher.go +++ b/internal/idlewatcher/watcher.go @@ -150,10 +150,8 @@ func NewWatcher(parent task.Parent, r routing.Route, cfg *Config) (*Watcher, err stateChangedCh: make(chan struct{}), events: gevents.NewHistory(), cfg: cfg, - routeHelper: routeHelper{ - hc: monitor.NewMonitor(r), - }, - dependsOn: make([]*dependency, 0, len(cfg.DependsOn)), + hc: monitor.NewMonitor(r), + dependsOn: make([]*dependency, 0, len(cfg.DependsOn)), } } diff --git a/internal/idlewatcher/watcher_dependencies_test.go b/internal/idlewatcher/watcher_dependencies_test.go index 6062bc14..d168a372 100644 --- a/internal/idlewatcher/watcher_dependencies_test.go +++ b/internal/idlewatcher/watcher_dependencies_test.go @@ -147,18 +147,14 @@ func newDependencyReloadTest(t *testing.T, id string, dependsOn []string) (*Watc func idlewatcherTestConfig(id string, dependsOn []string) *idlewatchertypes.Config { return &idlewatchertypes.Config{ - IdlewatcherProviderConfig: idlewatchertypes.ProviderConfig{ - Docker: &idlewatchertypes.DockerConfig{ - ContainerID: id, - ContainerName: id + "-container", - }, - }, - IdlewatcherConfigBase: idlewatchertypes.ConfigBase{ - IdleTimeout: time.Hour, - WakeTimeout: time.Second, - StopTimeout: time.Second, + Docker: &idlewatchertypes.DockerConfig{ + ContainerID: id, + ContainerName: id + "-container", }, - DependsOn: dependsOn, + IdleTimeout: time.Hour, + WakeTimeout: time.Second, + StopTimeout: time.Second, + DependsOn: dependsOn, } } diff --git a/internal/logging/accesslog/config.go b/internal/logging/accesslog/config.go index d039a266..aec96eb6 100644 --- a/internal/logging/accesslog/config.go +++ b/internal/logging/accesslog/config.go @@ -110,10 +110,8 @@ func (cfg *Config) ShouldLogRequest(req *http.Request, res *http.Response) bool func DefaultRequestLoggerConfig() *RequestLoggerConfig { return &RequestLoggerConfig{ - ConfigBase: ConfigBase{ - Retention: &Retention{Days: 30}, - }, - Format: FormatCombined, + Retention: &Retention{Days: 30}, + Format: FormatCombined, Fields: Fields{ Headers: FieldConfig{ Default: FieldModeDrop, @@ -130,9 +128,7 @@ func DefaultRequestLoggerConfig() *RequestLoggerConfig { func DefaultACLLoggerConfig() *ACLLoggerConfig { return &ACLLoggerConfig{ - ConfigBase: ConfigBase{ - Retention: &Retention{Days: 30}, - }, + Retention: &Retention{Days: 30}, } } diff --git a/internal/logging/accesslog/rotate.go b/internal/logging/accesslog/rotate.go index c026090d..5213f5a8 100644 --- a/internal/logging/accesslog/rotate.go +++ b/internal/logging/accesslog/rotate.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "io/fs" + "slices" "time" "github.com/rs/zerolog" @@ -196,8 +197,8 @@ func rotateLogFileByPolicy(file supportRotate, config *Retention, result *Rotate // Read each line and write it to the beginning of the file writePos := int64(0) // in reverse order to keep the order of the lines (from old to new) - for i := len(linesToKeep) - 1; i >= 0; i-- { - line := linesToKeep[i] + for _, line := range slices.Backward(linesToKeep) { + n := line.Size if err := fileContentMove(file, line.Pos, writePos, int(n)); err != nil { diff --git a/internal/logging/accesslog/rotate_test.go b/internal/logging/accesslog/rotate_test.go index 6a12d08b..7948556b 100644 --- a/internal/logging/accesslog/rotate_test.go +++ b/internal/logging/accesslog/rotate_test.go @@ -162,10 +162,8 @@ func TestRotateKeepDaysRollsRealFile(t *testing.T) { expect.NoError(t, err) logger := NewFileAccessLogger(task.RootTask("test", false), file, &RequestLoggerConfig{ - Format: FormatJSON, - ConfigBase: ConfigBase{ - Retention: strutils.MustParse[*Retention]("30 days"), - }, + Format: FormatJSON, + Retention: strutils.MustParse[*Retention]("30 days"), }) defer logger.Close() @@ -209,10 +207,8 @@ func TestRotateKeepDaysPreservesActiveFileMode(t *testing.T) { expect.NoError(t, err) logger := NewFileAccessLogger(task.RootTask("test", false), file, &RequestLoggerConfig{ - Format: FormatJSON, - ConfigBase: ConfigBase{ - Retention: strutils.MustParse[*Retention]("30 days"), - }, + Format: FormatJSON, + Retention: strutils.MustParse[*Retention]("30 days"), }) defer logger.Close() @@ -238,10 +234,8 @@ func TestRotateKeepDaysFlushesSharedFileLoggers(t *testing.T) { expect.NoError(t, err) cfg := &RequestLoggerConfig{ - Format: FormatJSON, - ConfigBase: ConfigBase{ - Retention: strutils.MustParse[*Retention]("30 days"), - }, + Format: FormatJSON, + Retention: strutils.MustParse[*Retention]("30 days"), } logger1 := NewFileAccessLogger(task.RootTask("test", false), file1, cfg) defer logger1.Close() @@ -269,10 +263,8 @@ func TestRotateKeepDaysDeletesExpiredArchives(t *testing.T) { expect.NoError(t, err) logger := NewFileAccessLogger(task.RootTask("test", false), file, &RequestLoggerConfig{ - Format: FormatJSON, - ConfigBase: ConfigBase{ - Retention: strutils.MustParse[*Retention]("30 days"), - }, + Format: FormatJSON, + Retention: strutils.MustParse[*Retention]("30 days"), }) defer logger.Close() @@ -410,10 +402,8 @@ func BenchmarkRotate(b *testing.B) { b.Run(fmt.Sprintf("retention_%s", retention.String()), func(b *testing.B) { file := newMockFile(true) logger := NewFileAccessLogger(task.RootTask("test", false), file, &RequestLoggerConfig{ - ConfigBase: ConfigBase{ - Retention: retention, - }, - Format: FormatJSON, + Retention: retention, + Format: FormatJSON, }) for i := range 100 { mockable.MockTimeNow(testTime.AddDate(0, 0, -100+i+1)) @@ -444,10 +434,8 @@ func BenchmarkRotateWithInvalidTime(b *testing.B) { b.Run(fmt.Sprintf("retention_%s", retention.String()), func(b *testing.B) { file := newMockFile(true) logger := NewFileAccessLogger(task.RootTask("test", false), file, &RequestLoggerConfig{ - ConfigBase: ConfigBase{ - Retention: retention, - }, - Format: FormatJSON, + Retention: retention, + Format: FormatJSON, }) for i := range 10000 { mockable.MockTimeNow(testTime.AddDate(0, 0, -10000+i+1)) diff --git a/internal/maxmind/maxmind.go b/internal/maxmind/maxmind.go index 69d0be30..c9873e78 100644 --- a/internal/maxmind/maxmind.go +++ b/internal/maxmind/maxmind.go @@ -92,8 +92,7 @@ func (cfg *MaxMind) LoadMaxMindDB(parent task.Parent) error { case errors.Is(err, os.ErrNotExist): default: // ignore invalid error, just download it again - var invalidErr maxminddb.InvalidDatabaseError - if !errors.As(err, &invalidErr) { + if _, ok := errors.AsType[maxminddb.InvalidDatabaseError](err); !ok { return err } } diff --git a/internal/net/gphttp/loadbalancer/server_test.go b/internal/net/gphttp/loadbalancer/server_test.go index 8a6d83a2..c159191a 100644 --- a/internal/net/gphttp/loadbalancer/server_test.go +++ b/internal/net/gphttp/loadbalancer/server_test.go @@ -1,13 +1,11 @@ package loadbalancer import ( - "net/url" - nettypes "github.com/yusing/godoxy/internal/net/types" "github.com/yusing/godoxy/internal/types" ) -var testServerURL = nettypes.URL{URL: url.URL{Scheme: "http", Host: "localhost"}} +var testServerURL = nettypes.URL{Scheme: "http", Host: "localhost"} func newTestServer(weight float64) types.LoadBalancerServer { u := testServerURL diff --git a/internal/notif/config_test.go b/internal/notif/config_test.go index 67f04d5d..23957c09 100644 --- a/internal/notif/config_test.go +++ b/internal/notif/config_test.go @@ -24,11 +24,9 @@ func TestNotificationConfig(t *testing.T) { "url": "https://example.com", }, expected: &Webhook{ - ProviderBase: ProviderBase{ - Name: "test", - URL: "https://example.com", - Format: LogFormatMarkdown, - }, + Name: "test", + URL: "https://example.com", + Format: LogFormatMarkdown, Template: "discord", Method: http.MethodPost, MIMEType: "application/json", @@ -47,12 +45,10 @@ func TestNotificationConfig(t *testing.T) { "format": "plain", }, expected: &GotifyClient{ - ProviderBase: ProviderBase{ - Name: "test", - URL: "https://example.com", - Token: "token", - Format: LogFormatPlain, - }, + Name: "test", + URL: "https://example.com", + Token: "token", + Format: LogFormatPlain, }, wantErr: false, }, @@ -65,12 +61,10 @@ func TestNotificationConfig(t *testing.T) { "url": "https://example.com", }, expected: &GotifyClient{ - ProviderBase: ProviderBase{ - Name: "test", - URL: "https://example.com", - Token: "token", - Format: LogFormatMarkdown, - }, + Name: "test", + URL: "https://example.com", + Token: "token", + Format: LogFormatMarkdown, }, wantErr: false, }, diff --git a/internal/route/provider/docker.go b/internal/route/provider/docker.go index 5220d82e..d847c4c4 100755 --- a/internal/route/provider/docker.go +++ b/internal/route/provider/docker.go @@ -122,10 +122,8 @@ func (p *DockerProvider) routesFromContainerLabels(container *docker.Container) // init entries map for all aliases for _, a := range container.Aliases { routes[a] = &route.Route{ - Alias: a, - Metadata: route.Metadata{ - Container: container, - }, + Alias: a, + Container: container, } } @@ -174,10 +172,8 @@ func (p *DockerProvider) routesFromContainerLabels(container *docker.Container) r, ok := routes[alias] if !ok { r = &route.Route{ - Alias: alias, - Metadata: route.Metadata{ - Container: container, - }, + Alias: alias, + Container: container, } routes[alias] = r } diff --git a/internal/route/provider/event_handler_test.go b/internal/route/provider/event_handler_test.go index 1c5f5242..3c6c6894 100644 --- a/internal/route/provider/event_handler_test.go +++ b/internal/route/provider/event_handler_test.go @@ -87,11 +87,9 @@ func TestEventHandlerShouldUpdateRouteOnForceReloadEvenWithoutMatchingContainerE ActorID: "other-id", ActorName: "other-name", }}, &route.Route{ - Metadata: route.Metadata{ - Container: &docker.Container{ - ContainerID: "app-id", - ContainerName: "app-name", - }, + Container: &docker.Container{ + ContainerID: "app-id", + ContainerName: "app-name", }, }) diff --git a/internal/route/route_test.go b/internal/route/route_test.go index dd4189b1..8125d36d 100644 --- a/internal/route/route_test.go +++ b/internal/route/route_test.go @@ -39,8 +39,8 @@ func TestHomepageItemContainerControls(t *testing.T) { { name: "docker container", route: &route.Route{ - Homepage: &homepage.ItemConfig{}, - Metadata: route.Metadata{Container: &docker.Container{ContainerID: "container-id"}}, + Homepage: &homepage.ItemConfig{}, + Container: &docker.Container{ContainerID: "container-id"}, }, wantContainerID: "container-id", }, @@ -77,7 +77,7 @@ func TestProxmoxDiscoveryRequiresSuccessfulMark(t *testing.T) { r := &route.Route{ Alias: "radarr", Proxmox: &proxmox.NodeConfig{Node: "pve", VMID: &vmid, VMName: "radarr-service"}, - Metadata: route.Metadata{ProxyURL: target}, + ProxyURL: target, } _, ok := r.ProxmoxDiscovery() @@ -222,12 +222,10 @@ func TestRouteValidate(t *testing.T) { Scheme: route.SchemeHTTP, Host: "example.com", Port: route.Port{Proxy: 80}, - Metadata: route.Metadata{ - Container: &docker.Container{ - ContainerID: "test-id", - Image: &docker.Image{ - Name: "test-image", - }, + Container: &docker.Container{ + ContainerID: "test-id", + Image: &docker.Image{ + Name: "test-image", }, }, } @@ -269,12 +267,10 @@ func TestDockerRouteDisallowAgent(t *testing.T) { Host: "example.com", Port: route.Port{Proxy: 80}, Agent: "test-agent", - Metadata: route.Metadata{ - Container: &docker.Container{ - ContainerID: "test-id", - Image: &docker.Image{ - Name: "test-image", - }, + Container: &docker.Container{ + ContainerID: "test-id", + Image: &docker.Image{ + Name: "test-image", }, }, } diff --git a/internal/routeimpl/fileserver_test.go b/internal/routeimpl/fileserver_test.go index d77b22ec..04a2d797 100644 --- a/internal/routeimpl/fileserver_test.go +++ b/internal/routeimpl/fileserver_test.go @@ -133,10 +133,10 @@ func TestEmbeddedFileServerUsesNginxTryFilesOrder(t *testing.T) { } fileServer, err := NewFileServer(&route.Route{ - Root: "embed://webui", - Metadata: route.Metadata{RootFS: fsys}, - SPA: true, - Index: "_shell.html", + Root: "embed://webui", + RootFS: fsys, + SPA: true, + Index: "_shell.html", }) expect.NoError(t, err) diff --git a/internal/routeimpl/reverse_proxy.go b/internal/routeimpl/reverse_proxy.go index c2e72c0f..a1729599 100755 --- a/internal/routeimpl/reverse_proxy.go +++ b/internal/routeimpl/reverse_proxy.go @@ -245,9 +245,7 @@ func (r *ReverseProxyRoute) addToLoadBalancer(parent task.Parent, ep routing.Ent Alias: cfg.Link, Homepage: r.Homepage, Bind: r.Bind, - Metadata: route.Metadata{ - LisURL: r.ListenURL(), - }, + LisURL: r.ListenURL(), }, loadBalancer: lb, handler: lb, diff --git a/internal/routeimpl/stream_test.go b/internal/routeimpl/stream_test.go index c17c4d66..746a91a9 100644 --- a/internal/routeimpl/stream_test.go +++ b/internal/routeimpl/stream_test.go @@ -81,10 +81,8 @@ func TestStreamRouteCancelFinishesTask(t *testing.T) { Alias: "echo-" + tt.name, Scheme: tt.scheme, HealthCheck: health.HealthCheckConfig{Disable: true}, - Metadata: route.Metadata{ - LisURL: lisURL, - ProxyURL: proxyURL, - }, + LisURL: lisURL, + ProxyURL: proxyURL, }) require.NoError(t, err) require.NoError(t, impl.Start(parent)) @@ -151,10 +149,8 @@ func TestStreamRouteListenErrorFinishesTask(t *testing.T) { Alias: "busy-tcp", Scheme: route.SchemeTCP, HealthCheck: health.HealthCheckConfig{Disable: true}, - Metadata: route.Metadata{ - LisURL: lisURL, - ProxyURL: proxyURL, - }, + LisURL: lisURL, + ProxyURL: proxyURL, }) require.NoError(t, err) require.Error(t, impl.Start(parent)) diff --git a/internal/routeimpl/webui_smoke_test.go b/internal/routeimpl/webui_smoke_test.go index 1cc5f3ee..a0ffcc2c 100644 --- a/internal/routeimpl/webui_smoke_test.go +++ b/internal/routeimpl/webui_smoke_test.go @@ -43,11 +43,11 @@ func TestEmbeddedWebUIRouteSmoke(t *testing.T) { require.True(t, ok) fileServer, err := NewFileServer(&route.Route{ - Root: "embed://webui", - Metadata: route.Metadata{RootFS: webui.Dist()}, - SPA: true, - Index: "_shell.html", - Rules: webuiRules, + Root: "embed://webui", + RootFS: webui.Dist(), + SPA: true, + Index: "_shell.html", + Rules: webuiRules, }) require.NoError(t, err) @@ -142,12 +142,12 @@ func TestEmbeddedWebUIRouteMiddlewaresWrapRules(t *testing.T) { require.True(t, ok) fileServer, err := NewFileServer(&route.Route{ - Alias: "godoxy", - Root: "embed://webui", - Metadata: route.Metadata{RootFS: webui.Dist()}, - SPA: true, - Index: "_shell.html", - Rules: webuiRules, + Alias: "godoxy", + Root: "embed://webui", + RootFS: webui.Dist(), + SPA: true, + Index: "_shell.html", + Rules: webuiRules, Middlewares: map[string]types.LabelMap{ "themed": { "css": "https://css.tyleo.dev/gdx/global.css", diff --git a/internal/routevalidate/finalize_test.go b/internal/routevalidate/finalize_test.go index e8ea1058..c7f22ede 100644 --- a/internal/routevalidate/finalize_test.go +++ b/internal/routevalidate/finalize_test.go @@ -23,13 +23,11 @@ func TestPreferredPort(t *testing.T) { func TestDockerRouteWithResolvablePortIsNotExcludedBeforeFinalize(t *testing.T) { r := &route.Route{ Alias: "app", - Metadata: route.Metadata{ - Container: &docker.Container{ - Image: &docker.Image{Name: "custom-app"}, - PrivateHostname: "172.18.0.2", - PrivatePortMapping: docker.PortMapping{ - 8080: container.Port{PrivatePort: 8080, Type: "tcp"}, - }, + Container: &docker.Container{ + Image: &docker.Image{Name: "custom-app"}, + PrivateHostname: "172.18.0.2", + PrivatePortMapping: docker.PortMapping{ + 8080: container.Port{PrivatePort: 8080, Type: "tcp"}, }, }, } @@ -45,14 +43,12 @@ func TestDockerRouteWithResolvablePortIsNotExcludedBeforeFinalize(t *testing.T) func TestFinalizeHomepage_ImmichServerUsesImmichCategory(t *testing.T) { r := &route.Route{ Alias: "immich-server", - Metadata: route.Metadata{ - Container: &docker.Container{ - ContainerName: "immich-server", - Image: &docker.Image{Name: "immich-server"}, - PrivateHostname: "172.18.0.2", - PrivatePortMapping: docker.PortMapping{ - 2283: container.Port{PrivatePort: 2283, Type: "tcp"}, - }, + Container: &docker.Container{ + ContainerName: "immich-server", + Image: &docker.Image{Name: "immich-server"}, + PrivateHostname: "172.18.0.2", + PrivatePortMapping: docker.PortMapping{ + 2283: container.Port{PrivatePort: 2283, Type: "tcp"}, }, }, } diff --git a/internal/routevalidate/proxmox_test.go b/internal/routevalidate/proxmox_test.go index fe12a980..f254ffb5 100644 --- a/internal/routevalidate/proxmox_test.go +++ b/internal/routevalidate/proxmox_test.go @@ -30,11 +30,9 @@ func TestResolveProxmoxBindsResolvedRouteToIdlewatcher(t *testing.T) { func TestResolveProxmoxUsesExplicitIdlewatcherBindingForRoute(t *testing.T) { r := &route.Route{ Idlewatcher: &idlewatcher.Config{ - IdlewatcherProviderConfig: idlewatcher.ProviderConfig{ - Proxmox: &idlewatcher.ProxmoxConfig{ - Node: "pve", - VMID: 119, - }, + Proxmox: &idlewatcher.ProxmoxConfig{ + Node: "pve", + VMID: 119, }, }, } diff --git a/internal/serialization/serialization.go b/internal/serialization/serialization.go index 5cc7e578..f017dfd8 100644 --- a/internal/serialization/serialization.go +++ b/internal/serialization/serialization.go @@ -115,8 +115,7 @@ func initPtr(dst reflect.Value) { func ValidateWithFieldTags(s any) error { var errs gperr.Builder err := validate.Struct(s) - var valErrs validator.ValidationErrors - if errors.As(err, &valErrs) { + if valErrs, ok := errors.AsType[validator.ValidationErrors](err); ok { for _, e := range valErrs { detail := e.ActualTag() if e.Param() != "" { diff --git a/socket-proxy/go.mod b/socket-proxy/go.mod index ae46633d..94955974 100644 --- a/socket-proxy/go.mod +++ b/socket-proxy/go.mod @@ -1,6 +1,6 @@ module github.com/yusing/godoxy/socketproxy -go 1.26.5 +go 1.27.0 replace github.com/yusing/goutils => ../goutils