diff --git a/build/build.sh b/build/build.sh index e5a4752..0822e22 100755 --- a/build/build.sh +++ b/build/build.sh @@ -5,7 +5,7 @@ function build() { NAME="edge-node" VERSION=$(lookup-version "$ROOT"/../internal/const/const.go) DIST=$ROOT/"../dist/${NAME}" - MUSL_DIR="/usr/local/opt/musl-cross/bin" + MUSL_DIR="/opt/homebrew/bin" SRCDIR=$(realpath "$ROOT/..") # for macOS users: precompiled gcc can be downloaded from https://github.com/messense/homebrew-macos-cross-toolchains @@ -74,50 +74,20 @@ function build() { CGO_LDFLAGS="" CGO_CFLAGS="" BUILD_TAG=$TAG - if [[ `uname -a` == *"Darwin"* && "${OS}" == "linux" ]]; then + if [[ "${OS}" == "linux" ]]; then if [ "${ARCH}" == "amd64" ]; then - # build with script support - if [ -d $GCC_X86_64_DIR ]; then - MUSL_DIR=$GCC_X86_64_DIR - CC_PATH="x86_64-unknown-linux-gnu-gcc" - CXX_PATH="x86_64-unknown-linux-gnu-g++" - if [ "$TAG" = "plus" ]; then - BUILD_TAG="plus,script,packet" - fi - else - CC_PATH="x86_64-linux-musl-gcc" - CXX_PATH="x86_64-linux-musl-g++" - fi - fi - if [ "${ARCH}" == "386" ]; then - CC_PATH="i486-linux-musl-gcc" - CXX_PATH="i486-linux-musl-g++" + CC_PATH=$(command -v x86_64-linux-musl-gcc) + CXX_PATH=$(command -v x86_64-linux-musl-g++) + # if [ "$TAG" = "plus" ]; then + # BUILD_TAG="plus,script,packet" + # fi fi if [ "${ARCH}" == "arm64" ]; then - # build with script support - if [ -d $GCC_ARM64_DIR ]; then - MUSL_DIR=$GCC_ARM64_DIR - CC_PATH="aarch64-unknown-linux-gnu-gcc" - CXX_PATH="aarch64-unknown-linux-gnu-g++" - if [ "$TAG" = "plus" ]; then - BUILD_TAG="plus,script,packet" - fi - else - CC_PATH="aarch64-linux-musl-gcc" - CXX_PATH="aarch64-linux-musl-g++" - fi - fi - if [ "${ARCH}" == "arm" ]; then - CC_PATH="arm-linux-musleabi-gcc" - CXX_PATH="arm-linux-musleabi-g++" - fi - if [ "${ARCH}" == "mips64" ]; then - CC_PATH="mips64-linux-musl-gcc" - CXX_PATH="mips64-linux-musl-g++" - fi - if [ "${ARCH}" == "mips64le" ]; then - CC_PATH="mips64el-linux-musl-gcc" - CXX_PATH="mips64el-linux-musl-g++" + CC_PATH=$(command -v aarch64-linux-musl-gcc) + CXX_PATH=$(command -v aarch64-linux-musl-g++) + # if [ "$TAG" = "plus" ]; then + # BUILD_TAG="plus,script,packet" + # fi fi fi @@ -127,9 +97,9 @@ function build() { CGO_CFLAGS="-I${SRCDIR}/libs/libpcap/src/libpcap -I${SRCDIR}/libs/libpcap/src/libpcap/pcap -I${SRCDIR}/libs/libbrotli/src/brotli/c/include" fi - if [ ! -z $CC_PATH ]; then - env CC=$MUSL_DIR/$CC_PATH \ - CXX=$MUSL_DIR/$CXX_PATH GOOS="${OS}" \ + if [ -f $CC_PATH ]; then + env CC=$CC_PATH \ + CXX=$CXX_PATH GOOS="${OS}" \ GOARCH="${ARCH}" CGO_ENABLED=1 \ CGO_LDFLAGS="${CGO_LDFLAGS}" \ CGO_CFLAGS="${CGO_CFLAGS}" \ diff --git a/cmd/edge-node/main.go b/cmd/edge-node/main.go index a28deb1..2936c4d 100644 --- a/cmd/edge-node/main.go +++ b/cmd/edge-node/main.go @@ -4,6 +4,17 @@ import ( "encoding/json" "flag" "fmt" + "net" + "net/http" + _ "net/http/pprof" + "os" + "path/filepath" + "runtime" + "sort" + "strings" + "syscall" + "time" + "github.com/TeaOSLab/EdgeNode/internal/apps" "github.com/TeaOSLab/EdgeNode/internal/configs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -18,16 +29,6 @@ import ( "github.com/iwind/TeaGo/types" "github.com/iwind/gosock/pkg/gosock" "gopkg.in/yaml.v3" - "net" - "net/http" - _ "net/http/pprof" - "os" - "path/filepath" - "runtime" - "sort" - "strings" - "syscall" - "time" ) func main() { diff --git a/go.mod b/go.mod index 433bb3c..95d4598 100644 --- a/go.mod +++ b/go.mod @@ -1,54 +1,53 @@ module github.com/TeaOSLab/EdgeNode -go 1.21 +go 1.22 -replace ( - github.com/TeaOSLab/EdgeCommon => ../EdgeCommon - github.com/dchest/captcha => github.com/iwind/captcha v0.0.0-20231130092438-ae985686ed84 - github.com/fsnotify/fsnotify => github.com/iwind/fsnotify v1.5.2-0.20220817040843-193be2051ff4 -) +replace github.com/TeaOSLab/EdgeCommon => ../EdgeCommon require ( - github.com/TeaOSLab/EdgeCommon v0.0.0-00010101000000-000000000000 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/andybalholm/brotli v1.0.5 github.com/aws/aws-sdk-go v1.44.279 github.com/baidubce/bce-sdk-go v0.9.170 github.com/biessek/golang-ico v0.0.0-20180326222316-d348d9ea4670 - github.com/cespare/xxhash/v2 v2.2.0 + github.com/cespare/xxhash/v2 v2.3.0 + github.com/coreos/go-iptables v0.6.0 github.com/cockroachdb/pebble v1.1.0 - github.com/dchest/captcha v0.0.0-00010101000000-000000000000 + github.com/dchest/captcha v1.0.0 + github.com/florianl/go-nfqueue v1.3.1 github.com/fsnotify/fsnotify v1.7.0 github.com/go-redis/redis/v8 v8.11.5 github.com/google/gopacket v1.1.19 github.com/google/nftables v0.2.0 github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.4+incompatible - github.com/iwind/TeaGo v0.0.0-20240411075713-6c1fc9aca7b6 + github.com/iwind/TeaGo v0.0.0-20240508072741-7647e70b7070 github.com/iwind/gofcgi v0.0.0-20210528023741-a92711d45f11 - github.com/iwind/gosock v0.0.0-20211103081026-ee4652210ca4 + github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62 github.com/iwind/gowebp v0.0.0-20240109104518-489f3429f5c5 github.com/klauspost/compress v1.17.8 - github.com/mattn/go-sqlite3 v1.14.17 + github.com/mattn/go-sqlite3 v1.14.22 github.com/mdlayher/netlink v1.7.2 - github.com/miekg/dns v1.1.43 + github.com/miekg/dns v1.1.59 github.com/mssola/useragent v1.0.0 + github.com/panjf2000/ants/v2 v2.7.5 github.com/pires/go-proxyproto v0.6.1 github.com/qiniu/go-sdk/v7 v7.16.0 - github.com/quic-go/quic-go v0.42.0 - github.com/shirou/gopsutil/v3 v3.22.2 - github.com/tdewolff/minify/v2 v2.20.19 + github.com/quic-go/quic-go v0.44.0 + github.com/shirou/gopsutil/v3 v3.24.2 + github.com/tdewolff/minify/v2 v2.20.24 github.com/tencentyun/cos-go-sdk-v5 v0.7.41 - golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f - golang.org/x/image v0.15.0 - golang.org/x/net v0.24.0 - golang.org/x/sys v0.19.0 - google.golang.org/grpc v1.62.1 + golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 + golang.org/x/image v0.16.0 + golang.org/x/net v0.25.0 + golang.org/x/sys v0.20.0 + google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v3 v3.0.1 + rogchap.com/v8go v0.8.0 ) require ( - github.com/DataDog/zstd v1.5.5 // indirect + github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/clbanning/mxj v1.8.4 // indirect github.com/cockroachdb/errors v1.11.1 // indirect @@ -58,13 +57,12 @@ require ( github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-querystring v1.0.0 // indirect - github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/pprof v0.0.0-20240509144519-723abb6459b7 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/native v1.1.0 // indirect github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect @@ -72,9 +70,9 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mdlayher/socket v0.5.0 // indirect - github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mozillazg/go-httpheader v0.2.1 // indirect - github.com/onsi/ginkgo/v2 v2.16.0 // indirect + github.com/onsi/ginkgo/v2 v2.17.3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/client_golang v1.19.0 // indirect @@ -83,16 +81,18 @@ require ( github.com/prometheus/procfs v0.13.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/tdewolff/parse/v2 v2.7.12 // indirect - github.com/tklauser/go-sysconf v0.3.9 // indirect - github.com/tklauser/numcpus v0.3.0 // indirect - github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/stretchr/testify v1.9.0 // indirect + github.com/tdewolff/parse/v2 v2.7.14 // indirect + github.com/tklauser/go-sysconf v0.3.13 // indirect + github.com/tklauser/numcpus v0.7.0 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect go.uber.org/mock v0.4.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.23.0 // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/text v0.15.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.20.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + golang.org/x/tools v0.21.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect ) diff --git a/go.sum b/go.sum index 7657a70..4bea2a7 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= -github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e h1:ZIWapoIRN1VqT8GR8jAwb1Ie9GyehWjVcGh32Y2MznE= +github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g= github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= @@ -13,8 +13,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/biessek/golang-ico v0.0.0-20180326222316-d348d9ea4670 h1:FQPKKjDhzG0T4ew6dm6MGrXb4PRAi8ZmTuYuxcF62BM= github.com/biessek/golang-ico v0.0.0-20180326222316-d348d9ea4670/go.mod h1:iRWAFbKXMMkVQyxZ1PfGlkBr1TjATx1zy2MRprV7A3Q= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= @@ -33,8 +33,12 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dchest/captcha v1.0.0 h1:vw+bm/qMFvTgcjQlYVTuQBJkarm5R0YSsDKhm1HZI2o= +github.com/dchest/captcha v1.0.0/go.mod h1:7zoElIawLp7GUMLcj54K9kbw+jEyvz2K0FDdRRYhvWo= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= @@ -51,41 +55,36 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/nftables v0.2.0 h1:PbJwaBmbVLzpeldoeUKGkE2RjstrjPKMl6oLrfEJ6/8= github.com/google/nftables v0.2.0/go.mod h1:Beg6V6zZ3oEn0JuiUQ4wqwuyqqzasOltcoXPtgLbFp4= -github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 h1:y3N7Bm7Y9/CtpiVkw/ZWj6lSlDF3F74SfKwfTCer72Q= -github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240509144519-723abb6459b7 h1:velgFPYr1X9TDwLIfkV7fWqsFlf7TeP11M/7kPd/dVI= +github.com/google/pprof v0.0.0-20240509144519-723abb6459b7/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.4+incompatible h1:XRAk4HBDLCYEdPLWtKf5iZhOi7lfx17aY0oSO9+mcg8= github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.4+incompatible/go.mod h1:l7VUhRbTKCzdOacdT4oWCwATKyvZqUOlOqr0Ous3k4s= -github.com/iwind/TeaGo v0.0.0-20240411075713-6c1fc9aca7b6 h1:dS3pTxrLlDQxdoxSUcHkHnr3LHpsBIXv8v2/xw65RN8= -github.com/iwind/TeaGo v0.0.0-20240411075713-6c1fc9aca7b6/go.mod h1:SfqVbWyIPdVflyA6lMgicZzsoGS8pyeLiTRe8/CIpGI= -github.com/iwind/captcha v0.0.0-20231130092438-ae985686ed84 h1:/RtK8t22a/YFkBWiEwxS+JWcDmxAKsu+r+p00c36K0Q= -github.com/iwind/captcha v0.0.0-20231130092438-ae985686ed84/go.mod h1:7zoElIawLp7GUMLcj54K9kbw+jEyvz2K0FDdRRYhvWo= -github.com/iwind/fsnotify v1.5.2-0.20220817040843-193be2051ff4 h1:PKtXlgNHJhdwl5ozio7KRV3n0SckMw+8ZC2NCpRSv8U= -github.com/iwind/fsnotify v1.5.2-0.20220817040843-193be2051ff4/go.mod h1:DmAukmDY25inGlriLn0B2jidmvaDR1REOcPXwvzvDPI= +github.com/iwind/TeaGo v0.0.0-20240508072741-7647e70b7070 h1:0YHZBcuXYbvtQ0XfEdtzr/XybiMrwD8vV1lvgAwzUW4= github.com/iwind/gofcgi v0.0.0-20210528023741-a92711d45f11 h1:DaQjoWZhLNxjhIXedVg4/vFEtHkZhK4IjIwsWdyzBLg= github.com/iwind/gofcgi v0.0.0-20210528023741-a92711d45f11/go.mod h1:JtbX20untAjUVjZs1ZBtq80f5rJWvwtQNRL6EnuYRnY= -github.com/iwind/gosock v0.0.0-20211103081026-ee4652210ca4 h1:VWGsCqTzObdlbf7UUE3oceIpcEKi4C/YBUszQXk118A= -github.com/iwind/gosock v0.0.0-20211103081026-ee4652210ca4/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA= +github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62 h1:HJH6RDheAY156DnIfJSD/bEvqyXzsZuE2gzs8PuUjoo= +github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA= github.com/iwind/gowebp v0.0.0-20240109104518-489f3429f5c5 h1:tA0HEDQJ/FM847wc7kVpSgkTfMF1LervEmd2UZQr3Po= github.com/iwind/gowebp v0.0.0-20240109104518-489f3429f5c5/go.mod h1:AYyXDhbbD7q9N6rJff2jrE7pGupaiyvtv3YeyIAQLXk= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -112,16 +111,17 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= -github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g= github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw= github.com/mdlayher/socket v0.5.0 h1:ilICZmJcQz70vrWVes1MFera4jGiWNocSkykwwoy3XI= github.com/mdlayher/socket v0.5.0/go.mod h1:WkcBFfvyG8QENs5+hfQPl1X6Jpd2yeLIYgrGFmJiJxI= -github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg= -github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= -github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= +github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs= +github.com/miekg/dns v1.1.59/go.mod h1:nZpewl5p6IvctfgrckopVx2OlSEHPRO/U4SYkRklrEk= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ= github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= github.com/mssola/useragent v1.0.0 h1:WRlDpXyxHDNfvZaPEut5Biveq86Ze4o4EMffyMxmH5o= @@ -130,10 +130,10 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM= -github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= -github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= -github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/ginkgo/v2 v2.17.3 h1:oJcvKpIb7/8uLpDDtnQuf18xVnwKp8DTD7DQ6gTd/MU= +github.com/onsi/ginkgo/v2 v2.17.3/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= +github.com/onsi/gomega v1.33.0 h1:snPCflnZrpMsy94p4lXVEkHo12lmPnc3vY5XBbreexE= +github.com/onsi/gomega v1.33.0/go.mod h1:+925n5YtiFsLzzafLUHzVMBpvvRAzrydIBiSIxjX3wY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pires/go-proxyproto v0.6.1 h1:EBupykFmo22SDjv4fQVQd2J9NOoLPmyZA/15ldOGkPw= @@ -159,25 +159,33 @@ github.com/qiniu/go-sdk/v7 v7.16.0/go.mod h1:nqoYCNo53ZlGA521RvRethvxUDvXKt4gtYX github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs= 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/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= -github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= +github.com/quic-go/quic-go v0.44.0 h1:So5wOr7jyO4vzL2sd8/pD9Kesciv91zSk8BoFngItQ0= +github.com/quic-go/quic-go v0.44.0/go.mod h1:z4cx/9Ny9UtGITIPzmPTXh1ULfOyWh4qGQlpnPcWmek= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks= -github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= +github.com/shirou/gopsutil/v3 v3.24.2 h1:kcR0erMbLg5/3LcInpw0X/rrPSqq4CDPyI6A6ZRC18Y= +github.com/shirou/gopsutil/v3 v3.24.2/go.mod h1:tSg/594BcA+8UdQU2XcW803GWYgdtauFFPgJCJKZlVk= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/tdewolff/minify/v2 v2.20.19 h1:tX0SR0LUrIqGoLjXnkIzRSIbKJ7PaNnSENLD4CyH6Xo= -github.com/tdewolff/minify/v2 v2.20.19/go.mod h1:ulkFoeAVWMLEyjuDz1ZIWOA31g5aWOawCFRp9R/MudM= -github.com/tdewolff/parse/v2 v2.7.12 h1:tgavkHc2ZDEQVKy1oWxwIyh5bP4F5fEh/JmBwPP/3LQ= -github.com/tdewolff/parse/v2 v2.7.12/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tdewolff/minify/v2 v2.20.24 h1:I4FCC5Q2YdGnmXNokZ1OkGpkO+Weao/62y5/2eQ19vo= +github.com/tdewolff/minify/v2 v2.20.24/go.mod h1:1TJni7+mATKu24cBQQpgwakrYRD27uC1/rdJOgdv8ns= +github.com/tdewolff/parse/v2 v2.7.14 h1:100KJ+QAO3PpMb3uUjzEU/NpmCdbBYz6KPmCIAfWpR8= +github.com/tdewolff/parse/v2 v2.7.14/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA= github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03u/dMQK9g+Iw9ewps4mCl1nB8Sscbo= github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= @@ -185,17 +193,19 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194/go.mod github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.194/go.mod h1:yrBKWhChnDqNz1xuXdSbWXG56XawEq0G5j1lg4VwBD4= github.com/tencentyun/cos-go-sdk-v5 v0.7.41 h1:iU0Li/Np78H4SBna0ECQoF3mpgi6ImLXU+doGzPFXGc= github.com/tencentyun/cos-go-sdk-v5 v0.7.41/go.mod h1:4dCEtLHGh8QPxHEkgq+nFaky7yZxQuYwgSJM87icDaw= -github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= -github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= -github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= -github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= +github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= +github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc h1:R83G5ikgLMxrBvLh22JhdfI8K6YXEPHx5P03Uu3DRs4= github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= -github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= 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= @@ -204,12 +214,12 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= -golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= -golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= -golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8= -golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= +golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +golang.org/x/image v0.16.0 h1:9kloLAKhUufZhA12l5fwnx2NZW39/we1UhBesW433jw= +golang.org/x/image v0.16.0/go.mod h1:ugSZItdV4nOxyqp56HmXwH0Ry0nBCpjnZdpDaIHdoPs= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -224,12 +234,11 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= @@ -239,16 +248,16 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -258,8 +267,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -268,16 +277,16 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= +golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -294,3 +303,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +rogchap.com/v8go v0.8.0 h1:/crDEiga68kOtbIqw3K9Rt9OztYz0LhAPHm2e3wK7Q4= +rogchap.com/v8go v0.8.0/go.mod h1:MxgP3pL2MW4dpme/72QRs8sgNMmM0pRc8DPhcuLWPAs= diff --git a/internal/apps/app_cmd.go b/internal/apps/app_cmd.go index cad4bd1..d9ed85b 100644 --- a/internal/apps/app_cmd.go +++ b/internal/apps/app_cmd.go @@ -3,12 +3,6 @@ package apps import ( "errors" "fmt" - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" - "github.com/iwind/TeaGo/logs" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" - "github.com/iwind/gosock/pkg/gosock" "os" "os/exec" "path/filepath" @@ -17,6 +11,13 @@ import ( "strings" "syscall" "time" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" + "github.com/iwind/gosock/pkg/gosock" ) // AppCmd App命令帮助 diff --git a/internal/apps/log_writer.go b/internal/apps/log_writer.go index 9a78272..1e9b149 100644 --- a/internal/apps/log_writer.go +++ b/internal/apps/log_writer.go @@ -1,16 +1,17 @@ package apps import ( - "github.com/TeaOSLab/EdgeNode/internal/utils" - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" - "github.com/iwind/TeaGo/Tea" - "github.com/iwind/TeaGo/files" - timeutil "github.com/iwind/TeaGo/utils/time" "log" "os" "runtime" "strconv" "strings" + + "github.com/TeaOSLab/EdgeNode/internal/utils" + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" + "github.com/iwind/TeaGo/Tea" + "github.com/iwind/TeaGo/files" + timeutil "github.com/iwind/TeaGo/utils/time" ) type LogWriter struct { diff --git a/internal/apps/main.go b/internal/apps/main.go index bc8454c..511f41c 100644 --- a/internal/apps/main.go +++ b/internal/apps/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package apps diff --git a/internal/caches/errros_test.go b/internal/caches/errros_test.go index 38ebbcd..fed0f5e 100644 --- a/internal/caches/errros_test.go +++ b/internal/caches/errros_test.go @@ -5,9 +5,10 @@ package caches_test import ( "errors" "fmt" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/iwind/TeaGo/assert" - "testing" ) func TestCanIgnoreErr(t *testing.T) { diff --git a/internal/caches/file_dir.go b/internal/caches/file_dir.go index 85292c4..4f3b371 100644 --- a/internal/caches/file_dir.go +++ b/internal/caches/file_dir.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches diff --git a/internal/caches/item.go b/internal/caches/item.go index d5bdb0d..94d3b44 100644 --- a/internal/caches/item.go +++ b/internal/caches/item.go @@ -1,8 +1,9 @@ package caches import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "strings" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" ) type ItemType = int diff --git a/internal/caches/item_test.go b/internal/caches/item_test.go index 886fda2..5be7fbd 100644 --- a/internal/caches/item_test.go +++ b/internal/caches/item_test.go @@ -4,15 +4,16 @@ package caches_test import ( "encoding/json" + "runtime" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "runtime" - "testing" - "time" ) func TestItem_Marshal(t *testing.T) { diff --git a/internal/caches/list_file_db_sqlite.go b/internal/caches/list_file_db_sqlite.go index 73c3d2d..bc60ea7 100644 --- a/internal/caches/list_file_db_sqlite.go +++ b/internal/caches/list_file_db_sqlite.go @@ -5,6 +5,13 @@ package caches import ( "errors" "fmt" + "net" + "net/url" + "os" + "runtime" + "strings" + "time" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" @@ -13,12 +20,6 @@ import ( memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/types" - "net" - "net/url" - "os" - "runtime" - "strings" - "time" ) type SQLiteFileListDB struct { diff --git a/internal/caches/list_file_db_sqlite_test.go b/internal/caches/list_file_db_sqlite_test.go index 27ed750..b268963 100644 --- a/internal/caches/list_file_db_sqlite_test.go +++ b/internal/caches/list_file_db_sqlite_test.go @@ -1,16 +1,17 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches_test import ( - "github.com/TeaOSLab/EdgeNode/internal/caches" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/Tea" - _ "github.com/iwind/TeaGo/bootstrap" "runtime" "runtime/debug" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/caches" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/Tea" + _ "github.com/iwind/TeaGo/bootstrap" ) func TestFileListDB_ListLFUItems(t *testing.T) { @@ -25,7 +26,7 @@ func TestFileListDB_ListLFUItems(t *testing.T) { }() err := db.Open(Tea.Root + "/data/cache-db-large.db") - //err := db.Open(Tea.Root + "/data/cache-index/p1/db-0.db") + // err := db.Open(Tea.Root + "/data/cache-index/p1/db-0.db") if err != nil { t.Fatal(err) } @@ -149,7 +150,7 @@ func TestFileListDB_Memory(t *testing.T) { runtime.GC() debug.FreeOSMemory() - //time.Sleep(600 * time.Second) + // time.Sleep(600 * time.Second) for i := 0; i < 1_000; i++ { _, err = db.ListLFUItems(5000) diff --git a/internal/caches/list_file_hash_map_sqlite.go b/internal/caches/list_file_hash_map_sqlite.go index 563f2ac..d7d3686 100644 --- a/internal/caches/list_file_hash_map_sqlite.go +++ b/internal/caches/list_file_hash_map_sqlite.go @@ -1,12 +1,13 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches import ( - memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "math/big" "sync" + + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) const HashMapSharding = 31 diff --git a/internal/caches/list_file_hash_map_sqlite_test.go b/internal/caches/list_file_hash_map_sqlite_test.go index 7348b37..cda84bf 100644 --- a/internal/caches/list_file_hash_map_sqlite_test.go +++ b/internal/caches/list_file_hash_map_sqlite_test.go @@ -1,8 +1,14 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches_test import ( + "math/big" + "runtime" + "strconv" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/TeaOSLab/EdgeNode/internal/utils/zero" @@ -11,11 +17,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "math/big" - "runtime" - "strconv" - "testing" - "time" ) func TestFileListHashMap_Memory(t *testing.T) { diff --git a/internal/caches/list_file_kv.go b/internal/caches/list_file_kv.go index 8d27403..95daac3 100644 --- a/internal/caches/list_file_kv.go +++ b/internal/caches/list_file_kv.go @@ -1,9 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches import ( "fmt" + "strings" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/fnv" @@ -11,8 +14,6 @@ import ( memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/TeaOSLab/EdgeNode/internal/utils/ttlcache" "github.com/iwind/TeaGo/types" - "strings" - "testing" ) const countKVStores = 10 diff --git a/internal/caches/list_file_kv_objects.go b/internal/caches/list_file_kv_objects.go index 5654f5d..0897ee3 100644 --- a/internal/caches/list_file_kv_objects.go +++ b/internal/caches/list_file_kv_objects.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches diff --git a/internal/caches/list_file_kv_objects_test.go b/internal/caches/list_file_kv_objects_test.go index bc13082..f6636ac 100644 --- a/internal/caches/list_file_kv_objects_test.go +++ b/internal/caches/list_file_kv_objects_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/iwind/TeaGo/assert" - "testing" ) func TestItemKVEncoder_EncodeField(t *testing.T) { diff --git a/internal/caches/list_file_kv_store.go b/internal/caches/list_file_kv_store.go index 41036ef..407d6c0 100644 --- a/internal/caches/list_file_kv_store.go +++ b/internal/caches/list_file_kv_store.go @@ -1,16 +1,17 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches import ( "errors" + "regexp" + "strings" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" "github.com/TeaOSLab/EdgeNode/internal/utils/ttlcache" "github.com/cockroachdb/pebble" - "regexp" - "strings" - "testing" ) type KVListFileStore struct { diff --git a/internal/caches/list_file_kv_test.go b/internal/caches/list_file_kv_test.go index d1bf457..be81a1d 100644 --- a/internal/caches/list_file_kv_test.go +++ b/internal/caches/list_file_kv_test.go @@ -1,19 +1,20 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches_test import ( "fmt" - "github.com/TeaOSLab/EdgeNode/internal/caches" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/Tea" - _ "github.com/iwind/TeaGo/bootstrap" - stringutil "github.com/iwind/TeaGo/utils/string" "math/rand" "strconv" "sync" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/caches" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/Tea" + _ "github.com/iwind/TeaGo/bootstrap" + stringutil "github.com/iwind/TeaGo/utils/string" ) var testingKVList *caches.KVFileList @@ -295,7 +296,7 @@ func TestKVFileList_Purge(t *testing.T) { var before = time.Now() count, err := list.Purge(4_000, func(hash string) error { - //t.Log("hash:", hash) + // t.Log("hash:", hash) return nil }) if err != nil { diff --git a/internal/caches/list_file_sqlite.go b/internal/caches/list_file_sqlite.go index 2609ddd..f940d5b 100644 --- a/internal/caches/list_file_sqlite.go +++ b/internal/caches/list_file_sqlite.go @@ -5,6 +5,11 @@ package caches import ( "database/sql" "errors" + "os" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" @@ -14,10 +19,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/ttlcache" "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "github.com/iwind/TeaGo/types" - "os" - "strings" - "sync" - "time" ) const CountFileDB = 20 diff --git a/internal/caches/list_file_sqlite_test.go b/internal/caches/list_file_sqlite_test.go index a86d824..e0e2947 100644 --- a/internal/caches/list_file_sqlite_test.go +++ b/internal/caches/list_file_sqlite_test.go @@ -3,6 +3,11 @@ package caches_test import ( + "strconv" + "sync" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" @@ -10,10 +15,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "strconv" - "sync" - "testing" - "time" ) func TestFileList_Init(t *testing.T) { diff --git a/internal/caches/list_memory.go b/internal/caches/list_memory.go index 7033837..4142b6b 100644 --- a/internal/caches/list_memory.go +++ b/internal/caches/list_memory.go @@ -1,8 +1,6 @@ package caches import ( - "github.com/TeaOSLab/EdgeCommon/pkg/configutils" - "github.com/iwind/TeaGo/logs" "net" "net/url" "strconv" @@ -10,6 +8,9 @@ import ( "sync" "sync/atomic" "testing" + + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" + "github.com/iwind/TeaGo/logs" ) // MemoryList 内存缓存列表管理 diff --git a/internal/caches/list_memory_test.go b/internal/caches/list_memory_test.go index 4ea1aa9..d8d89a0 100644 --- a/internal/caches/list_memory_test.go +++ b/internal/caches/list_memory_test.go @@ -2,6 +2,12 @@ package caches_test import ( "fmt" + "math/rand" + "sort" + "strconv" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/cespare/xxhash/v2" @@ -9,11 +15,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "math/rand" - "sort" - "strconv" - "testing" - "time" ) func TestMemoryList_Add(t *testing.T) { diff --git a/internal/caches/manager.go b/internal/caches/manager.go index c13457f..133dc36 100644 --- a/internal/caches/manager.go +++ b/internal/caches/manager.go @@ -2,6 +2,9 @@ package caches import ( "fmt" + "strconv" + "sync" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -11,8 +14,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" "golang.org/x/sys/unix" - "strconv" - "sync" ) var SharedManager = NewManager() diff --git a/internal/caches/manager_test.go b/internal/caches/manager_test.go index 07f187c..04d1fe5 100644 --- a/internal/caches/manager_test.go +++ b/internal/caches/manager_test.go @@ -1,11 +1,12 @@ package caches_test import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/iwind/TeaGo/Tea" - "testing" ) func TestManager_UpdatePolicies(t *testing.T) { diff --git a/internal/caches/open_file_cache.go b/internal/caches/open_file_cache.go index 1ff7e01..3dab7fa 100644 --- a/internal/caches/open_file_cache.go +++ b/internal/caches/open_file_cache.go @@ -4,16 +4,17 @@ package caches import ( "fmt" + "path/filepath" + "runtime" + "sync" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/TeaOSLab/EdgeNode/internal/utils/linkedlist" memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/fsnotify/fsnotify" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/types" - "path/filepath" - "runtime" - "sync" - "time" ) const ( diff --git a/internal/caches/open_file_cache_test.go b/internal/caches/open_file_cache_test.go index 2e34c6c..ec77e02 100644 --- a/internal/caches/open_file_cache_test.go +++ b/internal/caches/open_file_cache_test.go @@ -1,13 +1,14 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/types" - "testing" - "time" ) func TestNewOpenFileCache_Close(t *testing.T) { diff --git a/internal/caches/open_file_pool_test.go b/internal/caches/open_file_pool_test.go index ad470c6..ed5ba30 100644 --- a/internal/caches/open_file_pool_test.go +++ b/internal/caches/open_file_pool_test.go @@ -3,10 +3,11 @@ package caches_test import ( - "github.com/TeaOSLab/EdgeNode/internal/caches" - "github.com/iwind/TeaGo/rands" "sync" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/caches" + "github.com/iwind/TeaGo/rands" ) func TestOpenFilePool_Get(t *testing.T) { diff --git a/internal/caches/partial_ranges.go b/internal/caches/partial_ranges.go index b5f2172..2e17625 100644 --- a/internal/caches/partial_ranges.go +++ b/internal/caches/partial_ranges.go @@ -5,9 +5,10 @@ package caches import ( "bytes" "encoding/json" + "strconv" + rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" "github.com/iwind/TeaGo/types" - "strconv" ) // PartialRanges 内容分区范围定义 diff --git a/internal/caches/partial_ranges_queue.go b/internal/caches/partial_ranges_queue.go index a13cfc2..59fe770 100644 --- a/internal/caches/partial_ranges_queue.go +++ b/internal/caches/partial_ranges_queue.go @@ -1,15 +1,16 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches import ( + "sync" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils/fnv" fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" - "sync" ) var SharedPartialRangesQueue = NewPartialRangesQueue() diff --git a/internal/caches/partial_ranges_queue_test.go b/internal/caches/partial_ranges_queue_test.go index 20c6f66..ef720b8 100644 --- a/internal/caches/partial_ranges_queue_test.go +++ b/internal/caches/partial_ranges_queue_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/iwind/TeaGo/assert" - "testing" ) func TestNewPartialRangesQueue(t *testing.T) { diff --git a/internal/caches/partial_ranges_test.go b/internal/caches/partial_ranges_test.go index 28fc484..c64166d 100644 --- a/internal/caches/partial_ranges_test.go +++ b/internal/caches/partial_ranges_test.go @@ -6,11 +6,12 @@ import ( "crypto/md5" "encoding/base64" "encoding/json" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/logs" - "testing" - "time" ) func TestNewPartialRanges(t *testing.T) { diff --git a/internal/caches/reader.go b/internal/caches/reader.go index 2c7b77b..e0be603 100644 --- a/internal/caches/reader.go +++ b/internal/caches/reader.go @@ -1,8 +1,9 @@ package caches import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" "io" + + "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" ) type ReaderFunc func(n int) (goNext bool, err error) diff --git a/internal/caches/reader_base.go b/internal/caches/reader_base.go index 603e5af..63b27be 100644 --- a/internal/caches/reader_base.go +++ b/internal/caches/reader_base.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches diff --git a/internal/caches/reader_file.go b/internal/caches/reader_file.go index c1c9c1a..25b5116 100644 --- a/internal/caches/reader_file.go +++ b/internal/caches/reader_file.go @@ -3,11 +3,12 @@ package caches import ( "encoding/binary" "errors" + "io" + "os" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" "github.com/iwind/TeaGo/types" - "io" - "os" ) type FileReader struct { diff --git a/internal/caches/reader_file_mmap.go b/internal/caches/reader_file_mmap.go index 1c8b93c..7230f82 100644 --- a/internal/caches/reader_file_mmap.go +++ b/internal/caches/reader_file_mmap.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package caches diff --git a/internal/caches/reader_file_test.go b/internal/caches/reader_file_test.go index 1401afd..84853c8 100644 --- a/internal/caches/reader_file_test.go +++ b/internal/caches/reader_file_test.go @@ -1,11 +1,12 @@ package caches import ( + "os" + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" "github.com/iwind/TeaGo/Tea" - "os" - "testing" ) func TestFileReader(t *testing.T) { diff --git a/internal/caches/reader_memory.go b/internal/caches/reader_memory.go index 19e509c..a326d39 100644 --- a/internal/caches/reader_memory.go +++ b/internal/caches/reader_memory.go @@ -2,8 +2,9 @@ package caches import ( "errors" - rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" "io" + + rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" ) type MemoryReader struct { diff --git a/internal/caches/reader_partial_file.go b/internal/caches/reader_partial_file.go index 64d4119..fef1fa1 100644 --- a/internal/caches/reader_partial_file.go +++ b/internal/caches/reader_partial_file.go @@ -4,10 +4,11 @@ import ( "encoding/binary" "errors" "fmt" + "io" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" "github.com/iwind/TeaGo/types" - "io" ) type PartialFileReader struct { diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index 321887b..528a547 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -6,6 +6,17 @@ import ( "encoding/json" "errors" "fmt" + "math" + "os" + "path/filepath" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "syscall" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -27,16 +38,6 @@ import ( timeutil "github.com/iwind/TeaGo/utils/time" "github.com/iwind/gosock/pkg/gosock" "github.com/shirou/gopsutil/v3/load" - "math" - "os" - "path/filepath" - "regexp" - "sort" - "strconv" - "strings" - "sync" - "syscall" - "time" ) const ( diff --git a/internal/caches/storage_file_ext.go b/internal/caches/storage_file_ext.go index 9fc6b29..0912c75 100644 --- a/internal/caches/storage_file_ext.go +++ b/internal/caches/storage_file_ext.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package caches diff --git a/internal/caches/storage_file_test.go b/internal/caches/storage_file_test.go index b74b6a8..2447c02 100644 --- a/internal/caches/storage_file_test.go +++ b/internal/caches/storage_file_test.go @@ -3,12 +3,6 @@ package caches import ( "bytes" "errors" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeNode/internal/utils" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/Tea" - _ "github.com/iwind/TeaGo/bootstrap" - "github.com/iwind/TeaGo/logs" "io" "net/http" "runtime" @@ -16,6 +10,13 @@ import ( "sync" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeNode/internal/utils" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/Tea" + _ "github.com/iwind/TeaGo/bootstrap" + "github.com/iwind/TeaGo/logs" ) func TestFileStorage_Init(t *testing.T) { diff --git a/internal/caches/storage_memory.go b/internal/caches/storage_memory.go index fbc0160..4257ad4 100644 --- a/internal/caches/storage_memory.go +++ b/internal/caches/storage_memory.go @@ -2,6 +2,14 @@ package caches import ( "fmt" + "math" + "runtime" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils" @@ -14,13 +22,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "github.com/cespare/xxhash/v2" "github.com/iwind/TeaGo/types" - "math" - "runtime" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" ) type MemoryItem struct { diff --git a/internal/caches/storage_memory_test.go b/internal/caches/storage_memory_test.go index 89f6495..c4a2d6d 100644 --- a/internal/caches/storage_memory_test.go +++ b/internal/caches/storage_memory_test.go @@ -2,10 +2,6 @@ package caches import ( "bytes" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/logs" - "github.com/iwind/TeaGo/rands" "math/rand" "runtime" "runtime/debug" @@ -13,6 +9,11 @@ import ( "sync" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/rands" ) func TestMemoryStorage_OpenWriter(t *testing.T) { diff --git a/internal/caches/utils.go b/internal/caches/utils.go index d2ac9f3..634fc72 100644 --- a/internal/caches/utils.go +++ b/internal/caches/utils.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches import ( - "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "net" "strings" + + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" ) func ParseHost(key string) string { diff --git a/internal/caches/utils_test.go b/internal/caches/utils_test.go index 4996f79..257ac5b 100644 --- a/internal/caches/utils_test.go +++ b/internal/caches/utils_test.go @@ -1,14 +1,15 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches_test import ( "fmt" + "strconv" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/cespare/xxhash/v2" "github.com/iwind/TeaGo/types" - "strconv" - "testing" ) func TestParseHost(t *testing.T) { diff --git a/internal/caches/writer_file.go b/internal/caches/writer_file.go index 42c0584..95e690e 100644 --- a/internal/caches/writer_file.go +++ b/internal/caches/writer_file.go @@ -3,11 +3,12 @@ package caches import ( "encoding/binary" "errors" - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" - "github.com/iwind/TeaGo/types" "io" "strings" "sync" + + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" + "github.com/iwind/TeaGo/types" ) type FileWriter struct { diff --git a/internal/caches/writer_memory.go b/internal/caches/writer_memory.go index 2829266..28ce549 100644 --- a/internal/caches/writer_memory.go +++ b/internal/caches/writer_memory.go @@ -2,11 +2,12 @@ package caches import ( "errors" + "sync" + "sync/atomic" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/cespare/xxhash/v2" "github.com/iwind/TeaGo/types" - "sync" - "sync/atomic" ) type MemoryWriter struct { diff --git a/internal/caches/writer_memory_test.go b/internal/caches/writer_memory_test.go index ff863d4..79941a4 100644 --- a/internal/caches/writer_memory_test.go +++ b/internal/caches/writer_memory_test.go @@ -1,16 +1,17 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package caches_test import ( "bytes" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" - "github.com/TeaOSLab/EdgeNode/internal/caches" "math/rand" "strconv" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" + "github.com/TeaOSLab/EdgeNode/internal/caches" ) func TestNewMemoryWriter(t *testing.T) { diff --git a/internal/caches/writer_partial_file.go b/internal/caches/writer_partial_file.go index 14d07e1..eab13ab 100644 --- a/internal/caches/writer_partial_file.go +++ b/internal/caches/writer_partial_file.go @@ -4,11 +4,12 @@ package caches import ( "encoding/binary" - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" - "github.com/iwind/TeaGo/types" "io" "strings" "sync" + + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" + "github.com/iwind/TeaGo/types" ) type PartialFileWriter struct { diff --git a/internal/caches/writer_partial_file_test.go b/internal/caches/writer_partial_file_test.go index 468b7cb..213bc6d 100644 --- a/internal/caches/writer_partial_file_test.go +++ b/internal/caches/writer_partial_file_test.go @@ -3,12 +3,13 @@ package caches_test import ( - "github.com/TeaOSLab/EdgeNode/internal/caches" - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" - "github.com/iwind/TeaGo/types" "os" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/caches" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" + "github.com/iwind/TeaGo/types" ) func TestPartialFileWriter_Write(t *testing.T) { diff --git a/internal/compressions/errors.go b/internal/compressions/errors.go index 4e0a328..ad882c5 100644 --- a/internal/compressions/errors.go +++ b/internal/compressions/errors.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package compressions diff --git a/internal/compressions/reader_brotli.go b/internal/compressions/reader_brotli.go index 77d8426..96d2768 100644 --- a/internal/compressions/reader_brotli.go +++ b/internal/compressions/reader_brotli.go @@ -4,9 +4,10 @@ package compressions import ( - "github.com/andybalholm/brotli" "io" "strings" + + "github.com/andybalholm/brotli" ) type BrotliReader struct { diff --git a/internal/compressions/reader_brotli_test.go b/internal/compressions/reader_brotli_test.go index d235145..d4662e1 100644 --- a/internal/compressions/reader_brotli_test.go +++ b/internal/compressions/reader_brotli_test.go @@ -4,10 +4,11 @@ package compressions_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/compressions" "io" "os" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/compressions" ) func TestBrotliReader(t *testing.T) { diff --git a/internal/compressions/reader_deflate_test.go b/internal/compressions/reader_deflate_test.go index c2787e0..76be56e 100644 --- a/internal/compressions/reader_deflate_test.go +++ b/internal/compressions/reader_deflate_test.go @@ -4,9 +4,10 @@ package compressions_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/compressions" "io" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/compressions" ) func TestDeflateReader(t *testing.T) { diff --git a/internal/compressions/reader_gzip.go b/internal/compressions/reader_gzip.go index f5d9c4e..7df80cd 100644 --- a/internal/compressions/reader_gzip.go +++ b/internal/compressions/reader_gzip.go @@ -3,8 +3,9 @@ package compressions import ( - "github.com/klauspost/compress/gzip" "io" + + "github.com/klauspost/compress/gzip" ) type GzipReader struct { diff --git a/internal/compressions/reader_gzip_test.go b/internal/compressions/reader_gzip_test.go index 445c272..83b91c9 100644 --- a/internal/compressions/reader_gzip_test.go +++ b/internal/compressions/reader_gzip_test.go @@ -4,12 +4,13 @@ package compressions_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/compressions" - "github.com/iwind/TeaGo/rands" - "github.com/iwind/TeaGo/types" "io" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/compressions" + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" ) func TestGzipReader(t *testing.T) { diff --git a/internal/compressions/reader_pool_brotli.go b/internal/compressions/reader_pool_brotli.go index b281077..092b8c9 100644 --- a/internal/compressions/reader_pool_brotli.go +++ b/internal/compressions/reader_pool_brotli.go @@ -3,8 +3,9 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "io" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var sharedBrotliReaderPool *ReaderPool diff --git a/internal/compressions/reader_pool_deflate.go b/internal/compressions/reader_pool_deflate.go index 7cb2122..3ad2031 100644 --- a/internal/compressions/reader_pool_deflate.go +++ b/internal/compressions/reader_pool_deflate.go @@ -3,8 +3,9 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "io" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var sharedDeflateReaderPool *ReaderPool diff --git a/internal/compressions/reader_pool_gzip.go b/internal/compressions/reader_pool_gzip.go index 04a78f4..f6252b2 100644 --- a/internal/compressions/reader_pool_gzip.go +++ b/internal/compressions/reader_pool_gzip.go @@ -3,8 +3,9 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "io" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var sharedGzipReaderPool *ReaderPool diff --git a/internal/compressions/reader_pool_zstd.go b/internal/compressions/reader_pool_zstd.go index 3df562b..7536069 100644 --- a/internal/compressions/reader_pool_zstd.go +++ b/internal/compressions/reader_pool_zstd.go @@ -3,8 +3,9 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "io" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var sharedZSTDReaderPool *ReaderPool diff --git a/internal/compressions/reader_zstd.go b/internal/compressions/reader_zstd.go index 85dce22..170a0a7 100644 --- a/internal/compressions/reader_zstd.go +++ b/internal/compressions/reader_zstd.go @@ -3,8 +3,9 @@ package compressions import ( - "github.com/klauspost/compress/zstd" "io" + + "github.com/klauspost/compress/zstd" ) type ZSTDReader struct { diff --git a/internal/compressions/reader_zstd_test.go b/internal/compressions/reader_zstd_test.go index cb6d3b1..7504b84 100644 --- a/internal/compressions/reader_zstd_test.go +++ b/internal/compressions/reader_zstd_test.go @@ -4,12 +4,13 @@ package compressions_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/compressions" - "github.com/iwind/TeaGo/rands" - "github.com/iwind/TeaGo/types" "io" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/compressions" + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" ) func TestZSTDReader(t *testing.T) { diff --git a/internal/compressions/utils.go b/internal/compressions/utils.go index 138d65c..1ea092d 100644 --- a/internal/compressions/utils.go +++ b/internal/compressions/utils.go @@ -4,11 +4,12 @@ package compressions import ( "errors" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "io" "net/http" "runtime" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" ) type ContentEncoding = string diff --git a/internal/compressions/utils_test.go b/internal/compressions/utils_test.go index 7241866..e3dfc8a 100644 --- a/internal/compressions/utils_test.go +++ b/internal/compressions/utils_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package compressions_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/compressions" "github.com/iwind/TeaGo/assert" - "testing" ) func TestGenerateCompressLevel(t *testing.T) { diff --git a/internal/compressions/writer_brotli.go b/internal/compressions/writer_brotli.go index 14d2705..1abbdea 100644 --- a/internal/compressions/writer_brotli.go +++ b/internal/compressions/writer_brotli.go @@ -4,8 +4,9 @@ package compressions import ( - "github.com/andybalholm/brotli" "io" + + "github.com/andybalholm/brotli" ) type BrotliWriter struct { diff --git a/internal/compressions/writer_brotli_test.go b/internal/compressions/writer_brotli_test.go index 70b135e..5b293b6 100644 --- a/internal/compressions/writer_brotli_test.go +++ b/internal/compressions/writer_brotli_test.go @@ -4,11 +4,12 @@ package compressions_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/compressions" - stringutil "github.com/iwind/TeaGo/utils/string" "strings" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/compressions" + stringutil "github.com/iwind/TeaGo/utils/string" ) func TestBrotliWriter_LargeFile(t *testing.T) { diff --git a/internal/compressions/writer_deflate_test.go b/internal/compressions/writer_deflate_test.go index e364da9..ea0c610 100644 --- a/internal/compressions/writer_deflate_test.go +++ b/internal/compressions/writer_deflate_test.go @@ -4,9 +4,10 @@ package compressions_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/compressions" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/compressions" ) func BenchmarkDeflateWriter_Write(b *testing.B) { diff --git a/internal/compressions/writer_gzip.go b/internal/compressions/writer_gzip.go index 384e720..3de3a07 100644 --- a/internal/compressions/writer_gzip.go +++ b/internal/compressions/writer_gzip.go @@ -3,8 +3,9 @@ package compressions import ( - "github.com/klauspost/compress/gzip" "io" + + "github.com/klauspost/compress/gzip" ) type GzipWriter struct { diff --git a/internal/compressions/writer_gzip_test.go b/internal/compressions/writer_gzip_test.go index 3a0f967..624f1b4 100644 --- a/internal/compressions/writer_gzip_test.go +++ b/internal/compressions/writer_gzip_test.go @@ -4,8 +4,9 @@ package compressions_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/compressions" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/compressions" ) func BenchmarkGzipWriter_Write(b *testing.B) { diff --git a/internal/compressions/writer_pool.go b/internal/compressions/writer_pool.go index a62aa34..da33544 100644 --- a/internal/compressions/writer_pool.go +++ b/internal/compressions/writer_pool.go @@ -3,10 +3,11 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "io" "time" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" ) const maxWriterHits = 1 << 20 diff --git a/internal/compressions/writer_pool_brotli.go b/internal/compressions/writer_pool_brotli.go index f721759..d534d2a 100644 --- a/internal/compressions/writer_pool_brotli.go +++ b/internal/compressions/writer_pool_brotli.go @@ -3,8 +3,9 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "io" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var sharedBrotliWriterPool *WriterPool diff --git a/internal/compressions/writer_pool_deflate.go b/internal/compressions/writer_pool_deflate.go index 3a28927..dcc7b5e 100644 --- a/internal/compressions/writer_pool_deflate.go +++ b/internal/compressions/writer_pool_deflate.go @@ -3,8 +3,9 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "io" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var sharedDeflateWriterPool *WriterPool diff --git a/internal/compressions/writer_pool_gzip.go b/internal/compressions/writer_pool_gzip.go index 2350741..a78c376 100644 --- a/internal/compressions/writer_pool_gzip.go +++ b/internal/compressions/writer_pool_gzip.go @@ -3,8 +3,9 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "io" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var sharedGzipWriterPool *WriterPool diff --git a/internal/compressions/writer_pool_zstd.go b/internal/compressions/writer_pool_zstd.go index 416d8ce..38c0be8 100644 --- a/internal/compressions/writer_pool_zstd.go +++ b/internal/compressions/writer_pool_zstd.go @@ -3,8 +3,9 @@ package compressions import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "io" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var sharedZSTDWriterPool *WriterPool diff --git a/internal/compressions/writer_zstd.go b/internal/compressions/writer_zstd.go index 5b2e64d..96213fa 100644 --- a/internal/compressions/writer_zstd.go +++ b/internal/compressions/writer_zstd.go @@ -3,8 +3,9 @@ package compressions import ( - "github.com/klauspost/compress/zstd" "io" + + "github.com/klauspost/compress/zstd" ) type ZSTDWriter struct { diff --git a/internal/compressions/writer_zstd_test.go b/internal/compressions/writer_zstd_test.go index 7a6c202..6935006 100644 --- a/internal/compressions/writer_zstd_test.go +++ b/internal/compressions/writer_zstd_test.go @@ -4,9 +4,10 @@ package compressions_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/compressions" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/compressions" ) func TestNewZSTDWriter_Level0(t *testing.T) { diff --git a/internal/configs/api_config.go b/internal/configs/api_config.go index 4cc9cc5..a3ee249 100644 --- a/internal/configs/api_config.go +++ b/internal/configs/api_config.go @@ -2,9 +2,10 @@ package configs import ( "errors" + "os" + "github.com/iwind/TeaGo/Tea" "gopkg.in/yaml.v3" - "os" ) const ConfigFileName = "api_node.yaml" diff --git a/internal/configs/api_config_test.go b/internal/configs/api_config_test.go index e6efe20..161c66a 100644 --- a/internal/configs/api_config_test.go +++ b/internal/configs/api_config_test.go @@ -1,10 +1,11 @@ package configs_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/configs" _ "github.com/iwind/TeaGo/bootstrap" "gopkg.in/yaml.v3" - "testing" ) func TestLoadAPIConfig(t *testing.T) { diff --git a/internal/configs/cluster_config.go b/internal/configs/cluster_config.go index fcef5ea..19a4030 100644 --- a/internal/configs/cluster_config.go +++ b/internal/configs/cluster_config.go @@ -1,9 +1,10 @@ package configs import ( + "os" + "github.com/iwind/TeaGo/Tea" "gopkg.in/yaml.v3" - "os" ) // ClusterConfig 集群配置 diff --git a/internal/configs/cluster_config_test.go b/internal/configs/cluster_config_test.go index 90e7b20..a8bcb92 100644 --- a/internal/configs/cluster_config_test.go +++ b/internal/configs/cluster_config_test.go @@ -1,12 +1,13 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package configs_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/configs" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "gopkg.in/yaml.v3" - "testing" ) func TestLoadClusterConfig(t *testing.T) { diff --git a/internal/conns/linger.go b/internal/conns/linger.go index 7eddbea..cbf3c43 100644 --- a/internal/conns/linger.go +++ b/internal/conns/linger.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package conns diff --git a/internal/conns/map.go b/internal/conns/map.go index 0a59570..c346693 100644 --- a/internal/conns/map.go +++ b/internal/conns/map.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package conns import ( - "github.com/iwind/TeaGo/types" "net" "sync" + + "github.com/iwind/TeaGo/types" ) var SharedMap = NewMap() diff --git a/internal/conns/map_test_test.go b/internal/conns/map_test_test.go index 03cda22..4c1f6dd 100644 --- a/internal/conns/map_test_test.go +++ b/internal/conns/map_test_test.go @@ -1,14 +1,15 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package conns_test import ( - "github.com/TeaOSLab/EdgeNode/internal/conns" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "net" "runtime" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/conns" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" ) type testConn struct { diff --git a/internal/const/const.go b/internal/const/const.go index 2a64581..b1762d6 100644 --- a/internal/const/const.go +++ b/internal/const/const.go @@ -1,7 +1,7 @@ package teaconst const ( - Version = "1.3.9" + Version = "1.4.1" ProductName = "Edge Node" ProcessName = "edge-node" diff --git a/internal/const/vars.go b/internal/const/vars.go index 3ca722b..236231b 100644 --- a/internal/const/vars.go +++ b/internal/const/vars.go @@ -3,9 +3,10 @@ package teaconst import ( - "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "os" "strings" + + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" ) var ( @@ -18,6 +19,12 @@ var ( NodeIdString = "" IsMain = checkMain() + // Is301 是否 301 节点 + Is301 = false + + // BypassMobile 是否过移动 + BypassMobile int32 = 0 + GlobalProductName = nodeconfigs.DefaultProductName IsQuiting = false // 是否正在退出 diff --git a/internal/errors/error.go b/internal/errors/error.go index dbea041..8f3bce1 100644 --- a/internal/errors/error.go +++ b/internal/errors/error.go @@ -2,10 +2,11 @@ package errors import ( "errors" - "github.com/TeaOSLab/EdgeNode/internal/utils" "path/filepath" "runtime" "strconv" + + "github.com/TeaOSLab/EdgeNode/internal/utils" ) type errorObj struct { diff --git a/internal/events/utils.go b/internal/events/utils.go index bf72436..19252c2 100644 --- a/internal/events/utils.go +++ b/internal/events/utils.go @@ -1,8 +1,9 @@ package events import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "sync" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) type Callbacks = []func() diff --git a/internal/events/utils_test.go b/internal/events/utils_test.go index f1dd9fb..5356808 100644 --- a/internal/events/utils_test.go +++ b/internal/events/utils_test.go @@ -1,8 +1,9 @@ package events_test import ( - "github.com/TeaOSLab/EdgeNode/internal/events" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/events" ) func TestOn(t *testing.T) { diff --git a/internal/firewalls/ddos_protection.go b/internal/firewalls/ddos_protection.go index f6c6966..05f9394 100644 --- a/internal/firewalls/ddos_protection.go +++ b/internal/firewalls/ddos_protection.go @@ -8,6 +8,11 @@ import ( "encoding/json" "errors" "fmt" + "net" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ddosconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -20,10 +25,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "net" - "strings" - "sync" - "time" ) var SharedDDoSProtectionManager = NewDDoSProtectionManager() diff --git a/internal/firewalls/firewall.go b/internal/firewalls/firewall.go index fc6d568..2231b01 100644 --- a/internal/firewalls/firewall.go +++ b/internal/firewalls/firewall.go @@ -3,13 +3,14 @@ package firewalls import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/events" - "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "os" "runtime" "sync" "time" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + "github.com/TeaOSLab/EdgeNode/internal/events" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" ) var currentFirewall FirewallInterface diff --git a/internal/firewalls/firewall_base.go b/internal/firewalls/firewall_base.go index bb57a4d..3ddfdc7 100644 --- a/internal/firewalls/firewall_base.go +++ b/internal/firewalls/firewall_base.go @@ -1,12 +1,13 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package firewalls import ( - "github.com/iwind/TeaGo/types" "strings" "sync" "time" + + "github.com/iwind/TeaGo/types" ) type BaseFirewall struct { diff --git a/internal/firewalls/firewall_firewalld.go b/internal/firewalls/firewall_firewalld.go index 54ace4b..03a709b 100644 --- a/internal/firewalls/firewall_firewalld.go +++ b/internal/firewalls/firewall_firewalld.go @@ -4,13 +4,14 @@ package firewalls import ( "fmt" + "strings" + "time" + "github.com/TeaOSLab/EdgeNode/internal/conns" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/types" - "strings" - "time" ) type firewalldCmd struct { diff --git a/internal/firewalls/firewall_http.go b/internal/firewalls/firewall_http.go index 947caed..a1fcc2d 100644 --- a/internal/firewalls/firewall_http.go +++ b/internal/firewalls/firewall_http.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package firewalls @@ -6,11 +6,12 @@ import ( "encoding/json" "errors" "fmt" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" "io" "net/http" "net/url" + + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" ) type HTTPFirewall struct { diff --git a/internal/firewalls/firewall_nftables.go b/internal/firewalls/firewall_nftables.go index 45fdaa4..156f056 100644 --- a/internal/firewalls/firewall_nftables.go +++ b/internal/firewalls/firewall_nftables.go @@ -6,6 +6,12 @@ package firewalls import ( "errors" "fmt" + "net" + "regexp" + "runtime" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/iputils" "github.com/TeaOSLab/EdgeNode/internal/conns" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -16,11 +22,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/google/nftables/expr" "github.com/iwind/TeaGo/types" - "net" - "regexp" - "runtime" - "strings" - "time" ) // check nft status, if being enabled we load it automatically diff --git a/internal/firewalls/nftables/chain.go b/internal/firewalls/nftables/chain.go index 4ddb66f..1169b12 100644 --- a/internal/firewalls/nftables/chain.go +++ b/internal/firewalls/nftables/chain.go @@ -6,6 +6,7 @@ package nftables import ( "bytes" "errors" + nft "github.com/google/nftables" "github.com/google/nftables/expr" ) diff --git a/internal/firewalls/nftables/chain_test.go b/internal/firewalls/nftables/chain_test.go index e68cb48..ebd038a 100644 --- a/internal/firewalls/nftables/chain_test.go +++ b/internal/firewalls/nftables/chain_test.go @@ -4,9 +4,10 @@ package nftables_test import ( - "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" "net" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" ) func getIPv4Chain(t *testing.T) *nftables.Chain { diff --git a/internal/firewalls/nftables/conn.go b/internal/firewalls/nftables/conn.go index df203a2..ee3c8e5 100644 --- a/internal/firewalls/nftables/conn.go +++ b/internal/firewalls/nftables/conn.go @@ -5,6 +5,7 @@ package nftables import ( "errors" + nft "github.com/google/nftables" "github.com/iwind/TeaGo/types" ) diff --git a/internal/firewalls/nftables/conn_test.go b/internal/firewalls/nftables/conn_test.go index e249bdb..210d04f 100644 --- a/internal/firewalls/nftables/conn_test.go +++ b/internal/firewalls/nftables/conn_test.go @@ -5,9 +5,10 @@ package nftables_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" - "testing" ) func TestConn_Test(t *testing.T) { diff --git a/internal/firewalls/nftables/expration.go b/internal/firewalls/nftables/expration.go index 62ac16c..f9698ca 100644 --- a/internal/firewalls/nftables/expration.go +++ b/internal/firewalls/nftables/expration.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nftables diff --git a/internal/firewalls/nftables/expration_test.go b/internal/firewalls/nftables/expration_test.go index c6aebfe..5e9a751 100644 --- a/internal/firewalls/nftables/expration_test.go +++ b/internal/firewalls/nftables/expration_test.go @@ -1,14 +1,15 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nftables_test import ( - "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" - "github.com/iwind/TeaGo/rands" - "github.com/iwind/TeaGo/types" "net" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" ) func TestExpiration_Add(t *testing.T) { diff --git a/internal/firewalls/nftables/installer.go b/internal/firewalls/nftables/installer.go index 934f35f..7be5b8c 100644 --- a/internal/firewalls/nftables/installer.go +++ b/internal/firewalls/nftables/installer.go @@ -1,10 +1,14 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build linux package nftables import ( "fmt" + "os" + "runtime" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -12,9 +16,6 @@ import ( executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/logs" - "os" - "runtime" - "time" ) func init() { diff --git a/internal/firewalls/nftables/set.go b/internal/firewalls/nftables/set.go index c345bef..2a621f5 100644 --- a/internal/firewalls/nftables/set.go +++ b/internal/firewalls/nftables/set.go @@ -5,11 +5,12 @@ package nftables import ( "errors" - "github.com/TeaOSLab/EdgeNode/internal/utils" - nft "github.com/google/nftables" "net" "strings" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils" + nft "github.com/google/nftables" ) const MaxSetNameLength = 15 diff --git a/internal/firewalls/nftables/set_ext.go b/internal/firewalls/nftables/set_ext.go index deabc58..c6c8a65 100644 --- a/internal/firewalls/nftables/set_ext.go +++ b/internal/firewalls/nftables/set_ext.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build linux && !plus package nftables diff --git a/internal/firewalls/nftables/set_test.go b/internal/firewalls/nftables/set_test.go index 9a2f518..c65a301 100644 --- a/internal/firewalls/nftables/set_test.go +++ b/internal/firewalls/nftables/set_test.go @@ -5,12 +5,13 @@ package nftables_test import ( "errors" - "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" - "github.com/iwind/TeaGo/types" - "github.com/mdlayher/netlink" "net" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" + "github.com/iwind/TeaGo/types" + "github.com/mdlayher/netlink" ) func getIPv4Set(t *testing.T) *nftables.Set { diff --git a/internal/firewalls/nftables/table.go b/internal/firewalls/nftables/table.go index 8a85c08..2737de2 100644 --- a/internal/firewalls/nftables/table.go +++ b/internal/firewalls/nftables/table.go @@ -5,9 +5,10 @@ package nftables import ( "errors" + "strings" + nft "github.com/google/nftables" "github.com/iwind/TeaGo/types" - "strings" ) type Table struct { diff --git a/internal/firewalls/nftables/table_test.go b/internal/firewalls/nftables/table_test.go index 3632e08..30a365e 100644 --- a/internal/firewalls/nftables/table_test.go +++ b/internal/firewalls/nftables/table_test.go @@ -4,8 +4,9 @@ package nftables_test import ( - "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/firewalls/nftables" ) func getIPv4Table(t *testing.T) *nftables.Table { diff --git a/internal/firewalls/utils.go b/internal/firewalls/utils.go index f860830..ed2ebeb 100644 --- a/internal/firewalls/utils.go +++ b/internal/firewalls/utils.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package firewalls diff --git a/internal/iplibrary/action_base.go b/internal/iplibrary/action_base.go index 73cdd3e..bc05cc7 100644 --- a/internal/iplibrary/action_base.go +++ b/internal/iplibrary/action_base.go @@ -2,8 +2,9 @@ package iplibrary import ( "encoding/json" - "github.com/iwind/TeaGo/maps" "net/http" + + "github.com/iwind/TeaGo/maps" ) type BaseAction struct { diff --git a/internal/iplibrary/action_firewalld.go b/internal/iplibrary/action_firewalld.go index 192bb28..ec15745 100644 --- a/internal/iplibrary/action_firewalld.go +++ b/internal/iplibrary/action_firewalld.go @@ -3,11 +3,12 @@ package iplibrary import ( "errors" "fmt" + "runtime" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" - "runtime" - "time" ) // FirewalldAction Firewalld动作管理 diff --git a/internal/iplibrary/action_firewalld_test.go b/internal/iplibrary/action_firewalld_test.go index 7920f98..cd26b24 100644 --- a/internal/iplibrary/action_firewalld_test.go +++ b/internal/iplibrary/action_firewalld_test.go @@ -1,10 +1,11 @@ package iplibrary import ( - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" ) func TestFirewalldAction_AddItem(t *testing.T) { diff --git a/internal/iplibrary/action_html.go b/internal/iplibrary/action_html.go index 3f7c643..801dd30 100644 --- a/internal/iplibrary/action_html.go +++ b/internal/iplibrary/action_html.go @@ -1,9 +1,10 @@ package iplibrary import ( + "net/http" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" - "net/http" ) // HTMLAction HTML动作 diff --git a/internal/iplibrary/action_http_api.go b/internal/iplibrary/action_http_api.go index ef3f3ec..8d06eda 100644 --- a/internal/iplibrary/action_http_api.go +++ b/internal/iplibrary/action_http_api.go @@ -3,12 +3,13 @@ package iplibrary import ( "bytes" "encoding/json" + "net/http" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/iwind/TeaGo/maps" - "net/http" - "time" ) var httpAPIClient = &http.Client{ diff --git a/internal/iplibrary/action_http_api_test.go b/internal/iplibrary/action_http_api_test.go index d091155..c592315 100644 --- a/internal/iplibrary/action_http_api_test.go +++ b/internal/iplibrary/action_http_api_test.go @@ -1,10 +1,11 @@ package iplibrary import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "testing" ) func TestHTTPAPIAction_AddItem(t *testing.T) { diff --git a/internal/iplibrary/action_interface.go b/internal/iplibrary/action_interface.go index 15644aa..d2eee78 100644 --- a/internal/iplibrary/action_interface.go +++ b/internal/iplibrary/action_interface.go @@ -1,9 +1,10 @@ package iplibrary import ( + "net/http" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" - "net/http" ) type ActionInterface interface { diff --git a/internal/iplibrary/action_ipset.go b/internal/iplibrary/action_ipset.go index fd52915..b618102 100644 --- a/internal/iplibrary/action_ipset.go +++ b/internal/iplibrary/action_ipset.go @@ -3,14 +3,15 @@ package iplibrary import ( "errors" "fmt" - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" - executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" - "github.com/iwind/TeaGo/types" "runtime" "strconv" "strings" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" + executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" + "github.com/iwind/TeaGo/types" ) // IPSetAction IPSet动作 diff --git a/internal/iplibrary/action_ipset_test.go b/internal/iplibrary/action_ipset_test.go index 39c037a..9313580 100644 --- a/internal/iplibrary/action_ipset_test.go +++ b/internal/iplibrary/action_ipset_test.go @@ -1,13 +1,14 @@ package iplibrary_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/iplibrary" executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" "github.com/iwind/TeaGo/maps" - "testing" - "time" ) func TestIPSetAction_Init(t *testing.T) { diff --git a/internal/iplibrary/action_iptables.go b/internal/iplibrary/action_iptables.go index a77954d..b888692 100644 --- a/internal/iplibrary/action_iptables.go +++ b/internal/iplibrary/action_iptables.go @@ -2,13 +2,14 @@ package iplibrary import ( "fmt" + "runtime" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/utils" executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" - "runtime" - "strings" - "time" ) // IPTablesAction IPTables动作 diff --git a/internal/iplibrary/action_iptables_test.go b/internal/iplibrary/action_iptables_test.go index ae32182..bf1c848 100644 --- a/internal/iplibrary/action_iptables_test.go +++ b/internal/iplibrary/action_iptables_test.go @@ -1,11 +1,12 @@ package iplibrary import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" - "testing" - "time" ) func TestIPTablesAction_AddItem(t *testing.T) { diff --git a/internal/iplibrary/action_manager.go b/internal/iplibrary/action_manager.go index 879dfe1..16bcdb0 100644 --- a/internal/iplibrary/action_manager.go +++ b/internal/iplibrary/action_manager.go @@ -5,11 +5,12 @@ import ( "encoding/json" "errors" "fmt" + "strconv" + "sync" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" - "strconv" - "sync" ) var SharedActionManager = NewActionManager() diff --git a/internal/iplibrary/action_manager_test.go b/internal/iplibrary/action_manager_test.go index 219ed46..d781579 100644 --- a/internal/iplibrary/action_manager_test.go +++ b/internal/iplibrary/action_manager_test.go @@ -1,9 +1,10 @@ package iplibrary import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/iwind/TeaGo/maps" - "testing" ) func TestActionManager_UpdateActions(t *testing.T) { diff --git a/internal/iplibrary/action_script.go b/internal/iplibrary/action_script.go index fce6513..40ecd2b 100644 --- a/internal/iplibrary/action_script.go +++ b/internal/iplibrary/action_script.go @@ -2,11 +2,12 @@ package iplibrary import ( "fmt" + "path/filepath" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" - "path/filepath" - "time" ) // ScriptAction 脚本命令动作 diff --git a/internal/iplibrary/action_script_test.go b/internal/iplibrary/action_script_test.go index 1192d3c..fdf40f8 100644 --- a/internal/iplibrary/action_script_test.go +++ b/internal/iplibrary/action_script_test.go @@ -1,11 +1,12 @@ package iplibrary import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "testing" - "time" ) func TestScriptAction_AddItem(t *testing.T) { diff --git a/internal/iplibrary/ip_item_test.go b/internal/iplibrary/ip_item_test.go index c40aafb..251fe05 100644 --- a/internal/iplibrary/ip_item_test.go +++ b/internal/iplibrary/ip_item_test.go @@ -1,15 +1,16 @@ package iplibrary_test import ( - "github.com/TeaOSLab/EdgeCommon/pkg/iputils" - "github.com/TeaOSLab/EdgeNode/internal/iplibrary" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/assert" "math/rand" "runtime" "strconv" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/iputils" + "github.com/TeaOSLab/EdgeNode/internal/iplibrary" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/assert" ) func TestIPItem_Contains(t *testing.T) { diff --git a/internal/iplibrary/ip_list.go b/internal/iplibrary/ip_list.go index 6ecd99a..0a7c3ad 100644 --- a/internal/iplibrary/ip_list.go +++ b/internal/iplibrary/ip_list.go @@ -1,11 +1,12 @@ package iplibrary import ( + "sort" + "sync" + "github.com/TeaOSLab/EdgeCommon/pkg/iputils" "github.com/TeaOSLab/EdgeNode/internal/utils/expires" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "sort" - "sync" ) var GlobalBlackIPList = NewIPList() diff --git a/internal/iplibrary/ip_list_db.go b/internal/iplibrary/ip_list_db.go index 026ebf5..9753805 100644 --- a/internal/iplibrary/ip_list_db.go +++ b/internal/iplibrary/ip_list_db.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package iplibrary diff --git a/internal/iplibrary/ip_list_kv.go b/internal/iplibrary/ip_list_kv.go index d8fa891..8b710bd 100644 --- a/internal/iplibrary/ip_list_kv.go +++ b/internal/iplibrary/ip_list_kv.go @@ -1,10 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package iplibrary import ( "encoding/binary" "errors" + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" @@ -12,8 +15,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/TeaOSLab/EdgeNode/internal/utils/idles" "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" - "testing" - "time" ) type KVIPList struct { diff --git a/internal/iplibrary/ip_list_kv_objects.go b/internal/iplibrary/ip_list_kv_objects.go index b01a383..2e2e974 100644 --- a/internal/iplibrary/ip_list_kv_objects.go +++ b/internal/iplibrary/ip_list_kv_objects.go @@ -1,13 +1,14 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package iplibrary import ( "encoding/binary" "errors" + "math" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "google.golang.org/protobuf/proto" - "math" ) type IPItemEncoder[T interface{ *pb.IPItem }] struct { diff --git a/internal/iplibrary/ip_list_kv_test.go b/internal/iplibrary/ip_list_kv_test.go index 97ac803..548f967 100644 --- a/internal/iplibrary/ip_list_kv_test.go +++ b/internal/iplibrary/ip_list_kv_test.go @@ -1,15 +1,16 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package iplibrary_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/iplibrary" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/TeaOSLab/EdgeNode/internal/utils/zero" - "testing" - "time" ) func TestKVIPList_AddItem(t *testing.T) { diff --git a/internal/iplibrary/ip_list_sqlite.go b/internal/iplibrary/ip_list_sqlite.go index 6263c60..bb6c0da 100644 --- a/internal/iplibrary/ip_list_sqlite.go +++ b/internal/iplibrary/ip_list_sqlite.go @@ -3,6 +3,10 @@ package iplibrary import ( + "os" + "path/filepath" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" @@ -10,9 +14,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/TeaOSLab/EdgeNode/internal/utils/idles" "github.com/iwind/TeaGo/Tea" - "os" - "path/filepath" - "time" ) type SQLiteIPList struct { diff --git a/internal/iplibrary/ip_list_sqlite_test.go b/internal/iplibrary/ip_list_sqlite_test.go index 2279bde..41eb7c8 100644 --- a/internal/iplibrary/ip_list_sqlite_test.go +++ b/internal/iplibrary/ip_list_sqlite_test.go @@ -3,12 +3,13 @@ package iplibrary_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/iplibrary" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/logs" - "testing" - "time" ) func TestSQLiteIPList_AddItem(t *testing.T) { diff --git a/internal/iplibrary/ip_list_test.go b/internal/iplibrary/ip_list_test.go index af39d58..98cad4d 100644 --- a/internal/iplibrary/ip_list_test.go +++ b/internal/iplibrary/ip_list_test.go @@ -2,13 +2,6 @@ package iplibrary_test import ( "fmt" - "github.com/TeaOSLab/EdgeCommon/pkg/iputils" - "github.com/TeaOSLab/EdgeNode/internal/iplibrary" - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/assert" - "github.com/iwind/TeaGo/logs" - "github.com/iwind/TeaGo/rands" "math/rand" "runtime" "runtime/debug" @@ -16,6 +9,14 @@ import ( "sync" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/iputils" + "github.com/TeaOSLab/EdgeNode/internal/iplibrary" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/assert" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/rands" ) func TestIPList_Add_Empty(t *testing.T) { diff --git a/internal/iplibrary/list_utils.go b/internal/iplibrary/list_utils.go index e02b73b..fedf119 100644 --- a/internal/iplibrary/list_utils.go +++ b/internal/iplibrary/list_utils.go @@ -4,6 +4,7 @@ package iplibrary import ( "encoding/hex" + "github.com/TeaOSLab/EdgeCommon/pkg/iputils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/iwind/TeaGo/Tea" diff --git a/internal/iplibrary/list_utils_test.go b/internal/iplibrary/list_utils_test.go index 7eec577..e8b256c 100644 --- a/internal/iplibrary/list_utils_test.go +++ b/internal/iplibrary/list_utils_test.go @@ -3,9 +3,10 @@ package iplibrary import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" ) func TestIPIsAllowed(t *testing.T) { diff --git a/internal/iplibrary/manager_ip_list.go b/internal/iplibrary/manager_ip_list.go index 9008bb9..3cb4186 100644 --- a/internal/iplibrary/manager_ip_list.go +++ b/internal/iplibrary/manager_ip_list.go @@ -1,6 +1,10 @@ package iplibrary import ( + "os" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/iputils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" @@ -15,9 +19,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/types" - "os" - "sync" - "time" ) var SharedIPListManager = NewIPListManager() diff --git a/internal/iplibrary/manager_ip_list_test.go b/internal/iplibrary/manager_ip_list_test.go index 72b7e22..c9bb219 100644 --- a/internal/iplibrary/manager_ip_list_test.go +++ b/internal/iplibrary/manager_ip_list_test.go @@ -1,12 +1,13 @@ package iplibrary_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/iputils" "github.com/TeaOSLab/EdgeNode/internal/iplibrary" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/logs" - "testing" - "time" ) func TestIPListManager_init(t *testing.T) { diff --git a/internal/metrics/manager.go b/internal/metrics/manager.go index 059809a..c36e7f6 100644 --- a/internal/metrics/manager.go +++ b/internal/metrics/manager.go @@ -3,12 +3,13 @@ package metrics import ( + "strconv" + "sync" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" - "strconv" - "sync" ) var SharedManager = NewManager() diff --git a/internal/metrics/manager_test.go b/internal/metrics/manager_test.go index d19297e..ad01c05 100644 --- a/internal/metrics/manager_test.go +++ b/internal/metrics/manager_test.go @@ -3,9 +3,10 @@ package metrics_test import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/metrics" - "testing" ) func TestNewManager(t *testing.T) { diff --git a/internal/metrics/stat.go b/internal/metrics/stat.go index 7b598e0..96e07dd 100644 --- a/internal/metrics/stat.go +++ b/internal/metrics/stat.go @@ -6,10 +6,11 @@ import ( "bytes" "encoding/binary" "errors" - byteutils "github.com/TeaOSLab/EdgeNode/internal/utils/byte" - "github.com/TeaOSLab/EdgeNode/internal/utils/fnv" "strconv" "strings" + + byteutils "github.com/TeaOSLab/EdgeNode/internal/utils/byte" + "github.com/TeaOSLab/EdgeNode/internal/utils/fnv" ) type Stat struct { diff --git a/internal/metrics/stat_test.go b/internal/metrics/stat_test.go index 3e02026..aaa067c 100644 --- a/internal/metrics/stat_test.go +++ b/internal/metrics/stat_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package metrics_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/metrics" "github.com/iwind/TeaGo/assert" - "testing" ) func TestStat_EncodeValueKey(t *testing.T) { diff --git a/internal/metrics/sum_test.go b/internal/metrics/sum_test.go index e9f2a89..8275cf1 100644 --- a/internal/metrics/sum_test.go +++ b/internal/metrics/sum_test.go @@ -1,12 +1,13 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package metrics_test import ( - "github.com/TeaOSLab/EdgeNode/internal/metrics" - timeutil "github.com/iwind/TeaGo/utils/time" "runtime" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/metrics" + timeutil "github.com/iwind/TeaGo/utils/time" ) func BenchmarkSumStat(b *testing.B) { diff --git a/internal/metrics/task.go b/internal/metrics/task.go index c6207de..f9cea12 100644 --- a/internal/metrics/task.go +++ b/internal/metrics/task.go @@ -1,10 +1,11 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package metrics import ( - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) type Task interface { diff --git a/internal/metrics/task_base.go b/internal/metrics/task_base.go index 766675e..20debc7 100644 --- a/internal/metrics/task_base.go +++ b/internal/metrics/task_base.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package metrics import ( - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "sync" "sync/atomic" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) type BaseTask struct { diff --git a/internal/metrics/task_kv.go b/internal/metrics/task_kv.go index 493c71e..af3a452 100644 --- a/internal/metrics/task_kv.go +++ b/internal/metrics/task_kv.go @@ -1,8 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package metrics import ( + "strings" + "sync" + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" @@ -17,10 +22,6 @@ import ( "github.com/cockroachdb/pebble" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/types" - "strings" - "sync" - "testing" - "time" ) // TODO sumValues不用每次insertStat的时候都保存 diff --git a/internal/metrics/task_kv_objects.go b/internal/metrics/task_kv_objects.go index 208a399..998f874 100644 --- a/internal/metrics/task_kv_objects.go +++ b/internal/metrics/task_kv_objects.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package metrics diff --git a/internal/metrics/task_kv_test.go b/internal/metrics/task_kv_test.go index 1c0ae2e..be88a23 100644 --- a/internal/metrics/task_kv_test.go +++ b/internal/metrics/task_kv_test.go @@ -4,17 +4,18 @@ package metrics_test import ( "fmt" + "log" + "runtime" + "sync" + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/metrics" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/rands" - "log" - "runtime" - "sync" - "testing" - "time" ) type testObj struct { diff --git a/internal/metrics/task_sqlite.go b/internal/metrics/task_sqlite.go index 0bacf2f..85cce88 100644 --- a/internal/metrics/task_sqlite.go +++ b/internal/metrics/task_sqlite.go @@ -4,6 +4,11 @@ package metrics import ( "encoding/json" + "os" + "strconv" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -17,10 +22,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/types" - "os" - "strconv" - "sync" - "time" ) const MaxQueueSize = 256 // TODO 可以配置,可以在单个任务里配置 diff --git a/internal/monitor/value_queue.go b/internal/monitor/value_queue.go index 4f74ddb..3b4f2c7 100644 --- a/internal/monitor/value_queue.go +++ b/internal/monitor/value_queue.go @@ -4,6 +4,8 @@ package monitor import ( "encoding/json" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -11,7 +13,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/maps" - "time" ) var SharedValueQueue = NewValueQueue() diff --git a/internal/monitor/value_queue_test.go b/internal/monitor/value_queue_test.go index 85b8713..9cbf38e 100644 --- a/internal/monitor/value_queue_test.go +++ b/internal/monitor/value_queue_test.go @@ -3,13 +3,14 @@ package monitor import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/logs" "google.golang.org/grpc/status" - "testing" ) func TestValueQueue_RPC(t *testing.T) { diff --git a/internal/nodes/api_stream.go b/internal/nodes/api_stream.go index 4290ded..dda62f8 100644 --- a/internal/nodes/api_stream.go +++ b/internal/nodes/api_stream.go @@ -4,6 +4,12 @@ import ( "context" "encoding/json" "fmt" + "net/url" + "regexp" + "runtime" + "strconv" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" @@ -19,11 +25,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/maps" - "net/url" - "regexp" - "runtime" - "strconv" - "time" ) type APIStream struct { diff --git a/internal/nodes/api_stream_test.go b/internal/nodes/api_stream_test.go index ee44bd5..5686d9a 100644 --- a/internal/nodes/api_stream_test.go +++ b/internal/nodes/api_stream_test.go @@ -1,8 +1,9 @@ package nodes import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" ) func TestAPIStream_Start(t *testing.T) { diff --git a/internal/nodes/client_conn.go b/internal/nodes/client_conn.go index 7e61ae9..4ea3d90 100644 --- a/internal/nodes/client_conn.go +++ b/internal/nodes/client_conn.go @@ -4,6 +4,12 @@ package nodes import ( "fmt" + "net" + "os" + "strings" + "sync/atomic" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/conns" @@ -17,11 +23,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/types" - "net" - "os" - "strings" - "sync/atomic" - "time" ) // ClientConn 客户端连接 diff --git a/internal/nodes/client_conn_base.go b/internal/nodes/client_conn_base.go index 5787090..88f679e 100644 --- a/internal/nodes/client_conn_base.go +++ b/internal/nodes/client_conn_base.go @@ -4,11 +4,12 @@ package nodes import ( "crypto/tls" - "github.com/TeaOSLab/EdgeNode/internal/firewalls" - "github.com/TeaOSLab/EdgeNode/internal/iplibrary" "net" "sync/atomic" "time" + + "github.com/TeaOSLab/EdgeNode/internal/firewalls" + "github.com/TeaOSLab/EdgeNode/internal/iplibrary" ) type BaseClientConn struct { diff --git a/internal/nodes/client_conn_limiter.go b/internal/nodes/client_conn_limiter.go index 7b515d7..190106e 100644 --- a/internal/nodes/client_conn_limiter.go +++ b/internal/nodes/client_conn_limiter.go @@ -3,8 +3,9 @@ package nodes import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) var sharedClientConnLimiter = NewClientConnLimiter() diff --git a/internal/nodes/client_conn_limiter_test.go b/internal/nodes/client_conn_limiter_test.go index e559c87..48e0364 100644 --- a/internal/nodes/client_conn_limiter_test.go +++ b/internal/nodes/client_conn_limiter_test.go @@ -3,8 +3,9 @@ package nodes import ( - "github.com/iwind/TeaGo/logs" "testing" + + "github.com/iwind/TeaGo/logs" ) func TestClientConnLimiter_Add(t *testing.T) { diff --git a/internal/nodes/client_conn_traffic.go b/internal/nodes/client_conn_traffic.go index 823c050..f336df2 100644 --- a/internal/nodes/client_conn_traffic.go +++ b/internal/nodes/client_conn_traffic.go @@ -3,14 +3,15 @@ package nodes import ( + "sync/atomic" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/monitor" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/maps" - "sync/atomic" - "time" ) // 发送监控流量 diff --git a/internal/nodes/client_listener.go b/internal/nodes/client_listener.go index a8b6c04..315c833 100644 --- a/internal/nodes/client_listener.go +++ b/internal/nodes/client_listener.go @@ -3,11 +3,12 @@ package nodes import ( + "net" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/firewalls" "github.com/TeaOSLab/EdgeNode/internal/iplibrary" "github.com/TeaOSLab/EdgeNode/internal/waf" - "net" ) // ClientListener 客户端网络监听 diff --git a/internal/nodes/conn_linger.go b/internal/nodes/conn_linger.go index 04e1589..15f07bf 100644 --- a/internal/nodes/conn_linger.go +++ b/internal/nodes/conn_linger.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes diff --git a/internal/nodes/http_access_log_queue.go b/internal/nodes/http_access_log_queue.go index 8ebc3be..9c91a95 100644 --- a/internal/nodes/http_access_log_queue.go +++ b/internal/nodes/http_access_log_queue.go @@ -2,6 +2,10 @@ package nodes import ( "bytes" + "strings" + "time" + "unicode/utf8" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/rpc" @@ -10,9 +14,6 @@ import ( memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "strings" - "time" - "unicode/utf8" ) var sharedHTTPAccessLogQueue = NewHTTPAccessLogQueue() diff --git a/internal/nodes/http_access_log_queue_test.go b/internal/nodes/http_access_log_queue_test.go index 01422b6..6ec1630 100644 --- a/internal/nodes/http_access_log_queue_test.go +++ b/internal/nodes/http_access_log_queue_test.go @@ -4,12 +4,6 @@ package nodes_test import ( "bytes" - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - "github.com/TeaOSLab/EdgeNode/internal/nodes" - "github.com/TeaOSLab/EdgeNode/internal/rpc" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - _ "github.com/iwind/TeaGo/bootstrap" - "google.golang.org/grpc/status" "reflect" "runtime" "runtime/debug" @@ -18,6 +12,13 @@ import ( "testing" "time" "unicode/utf8" + + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeNode/internal/nodes" + "github.com/TeaOSLab/EdgeNode/internal/rpc" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + _ "github.com/iwind/TeaGo/bootstrap" + "google.golang.org/grpc/status" ) func TestHTTPAccessLogQueue_Push(t *testing.T) { diff --git a/internal/nodes/http_access_log_viewer.go b/internal/nodes/http_access_log_viewer.go index 61718f4..4557712 100644 --- a/internal/nodes/http_access_log_viewer.go +++ b/internal/nodes/http_access_log_viewer.go @@ -1,18 +1,19 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes import ( "fmt" - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/remotelogs" - "github.com/iwind/TeaGo/types" "net" "os" "strconv" "sync" "sync/atomic" + + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" + "github.com/iwind/TeaGo/types" ) var sharedHTTPAccessLogViewer = NewHTTPAccessLogViewer() diff --git a/internal/nodes/http_cache_task_manager.go b/internal/nodes/http_cache_task_manager.go index a0a0630..5cdc4e9 100644 --- a/internal/nodes/http_cache_task_manager.go +++ b/internal/nodes/http_cache_task_manager.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes @@ -7,6 +7,15 @@ import ( "crypto/tls" "errors" "fmt" + "io" + "net" + "net/http" + "os" + "regexp" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/caches" @@ -19,14 +28,6 @@ import ( connutils "github.com/TeaOSLab/EdgeNode/internal/utils/conns" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/Tea" - "io" - "net" - "net/http" - "os" - "regexp" - "strings" - "sync" - "time" ) func init() { diff --git a/internal/nodes/http_cache_task_manager_test.go b/internal/nodes/http_cache_task_manager_test.go index 3152683..6272f16 100644 --- a/internal/nodes/http_cache_task_manager_test.go +++ b/internal/nodes/http_cache_task_manager_test.go @@ -1,12 +1,13 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes_test import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/nodes" - "testing" ) func TestHTTPCacheTaskManager_Loop(t *testing.T) { diff --git a/internal/nodes/http_client.go b/internal/nodes/http_client.go index 771bdfe..eb4ba45 100644 --- a/internal/nodes/http_client.go +++ b/internal/nodes/http_client.go @@ -1,8 +1,9 @@ package nodes import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" ) // HTTPClient HTTP客户端 diff --git a/internal/nodes/http_client_pool.go b/internal/nodes/http_client_pool.go index 54826ba..39cfeff 100644 --- a/internal/nodes/http_client_pool.go +++ b/internal/nodes/http_client_pool.go @@ -4,12 +4,6 @@ import ( "context" "crypto/tls" "errors" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" - "github.com/cespare/xxhash/v2" - "github.com/pires/go-proxyproto" - "golang.org/x/net/http2" "net" "net/http" "runtime" @@ -17,6 +11,13 @@ import ( "strings" "sync" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" + "github.com/cespare/xxhash/v2" + "github.com/pires/go-proxyproto" + "golang.org/x/net/http2" ) // SharedHTTPClientPool HTTP客户端池单例 diff --git a/internal/nodes/http_client_pool_test.go b/internal/nodes/http_client_pool_test.go index 919dca5..d75c583 100644 --- a/internal/nodes/http_client_pool_test.go +++ b/internal/nodes/http_client_pool_test.go @@ -2,12 +2,13 @@ package nodes import ( "context" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "net/http" "runtime" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" ) func TestHTTPClientPool_Client(t *testing.T) { diff --git a/internal/nodes/http_client_transport.go b/internal/nodes/http_client_transport.go index 171be89..18a751a 100644 --- a/internal/nodes/http_client_transport.go +++ b/internal/nodes/http_client_transport.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes diff --git a/internal/nodes/http_request.go b/internal/nodes/http_request.go index f8ad15d..e49c65d 100644 --- a/internal/nodes/http_request.go +++ b/internal/nodes/http_request.go @@ -5,6 +5,16 @@ import ( "context" "errors" "fmt" + "io" + "net" + "net/http" + "net/url" + "os" + "path/filepath" + "strconv" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" iplib "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" @@ -17,15 +27,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "io" - "net" - "net/http" - "net/url" - "os" - "path/filepath" - "strconv" - "strings" - "time" ) // 环境变量 diff --git a/internal/nodes/http_request_acme.go b/internal/nodes/http_request_acme.go index 2b831ed..ce58fb3 100644 --- a/internal/nodes/http_request_acme.go +++ b/internal/nodes/http_request_acme.go @@ -1,10 +1,11 @@ package nodes import ( + "path/filepath" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/rpc" - "path/filepath" ) func (this *HTTPRequest) doACME() (shouldStop bool) { diff --git a/internal/nodes/http_request_auth.go b/internal/nodes/http_request_auth.go index 86b36f9..4bb519a 100644 --- a/internal/nodes/http_request_auth.go +++ b/internal/nodes/http_request_auth.go @@ -4,9 +4,10 @@ package nodes import ( "bytes" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "io" "net/http" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) // 执行认证 diff --git a/internal/nodes/http_request_cache.go b/internal/nodes/http_request_cache.go index 6a16dd3..7a88a81 100644 --- a/internal/nodes/http_request_cache.go +++ b/internal/nodes/http_request_cache.go @@ -3,6 +3,13 @@ package nodes import ( "bytes" "errors" + "io" + "net/http" + "path/filepath" + "strconv" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/compressions" @@ -11,12 +18,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" "github.com/iwind/TeaGo/types" - "io" - "net/http" - "path/filepath" - "strconv" - "strings" - "time" ) // 读取缓存 diff --git a/internal/nodes/http_request_cache_partial.go b/internal/nodes/http_request_cache_partial.go index e6f1491..915dfe0 100644 --- a/internal/nodes/http_request_cache_partial.go +++ b/internal/nodes/http_request_cache_partial.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes import ( - "github.com/TeaOSLab/EdgeNode/internal/caches" - "github.com/iwind/TeaGo/types" "io" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/caches" + "github.com/iwind/TeaGo/types" ) // HTTPRequestPartialReader 分区文件读取器 diff --git a/internal/nodes/http_request_cc.go b/internal/nodes/http_request_cc.go index 36f96b1..7e89b47 100644 --- a/internal/nodes/http_request_cc.go +++ b/internal/nodes/http_request_cc.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package nodes diff --git a/internal/nodes/http_request_error.go b/internal/nodes/http_request_error.go index cd6757e..4a24798 100644 --- a/internal/nodes/http_request_error.go +++ b/internal/nodes/http_request_error.go @@ -1,11 +1,12 @@ package nodes import ( + "net/http" + "strings" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" - "net/http" - "strings" ) const httpStatusPageTemplate = ` diff --git a/internal/nodes/http_request_fastcgi.go b/internal/nodes/http_request_fastcgi.go index 71c2607..44ee52b 100644 --- a/internal/nodes/http_request_fastcgi.go +++ b/internal/nodes/http_request_fastcgi.go @@ -5,6 +5,13 @@ package nodes import ( "errors" "fmt" + "io" + "net" + "net/http" + "net/url" + "path/filepath" + "strings" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" @@ -13,12 +20,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" "github.com/iwind/gofcgi/pkg/fcgi" - "io" - "net" - "net/http" - "net/url" - "path/filepath" - "strings" ) func (this *HTTPRequest) doFastcgi() (shouldStop bool) { diff --git a/internal/nodes/http_request_hls.go b/internal/nodes/http_request_hls.go index 9ec4312..7114e28 100644 --- a/internal/nodes/http_request_hls.go +++ b/internal/nodes/http_request_hls.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package nodes diff --git a/internal/nodes/http_request_host_redirect.go b/internal/nodes/http_request_host_redirect.go index 0cdf96a..fa0a6c6 100644 --- a/internal/nodes/http_request_host_redirect.go +++ b/internal/nodes/http_request_host_redirect.go @@ -1,14 +1,15 @@ package nodes import ( - "github.com/TeaOSLab/EdgeCommon/pkg/configutils" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/TeaOSLab/EdgeNode/internal/utils" - "github.com/iwind/TeaGo/types" "net" "net/http" "strconv" "strings" + + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeNode/internal/utils" + "github.com/iwind/TeaGo/types" ) // 主机地址快速跳转 diff --git a/internal/nodes/http_request_http3.go b/internal/nodes/http_request_http3.go index 4deaf14..f024072 100644 --- a/internal/nodes/http_request_http3.go +++ b/internal/nodes/http_request_http3.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package nodes diff --git a/internal/nodes/http_request_limit.go b/internal/nodes/http_request_limit.go index e2f72a6..4799db3 100644 --- a/internal/nodes/http_request_limit.go +++ b/internal/nodes/http_request_limit.go @@ -3,8 +3,9 @@ package nodes import ( - "github.com/TeaOSLab/EdgeNode/internal/iplibrary" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/iplibrary" ) func (this *HTTPRequest) doRequestLimit() (shouldStop bool) { diff --git a/internal/nodes/http_request_log.go b/internal/nodes/http_request_log.go index 8cc32db..845bc32 100644 --- a/internal/nodes/http_request_log.go +++ b/internal/nodes/http_request_log.go @@ -1,10 +1,11 @@ package nodes import ( - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "strings" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) const ( diff --git a/internal/nodes/http_request_mismatch.go b/internal/nodes/http_request_mismatch.go index 58d66d5..83da506 100644 --- a/internal/nodes/http_request_mismatch.go +++ b/internal/nodes/http_request_mismatch.go @@ -1,8 +1,11 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes import ( + "net/http" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeutils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" @@ -10,8 +13,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/ttlcache" "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/iwind/TeaGo/types" - "net/http" - "time" ) // 域名无匹配情况处理 diff --git a/internal/nodes/http_request_oss.go b/internal/nodes/http_request_oss.go index 280cbdd..02ef484 100644 --- a/internal/nodes/http_request_oss.go +++ b/internal/nodes/http_request_oss.go @@ -1,12 +1,13 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package nodes import ( "errors" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "net/http" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) func (this *HTTPRequest) doOSSOrigin(origin *serverconfigs.OriginConfig) (resp *http.Response, goNext bool, errorCode string, ossBucketName string, err error) { diff --git a/internal/nodes/http_request_page.go b/internal/nodes/http_request_page.go index b3a4a6f..a45e22e 100644 --- a/internal/nodes/http_request_page.go +++ b/internal/nodes/http_request_page.go @@ -1,15 +1,16 @@ package nodes import ( + "net/http" + "os" + "path" + "strings" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/bytepool" "github.com/iwind/TeaGo/Tea" - "net/http" - "os" - "path" - "strings" ) const defaultPageContentType = "text/html; charset=utf-8" diff --git a/internal/nodes/http_request_redirect_https.go b/internal/nodes/http_request_redirect_https.go index b7f6015..8410a88 100644 --- a/internal/nodes/http_request_redirect_https.go +++ b/internal/nodes/http_request_redirect_https.go @@ -1,10 +1,11 @@ package nodes import ( - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "net/http" "strconv" "strings" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) func (this *HTTPRequest) doRedirectToHTTPS(redirectToHTTPSConfig *serverconfigs.HTTPRedirectToHTTPSConfig) (shouldBreak bool) { diff --git a/internal/nodes/http_request_referers.go b/internal/nodes/http_request_referers.go index 0238c80..a796cb0 100644 --- a/internal/nodes/http_request_referers.go +++ b/internal/nodes/http_request_referers.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes diff --git a/internal/nodes/http_request_reverse_proxy.go b/internal/nodes/http_request_reverse_proxy.go index 47f0321..52cdade 100644 --- a/internal/nodes/http_request_reverse_proxy.go +++ b/internal/nodes/http_request_reverse_proxy.go @@ -3,6 +3,12 @@ package nodes import ( "context" "errors" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/TeaOSLab/EdgeNode/internal/compressions" @@ -13,11 +19,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/minifiers" "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" - "io" - "net/http" - "net/url" - "strconv" - "strings" ) // 处理反向代理 diff --git a/internal/nodes/http_request_rewrite.go b/internal/nodes/http_request_rewrite.go index 5b3d63d..a8ed739 100644 --- a/internal/nodes/http_request_rewrite.go +++ b/internal/nodes/http_request_rewrite.go @@ -1,8 +1,9 @@ package nodes import ( - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "net/http" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) // 调用Rewrite diff --git a/internal/nodes/http_request_root.go b/internal/nodes/http_request_root.go index f0f063c..c1f954c 100644 --- a/internal/nodes/http_request_root.go +++ b/internal/nodes/http_request_root.go @@ -2,12 +2,6 @@ package nodes import ( "fmt" - rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" - "github.com/cespare/xxhash/v2" - "github.com/iwind/TeaGo/Tea" - "github.com/iwind/TeaGo/logs" - "github.com/iwind/TeaGo/types" "io" "io/fs" "mime" @@ -17,6 +11,13 @@ import ( "path/filepath" "strconv" "strings" + + rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" + "github.com/cespare/xxhash/v2" + "github.com/iwind/TeaGo/Tea" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/types" ) // 文本mime-type列表 diff --git a/internal/nodes/http_request_shutdown.go b/internal/nodes/http_request_shutdown.go index 444dc16..f90d780 100644 --- a/internal/nodes/http_request_shutdown.go +++ b/internal/nodes/http_request_shutdown.go @@ -1,15 +1,16 @@ package nodes import ( + "net/http" + "os" + "path" + "strings" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/bytepool" "github.com/iwind/TeaGo/Tea" - "net/http" - "os" - "path" - "strings" ) // 调用临时关闭页面 diff --git a/internal/nodes/http_request_test.go b/internal/nodes/http_request_test.go index 6cac0b9..0bc2991 100644 --- a/internal/nodes/http_request_test.go +++ b/internal/nodes/http_request_test.go @@ -1,11 +1,12 @@ package nodes import ( - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/iwind/TeaGo/assert" "net/http" "runtime" "testing" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/iwind/TeaGo/assert" ) func TestHTTPRequest_RedirectToHTTPS(t *testing.T) { diff --git a/internal/nodes/http_request_url.go b/internal/nodes/http_request_url.go index a4b9ced..70fbaea 100644 --- a/internal/nodes/http_request_url.go +++ b/internal/nodes/http_request_url.go @@ -1,12 +1,13 @@ package nodes import ( - "github.com/TeaOSLab/EdgeNode/internal/remotelogs" - "github.com/TeaOSLab/EdgeNode/internal/utils" - "github.com/iwind/TeaGo/logs" "io" "net/http" "time" + + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" + "github.com/TeaOSLab/EdgeNode/internal/utils" + "github.com/iwind/TeaGo/logs" ) // 请求某个URL diff --git a/internal/nodes/http_request_user_agent.go b/internal/nodes/http_request_user_agent.go index 90efdf2..e7616d7 100644 --- a/internal/nodes/http_request_user_agent.go +++ b/internal/nodes/http_request_user_agent.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes diff --git a/internal/nodes/http_request_utils.go b/internal/nodes/http_request_utils.go index 192d706..d69228a 100644 --- a/internal/nodes/http_request_utils.go +++ b/internal/nodes/http_request_utils.go @@ -3,10 +3,6 @@ package nodes import ( "crypto/rand" "fmt" - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" - "github.com/iwind/TeaGo/types" "io" "net/http" "net/url" @@ -14,6 +10,11 @@ import ( "strconv" "strings" "sync/atomic" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" + "github.com/iwind/TeaGo/types" ) // 搜索引擎和爬虫正则 diff --git a/internal/nodes/http_request_utils_test.go b/internal/nodes/http_request_utils_test.go index 27d6ef3..5416bec 100644 --- a/internal/nodes/http_request_utils_test.go +++ b/internal/nodes/http_request_utils_test.go @@ -1,13 +1,14 @@ package nodes import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" - "github.com/iwind/TeaGo/assert" "runtime" "sync" "testing" "time" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" + "github.com/iwind/TeaGo/assert" ) func TestHTTPRequest_httpRequestGenBoundary(t *testing.T) { diff --git a/internal/nodes/http_request_waf.go b/internal/nodes/http_request_waf.go index 4c22478..ef7ff51 100644 --- a/internal/nodes/http_request_waf.go +++ b/internal/nodes/http_request_waf.go @@ -2,6 +2,10 @@ package nodes import ( "bytes" + "io" + "net/http" + "time" + iplib "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/iplibrary" @@ -11,9 +15,6 @@ import ( wafutils "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/types" - "io" - "net/http" - "time" ) // 调用WAF @@ -303,6 +304,44 @@ func (this *HTTPRequest) checkWAFRequest(firewallPolicy *firewallconfigs.HTTPFir } } } + + if regionConfig.MatchProviderURL(currentURL) { + // 检查运营商封禁 + if !regionConfig.IsAllowedProvider(result.ProviderId()) { + this.firewallPolicyId = firewallPolicy.Id + + if isDefendMode { + var promptHTML string + if len(regionConfig.ProviderHTML) > 0 { + promptHTML = regionConfig.ProviderHTML + } + + if len(promptHTML) > 0 { + var formattedHTML = this.Format(promptHTML) + this.writer.Header().Set("Content-Type", "text/html; charset=utf-8") + this.writer.Header().Set("Content-Length", types.String(len(formattedHTML))) + this.writer.WriteHeader(http.StatusForbidden) + _, _ = this.writer.Write([]byte(formattedHTML)) + } else { + this.writeCode(http.StatusForbidden, "The isp has been denied.", "当前运营商禁止访问") + } + + // 延时返回,避免攻击 + time.Sleep(1 * time.Second) + } + + // 停止日志 + if !logDenying { + this.disableLog = true + } else { + this.tags = append(this.tags, "denyProvider") + } + + if isDefendMode { + return true, false + } + } + } } } } diff --git a/internal/nodes/http_request_websocket.go b/internal/nodes/http_request_websocket.go index 6c89d77..f04803c 100644 --- a/internal/nodes/http_request_websocket.go +++ b/internal/nodes/http_request_websocket.go @@ -4,10 +4,11 @@ import ( "bufio" "bytes" "errors" - "github.com/TeaOSLab/EdgeNode/internal/utils/bytepool" "io" "net/http" "net/url" + + "github.com/TeaOSLab/EdgeNode/internal/utils/bytepool" ) // WebsocketResponseReader Websocket响应Reader diff --git a/internal/nodes/http_writer.go b/internal/nodes/http_writer.go index 781fb8c..1bd38dd 100644 --- a/internal/nodes/http_writer.go +++ b/internal/nodes/http_writer.go @@ -7,6 +7,20 @@ import ( "bytes" "errors" "fmt" + "image" + "image/gif" + _ "image/jpeg" + _ "image/png" + "io" + "net" + "net/http" + "net/textproto" + "os" + "path/filepath" + "runtime" + "strings" + "sync/atomic" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/caches" @@ -22,19 +36,6 @@ import ( "github.com/iwind/gowebp" _ "golang.org/x/image/bmp" _ "golang.org/x/image/webp" - "image" - "image/gif" - _ "image/jpeg" - _ "image/png" - "io" - "net" - "net/http" - "net/textproto" - "os" - "path/filepath" - "runtime" - "strings" - "sync/atomic" ) var webPThreads int32 diff --git a/internal/nodes/ip_library_updater.go b/internal/nodes/ip_library_updater.go index ac1f8ff..1a48378 100644 --- a/internal/nodes/ip_library_updater.go +++ b/internal/nodes/ip_library_updater.go @@ -1,16 +1,17 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes import ( "errors" + "io" + "os" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/types" - "io" - "os" ) type IPLibraryUpdater struct { diff --git a/internal/nodes/listener.go b/internal/nodes/listener.go index 6000e3b..4ce34ac 100644 --- a/internal/nodes/listener.go +++ b/internal/nodes/listener.go @@ -3,15 +3,16 @@ package nodes import ( "context" "errors" + "net" + "strings" + "sync" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "golang.org/x/net/ipv4" "golang.org/x/net/ipv6" - "net" - "strings" - "sync" ) type Listener struct { diff --git a/internal/nodes/listener_base.go b/internal/nodes/listener_base.go index 2f0ced9..7141c9c 100644 --- a/internal/nodes/listener_base.go +++ b/internal/nodes/listener_base.go @@ -3,13 +3,14 @@ package nodes import ( "crypto/tls" "errors" + "net" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/iwind/TeaGo/types" - "net" ) type BaseListener struct { diff --git a/internal/nodes/listener_base_ext.go b/internal/nodes/listener_base_ext.go index 5287d50..15cea92 100644 --- a/internal/nodes/listener_base_ext.go +++ b/internal/nodes/listener_base_ext.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package nodes diff --git a/internal/nodes/listener_base_test.go b/internal/nodes/listener_base_test.go index 42ed55b..6690ab4 100644 --- a/internal/nodes/listener_base_test.go +++ b/internal/nodes/listener_base_test.go @@ -4,11 +4,12 @@ package nodes import ( "context" + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/types" - "testing" - "time" ) func TestBaseListener_FindServer(t *testing.T) { diff --git a/internal/nodes/listener_http.go b/internal/nodes/listener_http.go index e487d6f..bb0c997 100644 --- a/internal/nodes/listener_http.go +++ b/internal/nodes/listener_http.go @@ -4,8 +4,6 @@ import ( "context" "crypto/tls" "errors" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "github.com/iwind/TeaGo/Tea" "io" "log" "net" @@ -13,6 +11,9 @@ import ( "strings" "sync/atomic" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/iwind/TeaGo/Tea" ) var httpErrorLogger = log.New(io.Discard, "", 0) diff --git a/internal/nodes/listener_manager.go b/internal/nodes/listener_manager.go index 6285968..cff7c39 100644 --- a/internal/nodes/listener_manager.go +++ b/internal/nodes/listener_manager.go @@ -2,6 +2,14 @@ package nodes import ( "fmt" + "net/url" + "regexp" + "runtime" + "sort" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -14,13 +22,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "net/url" - "regexp" - "runtime" - "sort" - "strings" - "sync" - "time" ) var sharedListenerManager *ListenerManager diff --git a/internal/nodes/listener_manager_test.go b/internal/nodes/listener_manager_test.go index ac9186f..bf83ec9 100644 --- a/internal/nodes/listener_manager_test.go +++ b/internal/nodes/listener_manager_test.go @@ -1,9 +1,10 @@ package nodes import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" - "testing" ) func TestListenerManager_Listen(t *testing.T) { diff --git a/internal/nodes/listener_tcp.go b/internal/nodes/listener_tcp.go index 41c7327..dd757ff 100644 --- a/internal/nodes/listener_tcp.go +++ b/internal/nodes/listener_tcp.go @@ -3,6 +3,10 @@ package nodes import ( "crypto/tls" "errors" + "net" + "strings" + "sync/atomic" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" @@ -11,9 +15,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/types" "github.com/pires/go-proxyproto" - "net" - "strings" - "sync/atomic" ) type TCPListener struct { diff --git a/internal/nodes/listener_test.go b/internal/nodes/listener_test.go index 545d347..8c48b73 100644 --- a/internal/nodes/listener_test.go +++ b/internal/nodes/listener_test.go @@ -1,8 +1,9 @@ package nodes import ( - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "testing" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) func TestListener_Listen(t *testing.T) { diff --git a/internal/nodes/listener_udp.go b/internal/nodes/listener_udp.go index 17ccdbf..7ca6e08 100644 --- a/internal/nodes/listener_udp.go +++ b/internal/nodes/listener_udp.go @@ -2,6 +2,11 @@ package nodes import ( "errors" + "net" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/firewalls" "github.com/TeaOSLab/EdgeNode/internal/iplibrary" @@ -14,10 +19,6 @@ import ( "github.com/pires/go-proxyproto" "golang.org/x/net/ipv4" "golang.org/x/net/ipv6" - "net" - "strings" - "sync" - "time" ) const ( diff --git a/internal/nodes/node.go b/internal/nodes/node.go index e30a3dd..6b1c695 100644 --- a/internal/nodes/node.go +++ b/internal/nodes/node.go @@ -6,6 +6,19 @@ import ( "encoding/json" "errors" "fmt" + "log" + "os" + "os/exec" + "os/signal" + "path/filepath" + "runtime" + "runtime/debug" + "sort" + "strings" + "sync" + "syscall" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" iplib "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" @@ -38,18 +51,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" "github.com/iwind/gosock/pkg/gosock" - "log" - "os" - "os/exec" - "os/signal" - "path/filepath" - "runtime" - "runtime/debug" - "sort" - "strings" - "sync" - "syscall" - "time" ) var sharedNodeConfig *nodeconfigs.NodeConfig @@ -194,6 +195,7 @@ func (this *Node) Start() { } teaconst.NodeId = nodeConfig.Id teaconst.NodeIdString = types.String(teaconst.NodeId) + teaconst.BypassMobile = nodeConfig.BypassMobile err, serverErrors := nodeConfig.Init(context.Background()) if err != nil { remotelogs.Error("NODE", "init node config failed: "+err.Error()) @@ -383,6 +385,7 @@ func (this *Node) syncConfig(taskVersion int64) error { } teaconst.NodeId = nodeConfig.Id teaconst.NodeIdString = types.String(teaconst.NodeId) + teaconst.BypassMobile = nodeConfig.BypassMobile // 检查时间是否一致 // 这个需要在 teaconst.NodeId 设置之后,因为上报到API节点的时候需要节点ID diff --git a/internal/nodes/node_panic.go b/internal/nodes/node_panic.go index 580499b..e5807ee 100644 --- a/internal/nodes/node_panic.go +++ b/internal/nodes/node_panic.go @@ -6,11 +6,12 @@ package nodes import ( "bytes" + "os" + "syscall" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/logs" - "os" - "syscall" ) // 处理异常 diff --git a/internal/nodes/node_status_executor.go b/internal/nodes/node_status_executor.go index fdc3dd5..a85aabe 100644 --- a/internal/nodes/node_status_executor.go +++ b/internal/nodes/node_status_executor.go @@ -2,6 +2,12 @@ package nodes import ( "encoding/json" + "math" + "os" + "runtime" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/caches" @@ -19,11 +25,6 @@ import ( "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/disk" "github.com/shirou/gopsutil/v3/net" - "math" - "os" - "runtime" - "strings" - "time" ) type NodeStatusExecutor struct { diff --git a/internal/nodes/node_status_executor_test.go b/internal/nodes/node_status_executor_test.go index c2ff7f6..9e842a8 100644 --- a/internal/nodes/node_status_executor_test.go +++ b/internal/nodes/node_status_executor_test.go @@ -1,9 +1,10 @@ package nodes import ( - "github.com/shirou/gopsutil/v3/cpu" "testing" "time" + + "github.com/shirou/gopsutil/v3/cpu" ) func TestNodeStatusExecutor_CPU(t *testing.T) { diff --git a/internal/nodes/node_status_executor_unix.go b/internal/nodes/node_status_executor_unix.go index ecc02cf..513ca3c 100644 --- a/internal/nodes/node_status_executor_unix.go +++ b/internal/nodes/node_status_executor_unix.go @@ -3,13 +3,14 @@ package nodes import ( + "runtime" + "runtime/debug" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeNode/internal/monitor" "github.com/iwind/TeaGo/maps" "github.com/shirou/gopsutil/v3/load" "github.com/shirou/gopsutil/v3/mem" - "runtime" - "runtime/debug" ) // 更新内存 diff --git a/internal/nodes/node_status_executor_windows.go b/internal/nodes/node_status_executor_windows.go index 4866e06..49754d4 100644 --- a/internal/nodes/node_status_executor_windows.go +++ b/internal/nodes/node_status_executor_windows.go @@ -4,11 +4,12 @@ package nodes import ( "context" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/mem" "math" "sync" "time" + + "github.com/shirou/gopsutil/v3/cpu" + "github.com/shirou/gopsutil/v3/mem" ) type WindowsLoadValue struct { diff --git a/internal/nodes/node_tasks.go b/internal/nodes/node_tasks.go index ea9da2f..b1814c8 100644 --- a/internal/nodes/node_tasks.go +++ b/internal/nodes/node_tasks.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes @@ -6,6 +6,10 @@ import ( "encoding/json" "errors" "fmt" + "os" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" @@ -22,9 +26,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "os" - "strings" - "time" ) // 循环 diff --git a/internal/nodes/node_tasks_ext.go b/internal/nodes/node_tasks_ext.go index 5863677..dc7f72e 100644 --- a/internal/nodes/node_tasks_ext.go +++ b/internal/nodes/node_tasks_ext.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package nodes diff --git a/internal/nodes/node_test.go b/internal/nodes/node_test.go index 7448058..e10bcd1 100644 --- a/internal/nodes/node_test.go +++ b/internal/nodes/node_test.go @@ -1,9 +1,10 @@ package nodes import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestNode_Start(t *testing.T) { diff --git a/internal/nodes/origin_conn.go b/internal/nodes/origin_conn.go index 47ea080..ed30dbd 100644 --- a/internal/nodes/origin_conn.go +++ b/internal/nodes/origin_conn.go @@ -1,15 +1,16 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes import ( + "net" + "sync" + "time" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/TeaOSLab/EdgeNode/internal/utils/zero" - "net" - "sync" - "time" ) const originConnCloseDelaySeconds = 3 diff --git a/internal/nodes/origin_state_manager.go b/internal/nodes/origin_state_manager.go index efdf8e0..01ddb99 100644 --- a/internal/nodes/origin_state_manager.go +++ b/internal/nodes/origin_state_manager.go @@ -3,6 +3,9 @@ package nodes import ( + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -10,8 +13,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/TeaOSLab/EdgeNode/internal/utils/trackers" "github.com/iwind/TeaGo/Tea" - "sync" - "time" ) var SharedOriginStateManager = NewOriginStateManager() diff --git a/internal/nodes/origin_utils.go b/internal/nodes/origin_utils.go index 313fc58..7ab28d8 100644 --- a/internal/nodes/origin_utils.go +++ b/internal/nodes/origin_utils.go @@ -3,12 +3,13 @@ package nodes import ( "crypto/tls" "errors" + "net" + "strconv" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/iwind/TeaGo/types" - "net" - "strconv" ) // OriginConnect 连接源站 diff --git a/internal/nodes/system_services.go b/internal/nodes/system_services.go index 5f5c040..4c108ac 100644 --- a/internal/nodes/system_services.go +++ b/internal/nodes/system_services.go @@ -4,6 +4,10 @@ import ( "bytes" "encoding/json" "errors" + "os" + "runtime" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -12,9 +16,6 @@ import ( executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/maps" - "os" - "runtime" - "time" ) func init() { diff --git a/internal/nodes/task_ocsp_update.go b/internal/nodes/task_ocsp_update.go index c0e042b..fba9289 100644 --- a/internal/nodes/task_ocsp_update.go +++ b/internal/nodes/task_ocsp_update.go @@ -3,6 +3,8 @@ package nodes import ( + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -10,7 +12,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/Tea" - "time" ) var sharedOCSPTask = NewOCSPUpdateTask() diff --git a/internal/nodes/task_ocsp_update_test.go b/internal/nodes/task_ocsp_update_test.go index 88c64d7..78a59de 100644 --- a/internal/nodes/task_ocsp_update_test.go +++ b/internal/nodes/task_ocsp_update_test.go @@ -3,8 +3,9 @@ package nodes_test import ( - "github.com/TeaOSLab/EdgeNode/internal/nodes" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/nodes" ) func TestOCSPUpdateTask_Loop(t *testing.T) { diff --git a/internal/nodes/task_sync_api_nodes.go b/internal/nodes/task_sync_api_nodes.go index 6657b6c..ce11370 100644 --- a/internal/nodes/task_sync_api_nodes.go +++ b/internal/nodes/task_sync_api_nodes.go @@ -1,6 +1,8 @@ package nodes import ( + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/configs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -11,7 +13,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/trackers" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/logs" - "time" ) var sharedSyncAPINodesTask = NewSyncAPINodesTask() diff --git a/internal/nodes/task_trim_disks.go b/internal/nodes/task_trim_disks.go index 030dbbd..c72f1de 100644 --- a/internal/nodes/task_trim_disks.go +++ b/internal/nodes/task_trim_disks.go @@ -1,15 +1,16 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes import ( "fmt" + "runtime" + "time" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" "github.com/TeaOSLab/EdgeNode/internal/utils/idles" "github.com/TeaOSLab/EdgeNode/internal/utils/trackers" - "runtime" - "time" ) // TrimDisksTask trim ssd disks automatically diff --git a/internal/nodes/toa_manager.go b/internal/nodes/toa_manager.go index 7c3f86d..70a3fe7 100644 --- a/internal/nodes/toa_manager.go +++ b/internal/nodes/toa_manager.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package nodes diff --git a/internal/nodes/upgrade_manager.go b/internal/nodes/upgrade_manager.go index 492286c..bdd6537 100644 --- a/internal/nodes/upgrade_manager.go +++ b/internal/nodes/upgrade_manager.go @@ -5,6 +5,11 @@ package nodes import ( "crypto/md5" "fmt" + "os" + "path/filepath" + "runtime" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -16,10 +21,6 @@ import ( "github.com/iwind/TeaGo/Tea" stringutil "github.com/iwind/TeaGo/utils/string" "github.com/iwind/gosock/pkg/gosock" - "os" - "path/filepath" - "runtime" - "time" ) var sharedUpgradeManager = NewUpgradeManager() diff --git a/internal/nodes/upgrade_manager_test.go b/internal/nodes/upgrade_manager_test.go index f267753..e4af51e 100644 --- a/internal/nodes/upgrade_manager_test.go +++ b/internal/nodes/upgrade_manager_test.go @@ -3,9 +3,10 @@ package nodes import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestUpgradeManager_install(t *testing.T) { diff --git a/internal/nodes/user_manager.go b/internal/nodes/user_manager.go index 05d59c0..1f1b247 100644 --- a/internal/nodes/user_manager.go +++ b/internal/nodes/user_manager.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes @@ -40,7 +40,7 @@ func (this *UserManager) CheckUserServersIsEnabled(userId int64) (isEnabled bool if userId <= 0 { return true } - + this.locker.RLock() u, ok := this.userMap[userId] if ok { diff --git a/internal/remotelogs/utils.go b/internal/remotelogs/utils.go index 2caaf57..213190f 100644 --- a/internal/remotelogs/utils.go +++ b/internal/remotelogs/utils.go @@ -2,6 +2,9 @@ package remotelogs import ( "encoding/json" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -13,8 +16,6 @@ import ( "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "strings" - "time" ) var logChan = make(chan *pb.NodeLog, 64) // 队列数量不需要太长,因为日志通常仅仅为调试用 diff --git a/internal/rpc/call_stat.go b/internal/rpc/call_stat.go index 9745288..4cd4438 100644 --- a/internal/rpc/call_stat.go +++ b/internal/rpc/call_stat.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package rpc diff --git a/internal/rpc/call_stat_test.go b/internal/rpc/call_stat_test.go index bbb1abf..5b37923 100644 --- a/internal/rpc/call_stat_test.go +++ b/internal/rpc/call_stat_test.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package rpc_test import ( - "github.com/TeaOSLab/EdgeNode/internal/rpc" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/rpc" ) func TestNewCallStat(t *testing.T) { diff --git a/internal/rpc/rpc_client.go b/internal/rpc/rpc_client.go index 610927f..44788c4 100644 --- a/internal/rpc/rpc_client.go +++ b/internal/rpc/rpc_client.go @@ -6,6 +6,10 @@ import ( "encoding/base64" "errors" "fmt" + "net/url" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/configs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -20,9 +24,6 @@ import ( "google.golang.org/grpc/encoding/gzip" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" - "net/url" - "sync" - "time" ) type RPCClient struct { diff --git a/internal/rpc/rpc_test.go b/internal/rpc/rpc_test.go index dbf381e..aa55bb0 100644 --- a/internal/rpc/rpc_test.go +++ b/internal/rpc/rpc_test.go @@ -1,16 +1,17 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package rpc_test import ( + "sync" + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" _ "github.com/iwind/TeaGo/bootstrap" timeutil "github.com/iwind/TeaGo/utils/time" - "sync" - "testing" - "time" ) func TestRPCConcurrentCall(t *testing.T) { diff --git a/internal/rpc/rpc_utils.go b/internal/rpc/rpc_utils.go index 0be403a..56c045c 100644 --- a/internal/rpc/rpc_utils.go +++ b/internal/rpc/rpc_utils.go @@ -1,11 +1,12 @@ package rpc import ( + "strings" + "sync" + "github.com/TeaOSLab/EdgeNode/internal/configs" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "strings" - "sync" ) var sharedRPC *RPCClient = nil diff --git a/internal/stats/bandwidth_stat_manager.go b/internal/stats/bandwidth_stat_manager.go index 3c88bc5..0ca8a01 100644 --- a/internal/stats/bandwidth_stat_manager.go +++ b/internal/stats/bandwidth_stat_manager.go @@ -1,9 +1,13 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package stats import ( "encoding/json" + "os" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -16,9 +20,6 @@ import ( "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "os" - "sync" - "time" ) var SharedBandwidthStatManager = NewBandwidthStatManager() diff --git a/internal/stats/bandwidth_stat_manager_test.go b/internal/stats/bandwidth_stat_manager_test.go index 4589281..ac71ecb 100644 --- a/internal/stats/bandwidth_stat_manager_test.go +++ b/internal/stats/bandwidth_stat_manager_test.go @@ -1,13 +1,14 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package stats_test import ( - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - "github.com/TeaOSLab/EdgeNode/internal/stats" "runtime" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeNode/internal/stats" ) func TestBandwidthStatManager_Add(t *testing.T) { diff --git a/internal/stats/dau_manager.go b/internal/stats/dau_manager.go index 011d67a..d70842c 100644 --- a/internal/stats/dau_manager.go +++ b/internal/stats/dau_manager.go @@ -1,9 +1,16 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package stats import ( "encoding/json" + "os" + "runtime" + "strings" + "sync" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" @@ -14,12 +21,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "os" - "runtime" - "strings" - "sync" - "testing" - "time" ) var SharedDAUManager = NewDAUManager() diff --git a/internal/stats/dau_manager_test.go b/internal/stats/dau_manager_test.go index 94fe1c5..d46af37 100644 --- a/internal/stats/dau_manager_test.go +++ b/internal/stats/dau_manager_test.go @@ -1,14 +1,15 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package stats_test import ( - "github.com/TeaOSLab/EdgeNode/internal/stats" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/rands" "runtime" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/stats" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/rands" ) func TestDAUManager_AddIP(t *testing.T) { diff --git a/internal/stats/http_request_stat_manager.go b/internal/stats/http_request_stat_manager.go index 6374d1e..2dc6ba2 100644 --- a/internal/stats/http_request_stat_manager.go +++ b/internal/stats/http_request_stat_manager.go @@ -1,6 +1,12 @@ package stats import ( + "sort" + "strconv" + "strings" + "sync" + "time" + iplib "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" @@ -17,11 +23,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "sort" - "strconv" - "strings" - "sync" - "time" ) type StatItem struct { diff --git a/internal/stats/http_request_stat_manager_test.go b/internal/stats/http_request_stat_manager_test.go index 589d363..f44bde6 100644 --- a/internal/stats/http_request_stat_manager_test.go +++ b/internal/stats/http_request_stat_manager_test.go @@ -1,10 +1,11 @@ package stats import ( + "testing" + iplib "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/logs" - "testing" ) func TestHTTPRequestStatManager_Loop_Region(t *testing.T) { diff --git a/internal/stats/traffic_stat_manager.go b/internal/stats/traffic_stat_manager.go index e5a9f11..bcf7f61 100644 --- a/internal/stats/traffic_stat_manager.go +++ b/internal/stats/traffic_stat_manager.go @@ -1,6 +1,12 @@ package stats import ( + "sort" + "strconv" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -12,11 +18,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "sort" - "strconv" - "strings" - "sync" - "time" ) var SharedTrafficStatManager = NewTrafficStatManager() diff --git a/internal/stats/traffic_stat_manager_test.go b/internal/stats/traffic_stat_manager_test.go index e92ba0a..8ef0b5d 100644 --- a/internal/stats/traffic_stat_manager_test.go +++ b/internal/stats/traffic_stat_manager_test.go @@ -1,11 +1,12 @@ package stats import ( - "github.com/iwind/TeaGo/rands" - "github.com/iwind/TeaGo/types" "math/rand" "runtime" "testing" + + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" ) func TestTrafficStatManager_Add(t *testing.T) { diff --git a/internal/stats/user_agent_parser.go b/internal/stats/user_agent_parser.go index 85351dd..8a859a6 100644 --- a/internal/stats/user_agent_parser.go +++ b/internal/stats/user_agent_parser.go @@ -3,13 +3,14 @@ package stats import ( + "sync" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/fnv" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" syncutils "github.com/TeaOSLab/EdgeNode/internal/utils/sync" "github.com/mssola/useragent" - "sync" - "time" ) var SharedUserAgentParser = NewUserAgentParser() diff --git a/internal/stats/user_agent_parser_test.go b/internal/stats/user_agent_parser_test.go index 73286c9..ee83217 100644 --- a/internal/stats/user_agent_parser_test.go +++ b/internal/stats/user_agent_parser_test.go @@ -3,15 +3,16 @@ package stats_test import ( + "runtime" + "runtime/debug" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/stats" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "runtime" - "runtime/debug" - "testing" - "time" ) func TestUserAgentParser_Parse(t *testing.T) { diff --git a/internal/utils/agents/agent.go b/internal/utils/agents/agent.go index f347586..6e210e0 100644 --- a/internal/utils/agents/agent.go +++ b/internal/utils/agents/agent.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents diff --git a/internal/utils/agents/agent_ip.go b/internal/utils/agents/agent_ip.go index 5da7135..bfe4e75 100644 --- a/internal/utils/agents/agent_ip.go +++ b/internal/utils/agents/agent_ip.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents diff --git a/internal/utils/agents/agents.go b/internal/utils/agents/agents.go index a7d0c92..7eb5ca4 100644 --- a/internal/utils/agents/agents.go +++ b/internal/utils/agents/agents.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents diff --git a/internal/utils/agents/agents_test.go b/internal/utils/agents/agents_test.go index 3568941..00dab31 100644 --- a/internal/utils/agents/agents_test.go +++ b/internal/utils/agents/agents_test.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/agents" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/agents" ) func TestIsAgentFromUserAgent(t *testing.T) { diff --git a/internal/utils/agents/db.go b/internal/utils/agents/db.go index 7ffa388..c0df3ca 100644 --- a/internal/utils/agents/db.go +++ b/internal/utils/agents/db.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents diff --git a/internal/utils/agents/db_kv.go b/internal/utils/agents/db_kv.go index ab52971..c3ec952 100644 --- a/internal/utils/agents/db_kv.go +++ b/internal/utils/agents/db_kv.go @@ -1,9 +1,10 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents import ( "errors" + "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" ) diff --git a/internal/utils/agents/db_kv_objects.go b/internal/utils/agents/db_kv_objects.go index 25f263b..9b13099 100644 --- a/internal/utils/agents/db_kv_objects.go +++ b/internal/utils/agents/db_kv_objects.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents diff --git a/internal/utils/agents/db_kv_test.go b/internal/utils/agents/db_kv_test.go index 446e83a..9d4a7fc 100644 --- a/internal/utils/agents/db_kv_test.go +++ b/internal/utils/agents/db_kv_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/agents" "strconv" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/agents" ) func TestKVDB_InsertAgentIP(t *testing.T) { diff --git a/internal/utils/agents/db_sqlite.go b/internal/utils/agents/db_sqlite.go index 05ee435..da780aa 100644 --- a/internal/utils/agents/db_sqlite.go +++ b/internal/utils/agents/db_sqlite.go @@ -4,15 +4,16 @@ package agents import ( "errors" + "log" + "os" + "path/filepath" + "strings" + "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/types" - "log" - "os" - "path/filepath" - "strings" ) const ( diff --git a/internal/utils/agents/ip_cache_map.go b/internal/utils/agents/ip_cache_map.go index 4bf834b..804b7d2 100644 --- a/internal/utils/agents/ip_cache_map.go +++ b/internal/utils/agents/ip_cache_map.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) type IPCacheMap struct { diff --git a/internal/utils/agents/ip_cache_map_test.go b/internal/utils/agents/ip_cache_map_test.go index b9bbe54..6dd90b5 100644 --- a/internal/utils/agents/ip_cache_map_test.go +++ b/internal/utils/agents/ip_cache_map_test.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents import ( - "github.com/iwind/TeaGo/logs" "testing" + + "github.com/iwind/TeaGo/logs" ) func TestNewIPCacheMap(t *testing.T) { diff --git a/internal/utils/agents/manager.go b/internal/utils/agents/manager.go index 4d0aa28..45c0a29 100644 --- a/internal/utils/agents/manager.go +++ b/internal/utils/agents/manager.go @@ -1,8 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents import ( + "os" + "sync" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -10,9 +14,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/Tea" - "os" - "sync" - "time" ) var SharedManager = NewManager() diff --git a/internal/utils/agents/manager_test.go b/internal/utils/agents/manager_test.go index beb6126..777d883 100644 --- a/internal/utils/agents/manager_test.go +++ b/internal/utils/agents/manager_test.go @@ -1,13 +1,14 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/agents" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/Tea" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestNewManager(t *testing.T) { diff --git a/internal/utils/agents/queue.go b/internal/utils/agents/queue.go index 4d33bef..51848af 100644 --- a/internal/utils/agents/queue.go +++ b/internal/utils/agents/queue.go @@ -1,8 +1,10 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents import ( + "net" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -10,7 +12,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/Tea" - "net" ) func init() { @@ -82,7 +83,7 @@ func (this *Queue) Process(ip string) error { return nil } - //remotelogs.Debug("AGENT", ip+" => "+ptr) + // remotelogs.Debug("AGENT", ip+" => "+ptr) var agentCode = this.ParsePtr(ptr) if len(agentCode) == 0 { diff --git a/internal/utils/agents/queue_test.go b/internal/utils/agents/queue_test.go index 1119050..2178594 100644 --- a/internal/utils/agents/queue_test.go +++ b/internal/utils/agents/queue_test.go @@ -1,14 +1,15 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package agents_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/agents" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/assert" _ "github.com/iwind/TeaGo/bootstrap" - "testing" - "time" ) func TestParseQueue_Process(t *testing.T) { diff --git a/internal/utils/bfs/block_info.go b/internal/utils/bfs/block_info.go index 9c2d4f2..30b44ad 100644 --- a/internal/utils/bfs/block_info.go +++ b/internal/utils/bfs/block_info.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs diff --git a/internal/utils/bfs/blocks_file.go b/internal/utils/bfs/blocks_file.go index cdecd9d..29df3d8 100644 --- a/internal/utils/bfs/blocks_file.go +++ b/internal/utils/bfs/blocks_file.go @@ -1,11 +1,10 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( "errors" "fmt" - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "io" "os" "path/filepath" @@ -13,6 +12,8 @@ import ( "sync" "sync/atomic" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) const BFileExt = ".b" @@ -317,7 +318,7 @@ func (this *BlocksFile) Close() error { } // TODO 决定是否同步 - //_ = this.sync(true) + // _ = this.sync(true) this.isClosed = true diff --git a/internal/utils/bfs/blocks_file_options.go b/internal/utils/bfs/blocks_file_options.go index 40c603a..be50809 100644 --- a/internal/utils/bfs/blocks_file_options.go +++ b/internal/utils/bfs/blocks_file_options.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs diff --git a/internal/utils/bfs/blocks_file_test.go b/internal/utils/bfs/blocks_file_test.go index 706d907..c9784c4 100644 --- a/internal/utils/bfs/blocks_file_test.go +++ b/internal/utils/bfs/blocks_file_test.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" - "github.com/iwind/TeaGo/assert" "os" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" + "github.com/iwind/TeaGo/assert" ) func TestBlocksFile_CanClose(t *testing.T) { diff --git a/internal/utils/bfs/errors.go b/internal/utils/bfs/errors.go index ef61d7d..78ef8a4 100644 --- a/internal/utils/bfs/errors.go +++ b/internal/utils/bfs/errors.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs diff --git a/internal/utils/bfs/file_header.go b/internal/utils/bfs/file_header.go index 86c24a3..e89cc90 100644 --- a/internal/utils/bfs/file_header.go +++ b/internal/utils/bfs/file_header.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( "encoding/json" - "github.com/TeaOSLab/EdgeNode/internal/utils" "sort" + + "github.com/TeaOSLab/EdgeNode/internal/utils" ) type FileHeader struct { diff --git a/internal/utils/bfs/file_header_lazy.go b/internal/utils/bfs/file_header_lazy.go index 2499ada..a5d06e7 100644 --- a/internal/utils/bfs/file_header_lazy.go +++ b/internal/utils/bfs/file_header_lazy.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs diff --git a/internal/utils/bfs/file_header_lazy_test.go b/internal/utils/bfs/file_header_lazy_test.go index ad000bd..813bfc1 100644 --- a/internal/utils/bfs/file_header_lazy_test.go +++ b/internal/utils/bfs/file_header_lazy_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" "runtime" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" ) func TestNewLazyFileHeaderFromData(t *testing.T) { diff --git a/internal/utils/bfs/file_header_test.go b/internal/utils/bfs/file_header_test.go index 8b866a3..8cfe8e8 100644 --- a/internal/utils/bfs/file_header_test.go +++ b/internal/utils/bfs/file_header_test.go @@ -1,16 +1,17 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( "encoding/json" + "math/rand" + "runtime" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/logs" - "math/rand" - "runtime" - "testing" ) func TestFileHeader_Compact(t *testing.T) { diff --git a/internal/utils/bfs/file_reader.go b/internal/utils/bfs/file_reader.go index 95e436f..cce973c 100644 --- a/internal/utils/bfs/file_reader.go +++ b/internal/utils/bfs/file_reader.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( "errors" - "github.com/iwind/TeaGo/types" "io" "os" + + "github.com/iwind/TeaGo/types" ) type FileReader struct { diff --git a/internal/utils/bfs/file_reader_test.go b/internal/utils/bfs/file_reader_test.go index 86da4a1..b61108e 100644 --- a/internal/utils/bfs/file_reader_test.go +++ b/internal/utils/bfs/file_reader_test.go @@ -1,14 +1,15 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( "fmt" - "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" "io" "os" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" ) func TestFileReader_Read_SmallBuf(t *testing.T) { diff --git a/internal/utils/bfs/file_writer.go b/internal/utils/bfs/file_writer.go index 38dc7b2..e070ef1 100644 --- a/internal/utils/bfs/file_writer.go +++ b/internal/utils/bfs/file_writer.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs diff --git a/internal/utils/bfs/file_writer_test.go b/internal/utils/bfs/file_writer_test.go index dfea51c..29f9d50 100644 --- a/internal/utils/bfs/file_writer_test.go +++ b/internal/utils/bfs/file_writer_test.go @@ -1,16 +1,17 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( "bytes" + "net/http" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/logs" - "net/http" - "testing" - "time" ) func TestNewFileWriter(t *testing.T) { diff --git a/internal/utils/bfs/fs.go b/internal/utils/bfs/fs.go index cec6520..f51a1ec 100644 --- a/internal/utils/bfs/fs.go +++ b/internal/utils/bfs/fs.go @@ -1,17 +1,18 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( "errors" - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" - "github.com/TeaOSLab/EdgeNode/internal/utils/linkedlist" - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "log" "runtime" "sync" "time" + + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" + "github.com/TeaOSLab/EdgeNode/internal/utils/linkedlist" + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) func IsEnabled() bool { diff --git a/internal/utils/bfs/fs_options.go b/internal/utils/bfs/fs_options.go index 57436aa..28283c1 100644 --- a/internal/utils/bfs/fs_options.go +++ b/internal/utils/bfs/fs_options.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( + "time" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" - "time" ) type FSOptions struct { diff --git a/internal/utils/bfs/fs_test.go b/internal/utils/bfs/fs_test.go index 938ed96..f3689e4 100644 --- a/internal/utils/bfs/fs_test.go +++ b/internal/utils/bfs/fs_test.go @@ -1,8 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( + "io" + "os" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/linkedlist" @@ -11,9 +15,6 @@ import ( _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/types" - "io" - "os" - "testing" ) func TestFS_OpenFileWriter(t *testing.T) { @@ -144,7 +145,7 @@ func TestFS_OpenFileWriter_Close(t *testing.T) { } for i := 0; i < count; i++ { - //t.Log("open", i) + // t.Log("open", i) writer, err := fs.OpenFileWriter(bfs.Hash(types.String(i)), -1, false) if err != nil { t.Fatal(err) diff --git a/internal/utils/bfs/gzip_reader_pool.go b/internal/utils/bfs/gzip_reader_pool.go index 794cba9..9317bba 100644 --- a/internal/utils/bfs/gzip_reader_pool.go +++ b/internal/utils/bfs/gzip_reader_pool.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/percpu" - "github.com/klauspost/compress/gzip" "io" "runtime" + + "github.com/TeaOSLab/EdgeNode/internal/utils/percpu" + "github.com/klauspost/compress/gzip" ) var SharedDecompressPool = NewGzipReaderPool() diff --git a/internal/utils/bfs/gzip_writer_pool.go b/internal/utils/bfs/gzip_writer_pool.go index 9835437..df83555 100644 --- a/internal/utils/bfs/gzip_writer_pool.go +++ b/internal/utils/bfs/gzip_writer_pool.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/percpu" - "github.com/klauspost/compress/gzip" "io" "runtime" + + "github.com/TeaOSLab/EdgeNode/internal/utils/percpu" + "github.com/klauspost/compress/gzip" ) var SharedCompressPool = NewGzipWriterPool() diff --git a/internal/utils/bfs/hash.go b/internal/utils/bfs/hash.go index 6f1d4d4..607e036 100644 --- a/internal/utils/bfs/hash.go +++ b/internal/utils/bfs/hash.go @@ -1,9 +1,10 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( "fmt" + stringutil "github.com/iwind/TeaGo/utils/string" ) diff --git a/internal/utils/bfs/hash_test.go b/internal/utils/bfs/hash_test.go index 8c01c69..76261ff 100644 --- a/internal/utils/bfs/hash_test.go +++ b/internal/utils/bfs/hash_test.go @@ -1,14 +1,15 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" - "github.com/iwind/TeaGo/assert" "math/rand" "strconv" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" + "github.com/iwind/TeaGo/assert" ) func TestCheckHash(t *testing.T) { diff --git a/internal/utils/bfs/meta_block.go b/internal/utils/bfs/meta_block.go index 00f9e94..b8849c3 100644 --- a/internal/utils/bfs/meta_block.go +++ b/internal/utils/bfs/meta_block.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs diff --git a/internal/utils/bfs/meta_block_test.go b/internal/utils/bfs/meta_block_test.go index 9284b14..47abeaf 100644 --- a/internal/utils/bfs/meta_block_test.go +++ b/internal/utils/bfs/meta_block_test.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( "bytes" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" "github.com/iwind/TeaGo/assert" - "testing" ) func TestMetaBlock(t *testing.T) { diff --git a/internal/utils/bfs/meta_file.go b/internal/utils/bfs/meta_file.go index 62ce247..801885e 100644 --- a/internal/utils/bfs/meta_file.go +++ b/internal/utils/bfs/meta_file.go @@ -1,15 +1,16 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs import ( "bytes" "encoding/binary" - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "io" "os" "sync" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) const MFileExt = ".m" diff --git a/internal/utils/bfs/meta_file_test.go b/internal/utils/bfs/meta_file_test.go index 0803922..637f3e3 100644 --- a/internal/utils/bfs/meta_file_test.go +++ b/internal/utils/bfs/meta_file_test.go @@ -1,15 +1,16 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs_test import ( + "sync" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/bfs" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/logs" - "sync" - "testing" - "time" ) func TestNewMetaFile(t *testing.T) { @@ -23,7 +24,7 @@ func TestNewMetaFile(t *testing.T) { var header, _ = mFile.FileHeader(bfs.Hash("123456")) logs.PrintAsJSON(header, t) - //logs.PrintAsJSON(mFile.Headers(), t) + // logs.PrintAsJSON(mFile.Headers(), t) } func TestNewMetaFile_Large(t *testing.T) { @@ -129,7 +130,7 @@ func TestMetaFile_WriteMeta(t *testing.T) { t.Fatal(err) } - //logs.PrintAsJSON(mFile.Header(hash), t) + // logs.PrintAsJSON(mFile.Header(hash), t) } func TestMetaFile_Write(t *testing.T) { diff --git a/internal/utils/bfs/threads_limiter.go b/internal/utils/bfs/threads_limiter.go index c76f7a2..2967ef9 100644 --- a/internal/utils/bfs/threads_limiter.go +++ b/internal/utils/bfs/threads_limiter.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package bfs diff --git a/internal/utils/buffer_pool_test.go b/internal/utils/buffer_pool_test.go index 71eac1d..d60df7c 100644 --- a/internal/utils/buffer_pool_test.go +++ b/internal/utils/buffer_pool_test.go @@ -1,12 +1,13 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/utils" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils" ) func TestNewBufferPool(t *testing.T) { diff --git a/internal/utils/byte/utils.go b/internal/utils/byte/utils.go index d0eb611..38f5296 100644 --- a/internal/utils/byte/utils.go +++ b/internal/utils/byte/utils.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package byteutils diff --git a/internal/utils/byte/utils_test.go b/internal/utils/byte/utils_test.go index aa91104..88365eb 100644 --- a/internal/utils/byte/utils_test.go +++ b/internal/utils/byte/utils_test.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package byteutils_test import ( "bytes" + "testing" + byteutils "github.com/TeaOSLab/EdgeNode/internal/utils/byte" "github.com/iwind/TeaGo/assert" - "testing" ) func TestCopy(t *testing.T) { diff --git a/internal/utils/bytepool/byte_pool_test.go b/internal/utils/bytepool/byte_pool_test.go index 560c1df..093e3ec 100644 --- a/internal/utils/bytepool/byte_pool_test.go +++ b/internal/utils/bytepool/byte_pool_test.go @@ -2,10 +2,11 @@ package bytepool_test import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/utils/bytepool" "runtime" "sync" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/bytepool" ) func TestBytePool_Memory(t *testing.T) { diff --git a/internal/utils/cachehits/stat.go b/internal/utils/cachehits/stat.go index 417903c..d72f63d 100644 --- a/internal/utils/cachehits/stat.go +++ b/internal/utils/cachehits/stat.go @@ -1,16 +1,17 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package cachehits import ( + "sync" + "sync/atomic" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/TeaOSLab/EdgeNode/internal/utils/idles" memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/iwind/TeaGo/Tea" - "sync" - "sync/atomic" - "time" ) const countSamples = 100_000 diff --git a/internal/utils/cachehits/stat_test.go b/internal/utils/cachehits/stat_test.go index 8845f76..8be7ba8 100644 --- a/internal/utils/cachehits/stat_test.go +++ b/internal/utils/cachehits/stat_test.go @@ -1,17 +1,18 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package cachehits_test import ( + "runtime" + "strconv" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/cachehits" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "runtime" - "strconv" - "testing" - "time" ) func TestNewStat(t *testing.T) { diff --git a/internal/utils/clock/manager.go b/internal/utils/clock/manager.go index a9f4c6d..c57c0cc 100644 --- a/internal/utils/clock/manager.go +++ b/internal/utils/clock/manager.go @@ -1,10 +1,14 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package clock import ( "encoding/binary" "fmt" + "net" + "runtime" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -12,9 +16,6 @@ import ( executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" timeutil "github.com/iwind/TeaGo/utils/time" - "net" - "runtime" - "time" ) var hasSynced = false diff --git a/internal/utils/clock/manager_test.go b/internal/utils/clock/manager_test.go index e2eb456..d369b84 100644 --- a/internal/utils/clock/manager_test.go +++ b/internal/utils/clock/manager_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package clock_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/clock" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "testing" ) func TestReadServer(t *testing.T) { diff --git a/internal/utils/clock/ntp_packet.go b/internal/utils/clock/ntp_packet.go index 2d942fa..4c5c484 100644 --- a/internal/utils/clock/ntp_packet.go +++ b/internal/utils/clock/ntp_packet.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package clock diff --git a/internal/utils/common_files.go b/internal/utils/common_files.go index d8d97cb..3940153 100644 --- a/internal/utils/common_files.go +++ b/internal/utils/common_files.go @@ -1,10 +1,11 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "strings" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) var commonFileExtensionsMap = map[string]zero.Zero{ diff --git a/internal/utils/common_files_test.go b/internal/utils/common_files_test.go index 7f019f6..4f789d3 100644 --- a/internal/utils/common_files_test.go +++ b/internal/utils/common_files_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/iwind/TeaGo/assert" - "testing" ) func TestIsCommonFileExtension(t *testing.T) { diff --git a/internal/utils/conns/conn_no_stat.go b/internal/utils/conns/conn_no_stat.go index 825c492..653deb0 100644 --- a/internal/utils/conns/conn_no_stat.go +++ b/internal/utils/conns/conn_no_stat.go @@ -1,12 +1,13 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package connutils import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "net" "sync" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) // 记录不需要带宽统计的连接 diff --git a/internal/utils/counters/counter.go b/internal/utils/counters/counter.go index 1c0d2a9..ac41159 100644 --- a/internal/utils/counters/counter.go +++ b/internal/utils/counters/counter.go @@ -1,15 +1,16 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package counters import ( + "sync" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" syncutils "github.com/TeaOSLab/EdgeNode/internal/utils/sync" "github.com/cespare/xxhash/v2" - "sync" - "time" ) const maxItemsPerGroup = 50_000 diff --git a/internal/utils/counters/counter_test.go b/internal/utils/counters/counter_test.go index 772c0ad..b40b3bf 100644 --- a/internal/utils/counters/counter_test.go +++ b/internal/utils/counters/counter_test.go @@ -1,19 +1,20 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package counters_test import ( + "runtime" + "runtime/debug" + "sync/atomic" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/counters" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "runtime" - "runtime/debug" - "sync/atomic" - "testing" - "time" ) func TestCounter_Increase(t *testing.T) { @@ -124,7 +125,7 @@ func BenchmarkCounter_Increase(b *testing.B) { } }) - //b.Log(counter.TotalItems()) + // b.Log(counter.TotalItems()) } func BenchmarkCounter_IncreaseKey(b *testing.B) { @@ -149,7 +150,7 @@ func BenchmarkCounter_IncreaseKey(b *testing.B) { } }) - //b.Log(counter.TotalItems()) + // b.Log(counter.TotalItems()) } func BenchmarkCounter_IncreaseKey2(b *testing.B) { @@ -173,7 +174,7 @@ func BenchmarkCounter_IncreaseKey2(b *testing.B) { } }) - //b.Log(counter.TotalItems()) + // b.Log(counter.TotalItems()) } func BenchmarkCounter_GC(b *testing.B) { @@ -193,5 +194,5 @@ func BenchmarkCounter_GC(b *testing.B) { } }) - //b.Log(counter.TotalItems()) + // b.Log(counter.TotalItems()) } diff --git a/internal/utils/counters/item.go b/internal/utils/counters/item.go index a3d4b6a..1374da6 100644 --- a/internal/utils/counters/item.go +++ b/internal/utils/counters/item.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package counters diff --git a/internal/utils/counters/item_test.go b/internal/utils/counters/item_test.go index 7e12a64..795542e 100644 --- a/internal/utils/counters/item_test.go +++ b/internal/utils/counters/item_test.go @@ -1,16 +1,17 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package counters_test import ( + "runtime" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/counters" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "runtime" - "testing" - "time" ) func TestItem_Increase(t *testing.T) { diff --git a/internal/utils/dbs/batch.go b/internal/utils/dbs/batch.go index e5e244c..f04508d 100644 --- a/internal/utils/dbs/batch.go +++ b/internal/utils/dbs/batch.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dbs import ( "database/sql" - "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "time" + + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" ) type batchItem struct { diff --git a/internal/utils/dbs/db.go b/internal/utils/dbs/db.go index 72bd393..9944e86 100644 --- a/internal/utils/dbs/db.go +++ b/internal/utils/dbs/db.go @@ -7,15 +7,16 @@ import ( "database/sql" "errors" "fmt" + "os" + "strings" + "sync" + "time" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils/fs" _ "github.com/mattn/go-sqlite3" - "os" - "strings" - "sync" - "time" ) const ( diff --git a/internal/utils/dbs/db_test.go b/internal/utils/dbs/db_test.go index c88791d..d664fa9 100644 --- a/internal/utils/dbs/db_test.go +++ b/internal/utils/dbs/db_test.go @@ -1,11 +1,12 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dbs_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" "net/url" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" ) func TestParseDSN(t *testing.T) { diff --git a/internal/utils/dbs/query_stat_manager.go b/internal/utils/dbs/query_stat_manager.go index f9dfd4e..95e2d12 100644 --- a/internal/utils/dbs/query_stat_manager.go +++ b/internal/utils/dbs/query_stat_manager.go @@ -4,14 +4,15 @@ package dbs import ( "fmt" - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/events" - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" - "github.com/iwind/TeaGo/logs" "sort" "strings" "sync" "time" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + "github.com/TeaOSLab/EdgeNode/internal/events" + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" + "github.com/iwind/TeaGo/logs" ) func init() { diff --git a/internal/utils/dbs/query_stat_manager_test.go b/internal/utils/dbs/query_stat_manager_test.go index c7ed687..01bb788 100644 --- a/internal/utils/dbs/query_stat_manager_test.go +++ b/internal/utils/dbs/query_stat_manager_test.go @@ -3,10 +3,11 @@ package dbs_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" - "github.com/iwind/TeaGo/logs" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" + "github.com/iwind/TeaGo/logs" ) func TestQueryStatManager(t *testing.T) { diff --git a/internal/utils/dbs/stmt.go b/internal/utils/dbs/stmt.go index 0a59d79..9e9477d 100644 --- a/internal/utils/dbs/stmt.go +++ b/internal/utils/dbs/stmt.go @@ -5,6 +5,7 @@ package dbs import ( "context" "database/sql" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" ) diff --git a/internal/utils/dbs/utils.go b/internal/utils/dbs/utils.go index aefdd82..18415ad 100644 --- a/internal/utils/dbs/utils.go +++ b/internal/utils/dbs/utils.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dbs diff --git a/internal/utils/encrypt.go b/internal/utils/encrypt.go index 535d69a..76604c1 100644 --- a/internal/utils/encrypt.go +++ b/internal/utils/encrypt.go @@ -9,6 +9,7 @@ import ( "encoding/base64" "encoding/json" "errors" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" diff --git a/internal/utils/encrypt/magic_key_test.go b/internal/utils/encrypt/magic_key_test.go index cf9b2fc..c9afa02 100644 --- a/internal/utils/encrypt/magic_key_test.go +++ b/internal/utils/encrypt/magic_key_test.go @@ -1,8 +1,9 @@ package encrypt_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" ) func TestMagicKeyEncode(t *testing.T) { diff --git a/internal/utils/encrypt/method_aes_128_cfb_test.go b/internal/utils/encrypt/method_aes_128_cfb_test.go index c74a577..aed4c46 100644 --- a/internal/utils/encrypt/method_aes_128_cfb_test.go +++ b/internal/utils/encrypt/method_aes_128_cfb_test.go @@ -1,10 +1,11 @@ package encrypt_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" "runtime" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" ) func TestAES128CFBMethod_Encrypt(t *testing.T) { diff --git a/internal/utils/encrypt/method_aes_192_cfb_test.go b/internal/utils/encrypt/method_aes_192_cfb_test.go index dd3c3c3..08cb4c8 100644 --- a/internal/utils/encrypt/method_aes_192_cfb_test.go +++ b/internal/utils/encrypt/method_aes_192_cfb_test.go @@ -1,10 +1,11 @@ package encrypt_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" "runtime" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" ) func TestAES192CFBMethod_Encrypt(t *testing.T) { diff --git a/internal/utils/encrypt/method_aes_256_cfb_test.go b/internal/utils/encrypt/method_aes_256_cfb_test.go index df494bd..601a7c5 100644 --- a/internal/utils/encrypt/method_aes_256_cfb_test.go +++ b/internal/utils/encrypt/method_aes_256_cfb_test.go @@ -1,8 +1,9 @@ package encrypt_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" ) func TestAES256CFBMethod_Encrypt(t *testing.T) { diff --git a/internal/utils/encrypt/method_raw_test.go b/internal/utils/encrypt/method_raw_test.go index 4ca2ed9..20ecae2 100644 --- a/internal/utils/encrypt/method_raw_test.go +++ b/internal/utils/encrypt/method_raw_test.go @@ -1,8 +1,9 @@ package encrypt_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" ) func TestRawMethod_Encrypt(t *testing.T) { diff --git a/internal/utils/encrypt/method_utils_test.go b/internal/utils/encrypt/method_utils_test.go index 3718272..5ddfe10 100644 --- a/internal/utils/encrypt/method_utils_test.go +++ b/internal/utils/encrypt/method_utils_test.go @@ -1,8 +1,9 @@ package encrypt_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/encrypt" ) func TestFindMethodInstance(t *testing.T) { diff --git a/internal/utils/encrypt_test.go b/internal/utils/encrypt_test.go index 1eecc06..34b0fb6 100644 --- a/internal/utils/encrypt_test.go +++ b/internal/utils/encrypt_test.go @@ -3,11 +3,12 @@ package utils_test import ( + "sync" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/maps" - "sync" - "testing" ) func TestSimpleEncrypt(t *testing.T) { diff --git a/internal/utils/exec/cmd.go b/internal/utils/exec/cmd.go index e1cd3f8..5492418 100644 --- a/internal/utils/exec/cmd.go +++ b/internal/utils/exec/cmd.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package executils diff --git a/internal/utils/exec/cmd_test.go b/internal/utils/exec/cmd_test.go index b1bffda..a2f997c 100644 --- a/internal/utils/exec/cmd_test.go +++ b/internal/utils/exec/cmd_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package executils_test import ( - executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" "testing" "time" + + executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" ) func TestNewTimeoutCmd_Sleep(t *testing.T) { diff --git a/internal/utils/exec/look_linux.go b/internal/utils/exec/look_linux.go index 9b15835..fecff41 100644 --- a/internal/utils/exec/look_linux.go +++ b/internal/utils/exec/look_linux.go @@ -1,14 +1,15 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build linux package executils import ( - "golang.org/x/sys/unix" "io/fs" "os" "os/exec" "syscall" + + "golang.org/x/sys/unix" ) // LookPath customize our LookPath() function, to work in broken $PATH environment variable @@ -56,4 +57,3 @@ func LookPath(file string) (string, error) { Err: exec.ErrNotFound, } } - diff --git a/internal/utils/exec/look_others.go b/internal/utils/exec/look_others.go index a759c8e..38c7e94 100644 --- a/internal/utils/exec/look_others.go +++ b/internal/utils/exec/look_others.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !linux package executils diff --git a/internal/utils/exit.go b/internal/utils/exit.go index 937e26c..b0f05fa 100644 --- a/internal/utils/exit.go +++ b/internal/utils/exit.go @@ -3,8 +3,9 @@ package utils import ( - "github.com/TeaOSLab/EdgeNode/internal/events" "os" + + "github.com/TeaOSLab/EdgeNode/internal/events" ) func Exit() { diff --git a/internal/utils/expires/id_key_map_test.go b/internal/utils/expires/id_key_map_test.go index dbdc5b6..82ba514 100644 --- a/internal/utils/expires/id_key_map_test.go +++ b/internal/utils/expires/id_key_map_test.go @@ -3,10 +3,11 @@ package expires_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/expires" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/logs" - "testing" ) func TestNewIdKeyMap(t *testing.T) { diff --git a/internal/utils/expires/list.go b/internal/utils/expires/list.go index 621cc5d..97fe7b8 100644 --- a/internal/utils/expires/list.go +++ b/internal/utils/expires/list.go @@ -1,8 +1,9 @@ package expires import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) type ItemMap = map[uint64]zero.Zero diff --git a/internal/utils/expires/list_test.go b/internal/utils/expires/list_test.go index 8562c17..fa78f51 100644 --- a/internal/utils/expires/list_test.go +++ b/internal/utils/expires/list_test.go @@ -1,17 +1,18 @@ package expires_test import ( + "math" + "math/rand" + "runtime" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/expires" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/logs" timeutil "github.com/iwind/TeaGo/utils/time" - "math" - "math/rand" - "runtime" - "testing" - "time" ) func TestList_Add(t *testing.T) { diff --git a/internal/utils/expires/manager.go b/internal/utils/expires/manager.go index bbddaf5..f256173 100644 --- a/internal/utils/expires/manager.go +++ b/internal/utils/expires/manager.go @@ -3,10 +3,11 @@ package expires import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) var SharedManager = NewManager() diff --git a/internal/utils/fasttime/time_fast.go b/internal/utils/fasttime/time_fast.go index c260dc2..91a31a9 100644 --- a/internal/utils/fasttime/time_fast.go +++ b/internal/utils/fasttime/time_fast.go @@ -1,13 +1,14 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fasttime import ( + "time" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) var sharedFastTime = NewFastTime() diff --git a/internal/utils/fasttime/time_fast_test.go b/internal/utils/fasttime/time_fast_test.go index 724247a..44537f9 100644 --- a/internal/utils/fasttime/time_fast_test.go +++ b/internal/utils/fasttime/time_fast_test.go @@ -1,12 +1,13 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fasttime_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - timeutil "github.com/iwind/TeaGo/utils/time" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + timeutil "github.com/iwind/TeaGo/utils/time" ) func TestFastTime_Unix(t *testing.T) { diff --git a/internal/utils/fnv/hash_test.go b/internal/utils/fnv/hash_test.go index 831a57b..43e8f82 100644 --- a/internal/utils/fnv/hash_test.go +++ b/internal/utils/fnv/hash_test.go @@ -3,9 +3,10 @@ package fnv_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/fnv" "github.com/iwind/TeaGo/types" - "testing" ) func TestHash(t *testing.T) { diff --git a/internal/utils/fs/disk.go b/internal/utils/fs/disk.go index 91f2595..ab21c8e 100644 --- a/internal/utils/fs/disk.go +++ b/internal/utils/fs/disk.go @@ -1,14 +1,15 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils import ( "bytes" "encoding/json" - "github.com/iwind/TeaGo/Tea" "math" "os" "time" + + "github.com/iwind/TeaGo/Tea" ) const diskSpeedDataFile = "disk.speed.json" diff --git a/internal/utils/fs/disk_test_test.go b/internal/utils/fs/disk_test_test.go index c20fd7a..1409915 100644 --- a/internal/utils/fs/disk_test_test.go +++ b/internal/utils/fs/disk_test_test.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils_test import ( - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" "testing" + + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" ) func TestCheckDiskWritingSpeed(t *testing.T) { @@ -13,4 +14,4 @@ func TestCheckDiskWritingSpeed(t *testing.T) { func TestCheckDiskIsFast(t *testing.T) { t.Log(fsutils.CheckDiskIsFast()) -} \ No newline at end of file +} diff --git a/internal/utils/fs/file.go b/internal/utils/fs/file.go index c3588cf..87db7b7 100644 --- a/internal/utils/fs/file.go +++ b/internal/utils/fs/file.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils diff --git a/internal/utils/fs/file_test.go b/internal/utils/fs/file_test.go index d9bd6d2..588b22b 100644 --- a/internal/utils/fs/file_test.go +++ b/internal/utils/fs/file_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils_test import ( + "testing" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" "github.com/iwind/TeaGo/assert" - "testing" ) func TestFileFlags(t *testing.T) { diff --git a/internal/utils/fs/limiter.go b/internal/utils/fs/limiter.go index 76fb50e..896dc63 100644 --- a/internal/utils/fs/limiter.go +++ b/internal/utils/fs/limiter.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils diff --git a/internal/utils/fs/limiter_test.go b/internal/utils/fs/limiter_test.go index 32acfd6..5de3752 100644 --- a/internal/utils/fs/limiter_test.go +++ b/internal/utils/fs/limiter_test.go @@ -1,15 +1,16 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils_test import ( - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/assert" "math/rand" "sync" "testing" "time" + + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/assert" ) func TestLimiter_SetThreads(t *testing.T) { diff --git a/internal/utils/fs/locker.go b/internal/utils/fs/locker.go index 2f6afbc..a6eb420 100644 --- a/internal/utils/fs/locker.go +++ b/internal/utils/fs/locker.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils diff --git a/internal/utils/fs/locker_test.go b/internal/utils/fs/locker_test.go index 07d5228..d79c768 100644 --- a/internal/utils/fs/locker_test.go +++ b/internal/utils/fs/locker_test.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/fs" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fs" ) func TestLocker_Lock(t *testing.T) { diff --git a/internal/utils/fs/os.go b/internal/utils/fs/os.go index 1dab308..d7b6307 100644 --- a/internal/utils/fs/os.go +++ b/internal/utils/fs/os.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils diff --git a/internal/utils/fs/os_test.go b/internal/utils/fs/os_test.go index c54259b..5601ab1 100644 --- a/internal/utils/fs/os_test.go +++ b/internal/utils/fs/os_test.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils_test import ( - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" - "github.com/iwind/TeaGo/assert" "os" "testing" + + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" + "github.com/iwind/TeaGo/assert" ) func TestOpenFile(t *testing.T) { diff --git a/internal/utils/fs/stat.go b/internal/utils/fs/stat.go index 0cf59ee..579406e 100644 --- a/internal/utils/fs/stat.go +++ b/internal/utils/fs/stat.go @@ -1,11 +1,12 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils import ( + "sync" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "golang.org/x/sys/unix" - "sync" ) // StatDevice device contains the path diff --git a/internal/utils/fs/stat_test.go b/internal/utils/fs/stat_test.go index 0adce53..34cc139 100644 --- a/internal/utils/fs/stat_test.go +++ b/internal/utils/fs/stat_test.go @@ -1,12 +1,13 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils_test import ( - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" "sync" "testing" "time" + + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" ) func TestStat(t *testing.T) { diff --git a/internal/utils/fs/status.go b/internal/utils/fs/status.go index 98f4662..dda91c8 100644 --- a/internal/utils/fs/status.go +++ b/internal/utils/fs/status.go @@ -1,15 +1,16 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils import ( "encoding/json" + "os" + "time" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/iwind/TeaGo/Tea" "github.com/shirou/gopsutil/v3/load" - "os" - "time" ) type Speed int diff --git a/internal/utils/fs/status_test.go b/internal/utils/fs/status_test.go index 54f3ad2..1d20ceb 100644 --- a/internal/utils/fs/status_test.go +++ b/internal/utils/fs/status_test.go @@ -1,11 +1,12 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package fsutils_test import ( - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" "testing" "time" + + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" ) func TestWaitLoad(t *testing.T) { diff --git a/internal/utils/get.go b/internal/utils/get.go index 6630f7f..369d901 100644 --- a/internal/utils/get.go +++ b/internal/utils/get.go @@ -1,9 +1,10 @@ package utils import ( - "github.com/iwind/TeaGo/types" "reflect" "regexp" + + "github.com/iwind/TeaGo/types" ) var RegexpDigitNumber = regexp.MustCompile(`^\d+$`) diff --git a/internal/utils/goman/lib.go b/internal/utils/goman/lib.go index 7c89572..c4d0d35 100644 --- a/internal/utils/goman/lib.go +++ b/internal/utils/goman/lib.go @@ -3,10 +3,11 @@ package goman import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "runtime" "sync" "time" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) var locker = &sync.Mutex{} diff --git a/internal/utils/goman/lib_test.go b/internal/utils/goman/lib_test.go index 838041d..5583041 100644 --- a/internal/utils/goman/lib_test.go +++ b/internal/utils/goman/lib_test.go @@ -3,9 +3,10 @@ package goman_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" ) func TestNew(t *testing.T) { diff --git a/internal/utils/goman/task_group.go b/internal/utils/goman/task_group.go index fda2339..277f840 100644 --- a/internal/utils/goman/task_group.go +++ b/internal/utils/goman/task_group.go @@ -1,11 +1,12 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package goman import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "runtime" "sync" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) type TaskGroup struct { diff --git a/internal/utils/goman/task_group_test.go b/internal/utils/goman/task_group_test.go index 4951357..d716905 100644 --- a/internal/utils/goman/task_group_test.go +++ b/internal/utils/goman/task_group_test.go @@ -1,11 +1,12 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package goman_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "runtime" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" ) func TestNewTaskGroup(t *testing.T) { diff --git a/internal/utils/http_test.go b/internal/utils/http_test.go index 6b5af02..e0c77e1 100644 --- a/internal/utils/http_test.go +++ b/internal/utils/http_test.go @@ -1,9 +1,10 @@ package utils import ( - "github.com/iwind/TeaGo/assert" "testing" "time" + + "github.com/iwind/TeaGo/assert" ) func TestNewHTTPClient(t *testing.T) { diff --git a/internal/utils/idles/run.go b/internal/utils/idles/run.go index 6ede0cf..7399490 100644 --- a/internal/utils/idles/run.go +++ b/internal/utils/idles/run.go @@ -1,19 +1,20 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package idles import ( "encoding/json" - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" - "github.com/iwind/TeaGo/Tea" - "github.com/shirou/gopsutil/v3/load" "math" "os" "slices" "sort" "time" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" + "github.com/iwind/TeaGo/Tea" + "github.com/shirou/gopsutil/v3/load" ) const maxSamples = 7 diff --git a/internal/utils/idles/run_test.go b/internal/utils/idles/run_test.go index 100f4f2..8c30c48 100644 --- a/internal/utils/idles/run_test.go +++ b/internal/utils/idles/run_test.go @@ -1,15 +1,16 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package idles_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/idles" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestCheckHourlyLoad(t *testing.T) { diff --git a/internal/utils/ip_test.go b/internal/utils/ip_test.go index 536cc85..6672c1c 100644 --- a/internal/utils/ip_test.go +++ b/internal/utils/ip_test.go @@ -1,9 +1,10 @@ package utils_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/iwind/TeaGo/assert" - "testing" ) func TestIsLocalIP(t *testing.T) { diff --git a/internal/utils/jsonutils/map.go b/internal/utils/jsonutils/map.go index 29d715c..03bf3ab 100644 --- a/internal/utils/jsonutils/map.go +++ b/internal/utils/jsonutils/map.go @@ -4,6 +4,7 @@ package jsonutils import ( "encoding/json" + "github.com/iwind/TeaGo/maps" ) diff --git a/internal/utils/jsonutils/map_test.go b/internal/utils/jsonutils/map_test.go index 0c0214d..6db020b 100644 --- a/internal/utils/jsonutils/map_test.go +++ b/internal/utils/jsonutils/map_test.go @@ -3,9 +3,10 @@ package jsonutils import ( + "testing" + "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/maps" - "testing" ) func TestMapToObject(t *testing.T) { diff --git a/internal/utils/jsonutils/utils_test.go b/internal/utils/jsonutils/utils_test.go index 56ca3ef..96f9732 100644 --- a/internal/utils/jsonutils/utils_test.go +++ b/internal/utils/jsonutils/utils_test.go @@ -1,12 +1,13 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package jsonutils_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/jsonutils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/maps" - "testing" ) func TestEqual(t *testing.T) { diff --git a/internal/utils/kvstore/db.go b/internal/utils/kvstore/db.go index 444f38b..3245800 100644 --- a/internal/utils/kvstore/db.go +++ b/internal/utils/kvstore/db.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore import ( "errors" - "github.com/cockroachdb/pebble" "sync" + + "github.com/cockroachdb/pebble" ) type DB struct { diff --git a/internal/utils/kvstore/db_test.go b/internal/utils/kvstore/db_test.go index ddfd369..020eb07 100644 --- a/internal/utils/kvstore/db_test.go +++ b/internal/utils/kvstore/db_test.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/cockroachdb/pebble" - "testing" ) func TestNewDB(t *testing.T) { diff --git a/internal/utils/kvstore/errors.go b/internal/utils/kvstore/errors.go index 4468228..d0cffd5 100644 --- a/internal/utils/kvstore/errors.go +++ b/internal/utils/kvstore/errors.go @@ -1,10 +1,11 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore import ( "errors" "fmt" + "github.com/cockroachdb/pebble" ) diff --git a/internal/utils/kvstore/item.go b/internal/utils/kvstore/item.go index a6187cc..079e7df 100644 --- a/internal/utils/kvstore/item.go +++ b/internal/utils/kvstore/item.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/iterator_options.go b/internal/utils/kvstore/iterator_options.go index 47d8fe6..17df737 100644 --- a/internal/utils/kvstore/iterator_options.go +++ b/internal/utils/kvstore/iterator_options.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/logger.go b/internal/utils/kvstore/logger.go index 25e3fd4..4acfa17 100644 --- a/internal/utils/kvstore/logger.go +++ b/internal/utils/kvstore/logger.go @@ -1,9 +1,10 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore import ( "fmt" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" ) diff --git a/internal/utils/kvstore/options.go b/internal/utils/kvstore/options.go index f58e6c5..c64a372 100644 --- a/internal/utils/kvstore/options.go +++ b/internal/utils/kvstore/options.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/query.go b/internal/utils/kvstore/query.go index b37f034..92415f5 100644 --- a/internal/utils/kvstore/query.go +++ b/internal/utils/kvstore/query.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore @@ -6,6 +6,7 @@ import ( "bytes" "errors" "fmt" + byteutils "github.com/TeaOSLab/EdgeNode/internal/utils/byte" ) @@ -132,37 +133,37 @@ func (this *Query[T]) FieldOffset(fieldOffset []byte) *Query[T] { return this } -//func (this *Query[T]) FieldLt(value any) *Query[T] { +// func (this *Query[T]) FieldLt(value any) *Query[T] { // this.fieldOperators = append(this.fieldOperators, QueryOperatorInfo{ // Operator: QueryOperatorLt, // Value: value, // }) // return this -//} +// } // -//func (this *Query[T]) FieldLte(value any) *Query[T] { +// func (this *Query[T]) FieldLte(value any) *Query[T] { // this.fieldOperators = append(this.fieldOperators, QueryOperatorInfo{ // Operator: QueryOperatorLte, // Value: value, // }) // return this -//} +// } // -//func (this *Query[T]) FieldGt(value any) *Query[T] { +// func (this *Query[T]) FieldGt(value any) *Query[T] { // this.fieldOperators = append(this.fieldOperators, QueryOperatorInfo{ // Operator: QueryOperatorGt, // Value: value, // }) // return this -//} +// } // -//func (this *Query[T]) FieldGte(value any) *Query[T] { +// func (this *Query[T]) FieldGte(value any) *Query[T] { // this.fieldOperators = append(this.fieldOperators, QueryOperatorInfo{ // Operator: QueryOperatorGte, // Value: value, // }) // return this -//} +// } func (this *Query[T]) FindAll(fn IteratorFunc[T]) (err error) { if this.table != nil && this.table.isClosed { diff --git a/internal/utils/kvstore/query_test.go b/internal/utils/kvstore/query_test.go index 88e2672..f4c07a6 100644 --- a/internal/utils/kvstore/query_test.go +++ b/internal/utils/kvstore/query_test.go @@ -1,14 +1,15 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( "fmt" - "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "runtime" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" ) func TestQuery_FindAll(t *testing.T) { @@ -228,8 +229,8 @@ func TestQuery_FindAll_Field(t *testing.T) { err := table. Query(). FieldAsc("expiresAt"). - //KeysOnly(). - //FieldLt(1710848959). + // KeysOnly(). + // FieldLt(1710848959). Limit(3). FindAll(func(tx *kvstore.Tx[*testCachedItem], item kvstore.Item[*testCachedItem]) (goNext bool, err error) { t.Log(item.Key, "=>", item.Value) @@ -247,8 +248,8 @@ func TestQuery_FindAll_Field(t *testing.T) { err := table. Query(). FieldAsc("expiresAt"). - //KeysOnly(). - //FieldLt(1710848959). + // KeysOnly(). + // FieldLt(1710848959). FieldOffset(lastFieldKey). Limit(3). FindAll(func(tx *kvstore.Tx[*testCachedItem], item kvstore.Item[*testCachedItem]) (goNext bool, err error) { diff --git a/internal/utils/kvstore/store.go b/internal/utils/kvstore/store.go index 085c934..0721611 100644 --- a/internal/utils/kvstore/store.go +++ b/internal/utils/kvstore/store.go @@ -1,21 +1,22 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore import ( "errors" "fmt" + "io" + "os" + "path/filepath" + "strings" + "sync" + "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/cockroachdb/pebble" "github.com/iwind/TeaGo/Tea" - "io" - "os" - "path/filepath" - "strings" - "sync" ) const StoreSuffix = ".store" diff --git a/internal/utils/kvstore/store_test.go b/internal/utils/kvstore/store_test.go index 9638988..6743c4f 100644 --- a/internal/utils/kvstore/store_test.go +++ b/internal/utils/kvstore/store_test.go @@ -1,16 +1,17 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( + "sync" + "testing" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" "github.com/cockroachdb/pebble" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/assert" _ "github.com/iwind/TeaGo/bootstrap" - "sync" - "testing" - "time" ) func TestMain(m *testing.M) { diff --git a/internal/utils/kvstore/table.go b/internal/utils/kvstore/table.go index 9d017bd..5fb4301 100644 --- a/internal/utils/kvstore/table.go +++ b/internal/utils/kvstore/table.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore @@ -7,9 +7,10 @@ import ( "encoding/binary" "errors" "fmt" + "sync" + "github.com/cockroachdb/pebble" "github.com/iwind/TeaGo/types" - "sync" ) const ( diff --git a/internal/utils/kvstore/table_counter.go b/internal/utils/kvstore/table_counter.go index 02cc7d0..c9ca745 100644 --- a/internal/utils/kvstore/table_counter.go +++ b/internal/utils/kvstore/table_counter.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/table_counter_test.go b/internal/utils/kvstore/table_counter_test.go index d187a92..777f0b3 100644 --- a/internal/utils/kvstore/table_counter_test.go +++ b/internal/utils/kvstore/table_counter_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" "runtime" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" ) func TestCounterTable_Increase(t *testing.T) { diff --git a/internal/utils/kvstore/table_field.go b/internal/utils/kvstore/table_field.go index d784420..1797b77 100644 --- a/internal/utils/kvstore/table_field.go +++ b/internal/utils/kvstore/table_field.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/table_field_test.go b/internal/utils/kvstore/table_field_test.go index 38f0323..4393881 100644 --- a/internal/utils/kvstore/table_field_test.go +++ b/internal/utils/kvstore/table_field_test.go @@ -1,16 +1,17 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( "encoding/binary" "errors" - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "strconv" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" ) type testCachedItem struct { @@ -103,7 +104,7 @@ func TestTable_AddField_Many(t *testing.T) { return } - //runtime.GOMAXPROCS(1) + // runtime.GOMAXPROCS(1) var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{}) @@ -161,7 +162,7 @@ func TestTable_AddField_Delete_Many(t *testing.T) { return } - //runtime.GOMAXPROCS(1) + // runtime.GOMAXPROCS(1) var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{}) diff --git a/internal/utils/kvstore/table_interface.go b/internal/utils/kvstore/table_interface.go index fd486e5..cf50c0a 100644 --- a/internal/utils/kvstore/table_interface.go +++ b/internal/utils/kvstore/table_interface.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/table_test.go b/internal/utils/kvstore/table_test.go index 3f120b8..54123db 100644 --- a/internal/utils/kvstore/table_test.go +++ b/internal/utils/kvstore/table_test.go @@ -1,18 +1,19 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( "fmt" - "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/assert" - "github.com/iwind/TeaGo/types" "math/rand" "runtime" "strconv" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/assert" + "github.com/iwind/TeaGo/types" ) func TestTable_Set(t *testing.T) { @@ -263,7 +264,7 @@ func TestTable_Count(t *testing.T) { // watch memory usage if testutils.IsSingleTesting() { - //time.Sleep(5 * time.Minute) + // time.Sleep(5 * time.Minute) } } diff --git a/internal/utils/kvstore/tx.go b/internal/utils/kvstore/tx.go index 070c06f..4656f5d 100644 --- a/internal/utils/kvstore/tx.go +++ b/internal/utils/kvstore/tx.go @@ -1,10 +1,11 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore import ( "errors" "fmt" + "github.com/cockroachdb/pebble" ) diff --git a/internal/utils/kvstore/tx_test.go b/internal/utils/kvstore/tx_test.go index d0268d8..a36e382 100644 --- a/internal/utils/kvstore/tx_test.go +++ b/internal/utils/kvstore/tx_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( "fmt" - "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" ) func TestTable_ReadTx(t *testing.T) { diff --git a/internal/utils/kvstore/utils.go b/internal/utils/kvstore/utils.go index 79008e8..e583907 100644 --- a/internal/utils/kvstore/utils.go +++ b/internal/utils/kvstore/utils.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/utils_test.go b/internal/utils/kvstore/utils_test.go index 5ffcdb5..d67a865 100644 --- a/internal/utils/kvstore/utils_test.go +++ b/internal/utils/kvstore/utils_test.go @@ -1,13 +1,14 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/assert" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestRemoveDB(t *testing.T) { diff --git a/internal/utils/kvstore/value_encode_int.go b/internal/utils/kvstore/value_encode_int.go index f47896a..d6d7438 100644 --- a/internal/utils/kvstore/value_encode_int.go +++ b/internal/utils/kvstore/value_encode_int.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore import ( "encoding/binary" + "strconv" + "github.com/iwind/TeaGo/types" "golang.org/x/exp/constraints" - "strconv" ) type IntValueEncoder[T constraints.Integer] struct { @@ -78,4 +79,3 @@ func (this *IntValueEncoder[T]) Decode(valueData []byte) (value T, err error) { return } - diff --git a/internal/utils/kvstore/value_encoder.go b/internal/utils/kvstore/value_encoder.go index f6db0d0..31caea0 100644 --- a/internal/utils/kvstore/value_encoder.go +++ b/internal/utils/kvstore/value_encoder.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/value_encoder_bool.go b/internal/utils/kvstore/value_encoder_bool.go index 303413e..b5aeba0 100644 --- a/internal/utils/kvstore/value_encoder_bool.go +++ b/internal/utils/kvstore/value_encoder_bool.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/value_encoder_bytes.go b/internal/utils/kvstore/value_encoder_bytes.go index 79ed051..5c232bd 100644 --- a/internal/utils/kvstore/value_encoder_bytes.go +++ b/internal/utils/kvstore/value_encoder_bytes.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/value_encoder_nil.go b/internal/utils/kvstore/value_encoder_nil.go index bc3a076..95ca06d 100644 --- a/internal/utils/kvstore/value_encoder_nil.go +++ b/internal/utils/kvstore/value_encoder_nil.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/value_encoder_string.go b/internal/utils/kvstore/value_encoder_string.go index 1bf390c..792a35e 100644 --- a/internal/utils/kvstore/value_encoder_string.go +++ b/internal/utils/kvstore/value_encoder_string.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore diff --git a/internal/utils/kvstore/value_encoder_test.go b/internal/utils/kvstore/value_encoder_test.go index 554ff84..d627a97 100644 --- a/internal/utils/kvstore/value_encoder_test.go +++ b/internal/utils/kvstore/value_encoder_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package kvstore_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/kvstore" "github.com/iwind/TeaGo/assert" - "testing" ) func TestStringValueEncoder_Encode(t *testing.T) { diff --git a/internal/utils/linkedlist/list_test.go b/internal/utils/linkedlist/list_test.go index 11e1334..53ccad2 100644 --- a/internal/utils/linkedlist/list_test.go +++ b/internal/utils/linkedlist/list_test.go @@ -3,11 +3,12 @@ package linkedlist_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/linkedlist" - "github.com/iwind/TeaGo/types" "runtime" "strconv" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/linkedlist" + "github.com/iwind/TeaGo/types" ) func TestNewList_Memory(t *testing.T) { diff --git a/internal/utils/maps/map_fixed.go b/internal/utils/maps/map_fixed.go index 7bb4184..54a86ad 100644 --- a/internal/utils/maps/map_fixed.go +++ b/internal/utils/maps/map_fixed.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package maputils diff --git a/internal/utils/maps/map_fixed_test.go b/internal/utils/maps/map_fixed_test.go index cc8f1b9..d1b7694 100644 --- a/internal/utils/maps/map_fixed_test.go +++ b/internal/utils/maps/map_fixed_test.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package maputils_test import ( - maputils "github.com/TeaOSLab/EdgeNode/internal/utils/maps" "testing" + + maputils "github.com/TeaOSLab/EdgeNode/internal/utils/maps" ) func TestNewFixedMap(t *testing.T) { diff --git a/internal/utils/mem/system.go b/internal/utils/mem/system.go index e000a7f..b9f83e9 100644 --- a/internal/utils/mem/system.go +++ b/internal/utils/mem/system.go @@ -3,10 +3,11 @@ package memutils import ( + "time" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/shirou/gopsutil/v3/mem" - "time" ) var systemTotalMemory = -1 diff --git a/internal/utils/mem/system_1.19.go b/internal/utils/mem/system_1.19.go index e97ed7c..20d4035 100644 --- a/internal/utils/mem/system_1.19.go +++ b/internal/utils/mem/system_1.19.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build go1.19 package memutils diff --git a/internal/utils/mem/system_before_1.19.go b/internal/utils/mem/system_before_1.19.go index 718c962..d2a7265 100644 --- a/internal/utils/mem/system_before_1.19.go +++ b/internal/utils/mem/system_before_1.19.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !go1.19 package memutils @@ -6,4 +6,4 @@ package memutils // 设置软内存最大值 func setMaxMemory(memoryGB int) { -} \ No newline at end of file +} diff --git a/internal/utils/mem/system_test.go b/internal/utils/mem/system_test.go index 8856d68..333ef64 100644 --- a/internal/utils/mem/system_test.go +++ b/internal/utils/mem/system_test.go @@ -3,8 +3,9 @@ package memutils_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/mem" ) func TestSystemMemoryGB(t *testing.T) { diff --git a/internal/utils/minifiers/minify.go b/internal/utils/minifiers/minify.go index a8eaaef..4b48cf0 100644 --- a/internal/utils/minifiers/minify.go +++ b/internal/utils/minifiers/minify.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package minifiers import ( - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "net/http" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) // MinifyResponse minify response body diff --git a/internal/utils/net.go b/internal/utils/net.go index 0d1fd0e..267b140 100644 --- a/internal/utils/net.go +++ b/internal/utils/net.go @@ -5,9 +5,10 @@ package utils import ( "context" - "github.com/iwind/TeaGo/logs" "net" "syscall" + + "github.com/iwind/TeaGo/logs" ) // ListenReuseAddr 监听可重用的端口 diff --git a/internal/utils/net_test.go b/internal/utils/net_test.go index 2e787e4..52a5f1a 100644 --- a/internal/utils/net_test.go +++ b/internal/utils/net_test.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils" ) func TestParseAddrHost(t *testing.T) { diff --git a/internal/utils/net_utils.go b/internal/utils/net_utils.go index fb02880..20a2cd2 100644 --- a/internal/utils/net_utils.go +++ b/internal/utils/net_utils.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils diff --git a/internal/utils/path_test.go b/internal/utils/path_test.go index f3fd35c..9566c42 100644 --- a/internal/utils/path_test.go +++ b/internal/utils/path_test.go @@ -1,8 +1,9 @@ package utils import ( - "github.com/iwind/TeaGo/assert" "testing" + + "github.com/iwind/TeaGo/assert" ) func TestCleanPath(t *testing.T) { diff --git a/internal/utils/percpu/chan.go b/internal/utils/percpu/chan.go index 63777bc..be5737f 100644 --- a/internal/utils/percpu/chan.go +++ b/internal/utils/percpu/chan.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package percpu diff --git a/internal/utils/percpu/chan_test.go b/internal/utils/percpu/chan_test.go index 038f3c1..5d2a756 100644 --- a/internal/utils/percpu/chan_test.go +++ b/internal/utils/percpu/chan_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package percpu_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/percpu" "github.com/TeaOSLab/EdgeNode/internal/utils/zero" - "testing" ) func TestChan_C(t *testing.T) { diff --git a/internal/utils/percpu/proc_id.go b/internal/utils/percpu/proc_id.go index d0cc5fa..23c54c4 100644 --- a/internal/utils/percpu/proc_id.go +++ b/internal/utils/percpu/proc_id.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package percpu diff --git a/internal/utils/ranges/range_test.go b/internal/utils/ranges/range_test.go index 241f081..ac5e1dd 100644 --- a/internal/utils/ranges/range_test.go +++ b/internal/utils/ranges/range_test.go @@ -3,9 +3,10 @@ package rangeutils_test import ( + "testing" + rangeutils "github.com/TeaOSLab/EdgeNode/internal/utils/ranges" "github.com/iwind/TeaGo/assert" - "testing" ) func TestRange(t *testing.T) { diff --git a/internal/utils/ratelimit/bandwidth.go b/internal/utils/ratelimit/bandwidth.go index 993ca96..6330741 100644 --- a/internal/utils/ratelimit/bandwidth.go +++ b/internal/utils/ratelimit/bandwidth.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package ratelimit import ( "context" - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "sync/atomic" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" ) // Bandwidth lossy bandwidth limiter diff --git a/internal/utils/ratelimit/bandwidth_test.go b/internal/utils/ratelimit/bandwidth_test.go index c87b424..56d28d8 100644 --- a/internal/utils/ratelimit/bandwidth_test.go +++ b/internal/utils/ratelimit/bandwidth_test.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package ratelimit_test import ( "context" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/ratelimit" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "testing" ) func TestBandwidth(t *testing.T) { @@ -16,8 +17,8 @@ func TestBandwidth(t *testing.T) { var bandwidth = ratelimit.NewBandwidth(32 << 10) bandwidth.Ack(context.Background(), 123) - bandwidth.Ack(context.Background(), 16 << 10) - bandwidth.Ack(context.Background(), 32 << 10) + bandwidth.Ack(context.Background(), 16<<10) + bandwidth.Ack(context.Background(), 32<<10) } func TestBandwidth_0(t *testing.T) { diff --git a/internal/utils/ratelimit/counter.go b/internal/utils/ratelimit/counter.go index 2581ecd..093f299 100644 --- a/internal/utils/ratelimit/counter.go +++ b/internal/utils/ratelimit/counter.go @@ -3,8 +3,9 @@ package ratelimit import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) type Counter struct { diff --git a/internal/utils/ratelimit/counter_test.go b/internal/utils/ratelimit/counter_test.go index 5d8b7be..d5aa0b5 100644 --- a/internal/utils/ratelimit/counter_test.go +++ b/internal/utils/ratelimit/counter_test.go @@ -3,10 +3,11 @@ package ratelimit_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/ratelimit" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/ratelimit" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" ) func TestCounter_ACK(t *testing.T) { diff --git a/internal/utils/re/regexp.go b/internal/utils/re/regexp.go index 2769ee3..ec93349 100644 --- a/internal/utils/re/regexp.go +++ b/internal/utils/re/regexp.go @@ -3,11 +3,12 @@ package re import ( - "github.com/iwind/TeaGo/types" "regexp" "regexp/syntax" "strings" "sync/atomic" + + "github.com/iwind/TeaGo/types" ) var prefixReg = regexp.MustCompile(`^\(\?([\w\s]+)\)`) // (?x) diff --git a/internal/utils/re/regexp_test.go b/internal/utils/re/regexp_test.go index eed01b4..cb339a3 100644 --- a/internal/utils/re/regexp_test.go +++ b/internal/utils/re/regexp_test.go @@ -3,12 +3,13 @@ package re_test import ( - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" - "github.com/TeaOSLab/EdgeNode/internal/utils/re" - "github.com/iwind/TeaGo/assert" "regexp" "strings" "testing" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" + "github.com/TeaOSLab/EdgeNode/internal/utils/re" + "github.com/iwind/TeaGo/assert" ) func TestRegexp(t *testing.T) { diff --git a/internal/utils/re/rune_tree_test.go b/internal/utils/re/rune_tree_test.go index 7fd5d1c..2729b91 100644 --- a/internal/utils/re/rune_tree_test.go +++ b/internal/utils/re/rune_tree_test.go @@ -3,10 +3,11 @@ package re_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/re" - "github.com/iwind/TeaGo/assert" "regexp" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/re" + "github.com/iwind/TeaGo/assert" ) func TestNewRuneTree(t *testing.T) { diff --git a/internal/utils/readers/reader_closer_byte_ranges.go b/internal/utils/readers/reader_closer_byte_ranges.go index ced5baa..d376056 100644 --- a/internal/utils/readers/reader_closer_byte_ranges.go +++ b/internal/utils/readers/reader_closer_byte_ranges.go @@ -4,12 +4,13 @@ package readers import ( "bytes" - "github.com/iwind/TeaGo/types" "io" "mime/multipart" "net/textproto" "regexp" "strings" + + "github.com/iwind/TeaGo/types" ) type OnPartReadHandler func(start int64, end int64, total int64, data []byte, header textproto.MIMEHeader) diff --git a/internal/utils/readers/reader_closer_byte_ranges_test.go b/internal/utils/readers/reader_closer_byte_ranges_test.go index df3b21a..7d8dde9 100644 --- a/internal/utils/readers/reader_closer_byte_ranges_test.go +++ b/internal/utils/readers/reader_closer_byte_ranges_test.go @@ -5,10 +5,11 @@ package readers_test import ( "bytes" "fmt" - "github.com/TeaOSLab/EdgeNode/internal/utils/readers" "io" "net/textproto" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/readers" ) func TestNewByteRangesReader(t *testing.T) { diff --git a/internal/utils/readers/reader_closer_filter_test.go b/internal/utils/readers/reader_closer_filter_test.go index 2e8fafa..d360bd9 100644 --- a/internal/utils/readers/reader_closer_filter_test.go +++ b/internal/utils/readers/reader_closer_filter_test.go @@ -5,8 +5,9 @@ package readers_test import ( "bytes" "errors" - "github.com/TeaOSLab/EdgeNode/internal/utils/readers" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/readers" ) func TestNewFilterReader(t *testing.T) { diff --git a/internal/utils/readers/reader_print.go b/internal/utils/readers/reader_print.go index 911430e..127d4e2 100644 --- a/internal/utils/readers/reader_print.go +++ b/internal/utils/readers/reader_print.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package readers diff --git a/internal/utils/runes/runes.go b/internal/utils/runes/runes.go index b13fd13..0228ccb 100644 --- a/internal/utils/runes/runes.go +++ b/internal/utils/runes/runes.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package runes diff --git a/internal/utils/runes/runes_test.go b/internal/utils/runes/runes_test.go index 51cb068..0221b19 100644 --- a/internal/utils/runes/runes_test.go +++ b/internal/utils/runes/runes_test.go @@ -1,16 +1,17 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package runes_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/re" - "github.com/TeaOSLab/EdgeNode/internal/utils/runes" - "github.com/iwind/TeaGo/assert" "regexp" "runtime" "sort" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/re" + "github.com/TeaOSLab/EdgeNode/internal/utils/runes" + "github.com/iwind/TeaGo/assert" ) func TestContainsAllWords(t *testing.T) { diff --git a/internal/utils/service.go b/internal/utils/service.go index 2c86d81..0e7bf73 100644 --- a/internal/utils/service.go +++ b/internal/utils/service.go @@ -1,14 +1,15 @@ package utils import ( - "github.com/iwind/TeaGo/Tea" - "github.com/iwind/TeaGo/files" - "github.com/iwind/TeaGo/logs" "log" "os" "path/filepath" "runtime" "sync" + + "github.com/iwind/TeaGo/Tea" + "github.com/iwind/TeaGo/files" + "github.com/iwind/TeaGo/logs" ) // ServiceManager 服务管理器 diff --git a/internal/utils/service_linux.go b/internal/utils/service_linux.go index 3228c04..a584357 100644 --- a/internal/utils/service_linux.go +++ b/internal/utils/service_linux.go @@ -6,14 +6,15 @@ package utils import ( "errors" "fmt" - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" - "github.com/iwind/TeaGo/Tea" - "github.com/iwind/TeaGo/files" "os" "os/exec" "regexp" "time" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" + executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec" + "github.com/iwind/TeaGo/Tea" + "github.com/iwind/TeaGo/files" ) var systemdServiceFile = "/etc/systemd/system/edge-node.service" diff --git a/internal/utils/service_test.go b/internal/utils/service_test.go index 8f1c416..1dc231f 100644 --- a/internal/utils/service_test.go +++ b/internal/utils/service_test.go @@ -1,8 +1,9 @@ package utils import ( - teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "testing" + + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" ) func TestServiceManager_Log(t *testing.T) { diff --git a/internal/utils/service_windows.go b/internal/utils/service_windows.go index da7c642..4141770 100644 --- a/internal/utils/service_windows.go +++ b/internal/utils/service_windows.go @@ -5,12 +5,13 @@ package utils import ( "fmt" + "os/exec" + teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/iwind/TeaGo/Tea" "golang.org/x/sys/windows" "golang.org/x/sys/windows/svc" "golang.org/x/sys/windows/svc/mgr" - "os/exec" ) // 安装服务 diff --git a/internal/utils/sets/set_fixed.go b/internal/utils/sets/set_fixed.go index a6e74ee..24a0d4e 100644 --- a/internal/utils/sets/set_fixed.go +++ b/internal/utils/sets/set_fixed.go @@ -3,8 +3,9 @@ package setutils import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) // FixedSet diff --git a/internal/utils/sets/set_fixed_test.go b/internal/utils/sets/set_fixed_test.go index b935c36..adfe65e 100644 --- a/internal/utils/sets/set_fixed_test.go +++ b/internal/utils/sets/set_fixed_test.go @@ -3,10 +3,11 @@ package setutils_test import ( + "testing" + setutils "github.com/TeaOSLab/EdgeNode/internal/utils/sets" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/rands" - "testing" ) func TestNewFixedSet(t *testing.T) { diff --git a/internal/utils/string_test.go b/internal/utils/string_test.go index f5991de..739f605 100644 --- a/internal/utils/string_test.go +++ b/internal/utils/string_test.go @@ -1,11 +1,12 @@ package utils_test import ( + "strings" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/types" - "strings" - "testing" ) func TestBytesToString(t *testing.T) { diff --git a/internal/utils/sync/map_int.go b/internal/utils/sync/map_int.go index 04cc25a..13ef152 100644 --- a/internal/utils/sync/map_int.go +++ b/internal/utils/sync/map_int.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package syncutils diff --git a/internal/utils/sync/map_int_test.go b/internal/utils/sync/map_int_test.go index c091e29..70b14f4 100644 --- a/internal/utils/sync/map_int_test.go +++ b/internal/utils/sync/map_int_test.go @@ -1,14 +1,15 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package syncutils_test import ( + "sync" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/stats" syncutils "github.com/TeaOSLab/EdgeNode/internal/utils/sync" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/types" - "sync" - "testing" ) func TestIntMap(t *testing.T) { diff --git a/internal/utils/sync/rw_mutex.go b/internal/utils/sync/rw_mutex.go index ad282c1..089cba5 100644 --- a/internal/utils/sync/rw_mutex.go +++ b/internal/utils/sync/rw_mutex.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package syncutils diff --git a/internal/utils/sync/rw_mutex_test.go b/internal/utils/sync/rw_mutex_test.go index 06e247a..3397250 100644 --- a/internal/utils/sync/rw_mutex_test.go +++ b/internal/utils/sync/rw_mutex_test.go @@ -1,13 +1,14 @@ -// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package syncutils_test import ( - syncutils "github.com/TeaOSLab/EdgeNode/internal/utils/sync" "runtime" "sync" "testing" "time" + + syncutils "github.com/TeaOSLab/EdgeNode/internal/utils/sync" ) func TestNewRWMutex(t *testing.T) { diff --git a/internal/utils/testutils/memory.go b/internal/utils/testutils/memory.go index 66543e4..8b4f9c7 100644 --- a/internal/utils/testutils/memory.go +++ b/internal/utils/testutils/memory.go @@ -4,10 +4,11 @@ package testutils import ( "fmt" - timeutil "github.com/iwind/TeaGo/utils/time" "runtime" "testing" "time" + + timeutil "github.com/iwind/TeaGo/utils/time" ) func StartMemoryStatsGC(t *testing.T) { diff --git a/internal/utils/testutils/utils.go b/internal/utils/testutils/utils.go index e4806c6..967dae9 100644 --- a/internal/utils/testutils/utils.go +++ b/internal/utils/testutils/utils.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package testutils diff --git a/internal/utils/ticker.go b/internal/utils/ticker.go index 29b893d..54f0ea3 100644 --- a/internal/utils/ticker.go +++ b/internal/utils/ticker.go @@ -1,9 +1,10 @@ package utils import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) // Ticker 类似于time.Ticker,但能够真正地停止 diff --git a/internal/utils/ticker_test.go b/internal/utils/ticker_test.go index 1d8a6c2..c59db59 100644 --- a/internal/utils/ticker_test.go +++ b/internal/utils/ticker_test.go @@ -1,10 +1,11 @@ package utils import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "sync" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" ) func TestRawTicker(t *testing.T) { diff --git a/internal/utils/ticker_utils.go b/internal/utils/ticker_utils.go index 2ff0da1..8f2b048 100644 --- a/internal/utils/ticker_utils.go +++ b/internal/utils/ticker_utils.go @@ -1,8 +1,9 @@ package utils import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" ) // Every 定时运行某个函数 diff --git a/internal/utils/time_test.go b/internal/utils/time_test.go index 2144212..a30a7ea 100644 --- a/internal/utils/time_test.go +++ b/internal/utils/time_test.go @@ -1,9 +1,10 @@ package utils_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils" ) func TestGMTUnixTime(t *testing.T) { diff --git a/internal/utils/trackers/manager_test.go b/internal/utils/trackers/manager_test.go index ad1d97a..769fdde 100644 --- a/internal/utils/trackers/manager_test.go +++ b/internal/utils/trackers/manager_test.go @@ -3,10 +3,11 @@ package trackers_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/trackers" - "github.com/iwind/TeaGo/logs" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/trackers" + "github.com/iwind/TeaGo/logs" ) func TestNewManager(t *testing.T) { diff --git a/internal/utils/ttlcache/cache.go b/internal/utils/ttlcache/cache.go index 31cd380..4cab844 100644 --- a/internal/utils/ttlcache/cache.go +++ b/internal/utils/ttlcache/cache.go @@ -1,9 +1,10 @@ package ttlcache import ( + "runtime" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" - "runtime" ) var SharedInt64Cache = NewBigCache[int64]() diff --git a/internal/utils/ttlcache/cache_test.go b/internal/utils/ttlcache/cache_test.go index e91d630..a706ba1 100644 --- a/internal/utils/ttlcache/cache_test.go +++ b/internal/utils/ttlcache/cache_test.go @@ -1,13 +1,6 @@ package ttlcache import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/iwind/TeaGo/assert" - "github.com/iwind/TeaGo/rands" - "github.com/iwind/TeaGo/types" - timeutil "github.com/iwind/TeaGo/utils/time" "runtime" "runtime/debug" "strconv" @@ -15,6 +8,14 @@ import ( "sync/atomic" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/iwind/TeaGo/assert" + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" + timeutil "github.com/iwind/TeaGo/utils/time" ) func TestNewCache(t *testing.T) { diff --git a/internal/utils/ttlcache/manager.go b/internal/utils/ttlcache/manager.go index eb6eca9..f26a960 100644 --- a/internal/utils/ttlcache/manager.go +++ b/internal/utils/ttlcache/manager.go @@ -3,10 +3,11 @@ package ttlcache import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/goman" - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/goman" + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) var SharedManager = NewManager() diff --git a/internal/utils/ttlcache/piece.go b/internal/utils/ttlcache/piece.go index 6de8426..5b6cd62 100644 --- a/internal/utils/ttlcache/piece.go +++ b/internal/utils/ttlcache/piece.go @@ -1,9 +1,10 @@ package ttlcache import ( + "sync" + "github.com/TeaOSLab/EdgeNode/internal/utils/expires" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "sync" ) type Piece[T any] struct { diff --git a/internal/utils/ttlcache/piece_test.go b/internal/utils/ttlcache/piece_test.go index 6107c6d..fe29bcd 100644 --- a/internal/utils/ttlcache/piece_test.go +++ b/internal/utils/ttlcache/piece_test.go @@ -1,9 +1,10 @@ package ttlcache import ( - "github.com/iwind/TeaGo/rands" "testing" "time" + + "github.com/iwind/TeaGo/rands" ) func TestPiece_Add(t *testing.T) { diff --git a/internal/utils/ttlcache/utils_test.go b/internal/utils/ttlcache/utils_test.go index bc18663..d6ac8c6 100644 --- a/internal/utils/ttlcache/utils_test.go +++ b/internal/utils/ttlcache/utils_test.go @@ -1,13 +1,14 @@ package ttlcache_test import ( + "runtime" + "strconv" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/TeaOSLab/EdgeNode/internal/utils/ttlcache" "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "github.com/cespare/xxhash/v2" - "runtime" - "strconv" - "testing" ) func TestHashCollision(t *testing.T) { diff --git a/internal/utils/version_test.go b/internal/utils/version_test.go index fddcb9e..72fe5c2 100644 --- a/internal/utils/version_test.go +++ b/internal/utils/version_test.go @@ -1,10 +1,11 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils" ) func TestVersionToLong(t *testing.T) { diff --git a/internal/utils/writers/writer_print.go b/internal/utils/writers/writer_print.go index 57ea995..291d9b5 100644 --- a/internal/utils/writers/writer_print.go +++ b/internal/utils/writers/writer_print.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package writers diff --git a/internal/utils/writers/writer_rate_limit.go b/internal/utils/writers/writer_rate_limit.go index 23071ea..82b38c6 100644 --- a/internal/utils/writers/writer_rate_limit.go +++ b/internal/utils/writers/writer_rate_limit.go @@ -4,9 +4,10 @@ package writers import ( "context" - "github.com/iwind/TeaGo/types" "io" "time" + + "github.com/iwind/TeaGo/types" ) // RateLimitWriter 限速写入 diff --git a/internal/utils/zero/zero_test.go b/internal/utils/zero/zero_test.go index f476d46..c249d4b 100644 --- a/internal/utils/zero/zero_test.go +++ b/internal/utils/zero/zero_test.go @@ -3,9 +3,10 @@ package zero_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "runtime" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) func TestZero_Chan(t *testing.T) { diff --git a/internal/waf/action_allow.go b/internal/waf/action_allow.go index 5cec376..7d553f0 100644 --- a/internal/waf/action_allow.go +++ b/internal/waf/action_allow.go @@ -1,8 +1,9 @@ package waf import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) type AllowScope = string diff --git a/internal/waf/action_block.go b/internal/waf/action_block.go index 0e0ef6b..e05ace4 100644 --- a/internal/waf/action_block.go +++ b/internal/waf/action_block.go @@ -1,6 +1,13 @@ package waf import ( + "io" + "net/http" + "os" + "path/filepath" + "regexp" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/utils" @@ -9,12 +16,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/rands" - "io" - "net/http" - "os" - "path/filepath" - "regexp" - "time" ) // url client configure diff --git a/internal/waf/action_captcha.go b/internal/waf/action_captcha.go index d8b6a68..bdc3525 100644 --- a/internal/waf/action_captcha.go +++ b/internal/waf/action_captcha.go @@ -1,6 +1,11 @@ package waf import ( + "net/http" + "net/url" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils" @@ -8,10 +13,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/waf/requests" wafutils "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/types" - "net/http" - "net/url" - "strings" - "time" ) const ( diff --git a/internal/waf/action_get_302.go b/internal/waf/action_get_302.go index fc2c657..63fd64f 100644 --- a/internal/waf/action_get_302.go +++ b/internal/waf/action_get_302.go @@ -1,13 +1,14 @@ package waf import ( + "net/http" + "net/url" + "time" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "net/http" - "net/url" - "time" ) const ( diff --git a/internal/waf/action_go_group.go b/internal/waf/action_go_group.go index a2e28d0..34ad15c 100644 --- a/internal/waf/action_go_group.go +++ b/internal/waf/action_go_group.go @@ -1,10 +1,11 @@ package waf import ( + "net/http" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "net/http" ) type GoGroupAction struct { diff --git a/internal/waf/action_go_set.go b/internal/waf/action_go_set.go index 38e75e6..ac02b05 100644 --- a/internal/waf/action_go_set.go +++ b/internal/waf/action_go_set.go @@ -1,10 +1,11 @@ package waf import ( + "net/http" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "net/http" ) type GoSetAction struct { diff --git a/internal/waf/action_interface.go b/internal/waf/action_interface.go index b06113a..4d39eaa 100644 --- a/internal/waf/action_interface.go +++ b/internal/waf/action_interface.go @@ -3,8 +3,9 @@ package waf import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) type ActionInterface interface { diff --git a/internal/waf/action_js_cookie.go b/internal/waf/action_js_cookie.go index 21f5518..790ec60 100644 --- a/internal/waf/action_js_cookie.go +++ b/internal/waf/action_js_cookie.go @@ -1,18 +1,19 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf import ( "crypto/md5" "fmt" + "net/http" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/utils/counters" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "net/http" - "strings" - "time" ) type JSCookieAction struct { diff --git a/internal/waf/action_log.go b/internal/waf/action_log.go index 15f6a03..d816128 100644 --- a/internal/waf/action_log.go +++ b/internal/waf/action_log.go @@ -1,8 +1,9 @@ package waf import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) type LogAction struct { diff --git a/internal/waf/action_notify.go b/internal/waf/action_notify.go index d26e1e9..96e0fe7 100644 --- a/internal/waf/action_notify.go +++ b/internal/waf/action_notify.go @@ -3,6 +3,9 @@ package waf import ( + "net/http" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" @@ -11,8 +14,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils/goman" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "net/http" - "time" ) type notifyTask struct { diff --git a/internal/waf/action_page.go b/internal/waf/action_page.go index ce5f2e0..4f739c8 100644 --- a/internal/waf/action_page.go +++ b/internal/waf/action_page.go @@ -3,8 +3,9 @@ package waf import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) type PageAction struct { diff --git a/internal/waf/action_post_307.go b/internal/waf/action_post_307.go index 718f5e5..e0d7bf9 100644 --- a/internal/waf/action_post_307.go +++ b/internal/waf/action_post_307.go @@ -1,14 +1,15 @@ package waf import ( + "io" + "net/http" + "time" + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/bytepool" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "io" - "net/http" - "time" ) type Post307Action struct { diff --git a/internal/waf/action_record_ip.go b/internal/waf/action_record_ip.go index 3344c74..763539e 100644 --- a/internal/waf/action_record_ip.go +++ b/internal/waf/action_record_ip.go @@ -1,6 +1,10 @@ package waf import ( + "net/http" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ipconfigs" @@ -12,9 +16,6 @@ import ( memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "net/http" - "strings" - "time" ) type recordIPTask struct { diff --git a/internal/waf/action_redirect.go b/internal/waf/action_redirect.go index 0b64e20..9835fc7 100644 --- a/internal/waf/action_redirect.go +++ b/internal/waf/action_redirect.go @@ -3,8 +3,9 @@ package waf import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) type RedirectAction struct { diff --git a/internal/waf/action_tag.go b/internal/waf/action_tag.go index ff0b1a5..1e03996 100644 --- a/internal/waf/action_tag.go +++ b/internal/waf/action_tag.go @@ -1,8 +1,9 @@ package waf import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) type TagAction struct { diff --git a/internal/waf/action_utils.go b/internal/waf/action_utils.go index ced1bec..f4f5a9d 100644 --- a/internal/waf/action_utils.go +++ b/internal/waf/action_utils.go @@ -2,10 +2,11 @@ package waf import ( "encoding/json" - "github.com/TeaOSLab/EdgeNode/internal/remotelogs" - "github.com/iwind/TeaGo/maps" "reflect" "sync/atomic" + + "github.com/TeaOSLab/EdgeNode/internal/remotelogs" + "github.com/iwind/TeaGo/maps" ) var seedActionId int64 = 1 diff --git a/internal/waf/action_utils_test.go b/internal/waf/action_utils_test.go index f1aba4d..265859b 100644 --- a/internal/waf/action_utils_test.go +++ b/internal/waf/action_utils_test.go @@ -1,12 +1,13 @@ package waf_test import ( + "runtime" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" - "runtime" - "testing" ) func TestFindActionInstance(t *testing.T) { diff --git a/internal/waf/allow_cookie_info.go b/internal/waf/allow_cookie_info.go index 8e337d2..bdc13be 100644 --- a/internal/waf/allow_cookie_info.go +++ b/internal/waf/allow_cookie_info.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf @@ -6,6 +6,7 @@ import ( "encoding/base64" "encoding/binary" "errors" + "github.com/TeaOSLab/EdgeNode/internal/utils" ) diff --git a/internal/waf/allow_cookie_info_test.go b/internal/waf/allow_cookie_info_test.go index c38967c..0df9430 100644 --- a/internal/waf/allow_cookie_info_test.go +++ b/internal/waf/allow_cookie_info_test.go @@ -1,13 +1,14 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/types" - "testing" ) func TestAllowCookieInfo_Encode(t *testing.T) { diff --git a/internal/waf/captcha_counter.go b/internal/waf/captcha_counter.go index d64a127..3532814 100644 --- a/internal/waf/captcha_counter.go +++ b/internal/waf/captcha_counter.go @@ -1,13 +1,14 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf import ( + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/utils/counters" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "time" ) type CaptchaPageCode = string diff --git a/internal/waf/captcha_generator.go b/internal/waf/captcha_generator.go index d5ba03b..56de9a9 100644 --- a/internal/waf/captcha_generator.go +++ b/internal/waf/captcha_generator.go @@ -1,13 +1,14 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf import ( "bytes" - "github.com/dchest/captcha" - "github.com/iwind/TeaGo/rands" "io" "time" + + "github.com/dchest/captcha" + "github.com/iwind/TeaGo/rands" ) // CaptchaGenerator captcha generator diff --git a/internal/waf/captcha_generator_test.go b/internal/waf/captcha_generator_test.go index d32eeeb..5d272d5 100644 --- a/internal/waf/captcha_generator_test.go +++ b/internal/waf/captcha_generator_test.go @@ -1,16 +1,17 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/TeaOSLab/EdgeNode/internal/waf" - "github.com/iwind/TeaGo/assert" - "github.com/iwind/TeaGo/types" "runtime" "strings" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/TeaOSLab/EdgeNode/internal/waf" + "github.com/iwind/TeaGo/assert" + "github.com/iwind/TeaGo/types" ) func TestCaptchaGenerator_NewCaptcha(t *testing.T) { diff --git a/internal/waf/captcha_test.go b/internal/waf/captcha_test.go index ea14bdb..e39f667 100644 --- a/internal/waf/captcha_test.go +++ b/internal/waf/captcha_test.go @@ -1,15 +1,16 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf_test import ( "bytes" "fmt" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/dchest/captcha" "runtime" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/dchest/captcha" ) func TestCaptchaMemory(t *testing.T) { diff --git a/internal/waf/captcha_validator.go b/internal/waf/captcha_validator.go index f903821..4afe3f2 100644 --- a/internal/waf/captcha_validator.go +++ b/internal/waf/captcha_validator.go @@ -5,6 +5,13 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/compressions" "github.com/TeaOSLab/EdgeNode/internal/utils" @@ -17,12 +24,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "io" - "net/http" - "net/url" - "strconv" - "strings" - "time" ) const captchaIdName = "GOEDGE_WAF_CAPTCHA_ID" diff --git a/internal/waf/checkpoints/cc.go b/internal/waf/checkpoints/cc.go index 3ce0be5..4c6c329 100644 --- a/internal/waf/checkpoints/cc.go +++ b/internal/waf/checkpoints/cc.go @@ -1,12 +1,13 @@ package checkpoints import ( + "regexp" + "github.com/TeaOSLab/EdgeNode/internal/utils/counters" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "regexp" ) // CCCheckpoint ${cc.arg} diff --git a/internal/waf/checkpoints/cc2.go b/internal/waf/checkpoints/cc2.go index 97ba022..aaa060c 100644 --- a/internal/waf/checkpoints/cc2.go +++ b/internal/waf/checkpoints/cc2.go @@ -4,14 +4,15 @@ package checkpoints import ( "fmt" + "path/filepath" + "strings" + "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/counters" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" wafutils "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "path/filepath" - "strings" ) // CC2Checkpoint 新的CC diff --git a/internal/waf/checkpoints/cc_test.go b/internal/waf/checkpoints/cc_test.go index fd90884..54e100c 100644 --- a/internal/waf/checkpoints/cc_test.go +++ b/internal/waf/checkpoints/cc_test.go @@ -1,10 +1,11 @@ package checkpoints import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" - "github.com/iwind/TeaGo/maps" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" + "github.com/iwind/TeaGo/maps" ) func TestCCCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/checkpoint.go b/internal/waf/checkpoints/checkpoint.go index f2764ba..effaae1 100644 --- a/internal/waf/checkpoints/checkpoint.go +++ b/internal/waf/checkpoints/checkpoint.go @@ -1,8 +1,9 @@ package checkpoints import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) type Checkpoint struct { diff --git a/internal/waf/checkpoints/request_all_test.go b/internal/waf/checkpoints/request_all_test.go index 5a28d8b..dceccb5 100644 --- a/internal/waf/checkpoints/request_all_test.go +++ b/internal/waf/checkpoints/request_all_test.go @@ -2,13 +2,14 @@ package checkpoints import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" - "github.com/iwind/TeaGo/types" "io" "net/http" "runtime" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" + "github.com/iwind/TeaGo/types" ) func TestRequestAllCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_arg_test.go b/internal/waf/checkpoints/request_arg_test.go index 541d69a..13b4a90 100644 --- a/internal/waf/checkpoints/request_arg_test.go +++ b/internal/waf/checkpoints/request_arg_test.go @@ -1,9 +1,10 @@ package checkpoints import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestArgParam_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_body_test.go b/internal/waf/checkpoints/request_body_test.go index ef5267b..7423cfd 100644 --- a/internal/waf/checkpoints/request_body_test.go +++ b/internal/waf/checkpoints/request_body_test.go @@ -2,12 +2,13 @@ package checkpoints import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" - "github.com/iwind/TeaGo/types" "io" "net/http" "strings" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" + "github.com/iwind/TeaGo/types" ) func TestRequestBodyCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_cookies.go b/internal/waf/checkpoints/request_cookies.go index 0ae40cf..b99cb5f 100644 --- a/internal/waf/checkpoints/request_cookies.go +++ b/internal/waf/checkpoints/request_cookies.go @@ -1,11 +1,12 @@ package checkpoints import ( + "net/url" + "strings" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" - "net/url" - "strings" ) type RequestCookiesCheckpoint struct { diff --git a/internal/waf/checkpoints/request_form_arg.go b/internal/waf/checkpoints/request_form_arg.go index b6db12f..1642366 100644 --- a/internal/waf/checkpoints/request_form_arg.go +++ b/internal/waf/checkpoints/request_form_arg.go @@ -1,10 +1,11 @@ package checkpoints import ( + "net/url" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" - "net/url" ) // RequestFormArgCheckpoint ${requestForm.arg} diff --git a/internal/waf/checkpoints/request_form_arg_test.go b/internal/waf/checkpoints/request_form_arg_test.go index 25a16d8..5f4bb55 100644 --- a/internal/waf/checkpoints/request_form_arg_test.go +++ b/internal/waf/checkpoints/request_form_arg_test.go @@ -2,11 +2,12 @@ package checkpoints import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "io" "net/http" "net/url" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestRequestFormArgCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_header.go b/internal/waf/checkpoints/request_header.go index 56024bd..1cce68e 100644 --- a/internal/waf/checkpoints/request_header.go +++ b/internal/waf/checkpoints/request_header.go @@ -1,10 +1,11 @@ package checkpoints import ( + "strings" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" - "strings" ) type RequestHeaderCheckpoint struct { diff --git a/internal/waf/checkpoints/request_header_names.go b/internal/waf/checkpoints/request_header_names.go index 74fbfad..19f93ec 100644 --- a/internal/waf/checkpoints/request_header_names.go +++ b/internal/waf/checkpoints/request_header_names.go @@ -1,10 +1,11 @@ package checkpoints import ( + "strings" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" - "strings" ) type RequestHeaderNamesCheckpoint struct { diff --git a/internal/waf/checkpoints/request_header_names_test.go b/internal/waf/checkpoints/request_header_names_test.go index 28d928b..5b7f645 100644 --- a/internal/waf/checkpoints/request_header_names_test.go +++ b/internal/waf/checkpoints/request_header_names_test.go @@ -3,10 +3,11 @@ package checkpoints_test import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/checkpoints" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/checkpoints" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestRequestHeaderNamesCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_headers.go b/internal/waf/checkpoints/request_headers.go index 53487bd..fb7352f 100644 --- a/internal/waf/checkpoints/request_headers.go +++ b/internal/waf/checkpoints/request_headers.go @@ -1,11 +1,12 @@ package checkpoints import ( + "sort" + "strings" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" - "sort" - "strings" ) type RequestHeadersCheckpoint struct { diff --git a/internal/waf/checkpoints/request_host_test.go b/internal/waf/checkpoints/request_host_test.go index 5f66ae0..ca5ee9e 100644 --- a/internal/waf/checkpoints/request_host_test.go +++ b/internal/waf/checkpoints/request_host_test.go @@ -1,9 +1,10 @@ package checkpoints import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestRequestHostCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_json_arg.go b/internal/waf/checkpoints/request_json_arg.go index eeddfbf..4887ac2 100644 --- a/internal/waf/checkpoints/request_json_arg.go +++ b/internal/waf/checkpoints/request_json_arg.go @@ -2,11 +2,12 @@ package checkpoints import ( "encoding/json" + "strings" + "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" wafutils "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" - "strings" ) // RequestJSONArgCheckpoint ${requestJSON.arg} diff --git a/internal/waf/checkpoints/request_json_arg_test.go b/internal/waf/checkpoints/request_json_arg_test.go index 095a3f5..8f5d7e2 100644 --- a/internal/waf/checkpoints/request_json_arg_test.go +++ b/internal/waf/checkpoints/request_json_arg_test.go @@ -2,10 +2,11 @@ package checkpoints import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "io" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestRequestJSONArgCheckpoint_RequestValue_Map(t *testing.T) { diff --git a/internal/waf/checkpoints/request_path_test.go b/internal/waf/checkpoints/request_path_test.go index 2121ce7..395e283 100644 --- a/internal/waf/checkpoints/request_path_test.go +++ b/internal/waf/checkpoints/request_path_test.go @@ -1,9 +1,10 @@ package checkpoints import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestRequestPathCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_raw_remote_addr.go b/internal/waf/checkpoints/request_raw_remote_addr.go index 726ae42..02bf4dc 100644 --- a/internal/waf/checkpoints/request_raw_remote_addr.go +++ b/internal/waf/checkpoints/request_raw_remote_addr.go @@ -1,10 +1,11 @@ package checkpoints import ( + "net" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" - "net" ) type RequestRawRemoteAddrCheckpoint struct { diff --git a/internal/waf/checkpoints/request_referer_block.go b/internal/waf/checkpoints/request_referer_block.go index c64581d..df9b4ae 100644 --- a/internal/waf/checkpoints/request_referer_block.go +++ b/internal/waf/checkpoints/request_referer_block.go @@ -3,12 +3,13 @@ package checkpoints import ( + "net/url" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "net/url" ) // RequestRefererBlockCheckpoint 防盗链 diff --git a/internal/waf/checkpoints/request_referer_origin_test.go b/internal/waf/checkpoints/request_referer_origin_test.go index d99f0ed..6f94719 100644 --- a/internal/waf/checkpoints/request_referer_origin_test.go +++ b/internal/waf/checkpoints/request_referer_origin_test.go @@ -1,10 +1,11 @@ package checkpoints_test import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/checkpoints" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/checkpoints" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestRequestRefererOriginCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_remote_port.go b/internal/waf/checkpoints/request_remote_port.go index 1f7c66a..0f62e84 100644 --- a/internal/waf/checkpoints/request_remote_port.go +++ b/internal/waf/checkpoints/request_remote_port.go @@ -1,11 +1,12 @@ package checkpoints import ( + "net" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "net" ) type RequestRemotePortCheckpoint struct { diff --git a/internal/waf/checkpoints/request_scheme_test.go b/internal/waf/checkpoints/request_scheme_test.go index 49bf153..a72750b 100644 --- a/internal/waf/checkpoints/request_scheme_test.go +++ b/internal/waf/checkpoints/request_scheme_test.go @@ -1,9 +1,10 @@ package checkpoints import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestRequestSchemeCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/request_upload.go b/internal/waf/checkpoints/request_upload.go index 192b324..12066bc 100644 --- a/internal/waf/checkpoints/request_upload.go +++ b/internal/waf/checkpoints/request_upload.go @@ -2,17 +2,18 @@ package checkpoints import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" - "github.com/TeaOSLab/EdgeNode/internal/waf/utils" - "github.com/iwind/TeaGo/lists" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" "io" "net/http" "path/filepath" "regexp" "strconv" "strings" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" + "github.com/TeaOSLab/EdgeNode/internal/waf/utils" + "github.com/iwind/TeaGo/lists" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" ) var multipartHeaderRegexp = regexp.MustCompile(`(?i)(?:^|\r\n)--+\w+\r\n((([\w-]+: .+)\r\n)+)`) diff --git a/internal/waf/checkpoints/request_upload_test.go b/internal/waf/checkpoints/request_upload_test.go index 6ae0089..9986836 100644 --- a/internal/waf/checkpoints/request_upload_test.go +++ b/internal/waf/checkpoints/request_upload_test.go @@ -2,11 +2,12 @@ package checkpoints import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "io" "mime/multipart" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestRequestUploadCheckpoint_RequestValue(t *testing.T) { diff --git a/internal/waf/checkpoints/response_body.go b/internal/waf/checkpoints/response_body.go index e6dc170..003ce55 100644 --- a/internal/waf/checkpoints/response_body.go +++ b/internal/waf/checkpoints/response_body.go @@ -2,10 +2,11 @@ package checkpoints import ( "bytes" + "io" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/maps" - "io" ) // ResponseBodyCheckpoint ${responseBody} diff --git a/internal/waf/checkpoints/response_body_test.go b/internal/waf/checkpoints/response_body_test.go index f36114d..4b647ce 100644 --- a/internal/waf/checkpoints/response_body_test.go +++ b/internal/waf/checkpoints/response_body_test.go @@ -2,10 +2,11 @@ package checkpoints import ( "bytes" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "io" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestResponseBodyCheckpoint_ResponseValue(t *testing.T) { diff --git a/internal/waf/checkpoints/response_header_test.go b/internal/waf/checkpoints/response_header_test.go index f41fc6c..7cb416c 100644 --- a/internal/waf/checkpoints/response_header_test.go +++ b/internal/waf/checkpoints/response_header_test.go @@ -1,9 +1,10 @@ package checkpoints import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestResponseHeaderCheckpoint_ResponseValue(t *testing.T) { diff --git a/internal/waf/checkpoints/response_status_test.go b/internal/waf/checkpoints/response_status_test.go index 89e86be..2028cd8 100644 --- a/internal/waf/checkpoints/response_status_test.go +++ b/internal/waf/checkpoints/response_status_test.go @@ -1,9 +1,10 @@ package checkpoints import ( - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "net/http" "testing" + + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) func TestResponseStatusCheckpoint_ResponseValue(t *testing.T) { diff --git a/internal/waf/checkpoints/utils.go b/internal/waf/checkpoints/utils.go index 8cd4651..862851a 100644 --- a/internal/waf/checkpoints/utils.go +++ b/internal/waf/checkpoints/utils.go @@ -149,7 +149,7 @@ var AllCheckpoints = []*CheckpointDefinition{ { Name: "CNAME", Prefix: "cname", - Description: "当前网站服务CNAME,比如38b48e4f.goedge.cn", + Description: "当前网站服务CNAME,比如38b48e4f.goedge.cloud", HasParams: false, Instance: new(RequestCNAMECheckpoint), Priority: 100, diff --git a/internal/waf/get302_validator.go b/internal/waf/get302_validator.go index 0bea906..d637fcc 100644 --- a/internal/waf/get302_validator.go +++ b/internal/waf/get302_validator.go @@ -3,11 +3,12 @@ package waf import ( + "net/http" + "time" + "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/types" - "net/http" - "time" ) var get302Validator = NewGet302Validator() diff --git a/internal/waf/info_arg.go b/internal/waf/info_arg.go index f1ac887..4cce714 100644 --- a/internal/waf/info_arg.go +++ b/internal/waf/info_arg.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf import ( + "net/url" + "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "net/url" ) type InfoArg struct { diff --git a/internal/waf/info_arg_test.go b/internal/waf/info_arg_test.go index 0bcb000..dd3f37a 100644 --- a/internal/waf/info_arg_test.go +++ b/internal/waf/info_arg_test.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf_test import ( - "github.com/TeaOSLab/EdgeNode/internal/waf" - "github.com/iwind/TeaGo/types" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/waf" + "github.com/iwind/TeaGo/types" ) func TestInfoArg_Encode(t *testing.T) { diff --git a/internal/waf/injectionutils/utils_sqli.go b/internal/waf/injectionutils/utils_sqli.go index a8acdc5..361cb6b 100644 --- a/internal/waf/injectionutils/utils_sqli.go +++ b/internal/waf/injectionutils/utils_sqli.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package injectionutils @@ -10,14 +10,15 @@ package injectionutils */ import "C" import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "github.com/TeaOSLab/EdgeNode/internal/waf/utils" - "github.com/cespare/xxhash/v2" "net/url" "strconv" "strings" "unicode/utf8" "unsafe" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + "github.com/TeaOSLab/EdgeNode/internal/waf/utils" + "github.com/cespare/xxhash/v2" ) // DetectSQLInjectionCache detect sql injection in string with cache diff --git a/internal/waf/injectionutils/utils_sqli_test.go b/internal/waf/injectionutils/utils_sqli_test.go index 476a62d..91217ec 100644 --- a/internal/waf/injectionutils/utils_sqli_test.go +++ b/internal/waf/injectionutils/utils_sqli_test.go @@ -1,16 +1,17 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package injectionutils_test import ( + "runtime" + "strings" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/waf/injectionutils" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "runtime" - "strings" - "testing" ) func TestDetectSQLInjection(t *testing.T) { diff --git a/internal/waf/injectionutils/utils_xss.go b/internal/waf/injectionutils/utils_xss.go index 531ec36..a31a41a 100644 --- a/internal/waf/injectionutils/utils_xss.go +++ b/internal/waf/injectionutils/utils_xss.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package injectionutils @@ -10,13 +10,14 @@ package injectionutils */ import "C" import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "github.com/TeaOSLab/EdgeNode/internal/waf/utils" - "github.com/cespare/xxhash/v2" "net/url" "strconv" "strings" "unsafe" + + "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + "github.com/TeaOSLab/EdgeNode/internal/waf/utils" + "github.com/cespare/xxhash/v2" ) func DetectXSSCache(input string, isStrict bool, cacheLife utils.CacheLife) bool { diff --git a/internal/waf/injectionutils/utils_xss_test.go b/internal/waf/injectionutils/utils_xss_test.go index 53e32b6..a26f4ba 100644 --- a/internal/waf/injectionutils/utils_xss_test.go +++ b/internal/waf/injectionutils/utils_xss_test.go @@ -1,13 +1,14 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package injectionutils_test import ( + "runtime" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/waf/injectionutils" "github.com/TeaOSLab/EdgeNode/internal/waf/utils" "github.com/iwind/TeaGo/assert" - "runtime" - "testing" ) func TestDetectXSS(t *testing.T) { diff --git a/internal/waf/ip_list.go b/internal/waf/ip_list.go index f4917c1..49fe1e5 100644 --- a/internal/waf/ip_list.go +++ b/internal/waf/ip_list.go @@ -4,6 +4,10 @@ package waf import ( "encoding/json" + "os" + "sync" + "sync/atomic" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/conns" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" @@ -14,9 +18,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "os" - "sync" - "sync/atomic" ) var SharedIPWhiteList = NewIPList(IPListTypeAllow) diff --git a/internal/waf/ip_list_test.go b/internal/waf/ip_list_test.go index bb3c016..3990f84 100644 --- a/internal/waf/ip_list_test.go +++ b/internal/waf/ip_list_test.go @@ -3,6 +3,12 @@ package waf_test import ( + "os" + "runtime" + "strconv" + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/TeaOSLab/EdgeNode/internal/waf" @@ -11,11 +17,6 @@ import ( _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/logs" timeutil "github.com/iwind/TeaGo/utils/time" - "os" - "runtime" - "strconv" - "testing" - "time" ) func TestNewIPList(t *testing.T) { diff --git a/internal/waf/ip_lists_deleted.go b/internal/waf/ip_lists_deleted.go index 5158e2e..41778c5 100644 --- a/internal/waf/ip_lists_deleted.go +++ b/internal/waf/ip_lists_deleted.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "sync" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) var deletedIPListIdMap = map[int64]zero.Zero{} // listId => Zero diff --git a/internal/waf/results.go b/internal/waf/results.go index b773104..2cebdcd 100644 --- a/internal/waf/results.go +++ b/internal/waf/results.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package waf diff --git a/internal/waf/rule.go b/internal/waf/rule.go index 4f1ac98..688b8e5 100644 --- a/internal/waf/rule.go +++ b/internal/waf/rule.go @@ -5,6 +5,12 @@ import ( "encoding/base64" "encoding/binary" "errors" + "net" + "reflect" + "regexp" + "sort" + "strings" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/filterconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" @@ -19,11 +25,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "net" - "reflect" - "regexp" - "sort" - "strings" ) var singleParamRegexp = regexp.MustCompile(`^\${[\w.-]+}$`) diff --git a/internal/waf/rule_group.go b/internal/waf/rule_group.go index 21cc235..6990f9c 100644 --- a/internal/waf/rule_group.go +++ b/internal/waf/rule_group.go @@ -2,6 +2,7 @@ package waf import ( "fmt" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" ) diff --git a/internal/waf/rule_set.go b/internal/waf/rule_set.go index d96c2b7..4868b34 100644 --- a/internal/waf/rule_set.go +++ b/internal/waf/rule_set.go @@ -2,6 +2,9 @@ package waf import ( "fmt" + "net/http" + "sort" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/utils" @@ -10,8 +13,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "net/http" - "sort" ) type RuleConnector = string diff --git a/internal/waf/rule_set_test.go b/internal/waf/rule_set_test.go index 7714943..502f2fe 100644 --- a/internal/waf/rule_set_test.go +++ b/internal/waf/rule_set_test.go @@ -2,15 +2,16 @@ package waf_test import ( "bytes" + "net/http" + "regexp" + "runtime" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/cespare/xxhash/v2" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/maps" - "net/http" - "regexp" - "runtime" - "testing" ) func TestRuleSet_MatchRequest(t *testing.T) { diff --git a/internal/waf/rule_test.go b/internal/waf/rule_test.go index 6c5c6d9..2dda118 100644 --- a/internal/waf/rule_test.go +++ b/internal/waf/rule_test.go @@ -1,13 +1,14 @@ package waf import ( + "net/http" + "net/url" + "testing" + "github.com/TeaOSLab/EdgeNode/internal/waf/checkpoints" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/maps" - "net/http" - "net/url" - "testing" ) func TestRule_Init_Single(t *testing.T) { diff --git a/internal/waf/template_test.go b/internal/waf/template_test.go index de0dc96..6b7919a 100644 --- a/internal/waf/template_test.go +++ b/internal/waf/template_test.go @@ -2,13 +2,6 @@ package waf_test import ( "bytes" - "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" - "github.com/TeaOSLab/EdgeNode/internal/waf" - "github.com/TeaOSLab/EdgeNode/internal/waf/requests" - "github.com/iwind/TeaGo/assert" - "github.com/iwind/TeaGo/lists" - "github.com/iwind/TeaGo/logs" - "github.com/iwind/TeaGo/types" "math/rand" "mime/multipart" "net/http" @@ -17,6 +10,14 @@ import ( "strings" "testing" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" + "github.com/TeaOSLab/EdgeNode/internal/waf" + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" + "github.com/iwind/TeaGo/assert" + "github.com/iwind/TeaGo/lists" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/types" ) const testUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_0_0) AppleWebKit/500.00 (KHTML, like Gecko) Chrome/100.0.0.0" diff --git a/internal/waf/utils/utils.go b/internal/waf/utils/utils.go index 4605f4d..f0a0be5 100644 --- a/internal/waf/utils/utils.go +++ b/internal/waf/utils/utils.go @@ -1,6 +1,8 @@ package utils import ( + "strconv" + "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/utils/agents" @@ -12,7 +14,6 @@ import ( "github.com/cespare/xxhash/v2" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "strconv" ) var SharedCache = ttlcache.NewCache[int8]() diff --git a/internal/waf/utils/utils_test.go b/internal/waf/utils/utils_test.go index a879c79..fed0b06 100644 --- a/internal/waf/utils/utils_test.go +++ b/internal/waf/utils/utils_test.go @@ -1,10 +1,6 @@ package utils_test import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/re" - "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" - "github.com/TeaOSLab/EdgeNode/internal/waf/utils" - "github.com/iwind/TeaGo/rands" "net/http" "regexp" "runtime" @@ -12,6 +8,11 @@ import ( "strings" "testing" "time" + + "github.com/TeaOSLab/EdgeNode/internal/utils/re" + "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" + "github.com/TeaOSLab/EdgeNode/internal/waf/utils" + "github.com/iwind/TeaGo/rands" ) func TestMatchStringCache(t *testing.T) { diff --git a/internal/waf/values/ip_range.go b/internal/waf/values/ip_range.go index 6203783..524e95e 100644 --- a/internal/waf/values/ip_range.go +++ b/internal/waf/values/ip_range.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package values diff --git a/internal/waf/values/ip_range_test.go b/internal/waf/values/ip_range_test.go index 552037c..4e26fb6 100644 --- a/internal/waf/values/ip_range_test.go +++ b/internal/waf/values/ip_range_test.go @@ -1,12 +1,13 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package values_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/waf/values" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/logs" - "testing" ) func TestIPRange_ParseIPRangeList(t *testing.T) { diff --git a/internal/waf/values/number_list.go b/internal/waf/values/number_list.go index 8bfde48..41842c6 100644 --- a/internal/waf/values/number_list.go +++ b/internal/waf/values/number_list.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package values import ( + "strings" + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "github.com/iwind/TeaGo/types" - "strings" ) type NumberList struct { diff --git a/internal/waf/values/number_list_test.go b/internal/waf/values/number_list_test.go index e81ef5e..48b73df 100644 --- a/internal/waf/values/number_list_test.go +++ b/internal/waf/values/number_list_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package values_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/waf/values" "github.com/iwind/TeaGo/assert" - "testing" ) func TestParseNumberList(t *testing.T) { diff --git a/internal/waf/values/string_list.go b/internal/waf/values/string_list.go index 967264d..9fc1bea 100644 --- a/internal/waf/values/string_list.go +++ b/internal/waf/values/string_list.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package values import ( - "github.com/TeaOSLab/EdgeNode/internal/utils/zero" "strings" + + "github.com/TeaOSLab/EdgeNode/internal/utils/zero" ) type StringList struct { diff --git a/internal/waf/values/string_list_test.go b/internal/waf/values/string_list_test.go index 4782a58..b9f58fe 100644 --- a/internal/waf/values/string_list_test.go +++ b/internal/waf/values/string_list_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package values_test import ( + "testing" + "github.com/TeaOSLab/EdgeNode/internal/waf/values" "github.com/iwind/TeaGo/assert" - "testing" ) func TestParseStringList(t *testing.T) { diff --git a/internal/waf/waf.go b/internal/waf/waf.go index 9f4e119..1600478 100644 --- a/internal/waf/waf.go +++ b/internal/waf/waf.go @@ -3,6 +3,10 @@ package waf import ( "errors" "fmt" + "net/http" + "os" + "reflect" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/waf/checkpoints" @@ -10,9 +14,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/files" "gopkg.in/yaml.v3" - "net/http" - "os" - "reflect" ) type WAF struct { diff --git a/internal/waf/waf_manager.go b/internal/waf/waf_manager.go index 3aeafe1..7619ad6 100644 --- a/internal/waf/waf_manager.go +++ b/internal/waf/waf_manager.go @@ -1,11 +1,12 @@ package waf import ( + "strconv" + "sync" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/errors" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" - "strconv" - "sync" ) var SharedWAFManager = NewWAFManager() diff --git a/internal/waf/waf_manager_test.go b/internal/waf/waf_manager_test.go index 648030f..4d9fd6e 100644 --- a/internal/waf/waf_manager_test.go +++ b/internal/waf/waf_manager_test.go @@ -1,10 +1,11 @@ package waf_test import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/iwind/TeaGo/logs" - "testing" ) func TestWAFManager_convert(t *testing.T) { diff --git a/internal/waf/waf_test.go b/internal/waf/waf_test.go index 45af496..d3cd87d 100644 --- a/internal/waf/waf_test.go +++ b/internal/waf/waf_test.go @@ -1,13 +1,14 @@ package waf_test import ( + "net/http" + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/maps" - "net/http" - "testing" ) func TestWAF_MatchRequest(t *testing.T) {