From 081ab6ee8d7577c002d85e5f46f84db9e3711c99 Mon Sep 17 00:00:00 2001 From: xingpiaoliang Date: Fri, 11 Jul 2025 10:43:00 +0800 Subject: [PATCH] Migrate WASM Go Plugins to New SDK and Go 1.24 (#2532) --- .../build-and-push-wasm-plugin-image.yaml | 27 +- .github/workflows/build-and-test-plugin.yaml | 32 +- hgctl/pkg/plugin/init/templates.go | 11 +- plugins/wasm-go/Dockerfile | 10 +- plugins/wasm-go/DockerfileBuilder | 90 +++--- plugins/wasm-go/Makefile | 9 +- plugins/wasm-go/examples/custom-log/go.mod | 16 +- plugins/wasm-go/examples/custom-log/go.sum | 27 +- plugins/wasm-go/examples/custom-log/main.go | 6 +- .../examples/custom-span-attribute/go.mod | 16 +- .../examples/custom-span-attribute/go.sum | 27 +- .../examples/custom-span-attribute/main.go | 6 +- plugins/wasm-go/extensions/ai-agent/config.go | 2 +- plugins/wasm-go/extensions/ai-agent/go.mod | 16 +- plugins/wasm-go/extensions/ai-agent/go.sum | 29 +- plugins/wasm-go/extensions/ai-agent/main.go | 31 +- .../extensions/ai-cache/cache/provider.go | 7 +- .../extensions/ai-cache/cache/redis.go | 7 +- .../extensions/ai-cache/config/config.go | 12 +- plugins/wasm-go/extensions/ai-cache/core.go | 29 +- .../extensions/ai-cache/embedding/azure.go | 4 +- .../extensions/ai-cache/embedding/cohere.go | 4 +- .../ai-cache/embedding/dashscope.go | 4 +- .../ai-cache/embedding/huggingface.go | 4 +- .../extensions/ai-cache/embedding/ollama.go | 4 +- .../extensions/ai-cache/embedding/openai.go | 4 +- .../extensions/ai-cache/embedding/provider.go | 2 +- .../extensions/ai-cache/embedding/textin.go | 4 +- .../extensions/ai-cache/embedding/xfyun.go | 4 +- plugins/wasm-go/extensions/ai-cache/go.mod | 15 +- plugins/wasm-go/extensions/ai-cache/go.sum | 20 +- plugins/wasm-go/extensions/ai-cache/main.go | 17 +- plugins/wasm-go/extensions/ai-cache/util.go | 13 +- .../extensions/ai-cache/vector/chroma.go | 13 +- .../extensions/ai-cache/vector/dashvector.go | 13 +- .../ai-cache/vector/elasticsearch.go | 13 +- .../extensions/ai-cache/vector/milvus.go | 13 +- .../extensions/ai-cache/vector/pinecone.go | 13 +- .../extensions/ai-cache/vector/provider.go | 19 +- .../extensions/ai-cache/vector/qdrant.go | 13 +- .../extensions/ai-cache/vector/weaviate.go | 13 +- plugins/wasm-go/extensions/ai-history/go.mod | 16 +- plugins/wasm-go/extensions/ai-history/go.sum | 27 +- plugins/wasm-go/extensions/ai-history/main.go | 21 +- .../extensions/ai-image-reader/dashscope.go | 7 +- .../wasm-go/extensions/ai-image-reader/go.mod | 16 +- .../wasm-go/extensions/ai-image-reader/go.sum | 25 +- .../extensions/ai-image-reader/main.go | 11 +- plugins/wasm-go/extensions/ai-intent/go.mod | 13 +- plugins/wasm-go/extensions/ai-intent/go.sum | 19 +- plugins/wasm-go/extensions/ai-intent/main.go | 25 +- .../wasm-go/extensions/ai-json-resp/go.mod | 18 +- .../wasm-go/extensions/ai-json-resp/go.sum | 33 +- .../wasm-go/extensions/ai-json-resp/main.go | 23 +- .../extensions/ai-prompt-decorator/go.mod | 16 +- .../extensions/ai-prompt-decorator/go.sum | 29 +- .../extensions/ai-prompt-decorator/main.go | 13 +- .../extensions/ai-prompt-template/go.mod | 17 +- .../extensions/ai-prompt-template/go.sum | 35 +-- .../extensions/ai-prompt-template/main.go | 13 +- plugins/wasm-go/extensions/ai-proxy/go.mod | 24 +- plugins/wasm-go/extensions/ai-proxy/go.sum | 32 +- plugins/wasm-go/extensions/ai-proxy/main.go | 10 +- .../extensions/ai-proxy/provider/ai360.go | 2 +- .../extensions/ai-proxy/provider/azure.go | 4 +- .../extensions/ai-proxy/provider/baichuan.go | 2 +- .../extensions/ai-proxy/provider/baidu.go | 2 +- .../extensions/ai-proxy/provider/bedrock.go | 4 +- .../extensions/ai-proxy/provider/claude.go | 4 +- .../ai-proxy/provider/cloudflare.go | 2 +- .../extensions/ai-proxy/provider/cohere.go | 2 +- .../extensions/ai-proxy/provider/context.go | 4 +- .../extensions/ai-proxy/provider/coze.go | 2 +- .../extensions/ai-proxy/provider/deepl.go | 2 +- .../extensions/ai-proxy/provider/deepseek.go | 2 +- .../extensions/ai-proxy/provider/dify.go | 4 +- .../extensions/ai-proxy/provider/doubao.go | 4 +- .../extensions/ai-proxy/provider/failover.go | 4 +- .../extensions/ai-proxy/provider/gemini.go | 4 +- .../extensions/ai-proxy/provider/github.go | 2 +- .../extensions/ai-proxy/provider/groq.go | 2 +- .../extensions/ai-proxy/provider/hunyuan.go | 4 +- .../extensions/ai-proxy/provider/minimax.go | 4 +- .../extensions/ai-proxy/provider/mistral.go | 2 +- .../extensions/ai-proxy/provider/model.go | 4 +- .../extensions/ai-proxy/provider/moonshot.go | 4 +- .../extensions/ai-proxy/provider/ollama.go | 2 +- .../extensions/ai-proxy/provider/openai.go | 4 +- .../extensions/ai-proxy/provider/provider.go | 4 +- .../extensions/ai-proxy/provider/qwen.go | 4 +- .../ai-proxy/provider/request_helper.go | 2 +- .../extensions/ai-proxy/provider/retry.go | 4 +- .../extensions/ai-proxy/provider/spark.go | 4 +- .../extensions/ai-proxy/provider/stepfun.go | 2 +- .../ai-proxy/provider/together_ai.go | 2 +- .../extensions/ai-proxy/provider/vertex.go | 4 +- .../extensions/ai-proxy/provider/yi.go | 2 +- .../extensions/ai-proxy/provider/zhipuai.go | 2 +- .../wasm-go/extensions/ai-proxy/util/http.go | 2 +- .../extensions/ai-proxy/util/string.go | 2 +- plugins/wasm-go/extensions/ai-quota/go.mod | 16 +- plugins/wasm-go/extensions/ai-quota/go.sum | 27 +- plugins/wasm-go/extensions/ai-quota/main.go | 23 +- plugins/wasm-go/extensions/ai-rag/go.mod | 16 +- plugins/wasm-go/extensions/ai-rag/go.sum | 29 +- plugins/wasm-go/extensions/ai-rag/main.go | 15 +- .../ai-search/engine/arxiv/arxiv.go | 2 +- .../extensions/ai-search/engine/bing/bing.go | 2 +- .../engine/elasticsearch/elasticsearch.go | 2 +- .../ai-search/engine/google/google.go | 2 +- .../ai-search/engine/quark/quark.go | 2 +- .../extensions/ai-search/engine/types.go | 2 +- plugins/wasm-go/extensions/ai-search/go.mod | 14 +- plugins/wasm-go/extensions/ai-search/go.sum | 25 +- plugins/wasm-go/extensions/ai-search/main.go | 23 +- .../extensions/ai-security-guard/go.mod | 16 +- .../extensions/ai-security-guard/go.sum | 27 +- .../extensions/ai-security-guard/main.go | 19 +- .../wasm-go/extensions/ai-statistics/go.mod | 17 +- .../wasm-go/extensions/ai-statistics/go.sum | 32 +- .../wasm-go/extensions/ai-statistics/main.go | 27 +- .../extensions/ai-token-ratelimit/config.go | 8 +- .../extensions/ai-token-ratelimit/go.mod | 22 +- .../extensions/ai-token-ratelimit/go.sum | 32 +- .../extensions/ai-token-ratelimit/main.go | 19 +- .../wasm-go/extensions/ai-transformer/go.mod | 16 +- .../wasm-go/extensions/ai-transformer/go.sum | 36 +-- .../wasm-go/extensions/ai-transformer/main.go | 17 +- .../wasm-go/extensions/api-workflow/go.mod | 16 +- .../wasm-go/extensions/api-workflow/go.sum | 29 +- .../wasm-go/extensions/api-workflow/main.go | 13 +- .../api-workflow/workflow/workflow.go | 2 +- plugins/wasm-go/extensions/basic-auth/go.mod | 16 +- plugins/wasm-go/extensions/basic-auth/go.sum | 32 +- plugins/wasm-go/extensions/basic-auth/main.go | 13 +- .../bot-detect/config/bot_detect_config.go | 2 +- .../config/bot_detect_config_test.go | 5 +- plugins/wasm-go/extensions/bot-detect/go.mod | 20 +- plugins/wasm-go/extensions/bot-detect/go.sum | 35 +-- plugins/wasm-go/extensions/bot-detect/main.go | 14 +- .../wasm-go/extensions/cache-control/go.mod | 16 +- .../wasm-go/extensions/cache-control/go.sum | 29 +- .../wasm-go/extensions/cache-control/main.go | 20 +- .../wasm-go/extensions/chatgpt-proxy/go.mod | 16 +- .../wasm-go/extensions/chatgpt-proxy/go.sum | 32 +- .../wasm-go/extensions/chatgpt-proxy/main.go | 11 +- .../cluster-key-rate-limit/config/config.go | 6 +- .../extensions/cluster-key-rate-limit/go.mod | 21 +- .../extensions/cluster-key-rate-limit/go.sum | 33 +- .../extensions/cluster-key-rate-limit/main.go | 9 +- .../extensions/cors/config/cors_config.go | 2 +- plugins/wasm-go/extensions/cors/go.mod | 21 +- plugins/wasm-go/extensions/cors/go.sum | 34 +-- plugins/wasm-go/extensions/cors/main.go | 13 +- .../wasm-go/extensions/custom-response/go.mod | 16 +- .../wasm-go/extensions/custom-response/go.sum | 32 +- .../extensions/custom-response/main.go | 8 +- .../de-graphql/config/degraphql_config.go | 2 +- plugins/wasm-go/extensions/de-graphql/go.mod | 21 +- plugins/wasm-go/extensions/de-graphql/go.sum | 34 +-- plugins/wasm-go/extensions/de-graphql/main.go | 17 +- .../extensions/ext-auth/config/config.go | 5 +- .../extensions/ext-auth/config/config_test.go | 3 +- .../extensions/ext-auth/expr/match_rules.go | 2 +- .../extensions/ext-auth/expr/matcher.go | 2 +- plugins/wasm-go/extensions/ext-auth/go.mod | 22 +- plugins/wasm-go/extensions/ext-auth/go.sum | 35 +-- plugins/wasm-go/extensions/ext-auth/main.go | 9 +- .../wasm-go/extensions/frontend-gray/go.mod | 17 +- .../wasm-go/extensions/frontend-gray/go.sum | 32 +- .../wasm-go/extensions/frontend-gray/main.go | 8 +- plugins/wasm-go/extensions/gc-test/go.mod | 18 +- plugins/wasm-go/extensions/gc-test/go.sum | 32 +- plugins/wasm-go/extensions/gc-test/main.go | 6 +- plugins/wasm-go/extensions/geo-ip/go.mod | 18 +- plugins/wasm-go/extensions/geo-ip/go.sum | 27 +- plugins/wasm-go/extensions/geo-ip/main.go | 15 +- .../wasm-go/extensions/gw-error-format/go.mod | 20 +- .../wasm-go/extensions/gw-error-format/go.sum | 32 +- .../extensions/gw-error-format/main.go | 13 +- plugins/wasm-go/extensions/hello-world/go.mod | 16 +- plugins/wasm-go/extensions/hello-world/go.sum | 32 +- .../wasm-go/extensions/hello-world/main.go | 10 +- plugins/wasm-go/extensions/http-call/go.mod | 16 +- plugins/wasm-go/extensions/http-call/go.sum | 32 +- plugins/wasm-go/extensions/http-call/main.go | 11 +- .../wasm-go/extensions/ip-restriction/go.mod | 16 +- .../wasm-go/extensions/ip-restriction/go.sum | 32 +- .../wasm-go/extensions/ip-restriction/main.go | 11 +- .../extensions/jwt-auth/config/parser.go | 6 +- plugins/wasm-go/extensions/jwt-auth/go.mod | 14 +- plugins/wasm-go/extensions/jwt-auth/go.sum | 26 +- .../extensions/jwt-auth/handler/handler.go | 5 +- plugins/wasm-go/extensions/jwt-auth/main.go | 7 +- plugins/wasm-go/extensions/key-auth/go.mod | 16 +- plugins/wasm-go/extensions/key-auth/go.sum | 30 +- plugins/wasm-go/extensions/key-auth/main.go | 13 +- .../extensions/log-request-response/go.mod | 16 +- .../extensions/log-request-response/go.sum | 27 +- .../extensions/log-request-response/main.go | 8 +- plugins/wasm-go/extensions/oidc/go.mod | 33 +- plugins/wasm-go/extensions/oidc/go.sum | 63 ++-- plugins/wasm-go/extensions/oidc/main.go | 13 +- plugins/wasm-go/extensions/opa/config.go | 2 +- plugins/wasm-go/extensions/opa/config_test.go | 6 +- plugins/wasm-go/extensions/opa/go.mod | 20 +- plugins/wasm-go/extensions/opa/go.sum | 30 +- plugins/wasm-go/extensions/opa/main.go | 15 +- .../replay-protection/config/config.go | 5 +- .../extensions/replay-protection/go.mod | 16 +- .../extensions/replay-protection/go.sum | 27 +- .../extensions/replay-protection/main.go | 16 +- .../replay-protection/util/utils.go | 2 +- .../wasm-go/extensions/request-block/go.mod | 19 +- .../wasm-go/extensions/request-block/go.sum | 36 +-- .../wasm-go/extensions/request-block/main.go | 16 +- .../extensions/request-validation/go.mod | 16 +- .../extensions/request-validation/go.sum | 32 +- .../extensions/request-validation/main.go | 13 +- .../wasm-go/extensions/simple-jwt-auth/go.mod | 16 +- .../wasm-go/extensions/simple-jwt-auth/go.sum | 32 +- .../extensions/simple-jwt-auth/main.go | 10 +- .../wasm-go/extensions/sni-misdirect/go.mod | 16 +- .../wasm-go/extensions/sni-misdirect/go.sum | 32 +- .../wasm-go/extensions/sni-misdirect/main.go | 9 +- .../extensions/streaming-body-example/go.mod | 16 +- .../extensions/streaming-body-example/go.sum | 32 +- .../extensions/streaming-body-example/main.go | 15 +- .../wasm-go/extensions/traffic-tag/content.go | 8 +- plugins/wasm-go/extensions/traffic-tag/go.mod | 20 +- plugins/wasm-go/extensions/traffic-tag/go.sum | 33 +- .../wasm-go/extensions/traffic-tag/main.go | 11 +- .../wasm-go/extensions/traffic-tag/parse.go | 11 +- .../wasm-go/extensions/traffic-tag/utils.go | 6 +- .../wasm-go/extensions/traffic-tag/weight.go | 6 +- plugins/wasm-go/extensions/transformer/go.mod | 19 +- plugins/wasm-go/extensions/transformer/go.sum | 31 +- .../wasm-go/extensions/transformer/main.go | 20 +- plugins/wasm-go/extensions/waf/go.mod | 21 +- plugins/wasm-go/extensions/waf/go.sum | 36 ++- .../wasm-go/extensions/waf/magefiles/go.mod | 2 +- .../wasm-go/extensions/waf/magefiles/go.sum | 4 + plugins/wasm-go/extensions/waf/main.go | 4 +- .../extensions/waf/wasmplugin/plugin.go | 15 +- .../extensions/waf/wasmplugin/utils.go | 11 +- plugins/wasm-go/go.mod | 12 +- plugins/wasm-go/go.sum | 12 +- plugins/wasm-go/mcp-filters/mcp-router/go.mod | 5 +- plugins/wasm-go/mcp-filters/mcp-router/go.sum | 10 +- .../wasm-go/mcp-filters/mcp-router/main.go | 6 +- plugins/wasm-go/mcp-servers/README.md | 12 +- plugins/wasm-go/mcp-servers/README_zh.md | 12 +- .../conformance/tests/go-wasm-ai-cache.yaml | 4 +- .../tests/go-wasm-basic-auth-template.yaml | 3 +- .../conformance/tests/go-wasm-basic-auth.yaml | 2 +- .../conformance/tests/go-wasm-bot-detect.yaml | 2 +- .../tests/go-wasm-cache-control.yaml | 2 +- .../tests/go-wasm-custom-response.yaml | 12 +- .../tests/go-wasm-ip-restriction-allow.yaml | 2 +- .../tests/go-wasm-ip-restriction-deny.yaml | 2 +- .../tests/go-wasm-jwt-auth-allow.yaml | 2 +- .../tests/go-wasm-jwt-auth-deny.yaml | 2 +- .../go-wasm-jwt-auth-single-consumer.yaml | 2 +- .../conformance/tests/go-wasm-key-auth.yaml | 2 +- test/e2e/conformance/tests/go-wasm-opa.yaml | 2 +- .../tests/go-wasm-request-block.yaml | 50 ++-- .../tests/go-wasm-request-validation.yaml | 12 +- .../tests/go-wasm-simple-jwt-auth.yaml | 22 +- .../tests/go-wasm-sni-misdirect.yaml | 2 +- .../tests/go-wasm-transformer.yaml | 281 +++++++++--------- .../tests/rust-wasm-ai-data-masking.yaml | 30 +- test/e2e/conformance/utils/config/timeout.go | 2 +- .../conformance/utils/kubernetes/helpers.go | 1 + tools/hack/build-wasm-plugins.sh | 4 +- 274 files changed, 2073 insertions(+), 2165 deletions(-) diff --git a/.github/workflows/build-and-push-wasm-plugin-image.yaml b/.github/workflows/build-and-push-wasm-plugin-image.yaml index 240658229..77281002d 100644 --- a/.github/workflows/build-and-push-wasm-plugin-image.yaml +++ b/.github/workflows/build-and-push-wasm-plugin-image.yaml @@ -3,22 +3,22 @@ name: Build and Push Wasm Plugin Image on: push: tags: - - "wasm-*-*-v*.*.*" # 匹配 wasm-{go|rust}-{pluginName}-vX.Y.Z 格式的标签 + - "wasm-*-*-v*.*.*" # 匹配 wasm-{go|rust}-{pluginName}-vX.Y.Z 格式的标签 workflow_dispatch: inputs: plugin_type: - description: 'Type of the plugin' + description: "Type of the plugin" required: true type: choice options: - go - rust plugin_name: - description: 'Name of the plugin' + description: "Name of the plugin" required: true type: string version: - description: 'Version of the plugin (optional, without leading v)' + description: "Version of the plugin (optional, without leading v)" required: false type: string @@ -31,8 +31,7 @@ jobs: IMAGE_REGISTRY_SERVICE: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }} IMAGE_REPOSITORY: ${{ vars.PLUGIN_IMAGE_REPOSITORY || 'plugins' }} RUST_VERSION: 1.82 - GO_VERSION: 1.19 - TINYGO_VERSION: 0.28.1 + GO_VERSION: 1.24.0 ORAS_VERSION: 1.0.0 steps: - name: Set plugin_type, plugin_name and version from inputs or ref_name @@ -53,7 +52,7 @@ jobs: if [[ "$plugin_type" == "rust" ]]; then builder_image="higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-rust-builder:rust${{ env.RUST_VERSION }}-oras${{ env.ORAS_VERSION }}" else - builder_image="higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go${{ env.GO_VERSION }}-tinygo${{ env.TINYGO_VERSION }}-oras${{ env.ORAS_VERSION }}" + builder_image="higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go${{ env.GO_VERSION }}-oras${{ env.ORAS_VERSION }}" fi echo "PLUGIN_TYPE=$plugin_type" >> $GITHUB_ENV echo "PLUGIN_NAME=$plugin_name" >> $GITHUB_ENV @@ -62,9 +61,9 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - + - name: File Check - run: | + run: | workspace=${{ github.workspace }}/plugins/wasm-${PLUGIN_TYPE}/extensions/${PLUGIN_NAME} push_command="./plugin.tar.gz:application/vnd.oci.image.layer.v1.tar+gzip" @@ -79,7 +78,7 @@ jobs: echo "README.md exists" push_command="./README.md:application/vnd.module.wasm.doc.v1+markdown $push_command " fi - + # 查找README_{lang}.md for file in ${workspace}/README_*.md; do if [ -f "$file" ]; then @@ -91,9 +90,9 @@ jobs: done echo "PUSH_COMMAND=\"$push_command\"" >> $GITHUB_ENV - + - name: Run a wasm-builder - env: + env: PLUGIN_NAME: ${{ env.PLUGIN_NAME }} BUILDER_IMAGE: ${{ env.BUILDER_IMAGE }} run: | @@ -104,7 +103,7 @@ jobs: push_command=${{ env.PUSH_COMMAND }} push_command=${push_command#\"} push_command=${push_command%\"} # 删除PUSH_COMMAND中的双引号,确保oras push正常解析 - + target_image="${{ env.IMAGE_REGISTRY_SERVICE }}/${{ env.IMAGE_REPOSITORY}}/${{ env.PLUGIN_NAME }}:${{ env.VERSION }}" target_image_latest="${{ env.IMAGE_REGISTRY_SERVICE }}/${{ env.IMAGE_REPOSITORY}}/${{ env.PLUGIN_NAME }}:latest" echo "TargetImage=${target_image}" @@ -123,7 +122,7 @@ jobs: set -e cd /workspace/plugins/wasm-go/extensions/${PLUGIN_NAME} go mod tidy - tinygo build -o ./plugin.wasm -scheduler=none -target=wasi -gc=custom -tags=\"custommalloc nottinygc_finalizer ${EXTRA_TAGS}\" . + GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o plugin.wasm main.go tar czvf plugin.tar.gz plugin.wasm echo ${{ secrets.REGISTRY_PASSWORD }} | oras login -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin ${{ env.IMAGE_REGISTRY_SERVICE }} oras push ${target_image} ${push_command} diff --git a/.github/workflows/build-and-test-plugin.yaml b/.github/workflows/build-and-test-plugin.yaml index ba0f5ce5f..0f3e68a25 100644 --- a/.github/workflows/build-and-test-plugin.yaml +++ b/.github/workflows/build-and-test-plugin.yaml @@ -2,20 +2,20 @@ name: "Build and Test Plugins" on: push: - branches: [ main ] + branches: [main] paths: - - 'plugins/**' - - 'test/**' - - 'helm/**' - - 'Makefile.core.mk' + - "plugins/**" + - "test/**" + - "helm/**" + - "Makefile.core.mk" pull_request: - branches: [ "*" ] + branches: ["*"] paths: - - 'plugins/**' - - 'test/**' - - 'helm/**' - - 'Makefile.core.mk' - workflow_dispatch: ~ + - "plugins/**" + - "test/**" + - "helm/**" + - "Makefile.core.mk" + workflow_dispatch: ~ jobs: lint: @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.22 + go-version: 1.24 # There are too many lint errors in current code bases # uncomment when we decide what lint should be addressed or ignored. # - run: make lint @@ -34,7 +34,7 @@ jobs: strategy: matrix: # TODO(Xunzhuo): Enable C WASM Filters in CI - wasmPluginType: [ GO, RUST ] + wasmPluginType: [GO, RUST] steps: - uses: actions/checkout@v4 @@ -46,12 +46,12 @@ jobs: dotnet: true haskell: true large-packages: true - swap-storage: true + swap-storage: true - name: "Setup Go" uses: actions/setup-go@v5 with: - go-version: 1.22 + go-version: 1.24 - name: Setup Rust uses: actions-rs/toolchain@v1 @@ -80,6 +80,6 @@ jobs: publish: runs-on: ubuntu-latest - needs: [ higress-wasmplugin-test ] + needs: [higress-wasmplugin-test] steps: - uses: actions/checkout@v4 diff --git a/hgctl/pkg/plugin/init/templates.go b/hgctl/pkg/plugin/init/templates.go index 83a7662bd..c5116a5e5 100644 --- a/hgctl/pkg/plugin/init/templates.go +++ b/hgctl/pkg/plugin/init/templates.go @@ -33,7 +33,8 @@ import ( "github.com/tidwall/gjson" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" + logs "github.com/higress-group/wasm-go/pkg/log" ) func main() { @@ -72,13 +73,13 @@ type PluginConfig struct { secondField string ` + "`required:\"true\"`" + ` } -func parseConfig(json gjson.Result, config *PluginConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *PluginConfig, log logs.Log) error { config.firstField = json.Get("firstField").String() config.secondField = json.Get("secondField").String() return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log logs.Log) types.Action { err := proxywasm.AddHttpRequestHeader(config.firstField, config.secondField) if err != nil { log.Critical("failed to set request header") @@ -90,10 +91,10 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrap module {{ .Name }} -go 1.19 +go 1.24 require ( - github.com/alibaba/higress/plugins/wasm-go main + github.com/higress-group/wasm-go main github.com/higress-group/proxy-wasm-go-sdk main github.com/tidwall/gjson v1.14.3 ) diff --git a/plugins/wasm-go/Dockerfile b/plugins/wasm-go/Dockerfile index ab9cdf029..26ed2defa 100644 --- a/plugins/wasm-go/Dockerfile +++ b/plugins/wasm-go/Dockerfile @@ -1,4 +1,4 @@ -ARG BUILDER=higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go1.20.14-tinygo0.29.0-oras1.0.0 +ARG BUILDER=higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go1.24.0-oras1.0.0 FROM $BUILDER AS builder @@ -18,13 +18,7 @@ WORKDIR /workspace/extensions/$PLUGIN_NAME RUN go mod tidy RUN \ - if echo "$PLUGIN_NAME" | grep -Eq '^waf$'; then \ - # Please use higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go1.19-tinygo0.28.1-oras1.0.0 as BUILDER - go run mage.go build && \ - mv ./local/main.wasm /main.wasm ; \ - else \ - tinygo build -o /main.wasm -scheduler=none -gc=custom -tags="custommalloc nottinygc_finalizer $EXTRA_TAGS" -target=wasi ./ ; \ - fi + GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o /main.wasm ./ FROM scratch AS output diff --git a/plugins/wasm-go/DockerfileBuilder b/plugins/wasm-go/DockerfileBuilder index c0b79d451..3c0479747 100644 --- a/plugins/wasm-go/DockerfileBuilder +++ b/plugins/wasm-go/DockerfileBuilder @@ -52,64 +52,50 @@ ARG BASE_IMAGE=docker.io/ubuntu FROM $BASE_IMAGE -ARG GO_VERSION -ARG TINYGO_VERSION -ARG ORAS_VERSION -ARG HIGRESS_VERSION -ARG USE_HIGRESS_TINYGO +ARG GO_VERSION=1.24.0 +ARG TINYGO_VERSION=0.30.0 +ARG ORAS_VERSION=1.0.0 +ARG HIGRESS_VERSION=1.0.0-rc +ARG USE_HIGRESS_TINYGO=false LABEL go_version=$GO_VERSION tinygo_version=$TINYGO_VERSION oras_version=$ORAS_VERSION -RUN apt-get update \ - && apt-get install -y wget \ - && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y wget tar && rm -rf /var/lib/apt/lists/* -RUN arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ - go_url=; \ - tinygo_url=; \ - go_version=${GO_VERSION:-1.19}; \ - tinygo_version=${TINYGO_VERSION:-0.25.0}; \ - oras_version=${ORAS_VERSION:-1.0.0}; \ - higress_version=${HIGRESS_VERSION:-1.0.0-rc}; \ - use_higress_tinygo=${USE_HIGRESS_TINYGO:-false}; \ - echo "arch: '$arch'"; \ - echo "go go_version: '$go_version'"; \ - echo "tinygo_version: '$tinygo_version'"; \ - echo "oras_version: '$oras_version'"; \ - echo "higress_version: '$higress_version'"; \ - echo "use_higress_tinygo: '$use_higress_tinygo'"; \ +RUN set -e; \ + arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ + echo "arch: $arch"; \ + go_url=""; tinygo_url=""; \ case "$arch" in \ - 'amd64') \ - go_url="https://golang.google.cn/dl/go$go_version.linux-amd64.tar.gz"; \ - if [ "$use_higress_tinygo" = "true" ]; \ - then \ - tinygo_url="https://github.com/alibaba/higress/releases/download/v$higress_version/higress-tinygo${tinygo_version}.linux-amd64.tar.gz"; \ - else \ - tinygo_url="https://github.com/tinygo-org/tinygo/releases/download/v$tinygo_version/tinygo${tinygo_version}.linux-amd64.tar.gz"; \ - fi; \ - oras_url="https://github.com/oras-project/oras/releases/download/v$oras_version/oras_${oras_version}_linux_amd64.tar.gz"; \ - ;; \ - 'arm64') \ - go_url="https://golang.google.cn/dl/go$go_version.linux-arm64.tar.gz"; \ - if [ "$use_higress_tinygo" = "true" ]; \ - then \ - tinygo_url="https://github.com/alibaba/higress/releases/download/v$higress_version/higress-tinygo${tinygo_version}.linux-arm64.tar.gz"; \ - else \ - tinygo_url="https://github.com/tinygo-org/tinygo/releases/download/v$tinygo_version/tinygo${tinygo_version}.linux-arm64.tar.gz"; \ - fi; \ - oras_url="https://github.com/oras-project/oras/releases/download/v$oras_version/oras_${oras_version}_linux_arm64.tar.gz"; \ - ;; \ - *) echo >&2 "error: unsupported architecture '$arch' "; exit 1 ;; \ + 'amd64') \ + go_url="https://golang.google.cn/dl/go${GO_VERSION}.linux-amd64.tar.gz"; \ + if [ "$USE_HIGRESS_TINYGO" = "true" ]; then \ + tinygo_url="https://github.com/alibaba/higress/releases/download/v${HIGRESS_VERSION}/higress-tinygo${TINYGO_VERSION}.linux-amd64.tar.gz"; \ + else \ + tinygo_url="https://github.com/tinygo-org/tinygo/releases/download/v${TINYGO_VERSION}/tinygo${TINYGO_VERSION}.linux-amd64.tar.gz"; \ + fi; \ + oras_url="https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz"; \ + ;; \ + 'arm64') \ + go_url="https://golang.google.cn/dl/go${GO_VERSION}.linux-arm64.tar.gz"; \ + if [ "$USE_HIGRESS_TINYGO" = "true" ]; then \ + tinygo_url="https://github.com/alibaba/higress/releases/download/v${HIGRESS_VERSION}/higress-tinygo${TINYGO_VERSION}.linux-arm64.tar.gz"; \ + else \ + tinygo_url="https://github.com/tinygo-org/tinygo/releases/download/v${TINYGO_VERSION}/tinygo${TINYGO_VERSION}.linux-arm64.tar.gz"; \ + fi; \ + oras_url="https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_arm64.tar.gz"; \ + ;; \ + *) echo >&2 "unsupported architecture: $arch"; exit 1 ;; \ esac; \ - echo "go_url: '$go_url'"; \ - wget -O go.tgz "$go_url" --progress=dot:giga; \ - rm -rf /usr/local/go && tar -C /usr/local -xzf go.tgz && rm -rf go.tgz; \ - echo "tinygo_url: '$tinygo_url'"; \ - wget -O tinygo.tgz "$tinygo_url" --progress=dot:giga; \ - rm -rf /usr/local/tinygo && tar -C /usr/local -xzf tinygo.tgz && rm -rf tinygo.tgz; \ - echo "oras_url: '$oras_url'"; \ - wget -O oras.tgz "$oras_url" --progress=dot:giga; \ - tar -C /usr/local/bin -xzf oras.tgz && rm -rf oras.tgz; \ + echo "go_url: $go_url"; \ + wget -O go.tgz "$go_url" --progress=dot:giga || (echo "Failed to download Go" && exit 1); \ + tar -C /usr/local -xzf go.tgz && rm go.tgz; \ + echo "tinygo_url: $tinygo_url"; \ + wget -O tinygo.tgz "$tinygo_url" --progress=dot:giga || (echo "Failed to download TinyGo" && exit 1); \ + tar -C /usr/local -xzf tinygo.tgz && rm tinygo.tgz; \ + echo "oras_url: $oras_url"; \ + wget -O oras.tgz "$oras_url" --progress=dot:giga || (echo "Failed to download ORAS" && exit 1); \ + tar -C /usr/local/bin -xzf oras.tgz && rm oras.tgz; \ echo "done"; ENV PATH=$PATH:/usr/local/go/bin:/usr/local/tinygo/bin:/usr/local/bin diff --git a/plugins/wasm-go/Makefile b/plugins/wasm-go/Makefile index 18e4b7c75..b9624544a 100644 --- a/plugins/wasm-go/Makefile +++ b/plugins/wasm-go/Makefile @@ -1,12 +1,12 @@ PLUGIN_NAME ?= hello-world BUILDER_REGISTRY ?= higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ REGISTRY ?= higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ -GO_VERSION ?= 1.20.14 +GO_VERSION ?= 1.24.0 TINYGO_VERSION ?= 0.29.0 ORAS_VERSION ?= 1.0.0 HIGRESS_VERSION ?= 1.0.0-rc USE_HIGRESS_TINYGO ?= false -BUILDER ?= ${BUILDER_REGISTRY}wasm-go-builder:go${GO_VERSION}-tinygo${TINYGO_VERSION}-oras${ORAS_VERSION} +BUILDER ?= ${BUILDER_REGISTRY}wasm-go-builder:go${GO_VERSION}-oras${ORAS_VERSION} BUILD_TIME := $(shell date "+%Y%m%d-%H%M%S") COMMIT_ID := $(shell git rev-parse --short HEAD 2>/dev/null) IMAGE_TAG = $(if $(strip $(PLUGIN_VERSION)),${PLUGIN_VERSION},${BUILD_TIME}-${COMMIT_ID}) @@ -64,9 +64,8 @@ builder: @echo "image: ${BUILDER}" local-build: - tinygo build -scheduler=none -target=wasi -gc=custom -tags='custommalloc nottinygc_finalizer' \ - -o extensions/${PLUGIN_NAME}/main.wasm \ - extensions/${PLUGIN_NAME}/main.go + GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o extensions/${PLUGIN_NAME}/main.wasm extensions/${PLUGIN_NAME}/main.go + @echo "" @echo "wasm: extensions/${PLUGIN_NAME}/main.wasm" diff --git a/plugins/wasm-go/examples/custom-log/go.mod b/plugins/wasm-go/examples/custom-log/go.mod index 5eacb3358..d5de96957 100644 --- a/plugins/wasm-go/examples/custom-log/go.mod +++ b/plugins/wasm-go/examples/custom-log/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/custom-logs -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/tidwall/gjson v1.17.3 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/examples/custom-log/go.sum b/plugins/wasm-go/examples/custom-log/go.sum index b4ab172fe..bc44cf8f0 100644 --- a/plugins/wasm-go/examples/custom-log/go.sum +++ b/plugins/wasm-go/examples/custom-log/go.sum @@ -1,20 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/examples/custom-log/main.go b/plugins/wasm-go/examples/custom-log/main.go index f6801c380..343d2eab0 100644 --- a/plugins/wasm-go/examples/custom-log/main.go +++ b/plugins/wasm-go/examples/custom-log/main.go @@ -19,10 +19,12 @@ import ( "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "custom-log", wrapper.ProcessRequestHeadersBy(onHttpRequestHeaders), diff --git a/plugins/wasm-go/examples/custom-span-attribute/go.mod b/plugins/wasm-go/examples/custom-span-attribute/go.mod index 5eacb3358..9fdfdade5 100644 --- a/plugins/wasm-go/examples/custom-span-attribute/go.mod +++ b/plugins/wasm-go/examples/custom-span-attribute/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/custom-logs -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/tidwall/gjson v1.17.3 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/examples/custom-span-attribute/go.sum b/plugins/wasm-go/examples/custom-span-attribute/go.sum index b4ab172fe..bc44cf8f0 100644 --- a/plugins/wasm-go/examples/custom-span-attribute/go.sum +++ b/plugins/wasm-go/examples/custom-span-attribute/go.sum @@ -1,20 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/examples/custom-span-attribute/main.go b/plugins/wasm-go/examples/custom-span-attribute/main.go index d971ae826..ef769db28 100644 --- a/plugins/wasm-go/examples/custom-span-attribute/main.go +++ b/plugins/wasm-go/examples/custom-span-attribute/main.go @@ -22,10 +22,12 @@ import ( "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/tidwall/gjson" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "custom-span-attribute", wrapper.ParseConfigBy(parseConfig), diff --git a/plugins/wasm-go/extensions/ai-agent/config.go b/plugins/wasm-go/extensions/ai-agent/config.go index 7c078d22c..10094f2e3 100644 --- a/plugins/wasm-go/extensions/ai-agent/config.go +++ b/plugins/wasm-go/extensions/ai-agent/config.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "gopkg.in/yaml.v2" ) diff --git a/plugins/wasm-go/extensions/ai-agent/go.mod b/plugins/wasm-go/extensions/ai-agent/go.mod index 352e7a20a..32adeea78 100644 --- a/plugins/wasm-go/extensions/ai-agent/go.mod +++ b/plugins/wasm-go/extensions/ai-agent/go.mod @@ -1,19 +1,19 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-agent -go 1.19 +go 1.24.1 + +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.2 - github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v0.0.0-20250628101008-bea7da01a545 + github.com/tidwall/gjson v1.18.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ai-agent/go.sum b/plugins/wasm-go/extensions/ai-agent/go.sum index 1b2c82d5a..06fadf9bf 100644 --- a/plugins/wasm-go/extensions/ai-agent/go.sum +++ b/plugins/wasm-go/extensions/ai-agent/go.sum @@ -1,22 +1,22 @@ -github.com/alibaba/higress/plugins/wasm-go v1.4.2 h1:gH7OIGXm4wtW5Vo7L2deMPqF7OVWNESDHv1CaaTGu6s= -github.com/alibaba/higress/plugins/wasm-go v1.4.2/go.mod h1:359don/ahMxpfeLMzr29Cjwcu8IywTTDUzWlBPRNLHw= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v0.0.0-20250628101008-bea7da01a545 h1:qb/Rhhfm1gzr/stim/L0cKNo0MPatdo0Rd8iYOAPWE0= +github.com/higress-group/wasm-go v0.0.0-20250628101008-bea7da01a545/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= @@ -24,3 +24,4 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-agent/main.go b/plugins/wasm-go/extensions/ai-agent/main.go index 5debf0dea..b3cbad227 100644 --- a/plugins/wasm-go/extensions/ai-agent/main.go +++ b/plugins/wasm-go/extensions/ai-agent/main.go @@ -11,9 +11,10 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-agent/dashscope" prompttpl "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-agent/promptTpl" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -26,7 +27,9 @@ const ActionPattern = `Action:\s*(.*?)[.\n]` const ActionInputPattern = `Action Input:\s*(.*)` const FinalAnswerPattern = `Final Answer:(.*)` -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-agent", wrapper.ParseConfigBy(parseConfig), @@ -37,7 +40,7 @@ func main() { ) } -func parseConfig(gjson gjson.Result, c *PluginConfig, log wrapper.Log) error { +func parseConfig(gjson gjson.Result, c *PluginConfig, log log.Log) error { initResponsePromptTpl(gjson, c) err := initAPIs(gjson, c) @@ -54,11 +57,11 @@ func parseConfig(gjson gjson.Result, c *PluginConfig, log wrapper.Log) error { return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { return types.ActionContinue } -func firstReq(ctx wrapper.HttpContext, config PluginConfig, prompt string, rawRequest Request, log wrapper.Log) types.Action { +func firstReq(ctx wrapper.HttpContext, config PluginConfig, prompt string, rawRequest Request, log log.Log) types.Action { log.Debugf("[onHttpRequestBody] firstreq:%s", prompt) var userMessage Message @@ -88,7 +91,7 @@ func firstReq(ctx wrapper.HttpContext, config PluginConfig, prompt string, rawRe } } -func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action { log.Debug("onHttpRequestBody start") defer log.Debug("onHttpRequestBody end") @@ -172,7 +175,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte return ret } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { log.Debug("onHttpResponseHeaders start") defer log.Debug("onHttpResponseHeaders end") @@ -200,7 +203,7 @@ func extractJson(bodyStr string) (string, error) { return jsonStr, nil } -func jsonFormat(llmClient wrapper.HttpClient, llmInfo LLMInfo, jsonSchema map[string]interface{}, assistantMessage Message, actionInput string, headers [][2]string, streamMode bool, rawResponse Response, log wrapper.Log) string { +func jsonFormat(llmClient wrapper.HttpClient, llmInfo LLMInfo, jsonSchema map[string]interface{}, assistantMessage Message, actionInput string, headers [][2]string, streamMode bool, rawResponse Response, log log.Log) string { prompt := fmt.Sprintf(prompttpl.Json_Resp_Template, jsonSchema, actionInput) messages := []dashscope.Message{{Role: "user", Content: prompt}} @@ -241,7 +244,7 @@ func jsonFormat(llmClient wrapper.HttpClient, llmInfo LLMInfo, jsonSchema map[st return content } -func noneStream(assistantMessage Message, actionInput string, rawResponse Response, log wrapper.Log) { +func noneStream(assistantMessage Message, actionInput string, rawResponse Response, log log.Log) { assistantMessage.Role = "assistant" assistantMessage.Content = actionInput rawResponse.Choices[0].Message = assistantMessage @@ -257,7 +260,7 @@ func noneStream(assistantMessage Message, actionInput string, rawResponse Respon } } -func stream(actionInput string, rawResponse Response, log wrapper.Log) { +func stream(actionInput string, rawResponse Response, log log.Log) { headers := [][2]string{{"content-type", "text/event-stream; charset=utf-8"}} proxywasm.ReplaceHttpResponseHeaders(headers) // Remove quotes from actionInput @@ -271,7 +274,7 @@ func stream(actionInput string, rawResponse Response, log wrapper.Log) { proxywasm.ResumeHttpResponse() } -func toolsCallResult(ctx wrapper.HttpContext, llmClient wrapper.HttpClient, llmInfo LLMInfo, jsonResp JsonResp, aPIsParam []APIsParam, aPIClient []wrapper.HttpClient, content string, rawResponse Response, log wrapper.Log, statusCode int, responseBody []byte) { +func toolsCallResult(ctx wrapper.HttpContext, llmClient wrapper.HttpClient, llmInfo LLMInfo, jsonResp JsonResp, aPIsParam []APIsParam, aPIClient []wrapper.HttpClient, content string, rawResponse Response, log log.Log, statusCode int, responseBody []byte) { if statusCode != http.StatusOK { log.Debugf("statusCode: %d", statusCode) } @@ -332,7 +335,7 @@ func toolsCallResult(ctx wrapper.HttpContext, llmClient wrapper.HttpClient, llmI } } -func outputParser(response string, log wrapper.Log) (string, string) { +func outputParser(response string, log log.Log) (string, string) { log.Debugf("Raw response:%s", response) start := strings.Index(response, "```") @@ -379,7 +382,7 @@ func outputParser(response string, log wrapper.Log) (string, string) { return "", "" } -func toolsCall(ctx wrapper.HttpContext, llmClient wrapper.HttpClient, llmInfo LLMInfo, jsonResp JsonResp, aPIsParam []APIsParam, aPIClient []wrapper.HttpClient, content string, rawResponse Response, log wrapper.Log) (types.Action, string) { +func toolsCall(ctx wrapper.HttpContext, llmClient wrapper.HttpClient, llmInfo LLMInfo, jsonResp JsonResp, aPIsParam []APIsParam, aPIClient []wrapper.HttpClient, content string, rawResponse Response, log log.Log) (types.Action, string) { dashscope.MessageStore.AddForAssistant(content) action, actionInput := outputParser(content, log) @@ -514,7 +517,7 @@ func toolsCall(ctx wrapper.HttpContext, llmClient wrapper.HttpClient, llmInfo LL } // 从response接收到firstreq的大模型返回 -func onHttpResponseBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action { log.Debugf("onHttpResponseBody start") defer log.Debugf("onHttpResponseBody end") diff --git a/plugins/wasm-go/extensions/ai-cache/cache/provider.go b/plugins/wasm-go/extensions/ai-cache/cache/provider.go index 9521978f2..ad19d5c29 100644 --- a/plugins/wasm-go/extensions/ai-cache/cache/provider.go +++ b/plugins/wasm-go/extensions/ai-cache/cache/provider.go @@ -4,7 +4,8 @@ import ( "errors" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -15,7 +16,7 @@ const ( type providerInitializer interface { ValidateConfig(ProviderConfig) error - CreateProvider(ProviderConfig, wrapper.Log) (Provider, error) + CreateProvider(ProviderConfig, log.Log) (Provider, error) } var ( @@ -128,7 +129,7 @@ func (c *ProviderConfig) Validate() error { return nil } -func CreateProvider(pc ProviderConfig, log wrapper.Log) (Provider, error) { +func CreateProvider(pc ProviderConfig, log log.Log) (Provider, error) { initializer, has := providerInitializers[pc.typ] if !has { return nil, errors.New("unknown provider type: " + pc.typ) diff --git a/plugins/wasm-go/extensions/ai-cache/cache/redis.go b/plugins/wasm-go/extensions/ai-cache/cache/redis.go index caa75c5ca..74134bbda 100644 --- a/plugins/wasm-go/extensions/ai-cache/cache/redis.go +++ b/plugins/wasm-go/extensions/ai-cache/cache/redis.go @@ -3,7 +3,8 @@ package cache import ( "errors" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) type redisProviderInitializer struct { @@ -16,7 +17,7 @@ func (r *redisProviderInitializer) ValidateConfig(cf ProviderConfig) error { return nil } -func (r *redisProviderInitializer) CreateProvider(cf ProviderConfig, log wrapper.Log) (Provider, error) { +func (r *redisProviderInitializer) CreateProvider(cf ProviderConfig, log log.Log) (Provider, error) { rp := redisProvider{ config: cf, client: wrapper.NewRedisClusterClient(wrapper.FQDNCluster{ @@ -32,7 +33,7 @@ func (r *redisProviderInitializer) CreateProvider(cf ProviderConfig, log wrapper type redisProvider struct { config ProviderConfig client wrapper.RedisClient - log wrapper.Log + log log.Log } func (rp *redisProvider) GetProviderType() string { diff --git a/plugins/wasm-go/extensions/ai-cache/config/config.go b/plugins/wasm-go/extensions/ai-cache/config/config.go index d8820c36c..5a8cb7f10 100644 --- a/plugins/wasm-go/extensions/ai-cache/config/config.go +++ b/plugins/wasm-go/extensions/ai-cache/config/config.go @@ -6,7 +6,7 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-cache/cache" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-cache/embedding" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-cache/vector" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" "github.com/tidwall/gjson" ) @@ -46,7 +46,7 @@ type PluginConfig struct { CacheKeyStrategy string } -func (c *PluginConfig) FromJson(json gjson.Result, log wrapper.Log) { +func (c *PluginConfig) FromJson(json gjson.Result, log log.Log) { c.embeddingProviderConfig = &embedding.ProviderConfig{} c.vectorProviderConfig = &vector.ProviderConfig{} c.cacheProviderConfig = &cache.ProviderConfig{} @@ -91,7 +91,7 @@ func (c *PluginConfig) FromJson(json gjson.Result, log wrapper.Log) { if json.Get("enableSemanticCache").Exists() { c.EnableSemanticCache = json.Get("enableSemanticCache").Bool() } else if c.GetVectorProvider() == nil { - c.EnableSemanticCache = false // set value to false when no vector provider + c.EnableSemanticCache = false // set value to false when no vector provider } else { c.EnableSemanticCache = true // set default value to true } @@ -142,7 +142,7 @@ func (c *PluginConfig) Validate() error { return nil } -func (c *PluginConfig) Complete(log wrapper.Log) error { +func (c *PluginConfig) Complete(log log.Log) error { var err error if c.embeddingProviderConfig.GetProviderType() != "" { log.Debugf("embedding provider is set to %s", c.embeddingProviderConfig.GetProviderType()) @@ -193,7 +193,7 @@ func (c *PluginConfig) GetCacheProvider() cache.Provider { return c.cacheProvider } -func convertLegacyMapFields(c *PluginConfig, json gjson.Result, log wrapper.Log) { +func convertLegacyMapFields(c *PluginConfig, json gjson.Result, log log.Log) { keyMap := map[string]string{ "cacheKeyFrom.requestBody": "cacheKeyFrom", "cacheValueFrom.requestBody": "cacheValueFrom", @@ -212,7 +212,7 @@ func convertLegacyMapFields(c *PluginConfig, json gjson.Result, log wrapper.Log) } } -func setField(c *PluginConfig, fieldName string, value string, log wrapper.Log) { +func setField(c *PluginConfig, fieldName string, value string, log log.Log) { switch fieldName { case "cacheKeyFrom": c.CacheKeyFrom = value diff --git a/plugins/wasm-go/extensions/ai-cache/core.go b/plugins/wasm-go/extensions/ai-cache/core.go index 44dea098d..e6c743a25 100644 --- a/plugins/wasm-go/extensions/ai-cache/core.go +++ b/plugins/wasm-go/extensions/ai-cache/core.go @@ -8,13 +8,14 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-cache/config" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-cache/vector" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" + logs "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/resp" ) // CheckCacheForKey checks if the key is in the cache, or triggers similarity search if not found. -func CheckCacheForKey(key string, ctx wrapper.HttpContext, c config.PluginConfig, log wrapper.Log, stream bool, useSimilaritySearch bool) error { +func CheckCacheForKey(key string, ctx wrapper.HttpContext, c config.PluginConfig, log logs.Log, stream bool, useSimilaritySearch bool) error { activeCacheProvider := c.GetCacheProvider() if activeCacheProvider == nil { log.Debugf("[%s] [CheckCacheForKey] no cache provider configured, performing similarity search", PLUGIN_NAME) @@ -37,7 +38,7 @@ func CheckCacheForKey(key string, ctx wrapper.HttpContext, c config.PluginConfig } // handleCacheResponse processes cache response and handles cache hits and misses. -func handleCacheResponse(key string, response resp.Value, ctx wrapper.HttpContext, log wrapper.Log, stream bool, c config.PluginConfig, useSimilaritySearch bool) { +func handleCacheResponse(key string, response resp.Value, ctx wrapper.HttpContext, log logs.Log, stream bool, c config.PluginConfig, useSimilaritySearch bool) { if err := response.Error(); err == nil && !response.IsNull() { log.Infof("[%s] cache hit for key: %s", PLUGIN_NAME, key) processCacheHit(key, response.String(), stream, ctx, c, log) @@ -60,7 +61,7 @@ func handleCacheResponse(key string, response resp.Value, ctx wrapper.HttpContex } // processCacheHit handles a successful cache hit. -func processCacheHit(key string, response string, stream bool, ctx wrapper.HttpContext, c config.PluginConfig, log wrapper.Log) { +func processCacheHit(key string, response string, stream bool, ctx wrapper.HttpContext, c config.PluginConfig, log logs.Log) { if strings.TrimSpace(response) == "" { log.Warnf("[%s] [processCacheHit] cached response for key %s is empty", PLUGIN_NAME, key) proxywasm.ResumeHttpRequest() @@ -85,7 +86,7 @@ func processCacheHit(key string, response string, stream bool, ctx wrapper.HttpC } // performSimilaritySearch determines the appropriate similarity search method to use. -func performSimilaritySearch(key string, ctx wrapper.HttpContext, c config.PluginConfig, log wrapper.Log, queryString string, stream bool) error { +func performSimilaritySearch(key string, ctx wrapper.HttpContext, c config.PluginConfig, log logs.Log, queryString string, stream bool) error { activeVectorProvider := c.GetVectorProvider() if activeVectorProvider == nil { return logAndReturnError(log, "[performSimilaritySearch] no vector provider configured for similarity search") @@ -107,19 +108,19 @@ func performSimilaritySearch(key string, ctx wrapper.HttpContext, c config.Plugi } // performStringQuery executes the string-based similarity search. -func performStringQuery(key string, queryString string, ctx wrapper.HttpContext, c config.PluginConfig, log wrapper.Log, stream bool) error { +func performStringQuery(key string, queryString string, ctx wrapper.HttpContext, c config.PluginConfig, log logs.Log, stream bool) error { stringQuerier, ok := c.GetVectorProvider().(vector.StringQuerier) if !ok { return logAndReturnError(log, "[performStringQuery] active vector provider does not implement StringQuerier interface") } - return stringQuerier.QueryString(queryString, ctx, log, func(results []vector.QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error) { + return stringQuerier.QueryString(queryString, ctx, log, func(results []vector.QueryResult, ctx wrapper.HttpContext, log logs.Log, err error) { handleQueryResults(key, results, ctx, log, stream, c, err) }) } // performEmbeddingQuery executes the embedding-based similarity search. -func performEmbeddingQuery(key string, ctx wrapper.HttpContext, c config.PluginConfig, log wrapper.Log, stream bool) error { +func performEmbeddingQuery(key string, ctx wrapper.HttpContext, c config.PluginConfig, log logs.Log, stream bool) error { embeddingQuerier, ok := c.GetVectorProvider().(vector.EmbeddingQuerier) if !ok { return logAndReturnError(log, fmt.Sprintf("[performEmbeddingQuery] active vector provider does not implement EmbeddingQuerier interface")) @@ -138,7 +139,7 @@ func performEmbeddingQuery(key string, ctx wrapper.HttpContext, c config.PluginC } ctx.SetContext(CACHE_KEY_EMBEDDING_KEY, textEmbedding) - err = embeddingQuerier.QueryEmbedding(textEmbedding, ctx, log, func(results []vector.QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error) { + err = embeddingQuerier.QueryEmbedding(textEmbedding, ctx, log, func(results []vector.QueryResult, ctx wrapper.HttpContext, log logs.Log, err error) { handleQueryResults(key, results, ctx, log, stream, c, err) }) if err != nil { @@ -148,7 +149,7 @@ func performEmbeddingQuery(key string, ctx wrapper.HttpContext, c config.PluginC } // handleQueryResults processes the results of similarity search and determines next actions. -func handleQueryResults(key string, results []vector.QueryResult, ctx wrapper.HttpContext, log wrapper.Log, stream bool, c config.PluginConfig, err error) { +func handleQueryResults(key string, results []vector.QueryResult, ctx wrapper.HttpContext, log logs.Log, stream bool, c config.PluginConfig, err error) { if err != nil { handleInternalError(err, fmt.Sprintf("[%s] [handleQueryResults] error querying vector database for key: %s", PLUGIN_NAME, key), log) return @@ -186,14 +187,14 @@ func handleQueryResults(key string, results []vector.QueryResult, ctx wrapper.Ht } // logAndReturnError logs an error and returns it. -func logAndReturnError(log wrapper.Log, message string) error { +func logAndReturnError(log logs.Log, message string) error { message = fmt.Sprintf("[%s] %s", PLUGIN_NAME, message) log.Errorf(message) return errors.New(message) } // handleInternalError logs an error and resumes the HTTP request. -func handleInternalError(err error, message string, log wrapper.Log) { +func handleInternalError(err error, message string, log logs.Log) { if err != nil { log.Errorf("[%s] [handleInternalError] %s: %v", PLUGIN_NAME, message, err) } else { @@ -204,7 +205,7 @@ func handleInternalError(err error, message string, log wrapper.Log) { } // Caches the response value -func cacheResponse(ctx wrapper.HttpContext, c config.PluginConfig, key string, value string, log wrapper.Log) { +func cacheResponse(ctx wrapper.HttpContext, c config.PluginConfig, key string, value string, log logs.Log) { if strings.TrimSpace(value) == "" { log.Warnf("[%s] [cacheResponse] cached value for key %s is empty", PLUGIN_NAME, key) return @@ -219,7 +220,7 @@ func cacheResponse(ctx wrapper.HttpContext, c config.PluginConfig, key string, v } // Handles embedding upload if available -func uploadEmbeddingAndAnswer(ctx wrapper.HttpContext, c config.PluginConfig, key string, value string, log wrapper.Log) { +func uploadEmbeddingAndAnswer(ctx wrapper.HttpContext, c config.PluginConfig, key string, value string, log logs.Log) { embedding := ctx.GetContext(CACHE_KEY_EMBEDDING_KEY) if embedding == nil { return diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/azure.go b/plugins/wasm-go/extensions/ai-cache/embedding/azure.go index 3fc33d23a..e4b400f3e 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/azure.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/azure.go @@ -7,8 +7,8 @@ import ( "net/http" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/cohere.go b/plugins/wasm-go/extensions/ai-cache/embedding/cohere.go index 1e37d1d77..348350249 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/cohere.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/cohere.go @@ -7,8 +7,8 @@ import ( "net/http" "strconv" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/dashscope.go b/plugins/wasm-go/extensions/ai-cache/embedding/dashscope.go index a577a024f..81ccf260a 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/dashscope.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/dashscope.go @@ -7,8 +7,8 @@ import ( "net/http" "strconv" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/huggingface.go b/plugins/wasm-go/extensions/ai-cache/embedding/huggingface.go index 8a6613916..bdbdc7023 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/huggingface.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/huggingface.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/ollama.go b/plugins/wasm-go/extensions/ai-cache/embedding/ollama.go index 49bc6e20b..ff045a627 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/ollama.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/ollama.go @@ -7,8 +7,8 @@ import ( "net/http" "strconv" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/openai.go b/plugins/wasm-go/extensions/ai-cache/embedding/openai.go index 6d504305a..c7de38299 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/openai.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/openai.go @@ -6,8 +6,8 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/provider.go b/plugins/wasm-go/extensions/ai-cache/embedding/provider.go index be0c84716..06a4d3193 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/provider.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/provider.go @@ -3,7 +3,7 @@ package embedding import ( "errors" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/textin.go b/plugins/wasm-go/extensions/ai-cache/embedding/textin.go index 6cef96baa..fc7a790bc 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/textin.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/textin.go @@ -7,8 +7,8 @@ import ( "net/http" "strconv" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/embedding/xfyun.go b/plugins/wasm-go/extensions/ai-cache/embedding/xfyun.go index 128c950fa..c33a3b825 100644 --- a/plugins/wasm-go/extensions/ai-cache/embedding/xfyun.go +++ b/plugins/wasm-go/extensions/ai-cache/embedding/xfyun.go @@ -14,8 +14,8 @@ import ( "strconv" "time" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-cache/go.mod b/plugins/wasm-go/extensions/ai-cache/go.mod index 56bea605f..6d024dcfd 100644 --- a/plugins/wasm-go/extensions/ai-cache/go.mod +++ b/plugins/wasm-go/extensions/ai-cache/go.mod @@ -2,23 +2,20 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-cache -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.2 github.com/google/uuid v1.6.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/resp v0.1.1 // github.com/weaviate/weaviate-go-client/v4 v4.15.1 ) require ( - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/stretchr/testify v1.9.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ai-cache/go.sum b/plugins/wasm-go/extensions/ai-cache/go.sum index 0a3635868..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/ai-cache/go.sum +++ b/plugins/wasm-go/extensions/ai-cache/go.sum @@ -1,21 +1,23 @@ 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/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/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/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/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-cache/main.go b/plugins/wasm-go/extensions/ai-cache/main.go index 41014c5eb..91a4eab79 100644 --- a/plugins/wasm-go/extensions/ai-cache/main.go +++ b/plugins/wasm-go/extensions/ai-cache/main.go @@ -6,9 +6,10 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-cache/config" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -26,7 +27,9 @@ const ( DEFAULT_MAX_BODY_BYTES uint32 = 100 * 1024 * 1024 ) -func main() { +func main() {} + +func init() { // CreateClient() wrapper.SetCtx( PLUGIN_NAME, @@ -38,7 +41,7 @@ func main() { ) } -func parseConfig(json gjson.Result, c *config.PluginConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, c *config.PluginConfig, log log.Log) error { // config.EmbeddingProviderConfig.FromJson(json.Get("embeddingProvider")) // config.VectorDatabaseProviderConfig.FromJson(json.Get("vectorBaseProvider")) // config.RedisConfig.FromJson(json.Get("redis")) @@ -54,7 +57,7 @@ func parseConfig(json gjson.Result, c *config.PluginConfig, log wrapper.Log) err return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, c config.PluginConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, c config.PluginConfig, log log.Log) types.Action { skipCache, _ := proxywasm.GetHttpRequestHeader(SKIP_CACHE_HEADER) if skipCache == "on" { ctx.SetContext(SKIP_CACHE_HEADER, struct{}{}) @@ -78,7 +81,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, c config.PluginConfig, log wr return types.HeaderStopIteration } -func onHttpRequestBody(ctx wrapper.HttpContext, c config.PluginConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, c config.PluginConfig, body []byte, log log.Log) types.Action { bodyJson := gjson.ParseBytes(body) // TODO: It may be necessary to support stream mode determination for different LLM providers. @@ -128,7 +131,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, c config.PluginConfig, body []by return types.ActionPause } -func onHttpResponseHeaders(ctx wrapper.HttpContext, c config.PluginConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, c config.PluginConfig, log log.Log) types.Action { skipCache := ctx.GetContext(SKIP_CACHE_HEADER) if skipCache != nil { ctx.SetUserAttribute("cache_status", "skip") @@ -150,7 +153,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, c config.PluginConfig, log w return types.ActionContinue } -func onHttpResponseBody(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, isLastChunk bool, log wrapper.Log) []byte { +func onHttpResponseBody(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, isLastChunk bool, log log.Log) []byte { log.Debugf("[onHttpResponseBody] is last chunk: %v", isLastChunk) log.Debugf("[onHttpResponseBody] chunk: %s", string(chunk)) diff --git a/plugins/wasm-go/extensions/ai-cache/util.go b/plugins/wasm-go/extensions/ai-cache/util.go index 50a39c88c..382b361f6 100644 --- a/plugins/wasm-go/extensions/ai-cache/util.go +++ b/plugins/wasm-go/extensions/ai-cache/util.go @@ -6,11 +6,12 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-cache/config" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func handleNonStreamChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, log wrapper.Log) error { +func handleNonStreamChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, log log.Log) error { tempContentI := ctx.GetContext(CACHE_CONTENT_CONTEXT_KEY) if tempContentI == nil { ctx.SetContext(CACHE_CONTENT_CONTEXT_KEY, chunk) @@ -28,7 +29,7 @@ func unifySSEChunk(data []byte) []byte { return data } -func handleStreamChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, log wrapper.Log) error { +func handleStreamChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, log log.Log) error { var partialMessage []byte partialMessageI := ctx.GetContext(PARTIAL_MESSAGE_CONTEXT_KEY) log.Debugf("[handleStreamChunk] cache content: %v", ctx.GetContext(CACHE_CONTENT_CONTEXT_KEY)) @@ -54,7 +55,7 @@ func handleStreamChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []b return nil } -func processNonStreamLastChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, log wrapper.Log) (string, error) { +func processNonStreamLastChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, log log.Log) (string, error) { var body []byte tempContentI := ctx.GetContext(CACHE_CONTENT_CONTEXT_KEY) if tempContentI != nil { @@ -70,7 +71,7 @@ func processNonStreamLastChunk(ctx wrapper.HttpContext, c config.PluginConfig, c return value, nil } -func processStreamLastChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, log wrapper.Log) (string, error) { +func processStreamLastChunk(ctx wrapper.HttpContext, c config.PluginConfig, chunk []byte, log log.Log) (string, error) { if len(chunk) > 0 { var lastMessage []byte partialMessageI := ctx.GetContext(PARTIAL_MESSAGE_CONTEXT_KEY) @@ -96,7 +97,7 @@ func processStreamLastChunk(ctx wrapper.HttpContext, c config.PluginConfig, chun return tempContentI.(string), nil } -func processSSEMessage(ctx wrapper.HttpContext, c config.PluginConfig, sseMessage string, log wrapper.Log) (string, error) { +func processSSEMessage(ctx wrapper.HttpContext, c config.PluginConfig, sseMessage string, log log.Log) (string, error) { content := "" for _, chunk := range strings.Split(sseMessage, "\n\n") { log.Debugf("single sse message: %s", chunk) diff --git a/plugins/wasm-go/extensions/ai-cache/vector/chroma.go b/plugins/wasm-go/extensions/ai-cache/vector/chroma.go index a15e72bd4..069a772c8 100644 --- a/plugins/wasm-go/extensions/ai-cache/vector/chroma.go +++ b/plugins/wasm-go/extensions/ai-cache/vector/chroma.go @@ -6,7 +6,8 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) type chromaProviderInitializer struct{} @@ -44,8 +45,8 @@ func (c *ChromaProvider) GetProviderType() string { func (d *ChromaProvider) QueryEmbedding( emb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 collection_id, embeddings 和 ids // 下面是一个例子 // { @@ -96,8 +97,8 @@ func (d *ChromaProvider) UploadAnswerAndEmbedding( queryEmb []float64, queryAnswer string, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 collection_id, embeddings 和 ids // 下面是一个例子 // { @@ -177,7 +178,7 @@ type chromaQueryResponse struct { Included []string `json:"included"` } -func (d *ChromaProvider) parseQueryResponse(responseBody []byte, log wrapper.Log) ([]QueryResult, error) { +func (d *ChromaProvider) parseQueryResponse(responseBody []byte, log log.Log) ([]QueryResult, error) { var queryResp chromaQueryResponse err := json.Unmarshal(responseBody, &queryResp) if err != nil { diff --git a/plugins/wasm-go/extensions/ai-cache/vector/dashvector.go b/plugins/wasm-go/extensions/ai-cache/vector/dashvector.go index 7bdb0a76d..8a2a2a980 100644 --- a/plugins/wasm-go/extensions/ai-cache/vector/dashvector.go +++ b/plugins/wasm-go/extensions/ai-cache/vector/dashvector.go @@ -6,7 +6,8 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) type dashVectorProviderInitializer struct { @@ -119,8 +120,8 @@ func (d *DvProvider) parseQueryResponse(responseBody []byte) (queryResponse, err func (d *DvProvider) QueryEmbedding( emb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error { url, body, headers, err := d.constructEmbeddingQueryParameters(emb) log.Debugf("url:%s, body:%s, headers:%v", url, string(body), headers) if err != nil { @@ -157,7 +158,7 @@ func getStringValue(fields map[string]interface{}, key string) string { return "" } -func (d *DvProvider) ParseQueryResponse(responseBody []byte, ctx wrapper.HttpContext, log wrapper.Log) ([]QueryResult, error) { +func (d *DvProvider) ParseQueryResponse(responseBody []byte, ctx wrapper.HttpContext, log log.Log) ([]QueryResult, error) { resp, err := d.parseQueryResponse(responseBody) if err != nil { return nil, err @@ -215,7 +216,7 @@ func (d *DvProvider) constructUploadParameters(emb []float64, queryString string return url, requestBody, header, err } -func (d *DvProvider) UploadEmbedding(queryString string, queryEmb []float64, ctx wrapper.HttpContext, log wrapper.Log, callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error { +func (d *DvProvider) UploadEmbedding(queryString string, queryEmb []float64, ctx wrapper.HttpContext, log log.Log, callback func(ctx wrapper.HttpContext, log log.Log, err error)) error { url, body, headers, err := d.constructUploadParameters(queryEmb, queryString, "") if err != nil { return err @@ -235,7 +236,7 @@ func (d *DvProvider) UploadEmbedding(queryString string, queryEmb []float64, ctx return err } -func (d *DvProvider) UploadAnswerAndEmbedding(queryString string, queryEmb []float64, queryAnswer string, ctx wrapper.HttpContext, log wrapper.Log, callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error { +func (d *DvProvider) UploadAnswerAndEmbedding(queryString string, queryEmb []float64, queryAnswer string, ctx wrapper.HttpContext, log log.Log, callback func(ctx wrapper.HttpContext, log log.Log, err error)) error { url, body, headers, err := d.constructUploadParameters(queryEmb, queryString, queryAnswer) if err != nil { return err diff --git a/plugins/wasm-go/extensions/ai-cache/vector/elasticsearch.go b/plugins/wasm-go/extensions/ai-cache/vector/elasticsearch.go index 263bdd285..2943d3777 100644 --- a/plugins/wasm-go/extensions/ai-cache/vector/elasticsearch.go +++ b/plugins/wasm-go/extensions/ai-cache/vector/elasticsearch.go @@ -7,7 +7,8 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) type esProviderInitializer struct{} @@ -45,8 +46,8 @@ func (c *ESProvider) GetProviderType() string { func (d *ESProvider) QueryEmbedding( emb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error { requestBody, err := json.Marshal(esQueryRequest{ Source: Source{Excludes: []string{"embedding"}}, @@ -99,8 +100,8 @@ func (d *ESProvider) UploadAnswerAndEmbedding( queryEmb []float64, queryAnswer string, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 index, embeddings 和 question // 下面是一个例子 // POST //_doc @@ -176,7 +177,7 @@ type esQueryResponse struct { } `json:"hits"` } -func (d *ESProvider) parseQueryResponse(responseBody []byte, log wrapper.Log) ([]QueryResult, error) { +func (d *ESProvider) parseQueryResponse(responseBody []byte, log log.Log) ([]QueryResult, error) { log.Infof("[ES] responseBody: %s", string(responseBody)) var queryResp esQueryResponse err := json.Unmarshal(responseBody, &queryResp) diff --git a/plugins/wasm-go/extensions/ai-cache/vector/milvus.go b/plugins/wasm-go/extensions/ai-cache/vector/milvus.go index 7e5ee205f..934519d82 100644 --- a/plugins/wasm-go/extensions/ai-cache/vector/milvus.go +++ b/plugins/wasm-go/extensions/ai-cache/vector/milvus.go @@ -6,7 +6,8 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -58,8 +59,8 @@ func (d *milvusProvider) UploadAnswerAndEmbedding( queryEmb []float64, queryAnswer string, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 collectionName, data 和 Authorization. question, answer 可选 // 需要填写 id,否则 v2.4.13-hotfix 提示 invalid syntax: invalid parameter[expected=Int64][actual=] // 如果不填写 id,要在创建 collection 的时候设置 autoId 为 true @@ -120,8 +121,8 @@ type milvusQueryRequest struct { func (d *milvusProvider) QueryEmbedding( emb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 collectionName, data, annsField. outputFields 为可选参数 // 下面是一个例子 // { @@ -175,7 +176,7 @@ func (d *milvusProvider) QueryEmbedding( ) } -func (d *milvusProvider) parseQueryResponse(responseBody []byte, log wrapper.Log) ([]QueryResult, error) { +func (d *milvusProvider) parseQueryResponse(responseBody []byte, log log.Log) ([]QueryResult, error) { if !gjson.GetBytes(responseBody, "data.0.distance").Exists() { log.Errorf("[Milvus] No distance found in response body: %s", responseBody) return nil, errors.New("[Milvus] No distance found in response body") diff --git a/plugins/wasm-go/extensions/ai-cache/vector/pinecone.go b/plugins/wasm-go/extensions/ai-cache/vector/pinecone.go index 9f490a5a4..2e9fddfd2 100644 --- a/plugins/wasm-go/extensions/ai-cache/vector/pinecone.go +++ b/plugins/wasm-go/extensions/ai-cache/vector/pinecone.go @@ -6,8 +6,9 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/google/uuid" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -67,8 +68,8 @@ func (d *pineconeProvider) UploadAnswerAndEmbedding( queryEmb []float64, queryAnswer string, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 vector 和 question // 下面是一个例子 // { @@ -122,8 +123,8 @@ type pineconeQueryRequest struct { func (d *pineconeProvider) QueryEmbedding( emb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 vector // 下面是一个例子 // { @@ -163,7 +164,7 @@ func (d *pineconeProvider) QueryEmbedding( ) } -func (d *pineconeProvider) parseQueryResponse(responseBody []byte, log wrapper.Log) ([]QueryResult, error) { +func (d *pineconeProvider) parseQueryResponse(responseBody []byte, log log.Log) ([]QueryResult, error) { if !gjson.GetBytes(responseBody, "matches.0.score").Exists() { log.Errorf("[Pinecone] No distance found in response body: %s", responseBody) return nil, errors.New("[Pinecone] No distance found in response body") diff --git a/plugins/wasm-go/extensions/ai-cache/vector/provider.go b/plugins/wasm-go/extensions/ai-cache/vector/provider.go index cbaff3691..37cc71d6f 100644 --- a/plugins/wasm-go/extensions/ai-cache/vector/provider.go +++ b/plugins/wasm-go/extensions/ai-cache/vector/provider.go @@ -3,7 +3,8 @@ package vector import ( "errors" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -50,8 +51,8 @@ type EmbeddingQuerier interface { QueryEmbedding( emb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error } type EmbeddingUploader interface { @@ -59,8 +60,8 @@ type EmbeddingUploader interface { queryString string, queryEmb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error + log log.Log, + callback func(ctx wrapper.HttpContext, log log.Log, err error)) error } type AnswerAndEmbeddingUploader interface { @@ -69,16 +70,16 @@ type AnswerAndEmbeddingUploader interface { queryEmb []float64, answer string, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error + log log.Log, + callback func(ctx wrapper.HttpContext, log log.Log, err error)) error } type StringQuerier interface { QueryString( queryString string, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error } type ProviderConfig struct { diff --git a/plugins/wasm-go/extensions/ai-cache/vector/qdrant.go b/plugins/wasm-go/extensions/ai-cache/vector/qdrant.go index 3355d0d9a..31d91367b 100644 --- a/plugins/wasm-go/extensions/ai-cache/vector/qdrant.go +++ b/plugins/wasm-go/extensions/ai-cache/vector/qdrant.go @@ -6,8 +6,9 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/google/uuid" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -63,8 +64,8 @@ func (d *qdrantProvider) UploadAnswerAndEmbedding( queryEmb []float64, queryAnswer string, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 id 和 vector. payload 可选 // 下面是一个例子 // { @@ -122,8 +123,8 @@ type qdrantQueryRequest struct { func (d *qdrantProvider) QueryEmbedding( emb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 vector 和 limit. with_payload 可选,为了直接得到问题答案,所以这里需要 // 下面是一个例子 // { @@ -164,7 +165,7 @@ func (d *qdrantProvider) QueryEmbedding( ) } -func (d *qdrantProvider) parseQueryResponse(responseBody []byte, log wrapper.Log) ([]QueryResult, error) { +func (d *qdrantProvider) parseQueryResponse(responseBody []byte, log log.Log) ([]QueryResult, error) { // 返回的内容例子如下 // { // "time": 0.002, diff --git a/plugins/wasm-go/extensions/ai-cache/vector/weaviate.go b/plugins/wasm-go/extensions/ai-cache/vector/weaviate.go index 668e2d7bc..ac3ff7031 100644 --- a/plugins/wasm-go/extensions/ai-cache/vector/weaviate.go +++ b/plugins/wasm-go/extensions/ai-cache/vector/weaviate.go @@ -6,7 +6,8 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -45,8 +46,8 @@ func (c *WeaviateProvider) GetProviderType() string { func (d *WeaviateProvider) QueryEmbedding( emb []float64, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(results []QueryResult, ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(results []QueryResult, ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 class, vector // 下面是一个例子 // {"query": "{ Get { Higress ( limit: 2 nearVector: { vector: [0.1, 0.2, 0.3] } ) { question _additional { distance } } } }"} @@ -109,8 +110,8 @@ func (d *WeaviateProvider) UploadAnswerAndEmbedding( queryEmb []float64, queryAnswer string, ctx wrapper.HttpContext, - log wrapper.Log, - callback func(ctx wrapper.HttpContext, log wrapper.Log, err error)) error { + log log.Log, + callback func(ctx wrapper.HttpContext, log log.Log, err error)) error { // 最少需要填写的参数为 class, vector 和 question 和 answer // 下面是一个例子 // {"class": "Higress", "vector": [0.1, 0.2, 0.3], "properties": {"question": "这里是问题", "answer": "这里是答案"}} @@ -155,7 +156,7 @@ type weaviateQueryRequest struct { Query string `json:"query"` } -func (d *WeaviateProvider) parseQueryResponse(responseBody []byte, log wrapper.Log) ([]QueryResult, error) { +func (d *WeaviateProvider) parseQueryResponse(responseBody []byte, log log.Log) ([]QueryResult, error) { log.Infof("[Weaviate] queryResp: %s", string(responseBody)) if !gjson.GetBytes(responseBody, fmt.Sprintf("data.Get.%s.0._additional.distance", d.config.collectionID)).Exists() { diff --git a/plugins/wasm-go/extensions/ai-history/go.mod b/plugins/wasm-go/extensions/ai-history/go.mod index c6d95fd30..934a810fd 100644 --- a/plugins/wasm-go/extensions/ai-history/go.mod +++ b/plugins/wasm-go/extensions/ai-history/go.mod @@ -2,21 +2,19 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-history -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.6-0.20240528060522-53bccf89f441 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/resp v0.1.1 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ai-history/go.sum b/plugins/wasm-go/extensions/ai-history/go.sum index b4ab172fe..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/ai-history/go.sum +++ b/plugins/wasm-go/extensions/ai-history/go.sum @@ -1,20 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-history/main.go b/plugins/wasm-go/extensions/ai-history/main.go index f0fabaaa4..cec2d2a0f 100644 --- a/plugins/wasm-go/extensions/ai-history/main.go +++ b/plugins/wasm-go/extensions/ai-history/main.go @@ -11,9 +11,10 @@ import ( "strconv" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/resp" ) @@ -29,7 +30,9 @@ const ( ChatHistories = "chatHistories" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-history", wrapper.ParseConfigBy(parseConfig), @@ -121,7 +124,7 @@ type ChatHistory struct { Content string `json:"content"` } -func parseConfig(json gjson.Result, c *PluginConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, c *PluginConfig, log log.Log) error { c.RedisInfo.ServiceName = json.Get("redis.serviceName").String() if c.RedisInfo.ServiceName == "" { return errors.New("redis service name must not be empty") @@ -166,7 +169,7 @@ func parseConfig(json gjson.Result, c *PluginConfig, log wrapper.Log) error { return c.redisClient.Init(c.RedisInfo.Username, c.RedisInfo.Password, int64(c.RedisInfo.Timeout), wrapper.WithDataBase(c.RedisInfo.Database)) } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { contentType, _ := proxywasm.GetHttpRequestHeader("content-type") if !strings.Contains(contentType, "application/json") { log.Warnf("content is not json, can't process:%s", contentType) @@ -192,7 +195,7 @@ func TrimQuote(source string) string { return strings.Trim(source, `"`) } -func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action { bodyJson := gjson.ParseBytes(body) if bodyJson.Get("stream").Bool() { ctx.SetContext(StreamContextKey, struct{}{}) @@ -319,7 +322,7 @@ func getIntQueryParameter(name string, path string, defaultValue int) int { return num } -func processSSEMessage(ctx wrapper.HttpContext, config PluginConfig, sseMessage string, log wrapper.Log) string { +func processSSEMessage(ctx wrapper.HttpContext, config PluginConfig, sseMessage string, log log.Log) string { content := "" for _, chunk := range strings.Split(sseMessage, "\n\n") { subMessages := strings.Split(chunk, "\n") @@ -355,14 +358,14 @@ func processSSEMessage(ctx wrapper.HttpContext, config PluginConfig, sseMessage return content } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { contentType, _ := proxywasm.GetHttpResponseHeader("content-type") if strings.Contains(contentType, "text/event-stream") { ctx.SetContext(StreamContextKey, struct{}{}) } return types.ActionContinue } -func onHttpStreamResponseBody(ctx wrapper.HttpContext, config PluginConfig, chunk []byte, isLastChunk bool, log wrapper.Log) []byte { +func onHttpStreamResponseBody(ctx wrapper.HttpContext, config PluginConfig, chunk []byte, isLastChunk bool, log log.Log) []byte { if ctx.GetContext(ToolCallsContextKey) != nil { // we should not cache tool call result return chunk @@ -454,7 +457,7 @@ func onHttpStreamResponseBody(ctx wrapper.HttpContext, config PluginConfig, chun return chunk } -func saveChatHistory(ctx wrapper.HttpContext, config PluginConfig, questionI any, value string, log wrapper.Log) { +func saveChatHistory(ctx wrapper.HttpContext, config PluginConfig, questionI any, value string, log log.Log) { question := questionI.(string) identityKey := ctx.GetStringContext(IdentityKey, "") var chat []ChatHistory diff --git a/plugins/wasm-go/extensions/ai-image-reader/dashscope.go b/plugins/wasm-go/extensions/ai-image-reader/dashscope.go index 90c4d8070..b6bec0954 100644 --- a/plugins/wasm-go/extensions/ai-image-reader/dashscope.go +++ b/plugins/wasm-go/extensions/ai-image-reader/dashscope.go @@ -4,11 +4,12 @@ import ( "encoding/json" "errors" "fmt" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" - "github.com/tidwall/gjson" "net/http" "strconv" + + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" + "github.com/tidwall/gjson" ) const ( diff --git a/plugins/wasm-go/extensions/ai-image-reader/go.mod b/plugins/wasm-go/extensions/ai-image-reader/go.mod index 7f50ccfcd..d5ca56ea5 100644 --- a/plugins/wasm-go/extensions/ai-image-reader/go.mod +++ b/plugins/wasm-go/extensions/ai-image-reader/go.mod @@ -1,19 +1,19 @@ module ai-image-reader -go 1.19 +go 1.24.1 + +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.4-0.20250621002302-e94ac43dd15c + github.com/higress-group/wasm-go v1.0.0 github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/higress-group/proxy-wasm-go-sdk v1.0.1 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - github.com/tidwall/sjson v1.2.5 // indirect + github.com/tidwall/sjson v1.2.5 ) diff --git a/plugins/wasm-go/extensions/ai-image-reader/go.sum b/plugins/wasm-go/extensions/ai-image-reader/go.sum index 54a7eb886..10f7f623e 100644 --- a/plugins/wasm-go/extensions/ai-image-reader/go.sum +++ b/plugins/wasm-go/extensions/ai-image-reader/go.sum @@ -1,25 +1,26 @@ -github.com/alibaba/higress/plugins/wasm-go v1.4.4-0.20250621002302-e94ac43dd15c h1:YGKECMrlahN6dyEaM/S5NEU4IJoFzWKsHQyawov6ep8= -github.com/alibaba/higress/plugins/wasm-go v1.4.4-0.20250621002302-e94ac43dd15c/go.mod h1:E2xVWrIovU3rZi4HGlMfcYf+c/UVh3aCtpcJlNjpxYc= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.1 h1:f9X4I5Y6jK3GrdsWn/lCTI1z5Lu5GOMazqQohAC3Vzk= -github.com/higress-group/proxy-wasm-go-sdk v1.0.1/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-image-reader/main.go b/plugins/wasm-go/extensions/ai-image-reader/main.go index 13c2d22fd..dc1a45794 100644 --- a/plugins/wasm-go/extensions/ai-image-reader/main.go +++ b/plugins/wasm-go/extensions/ai-image-reader/main.go @@ -3,13 +3,14 @@ package main import ( "errors" "fmt" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "strings" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/sjson" - "strings" ) const ( @@ -22,7 +23,9 @@ type Config struct { ocrProviderConfig *ProviderConfig } -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-image-reader", wrapper.ParseConfig(parseConfig), diff --git a/plugins/wasm-go/extensions/ai-intent/go.mod b/plugins/wasm-go/extensions/ai-intent/go.mod index 1ebbc1e8b..1037260b4 100644 --- a/plugins/wasm-go/extensions/ai-intent/go.mod +++ b/plugins/wasm-go/extensions/ai-intent/go.mod @@ -2,21 +2,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-intent -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.2 - github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f - github.com/tidwall/gjson v1.17.1 - + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/google/uuid v1.6.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect diff --git a/plugins/wasm-go/extensions/ai-intent/go.sum b/plugins/wasm-go/extensions/ai-intent/go.sum index 8b8fd23e1..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/ai-intent/go.sum +++ b/plugins/wasm-go/extensions/ai-intent/go.sum @@ -2,19 +2,16 @@ 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/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/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= -github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tetratelabs/wazero v1.6.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= diff --git a/plugins/wasm-go/extensions/ai-intent/main.go b/plugins/wasm-go/extensions/ai-intent/main.go index fdf6302e4..e7bd806c5 100644 --- a/plugins/wasm-go/extensions/ai-intent/main.go +++ b/plugins/wasm-go/extensions/ai-intent/main.go @@ -12,9 +12,10 @@ import ( "strconv" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -23,7 +24,9 @@ const ( defaultTimeout = 10 * 1000 // ms ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-intent", wrapper.ParseConfigBy(parseConfig), @@ -100,7 +103,7 @@ type KVExtractor struct { ResponseBody string `required:"false" yaml:"responseBody" json:"responseBody"` } -func parseConfig(json gjson.Result, c *PluginConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, c *PluginConfig, log log.Log) error { log.Infof("config:%s", json.Raw) // init scene c.SceneInfo.Category = json.Get("scene.category").String() @@ -194,14 +197,14 @@ func parseConfig(json gjson.Result, c *PluginConfig, log wrapper.Log) error { return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { log.Debug("start onHttpRequestHeaders function.") log.Debug("end onHttpRequestHeaders function.") return types.HeaderStopIteration } -func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action { log.Debug("start onHttpRequestBody function.") bodyJson := gjson.ParseBytes(body) TempKey := strings.Trim(bodyJson.Get(config.KeyFrom.RequestBody).Raw, `"`) @@ -259,21 +262,21 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte return types.ActionPause } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { log.Debug("start onHttpResponseHeaders function.") log.Debug("end onHttpResponseHeaders function.") return types.ActionContinue } -func onStreamingResponseBody(ctx wrapper.HttpContext, config PluginConfig, chunk []byte, isLastChunk bool, log wrapper.Log) []byte { +func onStreamingResponseBody(ctx wrapper.HttpContext, config PluginConfig, chunk []byte, isLastChunk bool, log log.Log) []byte { log.Debug("start onStreamingResponseBody function.") log.Debug("end onStreamingResponseBody function.") return chunk } -func onHttpResponseBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action { log.Debug("start onHttpResponseBody function.") log.Debug("end onHttpResponseBody function.") @@ -290,7 +293,7 @@ type ProxyRequestMessage struct { Content string `json:"content"` } -func generateProxyRequest(c *PluginConfig, texts []string, log wrapper.Log) (string, []byte, [][2]string) { +func generateProxyRequest(c *PluginConfig, texts []string, log log.Log) (string, []byte, [][2]string) { url := c.LLMInfo.ProxyPath var userMessage ProxyRequestMessage userMessage.Role = "user" @@ -338,7 +341,7 @@ type ProxyResponseOutputChoicesMessage struct { Content string `json:"content"` } -func proxyResponseHandler(responseBody []byte, log wrapper.Log) (*ProxyResponse, error) { +func proxyResponseHandler(responseBody []byte, log log.Log) (*ProxyResponse, error) { var response ProxyResponse err := json.Unmarshal(responseBody, &response) if err != nil { @@ -348,7 +351,7 @@ func proxyResponseHandler(responseBody []byte, log wrapper.Log) (*ProxyResponse, return &response, nil } -func getProxyResponseByExtractor(c *PluginConfig, responseBody []byte, log wrapper.Log) string { +func getProxyResponseByExtractor(c *PluginConfig, responseBody []byte, log log.Log) string { bodyJson := gjson.ParseBytes(responseBody) responseContent := strings.Trim(bodyJson.Get(c.KeyFrom.ResponseBody).Raw, `"`) // llm返回的结果 diff --git a/plugins/wasm-go/extensions/ai-json-resp/go.mod b/plugins/wasm-go/extensions/ai-json-resp/go.mod index 975ff1b1c..039285bce 100644 --- a/plugins/wasm-go/extensions/ai-json-resp/go.mod +++ b/plugins/wasm-go/extensions/ai-json-resp/go.mod @@ -1,21 +1,19 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/hello-world -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.2 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect - github.com/tidwall/gjson v1.17.3 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/santhosh-tekuri/jsonschema v1.2.4 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ai-json-resp/go.sum b/plugins/wasm-go/extensions/ai-json-resp/go.sum index 8fcbe81a0..a7b19e313 100644 --- a/plugins/wasm-go/extensions/ai-json-resp/go.sum +++ b/plugins/wasm-go/extensions/ai-json-resp/go.sum @@ -1,28 +1,25 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis= github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-json-resp/main.go b/plugins/wasm-go/extensions/ai-json-resp/main.go index 1034396d7..68837f157 100644 --- a/plugins/wasm-go/extensions/ai-json-resp/main.go +++ b/plugins/wasm-go/extensions/ai-json-resp/main.go @@ -23,10 +23,11 @@ import ( "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" "github.com/santhosh-tekuri/jsonschema" "github.com/tidwall/gjson" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) const ( @@ -110,7 +111,9 @@ type PluginConfig struct { enableJsonSchemaValidation bool } -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-json-resp", wrapper.ParseConfigBy(parseConfig), @@ -141,7 +144,7 @@ func parseUrl(url string) (string, string) { return url[:index], url[index:] } -func parseConfig(result gjson.Result, config *PluginConfig, log wrapper.Log) error { +func parseConfig(result gjson.Result, config *PluginConfig, log log.Log) error { config.serviceName = result.Get("serviceName").String() config.serviceUrl = result.Get("serviceUrl").String() config.serviceDomain = result.Get("serviceDomain").String() @@ -278,7 +281,7 @@ func (r *RequestContext) assembleReqBody(config PluginConfig) []byte { return reqBody } -func (r *RequestContext) SaveBodyToHistMsg(log wrapper.Log, reqBody []byte, respBody []byte) { +func (r *RequestContext) SaveBodyToHistMsg(log log.Log, reqBody []byte, respBody []byte) { r.RespBody = respBody lastUserMessage := "" lastSystemMessage := "" @@ -318,7 +321,7 @@ func (r *RequestContext) SaveBodyToHistMsg(log wrapper.Log, reqBody []byte, resp } } -func (r *RequestContext) SaveStrToHistMsg(log wrapper.Log, errMsg string) { +func (r *RequestContext) SaveStrToHistMsg(log log.Log, errMsg string) { r.HistoryMessages = append(r.HistoryMessages, chatMessage{ Role: "system", Content: errMsg, @@ -340,7 +343,7 @@ func (c *PluginConfig) ValidateBody(body []byte) error { return nil } -func (c *PluginConfig) ValidateJson(body []byte, log wrapper.Log) (string, error) { +func (c *PluginConfig) ValidateJson(body []byte, log log.Log) (string, error) { content := gjson.ParseBytes(body).Get(c.contentPath).String() // first extract json from response body if content == "" { @@ -399,7 +402,7 @@ func (c *PluginConfig) ExtractJson(bodyStr string) (string, error) { return jsonStr, nil } -func sendResponse(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log, body []byte) { +func sendResponse(ctx wrapper.HttpContext, config PluginConfig, log log.Log, body []byte) { log.Infof("Final send: Code %d, Message %s, Body: %s", config.rejectStruct.RejectCode, config.rejectStruct.RejectMsg, string(body)) header := [][2]string{ {"Content-Type", "application/json"}, @@ -414,7 +417,7 @@ func sendResponse(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log, } } -func recursiveRefineJson(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log, retryCount int, requestContext *RequestContext) { +func recursiveRefineJson(ctx wrapper.HttpContext, config PluginConfig, log log.Log, retryCount int, requestContext *RequestContext) { // if retry count exceeds max retry count, return the response if retryCount >= config.maxRetry { log.Debugf("retry count exceeds max retry count") @@ -445,7 +448,7 @@ func recursiveRefineJson(ctx wrapper.HttpContext, config PluginConfig, log wrapp }, uint32(config.serviceTimeout)) } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { if config.rejectStruct.RejectCode != HTTP_STATUS_OK { sendResponse(ctx, config, log, nil) return types.ActionPause @@ -505,7 +508,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrap return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action { // if the request is from this plugin, continue the request fromThisPlugin, ok := ctx.GetContext(FROM_THIS_PLUGIN_KEY).(bool) if ok && fromThisPlugin { diff --git a/plugins/wasm-go/extensions/ai-prompt-decorator/go.mod b/plugins/wasm-go/extensions/ai-prompt-decorator/go.mod index c20e17a41..20a5ccea6 100644 --- a/plugins/wasm-go/extensions/ai-prompt-decorator/go.mod +++ b/plugins/wasm-go/extensions/ai-prompt-decorator/go.mod @@ -1,21 +1,19 @@ module ai-prompt-decorator -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.5 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect github.com/tidwall/sjson v1.2.5 ) diff --git a/plugins/wasm-go/extensions/ai-prompt-decorator/go.sum b/plugins/wasm-go/extensions/ai-prompt-decorator/go.sum index 6deccd9c2..10f7f623e 100644 --- a/plugins/wasm-go/extensions/ai-prompt-decorator/go.sum +++ b/plugins/wasm-go/extensions/ai-prompt-decorator/go.sum @@ -1,25 +1,26 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-prompt-decorator/main.go b/plugins/wasm-go/extensions/ai-prompt-decorator/main.go index 9baf8c856..3be59e695 100644 --- a/plugins/wasm-go/extensions/ai-prompt-decorator/main.go +++ b/plugins/wasm-go/extensions/ai-prompt-decorator/main.go @@ -5,14 +5,17 @@ import ( "fmt" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-prompt-decorator", wrapper.ParseConfigBy(parseConfig), @@ -31,11 +34,11 @@ type AIPromptDecoratorConfig struct { Append []Message `json:"append"` } -func parseConfig(jsonConfig gjson.Result, config *AIPromptDecoratorConfig, log wrapper.Log) error { +func parseConfig(jsonConfig gjson.Result, config *AIPromptDecoratorConfig, log log.Log) error { return json.Unmarshal([]byte(jsonConfig.Raw), config) } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIPromptDecoratorConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIPromptDecoratorConfig, log log.Log) types.Action { proxywasm.RemoveHttpRequestHeader("content-length") return types.ActionContinue } @@ -66,7 +69,7 @@ func decorateGeographicPrompt(entry *Message) (*Message, error) { return entry, nil } -func onHttpRequestBody(ctx wrapper.HttpContext, config AIPromptDecoratorConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config AIPromptDecoratorConfig, body []byte, log log.Log) types.Action { messageJson := `{"messages":[]}` for _, entry := range config.Prepend { diff --git a/plugins/wasm-go/extensions/ai-prompt-template/go.mod b/plugins/wasm-go/extensions/ai-prompt-template/go.mod index b7c05d704..800506be0 100644 --- a/plugins/wasm-go/extensions/ai-prompt-template/go.mod +++ b/plugins/wasm-go/extensions/ai-prompt-template/go.mod @@ -1,21 +1,18 @@ module ai-prompt-template -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.5 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - github.com/tidwall/sjson v1.2.5 ) diff --git a/plugins/wasm-go/extensions/ai-prompt-template/go.sum b/plugins/wasm-go/extensions/ai-prompt-template/go.sum index 5c0e8e5d8..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/ai-prompt-template/go.sum +++ b/plugins/wasm-go/extensions/ai-prompt-template/go.sum @@ -1,28 +1,23 @@ -github.com/alibaba/higress/plugins/wasm-go v1.3.5 h1:VOLL3m442IHCSu8mR5AZ4sc6LVT9X0w1hdqDI7oB9jY= -github.com/alibaba/higress/plugins/wasm-go v1.3.5/go.mod h1:kr3V9Ntbspj1eSrX8rgjBsdMXkGupYEf+LM72caGPQc= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= -github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-prompt-template/main.go b/plugins/wasm-go/extensions/ai-prompt-template/main.go index da95df708..2c1cfb181 100644 --- a/plugins/wasm-go/extensions/ai-prompt-template/main.go +++ b/plugins/wasm-go/extensions/ai-prompt-template/main.go @@ -4,13 +4,16 @@ import ( "fmt" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-prompt-template", wrapper.ParseConfigBy(parseConfig), @@ -23,7 +26,7 @@ type AIPromptTemplateConfig struct { templates map[string]string } -func parseConfig(json gjson.Result, config *AIPromptTemplateConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *AIPromptTemplateConfig, log log.Log) error { config.templates = make(map[string]string) for _, v := range json.Get("templates").Array() { config.templates[v.Get("name").String()] = v.Get("template").Raw @@ -32,7 +35,7 @@ func parseConfig(json gjson.Result, config *AIPromptTemplateConfig, log wrapper. return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIPromptTemplateConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIPromptTemplateConfig, log log.Log) types.Action { templateEnable, _ := proxywasm.GetHttpRequestHeader("template-enable") if templateEnable == "false" { ctx.DontReadRequestBody() @@ -42,7 +45,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIPromptTemplateConfig return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config AIPromptTemplateConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config AIPromptTemplateConfig, body []byte, log log.Log) types.Action { if gjson.GetBytes(body, "template").Exists() && gjson.GetBytes(body, "properties").Exists() { name := gjson.GetBytes(body, "template").String() template := config.templates[name] diff --git a/plugins/wasm-go/extensions/ai-proxy/go.mod b/plugins/wasm-go/extensions/ai-proxy/go.mod index 30341e643..fbe1d7e89 100644 --- a/plugins/wasm-go/extensions/ai-proxy/go.mod +++ b/plugins/wasm-go/extensions/ai-proxy/go.mod @@ -2,31 +2,23 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 - github.com/wasilibs/go-re2 v1.6.0 -) - -require ( - github.com/tetratelabs/wazero v1.7.2 // indirect - golang.org/x/sys v0.21.0 // indirect + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.3.0 - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a // indirect + github.com/google/uuid v1.6.0 github.com/pmezard/go-difflib v1.0.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect github.com/tidwall/sjson v1.2.5 gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/plugins/wasm-go/extensions/ai-proxy/go.sum b/plugins/wasm-go/extensions/ai-proxy/go.sum index 066d7a2f2..0b0f12de9 100644 --- a/plugins/wasm-go/extensions/ai-proxy/go.sum +++ b/plugins/wasm-go/extensions/ai-proxy/go.sum @@ -1,35 +1,27 @@ 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a h1:tdPcGgyiH0K+SbsJBBm2oPyEIOTAvLBwD9TuUwVtZho= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= -github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= +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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/wasilibs/go-re2 v1.6.0 h1:CLlhDebt38wtl/zz4ww+hkXBMcxjrKFvTDXzFW2VOz8= -github.com/wasilibs/go-re2 v1.6.0/go.mod h1:prArCyErsypRBI/jFAFJEbzyHzjABKqkzlidF0SNA04= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/plugins/wasm-go/extensions/ai-proxy/main.go b/plugins/wasm-go/extensions/ai-proxy/main.go index 4c4b52ca6..7ab71956a 100644 --- a/plugins/wasm-go/extensions/ai-proxy/main.go +++ b/plugins/wasm-go/extensions/ai-proxy/main.go @@ -11,8 +11,10 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/config" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/provider" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/tidwall/gjson" @@ -25,7 +27,9 @@ const ( defaultMaxBodyBytes uint32 = 100 * 1024 * 1024 ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( pluginName, wrapper.ParseOverrideConfig(parseGlobalConfig, parseOverrideRuleConfig), diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/ai360.go b/plugins/wasm-go/extensions/ai-proxy/provider/ai360.go index 9976b1db4..4feba013e 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/ai360.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/ai360.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/azure.go b/plugins/wasm-go/extensions/ai-proxy/provider/azure.go index dfc1a0b0a..e2668c430 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/azure.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/azure.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/baichuan.go b/plugins/wasm-go/extensions/ai-proxy/provider/baichuan.go index 1bb622596..998b32014 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/baichuan.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/baichuan.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/baidu.go b/plugins/wasm-go/extensions/ai-proxy/provider/baidu.go index a914be901..3344f771b 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/baidu.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/baidu.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/bedrock.go b/plugins/wasm-go/extensions/ai-proxy/provider/bedrock.go index 906f7f3a9..aa3def679 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/bedrock.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/bedrock.go @@ -19,8 +19,8 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/tidwall/gjson" diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/claude.go b/plugins/wasm-go/extensions/ai-proxy/provider/claude.go index 6f0adf7d7..a324fe85e 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/claude.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/claude.go @@ -9,8 +9,8 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/cloudflare.go b/plugins/wasm-go/extensions/ai-proxy/provider/cloudflare.go index c47bf6228..900fe1199 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/cloudflare.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/cloudflare.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/cohere.go b/plugins/wasm-go/extensions/ai-proxy/provider/cohere.go index d593dd3b2..0fdb8e454 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/cohere.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/cohere.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/context.go b/plugins/wasm-go/extensions/ai-proxy/provider/context.go index 45fc8568d..42d22acad 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/context.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/context.go @@ -8,8 +8,8 @@ import ( "net/url" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/coze.go b/plugins/wasm-go/extensions/ai-proxy/provider/coze.go index 6709c1a6d..c9bb89f3d 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/coze.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/coze.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) const ( diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/deepl.go b/plugins/wasm-go/extensions/ai-proxy/provider/deepl.go index a42a84131..c8cabf688 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/deepl.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/deepl.go @@ -9,7 +9,7 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/deepseek.go b/plugins/wasm-go/extensions/ai-proxy/provider/deepseek.go index e0de217ed..70c5ec543 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/deepseek.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/deepseek.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/dify.go b/plugins/wasm-go/extensions/ai-proxy/provider/dify.go index 105f05c97..56563e63e 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/dify.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/dify.go @@ -11,8 +11,8 @@ import ( "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) const ( diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/doubao.go b/plugins/wasm-go/extensions/ai-proxy/provider/doubao.go index f63fc69db..4aa0509fe 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/doubao.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/doubao.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/failover.go b/plugins/wasm-go/extensions/ai-proxy/provider/failover.go index 2208e8779..0bf7fe419 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/failover.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/failover.go @@ -10,8 +10,8 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/google/uuid" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/gemini.go b/plugins/wasm-go/extensions/ai-proxy/provider/gemini.go index 9a10044be..5bdc2f425 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/gemini.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/gemini.go @@ -9,8 +9,8 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/google/uuid" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/github.go b/plugins/wasm-go/extensions/ai-proxy/provider/github.go index 3fbe53906..c6311980a 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/github.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/github.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/groq.go b/plugins/wasm-go/extensions/ai-proxy/provider/groq.go index bae7f1ba2..5c8f9a9e1 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/groq.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/groq.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/hunyuan.go b/plugins/wasm-go/extensions/ai-proxy/provider/hunyuan.go index 79d48126a..75e93d7d0 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/hunyuan.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/hunyuan.go @@ -13,8 +13,8 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/minimax.go b/plugins/wasm-go/extensions/ai-proxy/provider/minimax.go index bddc34d6e..9f0825c76 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/minimax.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/minimax.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/tidwall/gjson" diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/mistral.go b/plugins/wasm-go/extensions/ai-proxy/provider/mistral.go index 80ee814c2..f8ec624a8 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/mistral.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/mistral.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/model.go b/plugins/wasm-go/extensions/ai-proxy/provider/model.go index 3f9cec346..7c1e2811d 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/model.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/model.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) const ( diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/moonshot.go b/plugins/wasm-go/extensions/ai-proxy/provider/moonshot.go index 0558b60bc..31dd0d8da 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/moonshot.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/moonshot.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/tidwall/gjson" diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/ollama.go b/plugins/wasm-go/extensions/ai-proxy/provider/ollama.go index b9756666d..a4fccf32b 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/ollama.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/ollama.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/openai.go b/plugins/wasm-go/extensions/ai-proxy/provider/openai.go index b673710d4..e952ae6f0 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/openai.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/openai.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/provider.go b/plugins/wasm-go/extensions/ai-proxy/provider/provider.go index d4792a35c..48a485cea 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/provider.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/provider.go @@ -10,8 +10,8 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/tidwall/gjson" diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/qwen.go b/plugins/wasm-go/extensions/ai-proxy/provider/qwen.go index d9172c570..3e8263b31 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/qwen.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/qwen.go @@ -11,8 +11,8 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/tidwall/gjson" "github.com/tidwall/sjson" diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/request_helper.go b/plugins/wasm-go/extensions/ai-proxy/provider/request_helper.go index 52fa8a64d..665ba5fa8 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/request_helper.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/request_helper.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/log" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/retry.go b/plugins/wasm-go/extensions/ai-proxy/provider/retry.go index 67126afcb..385e0078a 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/retry.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/retry.go @@ -7,8 +7,8 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/spark.go b/plugins/wasm-go/extensions/ai-proxy/provider/spark.go index b1f297338..01d4dbf3e 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/spark.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/spark.go @@ -8,8 +8,8 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/stepfun.go b/plugins/wasm-go/extensions/ai-proxy/provider/stepfun.go index f1bed0469..68f46a20e 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/stepfun.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/stepfun.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/together_ai.go b/plugins/wasm-go/extensions/ai-proxy/provider/together_ai.go index 25b6c0864..83445bfca 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/together_ai.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/together_ai.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/vertex.go b/plugins/wasm-go/extensions/ai-proxy/provider/vertex.go index b94b17091..397a13879 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/vertex.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/vertex.go @@ -15,8 +15,8 @@ import ( "time" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" "github.com/tidwall/gjson" diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/yi.go b/plugins/wasm-go/extensions/ai-proxy/provider/yi.go index 63fd79468..9baa81311 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/yi.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/yi.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/zhipuai.go b/plugins/wasm-go/extensions/ai-proxy/provider/zhipuai.go index 1bbe21f1d..4af70e73d 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/zhipuai.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/zhipuai.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" ) diff --git a/plugins/wasm-go/extensions/ai-proxy/util/http.go b/plugins/wasm-go/extensions/ai-proxy/util/http.go index 90baa3f99..041c2d8f3 100644 --- a/plugins/wasm-go/extensions/ai-proxy/util/http.go +++ b/plugins/wasm-go/extensions/ai-proxy/util/http.go @@ -5,8 +5,8 @@ import ( "regexp" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" + "github.com/higress-group/wasm-go/pkg/log" ) const ( diff --git a/plugins/wasm-go/extensions/ai-proxy/util/string.go b/plugins/wasm-go/extensions/ai-proxy/util/string.go index 88a35f40c..69d1fd469 100644 --- a/plugins/wasm-go/extensions/ai-proxy/util/string.go +++ b/plugins/wasm-go/extensions/ai-proxy/util/string.go @@ -1,6 +1,6 @@ package util -import regexp "github.com/wasilibs/go-re2" +import "regexp" func StripPrefix(s string, prefix string) string { if len(prefix) != 0 && len(s) >= len(prefix) && s[0:len(prefix)] == prefix { diff --git a/plugins/wasm-go/extensions/ai-quota/go.mod b/plugins/wasm-go/extensions/ai-quota/go.mod index 8b9e11fd1..bd99507de 100644 --- a/plugins/wasm-go/extensions/ai-quota/go.mod +++ b/plugins/wasm-go/extensions/ai-quota/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-quota -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.3-0.20240808022948-34f5722d93de - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/resp v0.1.1 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ai-quota/go.sum b/plugins/wasm-go/extensions/ai-quota/go.sum index b4ab172fe..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/ai-quota/go.sum +++ b/plugins/wasm-go/extensions/ai-quota/go.sum @@ -1,20 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-quota/main.go b/plugins/wasm-go/extensions/ai-quota/main.go index 2c6d75e8f..10021ce13 100644 --- a/plugins/wasm-go/extensions/ai-quota/main.go +++ b/plugins/wasm-go/extensions/ai-quota/main.go @@ -11,9 +11,10 @@ import ( "strings" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-quota/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/resp" ) @@ -39,7 +40,9 @@ const ( AdminModeNone AdminMode = "none" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( pluginName, wrapper.ParseConfigBy(parseConfig), @@ -72,7 +75,7 @@ type RedisInfo struct { Database int `required:"false" yaml:"database" json:"database"` } -func parseConfig(json gjson.Result, config *QuotaConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *QuotaConfig, log log.Log) error { log.Debugf("parse config()") // admin config.AdminPath = json.Get("admin_path").String() @@ -126,7 +129,7 @@ func parseConfig(json gjson.Result, config *QuotaConfig, log wrapper.Log) error return config.redisClient.Init(username, password, int64(timeout), wrapper.WithDataBase(database)) } -func onHttpRequestHeaders(context wrapper.HttpContext, config QuotaConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(context wrapper.HttpContext, config QuotaConfig, log log.Log) types.Action { log.Debugf("onHttpRequestHeaders()") // get tokens consumer, err := proxywasm.GetHttpRequestHeader("x-mse-consumer") @@ -183,7 +186,7 @@ func onHttpRequestHeaders(context wrapper.HttpContext, config QuotaConfig, log w return types.HeaderStopAllIterationAndWatermark } -func onHttpRequestBody(ctx wrapper.HttpContext, config QuotaConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config QuotaConfig, body []byte, log log.Log) types.Action { log.Debugf("onHttpRequestBody()") chatMode, ok := ctx.GetContext("chatMode").(ChatMode) if !ok { @@ -211,7 +214,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config QuotaConfig, body []byte, return types.ActionContinue } -func onHttpStreamingResponseBody(ctx wrapper.HttpContext, config QuotaConfig, data []byte, endOfStream bool, log wrapper.Log) []byte { +func onHttpStreamingResponseBody(ctx wrapper.HttpContext, config QuotaConfig, data []byte, endOfStream bool, log log.Log) []byte { chatMode, ok := ctx.GetContext("chatMode").(ChatMode) if !ok { return data @@ -274,7 +277,7 @@ func deniedUnauthorizedConsumer() types.Action { return types.ActionContinue } -func getOperationMode(path string, adminPath string, log wrapper.Log) (ChatMode, AdminMode) { +func getOperationMode(path string, adminPath string, log log.Log) (ChatMode, AdminMode) { fullAdminPath := "/v1/chat/completions" + adminPath if strings.HasSuffix(path, fullAdminPath+"/refresh") { return ChatModeAdmin, AdminModeRefresh @@ -291,7 +294,7 @@ func getOperationMode(path string, adminPath string, log wrapper.Log) (ChatMode, return ChatModeNone, AdminModeNone } -func refreshQuota(ctx wrapper.HttpContext, config QuotaConfig, adminConsumer string, body string, log wrapper.Log) types.Action { +func refreshQuota(ctx wrapper.HttpContext, config QuotaConfig, adminConsumer string, body string, log log.Log) types.Action { // check consumer if adminConsumer != config.AdminConsumer { util.SendResponse(http.StatusForbidden, "ai-quota.unauthorized", "text/plain", "Request denied by ai quota check. Unauthorized admin consumer.") @@ -325,7 +328,7 @@ func refreshQuota(ctx wrapper.HttpContext, config QuotaConfig, adminConsumer str return types.ActionPause } -func queryQuota(ctx wrapper.HttpContext, config QuotaConfig, adminConsumer string, url *url.URL, log wrapper.Log) types.Action { +func queryQuota(ctx wrapper.HttpContext, config QuotaConfig, adminConsumer string, url *url.URL, log log.Log) types.Action { // check consumer if adminConsumer != config.AdminConsumer { util.SendResponse(http.StatusForbidden, "ai-quota.unauthorized", "text/plain", "Request denied by ai quota check. Unauthorized admin consumer.") @@ -368,7 +371,7 @@ func queryQuota(ctx wrapper.HttpContext, config QuotaConfig, adminConsumer strin } return types.ActionPause } -func deltaQuota(ctx wrapper.HttpContext, config QuotaConfig, adminConsumer string, body string, log wrapper.Log) types.Action { +func deltaQuota(ctx wrapper.HttpContext, config QuotaConfig, adminConsumer string, body string, log log.Log) types.Action { // check consumer if adminConsumer != config.AdminConsumer { util.SendResponse(http.StatusForbidden, "ai-quota.unauthorized", "text/plain", "Request denied by ai quota check. Unauthorized admin consumer.") diff --git a/plugins/wasm-go/extensions/ai-rag/go.mod b/plugins/wasm-go/extensions/ai-rag/go.mod index 2ce344eec..0c03d94b0 100644 --- a/plugins/wasm-go/extensions/ai-rag/go.mod +++ b/plugins/wasm-go/extensions/ai-rag/go.mod @@ -1,20 +1,18 @@ module ai-rag -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.5 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ai-rag/go.sum b/plugins/wasm-go/extensions/ai-rag/go.sum index 6b1c2c3cd..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/ai-rag/go.sum +++ b/plugins/wasm-go/extensions/ai-rag/go.sum @@ -1,22 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-rag/main.go b/plugins/wasm-go/extensions/ai-rag/main.go index b7be598c7..b257de3ca 100644 --- a/plugins/wasm-go/extensions/ai-rag/main.go +++ b/plugins/wasm-go/extensions/ai-rag/main.go @@ -9,13 +9,16 @@ import ( "ai-rag/dashscope" "ai-rag/dashvector" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-rag", wrapper.ParseConfigBy(parseConfig), @@ -51,7 +54,7 @@ type Message struct { Content string `json:"content"` } -func parseConfig(json gjson.Result, config *AIRagConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *AIRagConfig, log log.Log) error { checkList := []string{ "dashscope.apiKey", "dashscope.serviceFQDN", @@ -91,12 +94,12 @@ func parseConfig(json gjson.Result, config *AIRagConfig, log wrapper.Log) error return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIRagConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIRagConfig, log log.Log) types.Action { proxywasm.RemoveHttpRequestHeader("content-length") return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config AIRagConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config AIRagConfig, body []byte, log log.Log) types.Action { var rawRequest Request _ = json.Unmarshal(body, &rawRequest) messageLength := len(rawRequest.Messages) @@ -165,7 +168,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config AIRagConfig, body []byte, return types.ActionPause } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config AIRagConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config AIRagConfig, log log.Log) types.Action { recall, ok := ctx.GetContext("x-envoy-rag-recall").(bool) if ok && recall { proxywasm.AddHttpResponseHeader("x-envoy-rag-recall", "true") diff --git a/plugins/wasm-go/extensions/ai-search/engine/arxiv/arxiv.go b/plugins/wasm-go/extensions/ai-search/engine/arxiv/arxiv.go index 56a998ca3..12e338551 100644 --- a/plugins/wasm-go/extensions/ai-search/engine/arxiv/arxiv.go +++ b/plugins/wasm-go/extensions/ai-search/engine/arxiv/arxiv.go @@ -8,8 +8,8 @@ import ( "net/url" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/antchfx/xmlquery" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-search/engine" diff --git a/plugins/wasm-go/extensions/ai-search/engine/bing/bing.go b/plugins/wasm-go/extensions/ai-search/engine/bing/bing.go index b24fe3346..3edbdb8ba 100644 --- a/plugins/wasm-go/extensions/ai-search/engine/bing/bing.go +++ b/plugins/wasm-go/extensions/ai-search/engine/bing/bing.go @@ -7,7 +7,7 @@ import ( "net/url" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-search/engine" diff --git a/plugins/wasm-go/extensions/ai-search/engine/elasticsearch/elasticsearch.go b/plugins/wasm-go/extensions/ai-search/engine/elasticsearch/elasticsearch.go index 164df9838..9d3ad39a9 100644 --- a/plugins/wasm-go/extensions/ai-search/engine/elasticsearch/elasticsearch.go +++ b/plugins/wasm-go/extensions/ai-search/engine/elasticsearch/elasticsearch.go @@ -7,7 +7,7 @@ import ( "net/http" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-search/engine" diff --git a/plugins/wasm-go/extensions/ai-search/engine/google/google.go b/plugins/wasm-go/extensions/ai-search/engine/google/google.go index e189646b9..c1d7cafeb 100644 --- a/plugins/wasm-go/extensions/ai-search/engine/google/google.go +++ b/plugins/wasm-go/extensions/ai-search/engine/google/google.go @@ -7,7 +7,7 @@ import ( "net/url" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-search/engine" diff --git a/plugins/wasm-go/extensions/ai-search/engine/quark/quark.go b/plugins/wasm-go/extensions/ai-search/engine/quark/quark.go index 850f66f02..e647c2d3f 100644 --- a/plugins/wasm-go/extensions/ai-search/engine/quark/quark.go +++ b/plugins/wasm-go/extensions/ai-search/engine/quark/quark.go @@ -12,7 +12,7 @@ import ( "sort" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-search/engine" diff --git a/plugins/wasm-go/extensions/ai-search/engine/types.go b/plugins/wasm-go/extensions/ai-search/engine/types.go index a0d6780ba..5c94f9c5d 100644 --- a/plugins/wasm-go/extensions/ai-search/engine/types.go +++ b/plugins/wasm-go/extensions/ai-search/engine/types.go @@ -1,7 +1,7 @@ package engine import ( - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) type SearchResult struct { diff --git a/plugins/wasm-go/extensions/ai-search/go.mod b/plugins/wasm-go/extensions/ai-search/go.mod index 17bd972c4..1eb193c73 100644 --- a/plugins/wasm-go/extensions/ai-search/go.mod +++ b/plugins/wasm-go/extensions/ai-search/go.mod @@ -1,13 +1,13 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-search -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 github.com/antchfx/xmlquery v1.4.4 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.1-0.20250703020647-acfb94430802 github.com/tidwall/gjson v1.18.0 github.com/tidwall/sjson v1.2.5 ) @@ -15,11 +15,9 @@ require ( require ( github.com/antchfx/xpath v1.3.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/plugins/wasm-go/extensions/ai-search/go.sum b/plugins/wasm-go/extensions/ai-search/go.sum index 81d555f4b..a6a24979c 100644 --- a/plugins/wasm-go/extensions/ai-search/go.sum +++ b/plugins/wasm-go/extensions/ai-search/go.sum @@ -3,26 +3,30 @@ github.com/antchfx/xmlquery v1.4.4/go.mod h1:AEPEEPYE9GnA2mj5Ur2L5Q5/2PycJ0N9Fus github.com/antchfx/xpath v1.3.3 h1:tmuPQa1Uye0Ym1Zn65vxPgfltWb/Lxu2jeqIGteJSRs= github.com/antchfx/xpath v1.3.3/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= 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/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= +github.com/higress-group/wasm-go v1.0.1-0.20250703020647-acfb94430802 h1:oaeYQ7bMtPL9gG2yZzxu0VXWLx5/C1RctyBbcpwG49I= +github.com/higress-group/wasm-go v1.0.1-0.20250703020647-acfb94430802/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= @@ -94,3 +98,4 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-search/main.go b/plugins/wasm-go/extensions/ai-search/main.go index ed62ee271..99fe8c720 100644 --- a/plugins/wasm-go/extensions/ai-search/main.go +++ b/plugins/wasm-go/extensions/ai-search/main.go @@ -26,10 +26,11 @@ import ( "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" "github.com/tidwall/gjson" "github.com/tidwall/sjson" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-search/engine" "github.com/alibaba/higress/plugins/wasm-go/extensions/ai-search/engine/arxiv" @@ -80,7 +81,9 @@ var privateSearchPrompts string //go:embed prompts/chinese-internet.md var chineseInternetSearchPrompts string -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-search", wrapper.ParseConfigBy(parseConfig), @@ -92,7 +95,7 @@ func main() { ) } -func parseConfig(json gjson.Result, config *Config, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *Config, log log.Log) error { config.defaultEnable = true // Default to true if not specified if json.Get("defaultEnable").Exists() { config.defaultEnable = json.Get("defaultEnable").Bool() @@ -276,7 +279,7 @@ func parseConfig(json gjson.Result, config *Config, log wrapper.Log) error { return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log log.Log) types.Action { contentType, _ := proxywasm.GetHttpRequestHeader("content-type") // The request does not have a body. if contentType == "" { @@ -293,7 +296,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Lo return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config Config, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config Config, body []byte, log log.Log) types.Action { // Check if plugin should be enabled based on config and request webSearchOptions := gjson.GetBytes(body, "web_search_options") if !config.defaultEnable { @@ -453,7 +456,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config Config, body []byte, log }}, log) } -func executeSearch(ctx wrapper.HttpContext, config Config, queryIndex int, body []byte, searchContexts []engine.SearchContext, log wrapper.Log) types.Action { +func executeSearch(ctx wrapper.HttpContext, config Config, queryIndex int, body []byte, searchContexts []engine.SearchContext, log log.Log) types.Action { searchResultGroups := make([][]engine.SearchResult, len(config.engine)) var finished int var searching int @@ -556,7 +559,7 @@ func executeSearch(ctx wrapper.HttpContext, config Config, queryIndex int, body return types.ActionContinue } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config Config, log log.Log) types.Action { if !config.needReference { ctx.DontReadResponseBody() return types.ActionContinue @@ -573,7 +576,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, config Config, log wrapper.L return types.ActionContinue } -func onHttpResponseBody(ctx wrapper.HttpContext, config Config, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config Config, body []byte, log log.Log) types.Action { references := ctx.GetStringContext("References", "") if references == "" { return types.ActionContinue @@ -627,7 +630,7 @@ const ( BUFFER_SIZE = 30 ) -func onStreamingResponseBody(ctx wrapper.HttpContext, config Config, chunk []byte, isLastChunk bool, log wrapper.Log) []byte { +func onStreamingResponseBody(ctx wrapper.HttpContext, config Config, chunk []byte, isLastChunk bool, log log.Log) []byte { if ctx.GetBoolContext("ReferenceAppended", false) { return chunk } @@ -666,7 +669,7 @@ func onStreamingResponseBody(ctx wrapper.HttpContext, config Config, chunk []byt } } -func processSSEMessage(ctx wrapper.HttpContext, sseMessage string, references string, tailReference bool, log wrapper.Log) string { +func processSSEMessage(ctx wrapper.HttpContext, sseMessage string, references string, tailReference bool, log log.Log) string { log.Debugf("single sse message: %s", sseMessage) subMessages := strings.Split(sseMessage, "\n") var message string diff --git a/plugins/wasm-go/extensions/ai-security-guard/go.mod b/plugins/wasm-go/extensions/ai-security-guard/go.mod index c21172194..47e6c8b1f 100644 --- a/plugins/wasm-go/extensions/ai-security-guard/go.mod +++ b/plugins/wasm-go/extensions/ai-security-guard/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-security-guard -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.6-0.20240522012622-fc6a6aad8906 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ai-security-guard/go.sum b/plugins/wasm-go/extensions/ai-security-guard/go.sum index b4ab172fe..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/ai-security-guard/go.sum +++ b/plugins/wasm-go/extensions/ai-security-guard/go.sum @@ -1,20 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-security-guard/main.go b/plugins/wasm-go/extensions/ai-security-guard/main.go index c6cb475c1..b7bd234bb 100644 --- a/plugins/wasm-go/extensions/ai-security-guard/main.go +++ b/plugins/wasm-go/extensions/ai-security-guard/main.go @@ -17,13 +17,16 @@ import ( "strings" "time" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-security-guard", wrapper.ParseConfigBy(parseConfig), @@ -172,7 +175,7 @@ func generateHexID(length int) (string, error) { return hex.EncodeToString(bytes), nil } -func parseConfig(json gjson.Result, config *AISecurityConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *AISecurityConfig, log log.Log) error { serviceName := json.Get("serviceName").String() servicePort := json.Get("servicePort").Int() serviceHost := json.Get("serviceHost").String() @@ -250,7 +253,7 @@ func generateRandomID() string { return "chatcmpl-" + string(b) } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config AISecurityConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config AISecurityConfig, log log.Log) types.Action { if !config.checkRequest { log.Debugf("request checking is disabled") ctx.DontReadRequestBody() @@ -258,7 +261,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config AISecurityConfig, log return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config AISecurityConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config AISecurityConfig, body []byte, log log.Log) types.Action { log.Debugf("checking request body...") startTime := time.Now().UnixMilli() content := gjson.GetBytes(body, config.requestContentJsonPath).String() @@ -367,7 +370,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config AISecurityConfig, body [] return types.ActionPause } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config AISecurityConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config AISecurityConfig, log log.Log) types.Action { if !config.checkResponse { log.Debugf("response checking is disabled") ctx.DontReadResponseBody() @@ -382,7 +385,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, config AISecurityConfig, log return types.HeaderStopIteration } -func onHttpResponseBody(ctx wrapper.HttpContext, config AISecurityConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config AISecurityConfig, body []byte, log log.Log) types.Action { log.Debugf("checking response body...") startTime := time.Now().UnixMilli() contentType, _ := proxywasm.GetHttpResponseHeader("content-type") @@ -507,7 +510,7 @@ func extractMessageFromStreamingBody(data []byte, jsonPath string) string { return strings.Join(strChunks, "") } -func marshalStr(raw string, log wrapper.Log) string { +func marshalStr(raw string, log log.Log) string { helper := map[string]string{ "placeholder": raw, } diff --git a/plugins/wasm-go/extensions/ai-statistics/go.mod b/plugins/wasm-go/extensions/ai-statistics/go.mod index 46d6780f9..1925145c5 100644 --- a/plugins/wasm-go/extensions/ai-statistics/go.mod +++ b/plugins/wasm-go/extensions/ai-statistics/go.mod @@ -1,21 +1,18 @@ module ai-statistics -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.6-0.20240522012622-fc6a6aad8906 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.1-0.20250703020647-acfb94430802 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - github.com/tidwall/sjson v1.2.5 // indirect ) diff --git a/plugins/wasm-go/extensions/ai-statistics/go.sum b/plugins/wasm-go/extensions/ai-statistics/go.sum index f76459d11..f6a3df1ee 100644 --- a/plugins/wasm-go/extensions/ai-statistics/go.sum +++ b/plugins/wasm-go/extensions/ai-statistics/go.sum @@ -1,23 +1,25 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= +github.com/higress-group/wasm-go v1.0.1-0.20250703020647-acfb94430802 h1:oaeYQ7bMtPL9gG2yZzxu0VXWLx5/C1RctyBbcpwG49I= +github.com/higress-group/wasm-go v1.0.1-0.20250703020647-acfb94430802/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= -github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-statistics/main.go b/plugins/wasm-go/extensions/ai-statistics/main.go index ca930cf19..c9c131711 100644 --- a/plugins/wasm-go/extensions/ai-statistics/main.go +++ b/plugins/wasm-go/extensions/ai-statistics/main.go @@ -8,13 +8,16 @@ import ( "strings" "time" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-statistics", wrapper.ParseConfigBy(parseConfig), @@ -143,7 +146,7 @@ func (config *AIStatisticsConfig) incrementCounter(metricName string, inc uint64 counter.Increment(inc) } -func parseConfig(configJson gjson.Result, config *AIStatisticsConfig, log wrapper.Log) error { +func parseConfig(configJson gjson.Result, config *AIStatisticsConfig, log log.Log) error { // Parse tracing span attributes setting. attributeConfigs := configJson.Get("attributes").Array() config.attributes = make([]Attribute, len(attributeConfigs)) @@ -171,7 +174,7 @@ func parseConfig(configJson gjson.Result, config *AIStatisticsConfig, log wrappe return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIStatisticsConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIStatisticsConfig, log log.Log) types.Action { route, _ := getRouteName() cluster, _ := getClusterName() api, api_error := getAPIName() @@ -201,7 +204,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config AIStatisticsConfig, lo return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config AIStatisticsConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config AIStatisticsConfig, body []byte, log log.Log) types.Action { // Set user defined log & span attributes. setAttributeBySource(ctx, config, RequestBody, body, log) // Set span attributes for ARMS. @@ -226,7 +229,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config AIStatisticsConfig, body return types.ActionContinue } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config AIStatisticsConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config AIStatisticsConfig, log log.Log) types.Action { contentType, _ := proxywasm.GetHttpResponseHeader("content-type") if !strings.Contains(contentType, "text/event-stream") { ctx.BufferResponseBody() @@ -238,7 +241,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, config AIStatisticsConfig, l return types.ActionContinue } -func onHttpStreamingBody(ctx wrapper.HttpContext, config AIStatisticsConfig, data []byte, endOfStream bool, log wrapper.Log) []byte { +func onHttpStreamingBody(ctx wrapper.HttpContext, config AIStatisticsConfig, data []byte, endOfStream bool, log log.Log) []byte { // Buffer stream body for record log & span attributes if config.shouldBufferStreamingBody { var streamingBodyBuffer []byte @@ -307,7 +310,7 @@ func onHttpStreamingBody(ctx wrapper.HttpContext, config AIStatisticsConfig, dat return data } -func onHttpResponseBody(ctx wrapper.HttpContext, config AIStatisticsConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config AIStatisticsConfig, body []byte, log log.Log) types.Action { // Get requestStartTime from http context requestStartTime, _ := ctx.GetContext(StatisticsRequestStartTime).(int64) @@ -382,7 +385,7 @@ func getUsage(data []byte) (model string, inputTokenUsage int64, outputTokenUsag } // fetches the tracing span value from the specified source. -func setAttributeBySource(ctx wrapper.HttpContext, config AIStatisticsConfig, source string, body []byte, log wrapper.Log) { +func setAttributeBySource(ctx wrapper.HttpContext, config AIStatisticsConfig, source string, body []byte, log log.Log) { for _, attribute := range config.attributes { var key string var value interface{} @@ -431,7 +434,7 @@ func setAttributeBySource(ctx wrapper.HttpContext, config AIStatisticsConfig, so } } -func extractStreamingBodyByJsonPath(data []byte, jsonPath string, rule string, log wrapper.Log) interface{} { +func extractStreamingBodyByJsonPath(data []byte, jsonPath string, rule string, log log.Log) interface{} { chunks := bytes.Split(bytes.TrimSpace(unifySSEChunk(data)), []byte("\n\n")) var value interface{} if rule == RuleFirst { @@ -466,7 +469,7 @@ func extractStreamingBodyByJsonPath(data []byte, jsonPath string, rule string, l } // Set the tracing span with value. -func setSpanAttribute(key string, value interface{}, log wrapper.Log) { +func setSpanAttribute(key string, value interface{}, log log.Log) { if value != "" { traceSpanTag := wrapper.TraceSpanTagPrefix + key if e := proxywasm.SetProperty([]string{traceSpanTag}, []byte(fmt.Sprint(value))); e != nil { @@ -477,7 +480,7 @@ func setSpanAttribute(key string, value interface{}, log wrapper.Log) { } } -func writeMetric(ctx wrapper.HttpContext, config AIStatisticsConfig, log wrapper.Log) { +func writeMetric(ctx wrapper.HttpContext, config AIStatisticsConfig, log log.Log) { // Generate usage metrics var ok bool var route, cluster, model string diff --git a/plugins/wasm-go/extensions/ai-token-ratelimit/config.go b/plugins/wasm-go/extensions/ai-token-ratelimit/config.go index be148d7c4..0ed598caa 100644 --- a/plugins/wasm-go/extensions/ai-token-ratelimit/config.go +++ b/plugins/wasm-go/extensions/ai-token-ratelimit/config.go @@ -5,10 +5,12 @@ import ( "fmt" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + re "regexp" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" - re "github.com/wasilibs/go-re2" "github.com/zmap/go-iptree/iptree" ) @@ -84,7 +86,7 @@ type LimitConfigItem struct { timeWindow int64 // 时间窗口大小 } -func initRedisClusterClient(json gjson.Result, config *ClusterKeyRateLimitConfig, log wrapper.Log) error { +func initRedisClusterClient(json gjson.Result, config *ClusterKeyRateLimitConfig, log log.Log) error { redisConfig := json.Get("redis") if !redisConfig.Exists() { return errors.New("missing redis in config") diff --git a/plugins/wasm-go/extensions/ai-token-ratelimit/go.mod b/plugins/wasm-go/extensions/ai-token-ratelimit/go.mod index 8bc65c898..e3beaacb6 100644 --- a/plugins/wasm-go/extensions/ai-token-ratelimit/go.mod +++ b/plugins/wasm-go/extensions/ai-token-ratelimit/go.mod @@ -1,27 +1,21 @@ module ai-token-ratelimit -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.1-0.20240617024146-5f150179637c - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 - github.com/wasilibs/go-re2 v1.5.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 ) -require ( - github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 // indirect - github.com/tetratelabs/wazero v1.7.1 // indirect -) +require github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 // indirect require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 ) diff --git a/plugins/wasm-go/extensions/ai-token-ratelimit/go.sum b/plugins/wasm-go/extensions/ai-token-ratelimit/go.sum index 7b8c22894..588c05eaa 100644 --- a/plugins/wasm-go/extensions/ai-token-ratelimit/go.sum +++ b/plugins/wasm-go/extensions/ai-token-ratelimit/go.sum @@ -1,29 +1,27 @@ github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 h1:Wi5Tgn8K+jDcBYL+dIMS1+qXYH2r7tpRAyBgqrWfQtw= github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56/go.mod h1:8BhOLuqtSuT5NZtZMwfvEibi09RO3u79uqfHZzfDTR4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tetratelabs/wazero v1.7.1 h1:QtSfd6KLc41DIMpDYlJdoMc6k7QTN246DM2+n2Y/Dx8= -github.com/tetratelabs/wazero v1.7.1/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/wasilibs/go-re2 v1.5.3 h1:wiuTcgDZdLhu8NG8oqF5sF5Q3yIU14lPAvXqeYzDK3g= -github.com/wasilibs/go-re2 v1.5.3/go.mod h1:PzpVPsBdFC7vM8QJbbEnOeTmwA0DGE783d/Gex8eCV8= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 h1:DjHnADS2r2zynZ3WkCFAQ+PNYngMSNceRROi0pO6c3M= github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837/go.mod h1:9vp0bxqozzQwcjBwenEXfKVq8+mYbwHkQ1NF9Ap0DMw= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-token-ratelimit/main.go b/plugins/wasm-go/extensions/ai-token-ratelimit/main.go index 0437c460e..00c0ad082 100644 --- a/plugins/wasm-go/extensions/ai-token-ratelimit/main.go +++ b/plugins/wasm-go/extensions/ai-token-ratelimit/main.go @@ -22,14 +22,17 @@ import ( "strconv" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/resp" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-token-ratelimit", wrapper.ParseConfigBy(parseConfig), @@ -81,7 +84,7 @@ type LimitRedisContext struct { window int64 } -func parseConfig(json gjson.Result, config *ClusterKeyRateLimitConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *ClusterKeyRateLimitConfig, log log.Log) error { err := initRedisClusterClient(json, config, log) if err != nil { return err @@ -95,7 +98,7 @@ func parseConfig(json gjson.Result, config *ClusterKeyRateLimitConfig, log wrapp return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config ClusterKeyRateLimitConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config ClusterKeyRateLimitConfig, log log.Log) types.Action { // 判断是否命中限流规则 val, ruleItem, configItem := checkRequestAgainstLimitRule(ctx, config.ruleItems, log) if ruleItem == nil || configItem == nil { @@ -143,7 +146,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config ClusterKeyRateLimitCon return types.ActionPause } -func onHttpStreamingBody(ctx wrapper.HttpContext, config ClusterKeyRateLimitConfig, data []byte, endOfStream bool, log wrapper.Log) []byte { +func onHttpStreamingBody(ctx wrapper.HttpContext, config ClusterKeyRateLimitConfig, data []byte, endOfStream bool, log log.Log) []byte { var inputToken, outputToken int64 if inputToken, outputToken, ok := getUsage(data); ok { ctx.SetContext("input_token", inputToken) @@ -189,7 +192,7 @@ func getUsage(data []byte) (inputTokenUsage int64, outputTokenUsage int64, ok bo return } -func checkRequestAgainstLimitRule(ctx wrapper.HttpContext, ruleItems []LimitRuleItem, log wrapper.Log) (string, *LimitRuleItem, *LimitConfigItem) { +func checkRequestAgainstLimitRule(ctx wrapper.HttpContext, ruleItems []LimitRuleItem, log log.Log) (string, *LimitRuleItem, *LimitConfigItem) { for _, rule := range ruleItems { val, ruleItem, configItem := hitRateRuleItem(ctx, rule, log) if ruleItem != nil && configItem != nil { @@ -199,7 +202,7 @@ func checkRequestAgainstLimitRule(ctx wrapper.HttpContext, ruleItems []LimitRule return "", nil, nil } -func hitRateRuleItem(ctx wrapper.HttpContext, rule LimitRuleItem, log wrapper.Log) (string, *LimitRuleItem, *LimitConfigItem) { +func hitRateRuleItem(ctx wrapper.HttpContext, rule LimitRuleItem, log log.Log) (string, *LimitRuleItem, *LimitConfigItem) { switch rule.limitType { // 根据HTTP请求头限流 case limitByHeaderType, limitByPerHeaderType: @@ -258,7 +261,7 @@ func hitRateRuleItem(ctx wrapper.HttpContext, rule LimitRuleItem, log wrapper.Lo return "", nil, nil } -func logDebugAndReturnEmpty(log wrapper.Log, errMsg string, args ...interface{}) (string, *LimitRuleItem, *LimitConfigItem) { +func logDebugAndReturnEmpty(log log.Log, errMsg string, args ...interface{}) (string, *LimitRuleItem, *LimitConfigItem) { log.Debugf(errMsg, args...) return "", nil, nil } diff --git a/plugins/wasm-go/extensions/ai-transformer/go.mod b/plugins/wasm-go/extensions/ai-transformer/go.mod index 31f77c49d..9166615cb 100644 --- a/plugins/wasm-go/extensions/ai-transformer/go.mod +++ b/plugins/wasm-go/extensions/ai-transformer/go.mod @@ -1,21 +1,19 @@ module ai-transformer -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect github.com/tidwall/sjson v1.2.5 ) diff --git a/plugins/wasm-go/extensions/ai-transformer/go.sum b/plugins/wasm-go/extensions/ai-transformer/go.sum index 0451f8e45..10f7f623e 100644 --- a/plugins/wasm-go/extensions/ai-transformer/go.sum +++ b/plugins/wasm-go/extensions/ai-transformer/go.sum @@ -1,32 +1,26 @@ -github.com/alibaba/higress/plugins/wasm-go v1.3.5 h1:VOLL3m442IHCSu8mR5AZ4sc6LVT9X0w1hdqDI7oB9jY= -github.com/alibaba/higress/plugins/wasm-go v1.3.5/go.mod h1:kr3V9Ntbspj1eSrX8rgjBsdMXkGupYEf+LM72caGPQc= -github.com/alibaba/higress/plugins/wasm-go v1.4.0 h1:uFf+mbZ2iuRXJzRbmWBuxiHvNDMGf3PCBJ6TI86bopY= -github.com/alibaba/higress/plugins/wasm-go v1.4.0/go.mod h1:10jQXKsYFUF7djs+Oy7t82f4dbie9pISfP9FJwpPLuk= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc h1:t2AT8zb6N/59Y78lyRWedVoVWHNRSCBh0oWCC+bluTQ= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ai-transformer/main.go b/plugins/wasm-go/extensions/ai-transformer/main.go index dce13933f..5294f4e0f 100644 --- a/plugins/wasm-go/extensions/ai-transformer/main.go +++ b/plugins/wasm-go/extensions/ai-transformer/main.go @@ -5,14 +5,17 @@ import ( "net/http" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ai-transformer", wrapper.ParseConfigBy(parseConfig), @@ -52,7 +55,7 @@ const llmRequestTemplate = `{ } }` -func parseConfig(json gjson.Result, config *AITransformerConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *AITransformerConfig, log log.Log) error { config.requestTransformEnable = json.Get("request.enable").Bool() config.requestTransformPrompt = json.Get("request.prompt").String() config.responseTransformEnable = json.Get("response.enable").Bool() @@ -89,7 +92,7 @@ func extraceHttpFrame(frame string) ([][2]string, []byte, error) { return headers, body, nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config AITransformerConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config AITransformerConfig, log log.Log) types.Action { log.Info("onHttpRequestHeaders") if !config.requestTransformEnable || config.requestTransformPrompt == "" { ctx.DontReadRequestBody() @@ -99,7 +102,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config AITransformerConfig, l } } -func onHttpRequestBody(ctx wrapper.HttpContext, config AITransformerConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config AITransformerConfig, body []byte, log log.Log) types.Action { log.Info("onHttpRequestBody") headers, err := proxywasm.GetHttpRequestHeaders() if err != nil { @@ -133,7 +136,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config AITransformerConfig, body return types.ActionPause } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config AITransformerConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config AITransformerConfig, log log.Log) types.Action { if !config.responseTransformEnable || config.responseTransformPrompt == "" { ctx.DontReadResponseBody() return types.ActionContinue @@ -142,7 +145,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, config AITransformerConfig, } } -func onHttpResponseBody(ctx wrapper.HttpContext, config AITransformerConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config AITransformerConfig, body []byte, log log.Log) types.Action { headers, err := proxywasm.GetHttpResponseHeaders() if err != nil { log.Error("Failed to get http response headers.") diff --git a/plugins/wasm-go/extensions/api-workflow/go.mod b/plugins/wasm-go/extensions/api-workflow/go.mod index 41c7da312..77b4b67f2 100644 --- a/plugins/wasm-go/extensions/api-workflow/go.mod +++ b/plugins/wasm-go/extensions/api-workflow/go.mod @@ -1,21 +1,19 @@ module api-workflow -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/sjson v1.2.5 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/api-workflow/go.sum b/plugins/wasm-go/extensions/api-workflow/go.sum index 6deccd9c2..10f7f623e 100644 --- a/plugins/wasm-go/extensions/api-workflow/go.sum +++ b/plugins/wasm-go/extensions/api-workflow/go.sum @@ -1,25 +1,26 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/api-workflow/main.go b/plugins/wasm-go/extensions/api-workflow/main.go index 5a4254b8d..8e5f264f6 100644 --- a/plugins/wasm-go/extensions/api-workflow/main.go +++ b/plugins/wasm-go/extensions/api-workflow/main.go @@ -24,9 +24,10 @@ import ( "api-workflow/utils" . "api-workflow/workflow" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -36,7 +37,9 @@ const ( DefaultTimeout uint32 = 5000 ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "api-workflow", wrapper.ParseConfigBy(parseConfig), @@ -44,7 +47,7 @@ func main() { ) } -func parseConfig(json gjson.Result, c *PluginConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, c *PluginConfig, log log.Log) error { edges := make([]Edge, 0) nodes := make(map[string]Node) @@ -174,7 +177,7 @@ func initWorkflowExecStatus(config *PluginConfig) (map[string]int, error) { return result, nil } -func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action { initHeader := make([][2]string, 0) // 初始化运行状态 @@ -199,7 +202,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte } // 放入符合条件的edge -func recursive(edge Edge, headers [][2]string, body []byte, depth uint32, config PluginConfig, log wrapper.Log, ctx wrapper.HttpContext) error { +func recursive(edge Edge, headers [][2]string, body []byte, depth uint32, config PluginConfig, log log.Log, ctx wrapper.HttpContext) error { var err error // 防止递归次数太多 diff --git a/plugins/wasm-go/extensions/api-workflow/workflow/workflow.go b/plugins/wasm-go/extensions/api-workflow/workflow/workflow.go index 3b827c68e..21dafd8d4 100644 --- a/plugins/wasm-go/extensions/api-workflow/workflow/workflow.go +++ b/plugins/wasm-go/extensions/api-workflow/workflow/workflow.go @@ -6,7 +6,7 @@ import ( "api-workflow/utils" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) diff --git a/plugins/wasm-go/extensions/basic-auth/go.mod b/plugins/wasm-go/extensions/basic-auth/go.mod index 44ab06521..1b8e9fcf2 100644 --- a/plugins/wasm-go/extensions/basic-auth/go.mod +++ b/plugins/wasm-go/extensions/basic-auth/go.mod @@ -1,21 +1,19 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/basic-auth -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 github.com/pkg/errors v0.9.1 - github.com/tidwall/gjson v1.17.3 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/basic-auth/go.sum b/plugins/wasm-go/extensions/basic-auth/go.sum index fec3080c6..c117d2545 100644 --- a/plugins/wasm-go/extensions/basic-auth/go.sum +++ b/plugins/wasm-go/extensions/basic-auth/go.sum @@ -1,27 +1,25 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/basic-auth/main.go b/plugins/wasm-go/extensions/basic-auth/main.go index e6c8ce754..394ed6745 100644 --- a/plugins/wasm-go/extensions/basic-auth/main.go +++ b/plugins/wasm-go/extensions/basic-auth/main.go @@ -22,7 +22,8 @@ import ( "net/http" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" @@ -30,7 +31,9 @@ import ( "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "basic-auth", wrapper.ParseOverrideConfigBy(parseGlobalConfig, parseOverrideRuleConfig), @@ -106,7 +109,7 @@ var ( protectionSpace = "MSE Gateway" // 认证失败时,返回响应头 WWW-Authenticate: Basic realm=MSE Gateway ) -func parseGlobalConfig(json gjson.Result, global *BasicAuthConfig, log wrapper.Log) error { +func parseGlobalConfig(json gjson.Result, global *BasicAuthConfig, log log.Log) error { // log.Debug("global config") ruleSet = false global.credential2Name = make(map[string]string) @@ -155,7 +158,7 @@ func parseGlobalConfig(json gjson.Result, global *BasicAuthConfig, log wrapper.L return nil } -func parseOverrideRuleConfig(json gjson.Result, global BasicAuthConfig, config *BasicAuthConfig, log wrapper.Log) error { +func parseOverrideRuleConfig(json gjson.Result, global BasicAuthConfig, config *BasicAuthConfig, log log.Log) error { log.Debug("domain/route config") // override config via global *config = global @@ -188,7 +191,7 @@ func parseOverrideRuleConfig(json gjson.Result, global BasicAuthConfig, config * // - global_auth 未设置: // - 若没有一个 domain/route 配置该插件:则遵循 (1*) // - 若有至少一个 domain/route 配置该插件:则遵循 (2*) -func onHttpRequestHeaders(ctx wrapper.HttpContext, config BasicAuthConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config BasicAuthConfig, log log.Log) types.Action { var ( noAllow = len(config.allow) == 0 // 未配置 allow 列表,表示插件在该 domain/route 未生效 globalAuthNoSet = config.globalAuth == nil diff --git a/plugins/wasm-go/extensions/bot-detect/config/bot_detect_config.go b/plugins/wasm-go/extensions/bot-detect/config/bot_detect_config.go index 275512b1f..86b37dbf2 100644 --- a/plugins/wasm-go/extensions/bot-detect/config/bot_detect_config.go +++ b/plugins/wasm-go/extensions/bot-detect/config/bot_detect_config.go @@ -17,7 +17,7 @@ package config import ( - regexp "github.com/wasilibs/go-re2" + "regexp" ) var DefaultBotRegex = []*regexp.Regexp{ diff --git a/plugins/wasm-go/extensions/bot-detect/config/bot_detect_config_test.go b/plugins/wasm-go/extensions/bot-detect/config/bot_detect_config_test.go index aee7adb95..b2761543d 100644 --- a/plugins/wasm-go/extensions/bot-detect/config/bot_detect_config_test.go +++ b/plugins/wasm-go/extensions/bot-detect/config/bot_detect_config_test.go @@ -17,10 +17,11 @@ package config import ( - "github.com/stretchr/testify/assert" - regexp "github.com/wasilibs/go-re2" "log" + "regexp" "testing" + + "github.com/stretchr/testify/assert" ) func toRegexMatch(regexs []string) []*regexp.Regexp { diff --git a/plugins/wasm-go/extensions/bot-detect/go.mod b/plugins/wasm-go/extensions/bot-detect/go.mod index 6a2b1dd55..7455003e1 100644 --- a/plugins/wasm-go/extensions/bot-detect/go.mod +++ b/plugins/wasm-go/extensions/bot-detect/go.mod @@ -1,26 +1,22 @@ module bot-detect -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.2 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 - github.com/wasilibs/go-re2 v1.4.1 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/tetratelabs/wazero v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/extensions/bot-detect/go.sum b/plugins/wasm-go/extensions/bot-detect/go.sum index 2b1700b22..a8ff03319 100644 --- a/plugins/wasm-go/extensions/bot-detect/go.sum +++ b/plugins/wasm-go/extensions/bot-detect/go.sum @@ -1,35 +1,24 @@ 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= -github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tetratelabs/wazero v1.6.0 h1:z0H1iikCdP8t+q341xqepY4EWvHEw8Es7tlqiVzlP3g= -github.com/tetratelabs/wazero v1.6.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/wasilibs/go-re2 v1.4.1 h1:E5+9O1M8UoGeqLB2A9omeoaWImqpuYDs9cKwvTJq/Oo= -github.com/wasilibs/go-re2 v1.4.1/go.mod h1:ynB8eCwd9JsqUnsk8WlPDk6cEeme8BguZmnqOSURE4Y= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/plugins/wasm-go/extensions/bot-detect/main.go b/plugins/wasm-go/extensions/bot-detect/main.go index a29368449..539566b2a 100644 --- a/plugins/wasm-go/extensions/bot-detect/main.go +++ b/plugins/wasm-go/extensions/bot-detect/main.go @@ -19,14 +19,18 @@ package main import ( "bot-detect/config" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "regexp" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" - regexp "github.com/wasilibs/go-re2" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "bot-detect", wrapper.ParseConfigBy(parseConfig), @@ -34,7 +38,7 @@ func main() { ) } -func parseConfig(json gjson.Result, botDetectConfig *config.BotDetectConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, botDetectConfig *config.BotDetectConfig, log log.Log) error { log.Debug("parseConfig()") if json.Get("blocked_code").Exists() { @@ -81,7 +85,7 @@ func parseConfig(json gjson.Result, botDetectConfig *config.BotDetectConfig, log } -func onHttpRequestHeaders(ctx wrapper.HttpContext, botDetectConfig config.BotDetectConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, botDetectConfig config.BotDetectConfig, log log.Log) types.Action { log.Debug("onHttpRequestHeaders()") //// Get user-agent header ua, err := proxywasm.GetHttpRequestHeader("user-agent") diff --git a/plugins/wasm-go/extensions/cache-control/go.mod b/plugins/wasm-go/extensions/cache-control/go.mod index 8738fdbe0..dad24958b 100644 --- a/plugins/wasm-go/extensions/cache-control/go.mod +++ b/plugins/wasm-go/extensions/cache-control/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/cache-control -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/cache-control/go.sum b/plugins/wasm-go/extensions/cache-control/go.sum index dc870371d..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/cache-control/go.sum +++ b/plugins/wasm-go/extensions/cache-control/go.sum @@ -1,12 +1,23 @@ -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/cache-control/main.go b/plugins/wasm-go/extensions/cache-control/main.go index e5b7d16cf..c598e4fa5 100644 --- a/plugins/wasm-go/extensions/cache-control/main.go +++ b/plugins/wasm-go/extensions/cache-control/main.go @@ -1,17 +1,21 @@ package main import ( - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" - "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" - "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" - "github.com/tidwall/gjson" "net/http" "strconv" "strings" "time" + + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" + "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "cache-control", wrapper.ParseConfigBy(parseConfig), @@ -25,7 +29,7 @@ type CacheControlConfig struct { expires string } -func parseConfig(json gjson.Result, config *CacheControlConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *CacheControlConfig, log log.Log) error { suffix := json.Get("suffix").String() if suffix != "" { parts := strings.Split(suffix, "|") @@ -38,7 +42,7 @@ func parseConfig(json gjson.Result, config *CacheControlConfig, log wrapper.Log) return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config CacheControlConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config CacheControlConfig, log log.Log) types.Action { path := ctx.Path() if strings.Contains(path, "?") { path = strings.Split(path, "?")[0] @@ -49,7 +53,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config CacheControlConfig, lo return types.ActionContinue } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config CacheControlConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config CacheControlConfig, log log.Log) types.Action { hit := false if len(config.suffix) == 0 { hit = true diff --git a/plugins/wasm-go/extensions/chatgpt-proxy/go.mod b/plugins/wasm-go/extensions/chatgpt-proxy/go.mod index 350edb0f8..8969dac75 100644 --- a/plugins/wasm-go/extensions/chatgpt-proxy/go.mod +++ b/plugins/wasm-go/extensions/chatgpt-proxy/go.mod @@ -1,20 +1,18 @@ module chatgpt-proxy -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0-20230629030002-81e467b6242d - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/chatgpt-proxy/go.sum b/plugins/wasm-go/extensions/chatgpt-proxy/go.sum index 9c510ab4b..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/chatgpt-proxy/go.sum +++ b/plugins/wasm-go/extensions/chatgpt-proxy/go.sum @@ -1,25 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/chatgpt-proxy/main.go b/plugins/wasm-go/extensions/chatgpt-proxy/main.go index b41bfae54..0a31c5d19 100644 --- a/plugins/wasm-go/extensions/chatgpt-proxy/main.go +++ b/plugins/wasm-go/extensions/chatgpt-proxy/main.go @@ -7,13 +7,16 @@ import ( "net/url" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "chatgpt-proxy", wrapper.ParseConfigBy(parseConfig), @@ -31,7 +34,7 @@ type MyConfig struct { client wrapper.HttpClient } -func parseConfig(json gjson.Result, config *MyConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *MyConfig, log log.Log) error { chatgptUri := json.Get("chatgptUri").String() var chatgptHost string if chatgptUri == "" { @@ -90,7 +93,7 @@ const bodyTemplate string = ` } ` -func onHttpRequestHeaders(ctx wrapper.HttpContext, config MyConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config MyConfig, log log.Log) types.Action { pairs := strings.SplitN(ctx.Path(), "?", 2) if len(pairs) < 2 { diff --git a/plugins/wasm-go/extensions/cluster-key-rate-limit/config/config.go b/plugins/wasm-go/extensions/cluster-key-rate-limit/config/config.go index 17058b77c..019ddb214 100644 --- a/plugins/wasm-go/extensions/cluster-key-rate-limit/config/config.go +++ b/plugins/wasm-go/extensions/cluster-key-rate-limit/config/config.go @@ -6,9 +6,11 @@ import ( "strings" "cluster-key-rate-limit/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + + re "regexp" + + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" - re "github.com/wasilibs/go-re2" "github.com/zmap/go-iptree/iptree" ) diff --git a/plugins/wasm-go/extensions/cluster-key-rate-limit/go.mod b/plugins/wasm-go/extensions/cluster-key-rate-limit/go.mod index a2db02e95..a2edff8e2 100644 --- a/plugins/wasm-go/extensions/cluster-key-rate-limit/go.mod +++ b/plugins/wasm-go/extensions/cluster-key-rate-limit/go.mod @@ -1,29 +1,24 @@ module cluster-key-rate-limit -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/resp v0.1.1 - github.com/wasilibs/go-re2 v1.5.3 github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 ) require ( github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/tetratelabs/wazero v1.7.1 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect - github.com/tidwall/sjson v1.2.5 // indirect + github.com/tidwall/pretty v1.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/extensions/cluster-key-rate-limit/go.sum b/plugins/wasm-go/extensions/cluster-key-rate-limit/go.sum index 96927ade5..54d941aef 100644 --- a/plugins/wasm-go/extensions/cluster-key-rate-limit/go.sum +++ b/plugins/wasm-go/extensions/cluster-key-rate-limit/go.sum @@ -2,34 +2,25 @@ github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 h1:Wi5Tgn8K+jDcBY github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56/go.mod h1:8BhOLuqtSuT5NZtZMwfvEibi09RO3u79uqfHZzfDTR4= 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tetratelabs/wazero v1.7.1 h1:QtSfd6KLc41DIMpDYlJdoMc6k7QTN246DM2+n2Y/Dx8= -github.com/tetratelabs/wazero v1.7.1/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= -github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/wasilibs/go-re2 v1.5.3 h1:wiuTcgDZdLhu8NG8oqF5sF5Q3yIU14lPAvXqeYzDK3g= -github.com/wasilibs/go-re2 v1.5.3/go.mod h1:PzpVPsBdFC7vM8QJbbEnOeTmwA0DGE783d/Gex8eCV8= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 h1:DjHnADS2r2zynZ3WkCFAQ+PNYngMSNceRROi0pO6c3M= github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837/go.mod h1:9vp0bxqozzQwcjBwenEXfKVq8+mYbwHkQ1NF9Ap0DMw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/plugins/wasm-go/extensions/cluster-key-rate-limit/main.go b/plugins/wasm-go/extensions/cluster-key-rate-limit/main.go index 0ce0bb2de..945a536cc 100644 --- a/plugins/wasm-go/extensions/cluster-key-rate-limit/main.go +++ b/plugins/wasm-go/extensions/cluster-key-rate-limit/main.go @@ -23,15 +23,18 @@ import ( "cluster-key-rate-limit/config" "cluster-key-rate-limit/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/resp" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "cluster-key-rate-limit", wrapper.ParseConfig(parseConfig), diff --git a/plugins/wasm-go/extensions/cors/config/cors_config.go b/plugins/wasm-go/extensions/cors/config/cors_config.go index 74209e9fd..e9b336924 100644 --- a/plugins/wasm-go/extensions/cors/config/cors_config.go +++ b/plugins/wasm-go/extensions/cors/config/cors_config.go @@ -20,7 +20,7 @@ import ( "net/url" "strings" - regexp "github.com/wasilibs/go-re2" + "regexp" ) const ( diff --git a/plugins/wasm-go/extensions/cors/go.mod b/plugins/wasm-go/extensions/cors/go.mod index da78b7386..dcc2034da 100644 --- a/plugins/wasm-go/extensions/cors/go.mod +++ b/plugins/wasm-go/extensions/cors/go.mod @@ -1,27 +1,22 @@ module cors -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0-20230519024024-625c06e58f91 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 - github.com/wasilibs/go-re2 v1.6.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a // indirect + github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/tetratelabs/wazero v1.7.2 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - golang.org/x/sys v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/extensions/cors/go.sum b/plugins/wasm-go/extensions/cors/go.sum index 93c6d3541..a8ff03319 100644 --- a/plugins/wasm-go/extensions/cors/go.sum +++ b/plugins/wasm-go/extensions/cors/go.sum @@ -1,34 +1,24 @@ 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a h1:tdPcGgyiH0K+SbsJBBm2oPyEIOTAvLBwD9TuUwVtZho= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= -github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/wasilibs/go-re2 v1.6.0 h1:CLlhDebt38wtl/zz4ww+hkXBMcxjrKFvTDXzFW2VOz8= -github.com/wasilibs/go-re2 v1.6.0/go.mod h1:prArCyErsypRBI/jFAFJEbzyHzjABKqkzlidF0SNA04= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/plugins/wasm-go/extensions/cors/main.go b/plugins/wasm-go/extensions/cors/main.go index b1ed20c7d..54f57e9ab 100644 --- a/plugins/wasm-go/extensions/cors/main.go +++ b/plugins/wasm-go/extensions/cors/main.go @@ -19,13 +19,16 @@ import ( "fmt" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "cors", wrapper.ParseConfigBy(parseConfig), @@ -34,7 +37,7 @@ func main() { ) } -func parseConfig(json gjson.Result, corsConfig *config.CorsConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, corsConfig *config.CorsConfig, log log.Log) error { log.Debug("parseConfig()") allowOrigins := json.Get("allow_origins").Array() for _, origin := range allowOrigins { @@ -71,7 +74,7 @@ func parseConfig(json gjson.Result, corsConfig *config.CorsConfig, log wrapper.L return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, corsConfig config.CorsConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, corsConfig config.CorsConfig, log log.Log) types.Action { log.Debug("onHttpRequestHeaders()") requestUrl, _ := proxywasm.GetHttpRequestHeader(":path") method, _ := proxywasm.GetHttpRequestHeader(":method") @@ -109,7 +112,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, corsConfig config.CorsConfig, return types.ActionContinue } -func onHttpResponseHeaders(ctx wrapper.HttpContext, corsConfig config.CorsConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, corsConfig config.CorsConfig, log log.Log) types.Action { log.Debug("onHttpResponseHeaders()") // Remove trace header if existed proxywasm.RemoveHttpResponseHeader(config.HeaderPluginTrace) diff --git a/plugins/wasm-go/extensions/custom-response/go.mod b/plugins/wasm-go/extensions/custom-response/go.mod index ff864abb5..d543fcdec 100644 --- a/plugins/wasm-go/extensions/custom-response/go.mod +++ b/plugins/wasm-go/extensions/custom-response/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/basic-auth -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/custom-response/go.sum b/plugins/wasm-go/extensions/custom-response/go.sum index f0206f83d..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/custom-response/go.sum +++ b/plugins/wasm-go/extensions/custom-response/go.sum @@ -1,25 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/custom-response/main.go b/plugins/wasm-go/extensions/custom-response/main.go index c8388d3d6..f195bc6a2 100644 --- a/plugins/wasm-go/extensions/custom-response/main.go +++ b/plugins/wasm-go/extensions/custom-response/main.go @@ -21,14 +21,16 @@ import ( "strconv" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "custom-response", wrapper.ParseConfig(parseConfig), diff --git a/plugins/wasm-go/extensions/de-graphql/config/degraphql_config.go b/plugins/wasm-go/extensions/de-graphql/config/degraphql_config.go index 3177a7198..81dcaca48 100644 --- a/plugins/wasm-go/extensions/de-graphql/config/degraphql_config.go +++ b/plugins/wasm-go/extensions/de-graphql/config/degraphql_config.go @@ -19,7 +19,7 @@ import ( "net/url" "strings" - regexp "github.com/wasilibs/go-re2" + "regexp" ) const ( diff --git a/plugins/wasm-go/extensions/de-graphql/go.mod b/plugins/wasm-go/extensions/de-graphql/go.mod index 6e0d84d73..b2936bbde 100644 --- a/plugins/wasm-go/extensions/de-graphql/go.mod +++ b/plugins/wasm-go/extensions/de-graphql/go.mod @@ -1,27 +1,22 @@ module de-graphql -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0-20230410091208-df60dd43079c - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 - github.com/wasilibs/go-re2 v1.6.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a // indirect + github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/tetratelabs/wazero v1.7.2 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - golang.org/x/sys v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/extensions/de-graphql/go.sum b/plugins/wasm-go/extensions/de-graphql/go.sum index 93c6d3541..a8ff03319 100644 --- a/plugins/wasm-go/extensions/de-graphql/go.sum +++ b/plugins/wasm-go/extensions/de-graphql/go.sum @@ -1,34 +1,24 @@ 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a h1:tdPcGgyiH0K+SbsJBBm2oPyEIOTAvLBwD9TuUwVtZho= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= -github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/wasilibs/go-re2 v1.6.0 h1:CLlhDebt38wtl/zz4ww+hkXBMcxjrKFvTDXzFW2VOz8= -github.com/wasilibs/go-re2 v1.6.0/go.mod h1:prArCyErsypRBI/jFAFJEbzyHzjABKqkzlidF0SNA04= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/plugins/wasm-go/extensions/de-graphql/main.go b/plugins/wasm-go/extensions/de-graphql/main.go index 49ef8f83c..818023104 100644 --- a/plugins/wasm-go/extensions/de-graphql/main.go +++ b/plugins/wasm-go/extensions/de-graphql/main.go @@ -20,13 +20,16 @@ import ( "de-graphql/config" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "de-graphql", wrapper.ParseConfigBy(parseConfig), @@ -37,7 +40,7 @@ func main() { ) } -func parseConfig(json gjson.Result, config *config.DeGraphQLConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *config.DeGraphQLConfig, log log.Log) error { log.Debug("parseConfig()") gql := json.Get("gql").String() endpoint := json.Get("endpoint").String() @@ -57,7 +60,7 @@ func parseConfig(json gjson.Result, config *config.DeGraphQLConfig, log wrapper. return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config config.DeGraphQLConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config config.DeGraphQLConfig, log log.Log) types.Action { log.Debug("onHttpRequestHeaders()") log.Debugf("schema:%s host:%s path:%s", ctx.Scheme(), ctx.Host(), ctx.Path()) requestUrl, _ := proxywasm.GetHttpRequestHeader(":path") @@ -102,17 +105,17 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config config.DeGraphQLConfig return types.ActionPause } -func onHttpRequestBody(ctx wrapper.HttpContext, config config.DeGraphQLConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config config.DeGraphQLConfig, body []byte, log log.Log) types.Action { log.Debug("onHttpRequestBody()") return types.ActionContinue } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config config.DeGraphQLConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config config.DeGraphQLConfig, log log.Log) types.Action { log.Debug("onHttpResponseHeaders()") return types.ActionContinue } -func onHttpResponseBody(ctx wrapper.HttpContext, config config.DeGraphQLConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config config.DeGraphQLConfig, body []byte, log log.Log) types.Action { log.Debug("onHttpResponseBody()") return types.ActionContinue } diff --git a/plugins/wasm-go/extensions/ext-auth/config/config.go b/plugins/wasm-go/extensions/ext-auth/config/config.go index 648c94c04..3c2ec8c74 100644 --- a/plugins/wasm-go/extensions/ext-auth/config/config.go +++ b/plugins/wasm-go/extensions/ext-auth/config/config.go @@ -7,8 +7,9 @@ import ( "strings" "ext-auth/expr" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ext-auth/config/config_test.go b/plugins/wasm-go/extensions/ext-auth/config/config_test.go index 7e4dc1fb8..ec551c043 100644 --- a/plugins/wasm-go/extensions/ext-auth/config/config_test.go +++ b/plugins/wasm-go/extensions/ext-auth/config/config_test.go @@ -4,7 +4,8 @@ import ( "testing" "ext-auth/expr" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/stretchr/testify/assert" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/ext-auth/expr/match_rules.go b/plugins/wasm-go/extensions/ext-auth/expr/match_rules.go index bc74cd9bf..540f33652 100644 --- a/plugins/wasm-go/extensions/ext-auth/expr/match_rules.go +++ b/plugins/wasm-go/extensions/ext-auth/expr/match_rules.go @@ -4,7 +4,7 @@ import ( "strings" "ext-auth/util" - regexp "github.com/wasilibs/go-re2" + "regexp" ) const ( diff --git a/plugins/wasm-go/extensions/ext-auth/expr/matcher.go b/plugins/wasm-go/extensions/ext-auth/expr/matcher.go index 608d6137a..92af6288e 100644 --- a/plugins/wasm-go/extensions/ext-auth/expr/matcher.go +++ b/plugins/wasm-go/extensions/ext-auth/expr/matcher.go @@ -4,7 +4,7 @@ import ( "errors" "strings" - regexp "github.com/wasilibs/go-re2" + "regexp" ) const ( diff --git a/plugins/wasm-go/extensions/ext-auth/go.mod b/plugins/wasm-go/extensions/ext-auth/go.mod index 1f426fae2..63c5b55a8 100644 --- a/plugins/wasm-go/extensions/ext-auth/go.mod +++ b/plugins/wasm-go/extensions/ext-auth/go.mod @@ -1,28 +1,22 @@ module ext-auth -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 - github.com/wasilibs/go-re2 v1.6.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a // indirect + github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/tetratelabs/wazero v1.7.2 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - github.com/tidwall/sjson v1.2.5 // indirect - golang.org/x/sys v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ext-auth/go.sum b/plugins/wasm-go/extensions/ext-auth/go.sum index 066d7a2f2..a8ff03319 100644 --- a/plugins/wasm-go/extensions/ext-auth/go.sum +++ b/plugins/wasm-go/extensions/ext-auth/go.sum @@ -1,35 +1,24 @@ 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a h1:tdPcGgyiH0K+SbsJBBm2oPyEIOTAvLBwD9TuUwVtZho= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= -github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= -github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/wasilibs/go-re2 v1.6.0 h1:CLlhDebt38wtl/zz4ww+hkXBMcxjrKFvTDXzFW2VOz8= -github.com/wasilibs/go-re2 v1.6.0/go.mod h1:prArCyErsypRBI/jFAFJEbzyHzjABKqkzlidF0SNA04= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/plugins/wasm-go/extensions/ext-auth/main.go b/plugins/wasm-go/extensions/ext-auth/main.go index 53b777a5b..3cdb60cec 100644 --- a/plugins/wasm-go/extensions/ext-auth/main.go +++ b/plugins/wasm-go/extensions/ext-auth/main.go @@ -20,14 +20,17 @@ import ( "ext-auth/config" "ext-auth/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ext-auth", wrapper.ParseConfig(config.ParseConfig), diff --git a/plugins/wasm-go/extensions/frontend-gray/go.mod b/plugins/wasm-go/extensions/frontend-gray/go.mod index e7186f099..080135719 100644 --- a/plugins/wasm-go/extensions/frontend-gray/go.mod +++ b/plugins/wasm-go/extensions/frontend-gray/go.mod @@ -1,26 +1,23 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/frontend-gray -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.3-0.20240727022514-bccfbde62188 github.com/bmatcuk/doublestar/v4 v4.6.1 - github.com/google/uuid v1.3.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/google/uuid v1.6.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 github.com/stretchr/testify v1.9.0 - github.com/tidwall/gjson v1.17.3 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - github.com/tidwall/sjson v1.2.5 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/extensions/frontend-gray/go.sum b/plugins/wasm-go/extensions/frontend-gray/go.sum index 4f7e6dada..dbb3455ee 100644 --- a/plugins/wasm-go/extensions/frontend-gray/go.sum +++ b/plugins/wasm-go/extensions/frontend-gray/go.sum @@ -2,36 +2,26 @@ github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwN github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= 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/davecgh/go-spew v1.1.1+incompatible/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= -github.com/pmezard/go-difflib v1.0.0+incompatible/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= -github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= -github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/frontend-gray/main.go b/plugins/wasm-go/extensions/frontend-gray/main.go index 874632fcd..e52b6ea00 100644 --- a/plugins/wasm-go/extensions/frontend-gray/main.go +++ b/plugins/wasm-go/extensions/frontend-gray/main.go @@ -6,15 +6,17 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/extensions/frontend-gray/config" "github.com/alibaba/higress/plugins/wasm-go/extensions/frontend-gray/util" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "frontend-gray", wrapper.ParseConfig(parseConfig), diff --git a/plugins/wasm-go/extensions/gc-test/go.mod b/plugins/wasm-go/extensions/gc-test/go.mod index e367ab78c..e929a0c1c 100644 --- a/plugins/wasm-go/extensions/gc-test/go.mod +++ b/plugins/wasm-go/extensions/gc-test/go.mod @@ -1,22 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/gc-test -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. - -replace github.com/wasilibs/nottinygc v0.5.1 => github.com/higress-group/nottinygc v0.0.0-20231019105920-c4d985d443e1 +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/gc-test/go.sum b/plugins/wasm-go/extensions/gc-test/go.sum index f0206f83d..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/gc-test/go.sum +++ b/plugins/wasm-go/extensions/gc-test/go.sum @@ -1,25 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/gc-test/main.go b/plugins/wasm-go/extensions/gc-test/main.go index 48cb0904f..7427dd908 100644 --- a/plugins/wasm-go/extensions/gc-test/main.go +++ b/plugins/wasm-go/extensions/gc-test/main.go @@ -5,13 +5,15 @@ import ( "net/http" "runtime" - . "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + . "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { SetCtx( "gc-test", ParseConfigBy(parseConfig), diff --git a/plugins/wasm-go/extensions/geo-ip/go.mod b/plugins/wasm-go/extensions/geo-ip/go.mod index 2e383d046..09445dce3 100644 --- a/plugins/wasm-go/extensions/geo-ip/go.mod +++ b/plugins/wasm-go/extensions/geo-ip/go.mod @@ -1,24 +1,24 @@ module higress/plugins/wasm-go/extensions/geo-ip -go 1.19 +go 1.24.1 + +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.2 - github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 ) require ( github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/extensions/geo-ip/go.sum b/plugins/wasm-go/extensions/geo-ip/go.sum index 93c1e19ae..54d941aef 100644 --- a/plugins/wasm-go/extensions/geo-ip/go.sum +++ b/plugins/wasm-go/extensions/geo-ip/go.sum @@ -1,27 +1,24 @@ -github.com/alibaba/higress/plugins/wasm-go v1.4.2 h1:gH7OIGXm4wtW5Vo7L2deMPqF7OVWNESDHv1CaaTGu6s= -github.com/alibaba/higress/plugins/wasm-go v1.4.2/go.mod h1:359don/ahMxpfeLMzr29Cjwcu8IywTTDUzWlBPRNLHw= github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 h1:Wi5Tgn8K+jDcBYL+dIMS1+qXYH2r7tpRAyBgqrWfQtw= github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56/go.mod h1:8BhOLuqtSuT5NZtZMwfvEibi09RO3u79uqfHZzfDTR4= 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 h1:DjHnADS2r2zynZ3WkCFAQ+PNYngMSNceRROi0pO6c3M= diff --git a/plugins/wasm-go/extensions/geo-ip/main.go b/plugins/wasm-go/extensions/geo-ip/main.go index 1d512b9eb..81f510d12 100644 --- a/plugins/wasm-go/extensions/geo-ip/main.go +++ b/plugins/wasm-go/extensions/geo-ip/main.go @@ -8,9 +8,10 @@ import ( _ "embed" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/zmap/go-iptree/iptree" ) @@ -34,7 +35,9 @@ var internalIpCidr []string = []string{"0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/11 "192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "224.0.0.0/3", } -func main() { +func main() {} + +func init() { wrapper.SetCtx( "geo-ip", wrapper.ParseConfigBy(parseConfig), @@ -56,7 +59,7 @@ type GeoIpData struct { Isp string `json:"isp"` } -func parseConfig(json gjson.Result, config *GeoIpConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *GeoIpConfig, log log.Log) error { sourceType := json.Get("ip_source_type") if sourceType.Exists() && sourceType.String() != "" { switch sourceType.String() { @@ -104,7 +107,7 @@ func parseConfig(json gjson.Result, config *GeoIpConfig, log wrapper.Log) error return nil } -func ReadGeoIpDataToRdxtree(log wrapper.Log) error { +func ReadGeoIpDataToRdxtree(log log.Log) error { GeoIpRdxTree = iptree.New() //eg., cidr country province city isp @@ -141,7 +144,7 @@ func ReadGeoIpDataToRdxtree(log wrapper.Log) error { } // search geodata using client ip in radixtree. -func SearchGeoIpDataInRdxtree(ip string, log wrapper.Log) (*GeoIpData, error) { +func SearchGeoIpDataInRdxtree(ip string, log log.Log) (*GeoIpData, error) { val, found, err := GeoIpRdxTree.GetByString(ip) if err != nil { log.Errorf("search geo ip data in raditree failed. %v %s", err, ip) @@ -196,7 +199,7 @@ func isInternalIp(ip string) (string, error) { return "", nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config GeoIpConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config GeoIpConfig, log log.Log) types.Action { var ( s string err error diff --git a/plugins/wasm-go/extensions/gw-error-format/go.mod b/plugins/wasm-go/extensions/gw-error-format/go.mod index ad04869ef..5c8deaa70 100644 --- a/plugins/wasm-go/extensions/gw-error-format/go.mod +++ b/plugins/wasm-go/extensions/gw-error-format/go.mod @@ -1,23 +1,19 @@ module wasm-demo -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/tidwall/gjson v1.18.0 ) -require ( - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/tidwall/resp v0.1.1 // indirect -) +require github.com/tidwall/resp v0.1.1 // indirect require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0-20221116034346-4eb91e6918b8 - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/higress-group/wasm-go v1.0.0 github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect ) diff --git a/plugins/wasm-go/extensions/gw-error-format/go.sum b/plugins/wasm-go/extensions/gw-error-format/go.sum index f0206f83d..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/gw-error-format/go.sum +++ b/plugins/wasm-go/extensions/gw-error-format/go.sum @@ -1,25 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/gw-error-format/main.go b/plugins/wasm-go/extensions/gw-error-format/main.go index 24a2f5094..68d6b690f 100644 --- a/plugins/wasm-go/extensions/gw-error-format/main.go +++ b/plugins/wasm-go/extensions/gw-error-format/main.go @@ -3,13 +3,16 @@ package main import ( "errors" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "gw-error-format", wrapper.ParseConfigBy(parseConfig), @@ -23,7 +26,7 @@ type MyConfig struct { set_header []gjson.Result } -func parseConfig(json gjson.Result, config *MyConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *MyConfig, log log.Log) error { config.set_header = json.Get("set_header").Array() config.rules = json.Get("rules").Array() for _, item := range config.rules { @@ -39,7 +42,7 @@ func parseConfig(json gjson.Result, config *MyConfig, log wrapper.Log) error { return nil } -func onHttpResponseHeader(ctx wrapper.HttpContext, config MyConfig, log wrapper.Log) types.Action { +func onHttpResponseHeader(ctx wrapper.HttpContext, config MyConfig, log log.Log) types.Action { dontReadResponseBody := false currentStatuscode, _ := proxywasm.GetHttpResponseHeader(":status") @@ -82,7 +85,7 @@ func onHttpResponseHeader(ctx wrapper.HttpContext, config MyConfig, log wrapper. return types.ActionContinue } -func onHttpResponseBody(ctx wrapper.HttpContext, config MyConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config MyConfig, body []byte, log log.Log) types.Action { bodyStr := string(body) for _, item := range config.rules { diff --git a/plugins/wasm-go/extensions/hello-world/go.mod b/plugins/wasm-go/extensions/hello-world/go.mod index 28abc3ec9..02e170812 100644 --- a/plugins/wasm-go/extensions/hello-world/go.mod +++ b/plugins/wasm-go/extensions/hello-world/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/hello-world -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/tidwall/gjson v1.17.3 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/hello-world/go.sum b/plugins/wasm-go/extensions/hello-world/go.sum index f0206f83d..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/hello-world/go.sum +++ b/plugins/wasm-go/extensions/hello-world/go.sum @@ -1,25 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/hello-world/main.go b/plugins/wasm-go/extensions/hello-world/main.go index bff252d6a..a983d3d76 100644 --- a/plugins/wasm-go/extensions/hello-world/main.go +++ b/plugins/wasm-go/extensions/hello-world/main.go @@ -19,11 +19,13 @@ import ( "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" - - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "hello-world", wrapper.ProcessRequestHeadersBy(onHttpRequestHeaders), @@ -33,7 +35,7 @@ func main() { type HelloWorldConfig struct { } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config HelloWorldConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config HelloWorldConfig, log log.Log) types.Action { err := proxywasm.AddHttpRequestHeader("hello", "world") if err != nil { log.Critical("failed to set request header") diff --git a/plugins/wasm-go/extensions/http-call/go.mod b/plugins/wasm-go/extensions/http-call/go.mod index 24c1fe6eb..e0d2fac34 100644 --- a/plugins/wasm-go/extensions/http-call/go.mod +++ b/plugins/wasm-go/extensions/http-call/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/http-call -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/http-call/go.sum b/plugins/wasm-go/extensions/http-call/go.sum index f0206f83d..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/http-call/go.sum +++ b/plugins/wasm-go/extensions/http-call/go.sum @@ -1,25 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/http-call/main.go b/plugins/wasm-go/extensions/http-call/main.go index 056e62e33..ddfe6b387 100644 --- a/plugins/wasm-go/extensions/http-call/main.go +++ b/plugins/wasm-go/extensions/http-call/main.go @@ -21,12 +21,15 @@ import ( "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" "github.com/tidwall/gjson" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "http-call", wrapper.ParseConfigBy(parseConfig), @@ -41,7 +44,7 @@ type HttpCallConfig struct { tokenHeader string } -func parseConfig(json gjson.Result, config *HttpCallConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *HttpCallConfig, log log.Log) error { config.bodyHeader = json.Get("bodyHeader").String() if config.bodyHeader == "" { return errors.New("missing bodyHeader in config") @@ -96,7 +99,7 @@ func parseConfig(json gjson.Result, config *HttpCallConfig, log wrapper.Log) err } } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config HttpCallConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config HttpCallConfig, log log.Log) types.Action { config.client.Get(config.requestPath, nil, func(statusCode int, responseHeaders http.Header, responseBody []byte) { defer proxywasm.ResumeHttpRequest() diff --git a/plugins/wasm-go/extensions/ip-restriction/go.mod b/plugins/wasm-go/extensions/ip-restriction/go.mod index 9d3f255bd..c66e0d2ea 100644 --- a/plugins/wasm-go/extensions/ip-restriction/go.mod +++ b/plugins/wasm-go/extensions/ip-restriction/go.mod @@ -1,22 +1,20 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/ip-restriction -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 ) require ( github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/ip-restriction/go.sum b/plugins/wasm-go/extensions/ip-restriction/go.sum index c58fd2aeb..588c05eaa 100644 --- a/plugins/wasm-go/extensions/ip-restriction/go.sum +++ b/plugins/wasm-go/extensions/ip-restriction/go.sum @@ -1,29 +1,27 @@ github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56 h1:Wi5Tgn8K+jDcBYL+dIMS1+qXYH2r7tpRAyBgqrWfQtw= github.com/asergeyev/nradix v0.0.0-20170505151046-3872ab85bb56/go.mod h1:8BhOLuqtSuT5NZtZMwfvEibi09RO3u79uqfHZzfDTR4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837 h1:DjHnADS2r2zynZ3WkCFAQ+PNYngMSNceRROi0pO6c3M= github.com/zmap/go-iptree v0.0.0-20210731043055-d4e632617837/go.mod h1:9vp0bxqozzQwcjBwenEXfKVq8+mYbwHkQ1NF9Ap0DMw= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/ip-restriction/main.go b/plugins/wasm-go/extensions/ip-restriction/main.go index c9e8b04a2..d0e86493e 100644 --- a/plugins/wasm-go/extensions/ip-restriction/main.go +++ b/plugins/wasm-go/extensions/ip-restriction/main.go @@ -5,9 +5,10 @@ import ( "fmt" "net" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/zmap/go-iptree/iptree" ) @@ -31,14 +32,16 @@ type RestrictionConfig struct { Message string `json:"message"` //被拒绝时返回的消息 } -func main() { +func main() {} + +func init() { wrapper.SetCtx( "ip-restriction", wrapper.ParseConfigBy(parseConfig), wrapper.ProcessRequestHeadersBy(onHttpRequestHeaders)) } -func parseConfig(json gjson.Result, config *RestrictionConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *RestrictionConfig, log log.Log) error { sourceType := json.Get("ip_source_type") if sourceType.Exists() && sourceType.String() != "" { switch sourceType.String() { @@ -117,7 +120,7 @@ func getDownStreamIp(config RestrictionConfig) (net.IP, error) { return realIP, nil } -func onHttpRequestHeaders(context wrapper.HttpContext, config RestrictionConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(context wrapper.HttpContext, config RestrictionConfig, log log.Log) types.Action { realIp, err := getDownStreamIp(config) if err != nil { return deniedUnauthorized(config, "get_ip_failed") diff --git a/plugins/wasm-go/extensions/jwt-auth/config/parser.go b/plugins/wasm-go/extensions/jwt-auth/config/parser.go index 83bd8f878..68eda2b57 100644 --- a/plugins/wasm-go/extensions/jwt-auth/config/parser.go +++ b/plugins/wasm-go/extensions/jwt-auth/config/parser.go @@ -18,8 +18,8 @@ import ( "encoding/json" "fmt" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/go-jose/go-jose/v3" + "github.com/higress-group/wasm-go/pkg/log" "github.com/tidwall/gjson" ) @@ -28,7 +28,7 @@ var RuleSet bool // ParseGlobalConfig 从wrapper提供的配置中解析并转换到插件运行时需要使用的配置。 // 此处解析的是全局配置,域名和路由级配置由 ParseRuleConfig 负责。 -func ParseGlobalConfig(json gjson.Result, config *JWTAuthConfig, log wrapper.Log) error { +func ParseGlobalConfig(json gjson.Result, config *JWTAuthConfig, log log.Log) error { RuleSet = false consumers := json.Get("consumers") if !consumers.IsArray() { @@ -53,7 +53,7 @@ func ParseGlobalConfig(json gjson.Result, config *JWTAuthConfig, log wrapper.Log // ParseRuleConfig 从wrapper提供的配置中解析并转换到插件运行时需要使用的配置。 // 此处解析的是域名和路由级配置,全局配置由 ParseConfig 负责。 -func ParseRuleConfig(json gjson.Result, global JWTAuthConfig, config *JWTAuthConfig, log wrapper.Log) error { +func ParseRuleConfig(json gjson.Result, global JWTAuthConfig, config *JWTAuthConfig, log log.Log) error { // override config via global *config = global diff --git a/plugins/wasm-go/extensions/jwt-auth/go.mod b/plugins/wasm-go/extensions/jwt-auth/go.mod index 8b99aea01..3b28c324b 100644 --- a/plugins/wasm-go/extensions/jwt-auth/go.mod +++ b/plugins/wasm-go/extensions/jwt-auth/go.mod @@ -1,22 +1,20 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/jwt-auth -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.5 github.com/go-jose/go-jose/v3 v3.0.3 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/google/uuid v1.6.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - golang.org/x/crypto v0.23.0 // indirect + golang.org/x/crypto v0.26.0 // indirect ) diff --git a/plugins/wasm-go/extensions/jwt-auth/go.sum b/plugins/wasm-go/extensions/jwt-auth/go.sum index 470d7768c..ddd6c4ce6 100644 --- a/plugins/wasm-go/extensions/jwt-auth/go.sum +++ b/plugins/wasm-go/extensions/jwt-auth/go.sum @@ -1,27 +1,24 @@ 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/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k= github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 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/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc h1:t2AT8zb6N/59Y78lyRWedVoVWHNRSCBh0oWCC+bluTQ= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= -github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -33,8 +30,8 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -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/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -72,3 +69,4 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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= diff --git a/plugins/wasm-go/extensions/jwt-auth/handler/handler.go b/plugins/wasm-go/extensions/jwt-auth/handler/handler.go index 41dfbc1bb..1fb575dfc 100644 --- a/plugins/wasm-go/extensions/jwt-auth/handler/handler.go +++ b/plugins/wasm-go/extensions/jwt-auth/handler/handler.go @@ -18,8 +18,9 @@ import ( "time" cfg "github.com/alibaba/higress/plugins/wasm-go/extensions/jwt-auth/config" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) // jwt-auth 插件认证逻辑与 basic-auth 一致: @@ -36,7 +37,7 @@ import ( // - 若有至少一个 domain/route 配置该插件:则遵循 (2*) // // https://github.com/alibaba/higress/blob/e09edff827b94fa5bcc149bbeadc905361100c2a/plugins/wasm-go/extensions/basic-auth/main.go#L191 -func OnHTTPRequestHeaders(ctx wrapper.HttpContext, config cfg.JWTAuthConfig, log wrapper.Log) types.Action { +func OnHTTPRequestHeaders(ctx wrapper.HttpContext, config cfg.JWTAuthConfig, log log.Log) types.Action { var ( noAllow = len(config.Allow) == 0 // 未配置 allow 列表,表示插件在该 domain/route 未生效 globalAuthNoSet = config.GlobalAuthCheck() == cfg.GlobalAuthNoSet diff --git a/plugins/wasm-go/extensions/jwt-auth/main.go b/plugins/wasm-go/extensions/jwt-auth/main.go index 1961278ce..8453193f0 100644 --- a/plugins/wasm-go/extensions/jwt-auth/main.go +++ b/plugins/wasm-go/extensions/jwt-auth/main.go @@ -17,7 +17,7 @@ package main import ( "github.com/alibaba/higress/plugins/wasm-go/extensions/jwt-auth/config" "github.com/alibaba/higress/plugins/wasm-go/extensions/jwt-auth/handler" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) // @Name jwt-proxy @@ -33,10 +33,11 @@ import ( // @Contact.email ink33@smlk.org // // @Example -//{} +// {} // @End +func main() {} -func main() { +func init() { wrapper.SetCtx( // 插件名称 "jwt-auth", diff --git a/plugins/wasm-go/extensions/key-auth/go.mod b/plugins/wasm-go/extensions/key-auth/go.mod index a9d8c8ea5..e8dcdadee 100644 --- a/plugins/wasm-go/extensions/key-auth/go.mod +++ b/plugins/wasm-go/extensions/key-auth/go.mod @@ -1,20 +1,18 @@ module key-auth -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0-20231017105619-a18879bf867c - github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f - github.com/tidwall/gjson v1.14.4 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/key-auth/go.sum b/plugins/wasm-go/extensions/key-auth/go.sum index c67bf7baf..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/key-auth/go.sum +++ b/plugins/wasm-go/extensions/key-auth/go.sum @@ -1,23 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/key-auth/main.go b/plugins/wasm-go/extensions/key-auth/main.go index 6733e38a7..844ee72ca 100644 --- a/plugins/wasm-go/extensions/key-auth/main.go +++ b/plugins/wasm-go/extensions/key-auth/main.go @@ -20,9 +20,10 @@ import ( "net/http" "net/url" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -31,7 +32,9 @@ var ( protectionSpace = "MSE Gateway" // 认证失败时,返回响应头 WWW-Authenticate: Key realm=MSE Gateway ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "key-auth", // middleware name wrapper.ParseOverrideConfigBy(parseGlobalConfig, parseOverrideRuleConfig), @@ -127,7 +130,7 @@ type KeyAuthConfig struct { credential2Name map[string]string `yaml:"-"` } -func parseGlobalConfig(json gjson.Result, global *KeyAuthConfig, log wrapper.Log) error { +func parseGlobalConfig(json gjson.Result, global *KeyAuthConfig, log log.Log) error { log.Debug("global config") // init @@ -200,7 +203,7 @@ func parseGlobalConfig(json gjson.Result, global *KeyAuthConfig, log wrapper.Log return nil } -func parseOverrideRuleConfig(json gjson.Result, global KeyAuthConfig, config *KeyAuthConfig, log wrapper.Log) error { +func parseOverrideRuleConfig(json gjson.Result, global KeyAuthConfig, config *KeyAuthConfig, log log.Log) error { log.Debug("domain/route config") *config = global @@ -233,7 +236,7 @@ func parseOverrideRuleConfig(json gjson.Result, global KeyAuthConfig, config *Ke // - global_auth 未设置: // - 若没有一个 domain/route 配置该插件:则遵循 (1*) // - 若有至少一个 domain/route 配置该插件:则遵循 (2*) -func onHttpRequestHeaders(ctx wrapper.HttpContext, config KeyAuthConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config KeyAuthConfig, log log.Log) types.Action { var ( noAllow = len(config.allow) == 0 // 未配置 allow 列表,表示插件在该 domain/route 未生效 globalAuthNoSet = config.globalAuth == nil diff --git a/plugins/wasm-go/extensions/log-request-response/go.mod b/plugins/wasm-go/extensions/log-request-response/go.mod index bd98ee492..55fc79658 100644 --- a/plugins/wasm-go/extensions/log-request-response/go.mod +++ b/plugins/wasm-go/extensions/log-request-response/go.mod @@ -1,21 +1,19 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/log-request-response -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/sjson v1.2.5 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/log-request-response/go.sum b/plugins/wasm-go/extensions/log-request-response/go.sum index f76459d11..10f7f623e 100644 --- a/plugins/wasm-go/extensions/log-request-response/go.sum +++ b/plugins/wasm-go/extensions/log-request-response/go.sum @@ -1,23 +1,26 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/log-request-response/main.go b/plugins/wasm-go/extensions/log-request-response/main.go index 4bd218643..d8fca9557 100644 --- a/plugins/wasm-go/extensions/log-request-response/main.go +++ b/plugins/wasm-go/extensions/log-request-response/main.go @@ -4,10 +4,10 @@ import ( "encoding/json" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) @@ -36,7 +36,9 @@ var http2HeaderMap = map[string]string{ ":status": "status", } -func main() { +func main() {} + +func init() { wrapper.SetCtx( // Plugin name pluginName, diff --git a/plugins/wasm-go/extensions/oidc/go.mod b/plugins/wasm-go/extensions/oidc/go.mod index 32a3b5dc6..d68bdc58a 100644 --- a/plugins/wasm-go/extensions/oidc/go.mod +++ b/plugins/wasm-go/extensions/oidc/go.mod @@ -1,35 +1,30 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/oidc -go 1.20 +go 1.24.1 -// toolchain go1.22.5 - -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.6-0.20240531060402-2807ddfbb79e - github.com/higress-group/oauth2-proxy v1.0.1-0.20241227095721-c1a05d79c2a3 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/oauth2-proxy v1.0.1-0.20250702092041-8932d225759a + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/benbjohnson/clock v1.3.5 // indirect github.com/bitly/go-simplejson v0.5.1 // indirect - github.com/go-jose/go-jose/v4 v4.0.1 // indirect + github.com/go-jose/go-jose/v4 v4.1.1 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/mux v1.8.1 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect github.com/justinas/alice v1.2.0 // indirect - github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a // indirect - github.com/ohler55/ojg v1.22.0 // indirect - github.com/spf13/cast v1.6.0 // indirect - github.com/tetratelabs/wazero v1.7.2 // indirect + github.com/ohler55/ojg v1.26.8 // indirect + github.com/spf13/cast v1.9.2 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - github.com/wasilibs/go-re2 v1.6.0 // indirect - golang.org/x/crypto v0.23.0 // indirect - golang.org/x/oauth2 v0.20.0 // indirect - golang.org/x/sys v0.21.0 // indirect + // indirect + golang.org/x/crypto v0.39.0 // indirect + golang.org/x/oauth2 v0.30.0 // indirect + golang.org/x/sys v0.33.0 // indirect ) diff --git a/plugins/wasm-go/extensions/oidc/go.sum b/plugins/wasm-go/extensions/oidc/go.sum index 630debecc..982f5e9ef 100644 --- a/plugins/wasm-go/extensions/oidc/go.sum +++ b/plugins/wasm-go/extensions/oidc/go.sum @@ -3,52 +3,53 @@ github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow= github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= -github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U= -github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/go-jose/go-jose/v4 v4.1.1 h1:JYhSgy4mXXzAdF3nUx3ygx347LRXJRrpgyU3adRmkAI= +github.com/go-jose/go-jose/v4 v4.1.1/go.mod h1:BdsZGqgdO3b6tTc6LSE56wcDbMMLuPsw5d4ZD5f94kA= 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/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/oauth2-proxy v1.0.1-0.20241112053537-6731cf68d467 h1:A/29Au8/Eoys+2oXRWnY2draLKCZ7Yg4gbg2cWi57lE= -github.com/higress-group/oauth2-proxy v1.0.1-0.20241112053537-6731cf68d467/go.mod h1:UOXEF1DEkmLIfVO0p+gP5ceGPuWHI4IKMmQGt8aUTrw= -github.com/higress-group/oauth2-proxy v1.0.1-0.20241227095721-c1a05d79c2a3 h1:wy/whwuL2rJ1BVhysgjGJ3cZ8kPxmX+2YP72fbvVZ9U= -github.com/higress-group/oauth2-proxy v1.0.1-0.20241227095721-c1a05d79c2a3/go.mod h1:UOXEF1DEkmLIfVO0p+gP5ceGPuWHI4IKMmQGt8aUTrw= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= +github.com/higress-group/oauth2-proxy v1.0.1-0.20250702092041-8932d225759a h1:wVUwaQ0AZ4DXlFJtHH/KasIh/AeJEDpwKYgG8VtNK9c= +github.com/higress-group/oauth2-proxy v1.0.1-0.20250702092041-8932d225759a/go.mod h1:sDlsoo4dx+Cx56vI5kegeXZAoQ4nnd7xWL7Oc4/4hLI= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo= github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a h1:tdPcGgyiH0K+SbsJBBm2oPyEIOTAvLBwD9TuUwVtZho= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= -github.com/ohler55/ojg v1.22.0 h1:McZObj3cD/Zz/ojzk5Pi5VvgQcagxmT1bVKNzhE5ihI= -github.com/ohler55/ojg v1.22.0/go.mod h1:gQhDVpQLqrmnd2eqGAvJtn+NfKoYJbe/A4Sj3/Vro4o= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/ohler55/ojg v1.26.8 h1:njM65m+ej8sLHiFZIhJK9UkwOmDPsUikjGbTgcwu8CU= +github.com/ohler55/ojg v1.26.8/go.mod h1:/Y5dGWkekv9ocnUixuETqiL58f+5pAsUfg5P8e7Pa2o= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= -github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= -github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE= +github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/wasilibs/go-re2 v1.6.0 h1:CLlhDebt38wtl/zz4ww+hkXBMcxjrKFvTDXzFW2VOz8= -github.com/wasilibs/go-re2 v1.6.0/go.mod h1:prArCyErsypRBI/jFAFJEbzyHzjABKqkzlidF0SNA04= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= -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/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= +golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= +golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= +golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/oidc/main.go b/plugins/wasm-go/extensions/oidc/main.go index 63510e9a7..456e2246f 100644 --- a/plugins/wasm-go/extensions/oidc/main.go +++ b/plugins/wasm-go/extensions/oidc/main.go @@ -9,14 +9,17 @@ import ( oidc "github.com/higress-group/oauth2-proxy" "github.com/higress-group/oauth2-proxy/pkg/apis/options" "github.com/higress-group/oauth2-proxy/pkg/util" + "github.com/higress-group/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( // 插件名称 "oidc", @@ -35,7 +38,7 @@ type PluginConfig struct { } // 在控制台插件配置中填写的yaml配置会自动转换为json,此处直接从json这个参数里解析配置即可 -func parseConfig(json gjson.Result, config *PluginConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *PluginConfig, log log.Log) error { oidc.SetLogger(log) opts, err := oidc.LoadOptions(json) if err != nil { @@ -55,7 +58,7 @@ func parseConfig(json gjson.Result, config *PluginConfig, log wrapper.Log) error return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { config.oidcHandler.SetContext(ctx) req := getHttpRequest() rw := util.NewRecorder() @@ -77,7 +80,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrap return types.ActionPause } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action { value := ctx.GetContext(oidc.SetCookieHeader) if value != nil { proxywasm.AddHttpResponseHeader(oidc.SetCookieHeader, value.(string)) diff --git a/plugins/wasm-go/extensions/opa/config.go b/plugins/wasm-go/extensions/opa/config.go index fffb1fe85..7ee5d16e9 100644 --- a/plugins/wasm-go/extensions/opa/config.go +++ b/plugins/wasm-go/extensions/opa/config.go @@ -18,7 +18,7 @@ import ( "errors" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) diff --git a/plugins/wasm-go/extensions/opa/config_test.go b/plugins/wasm-go/extensions/opa/config_test.go index 87ab9d2ad..5c6a6a6f7 100644 --- a/plugins/wasm-go/extensions/opa/config_test.go +++ b/plugins/wasm-go/extensions/opa/config_test.go @@ -17,7 +17,7 @@ package main import ( "testing" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" "github.com/stretchr/testify/assert" "github.com/tidwall/gjson" ) @@ -25,7 +25,7 @@ import ( func TestConfig(t *testing.T) { json := gjson.Result{Type: gjson.JSON, Raw: `{"serviceSource": "k8s","serviceName": "opa","servicePort": 8181,"namespace": "example1","policy": "example1","timeout": "5s"}`} config := &OpaConfig{} - assert.NoError(t, parseConfig(json, config, wrapper.Log{})) + assert.NoError(t, parseConfig(json, config, log.Log{})) assert.Equal(t, config.policy, "example1") assert.Equal(t, config.timeout, uint32(5000)) assert.NotNil(t, config.client) @@ -45,6 +45,6 @@ func TestConfig(t *testing.T) { for _, test := range tests { json = gjson.Result{Type: gjson.JSON, Raw: test.raw} - assert.Equal(t, parseConfig(json, config, wrapper.Log{}) == nil, test.result) + assert.Equal(t, parseConfig(json, config, log.Log{}) == nil, test.result) } } diff --git a/plugins/wasm-go/extensions/opa/go.mod b/plugins/wasm-go/extensions/opa/go.mod index eb94affd3..343560f27 100644 --- a/plugins/wasm-go/extensions/opa/go.mod +++ b/plugins/wasm-go/extensions/opa/go.mod @@ -1,24 +1,22 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/opa -go 1.19 +go 1.24.1 + +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.5.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/alibaba/higress/plugins/wasm-go => ../.. diff --git a/plugins/wasm-go/extensions/opa/go.sum b/plugins/wasm-go/extensions/opa/go.sum index 5ea348905..a8ff03319 100644 --- a/plugins/wasm-go/extensions/opa/go.sum +++ b/plugins/wasm-go/extensions/opa/go.sum @@ -1,28 +1,22 @@ 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/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/plugins/wasm-go/extensions/opa/main.go b/plugins/wasm-go/extensions/opa/main.go index 94b5ceb2e..3c816d2b8 100644 --- a/plugins/wasm-go/extensions/opa/main.go +++ b/plugins/wasm-go/extensions/opa/main.go @@ -23,13 +23,16 @@ import ( "strings" "time" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "opa", wrapper.ParseConfigBy(parseConfig), @@ -42,7 +45,7 @@ type Metadata struct { Input map[string]interface{} `json:"input"` } -func parseConfig(json gjson.Result, config *OpaConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *OpaConfig, log log.Log) error { policy := json.Get("policy").String() if strings.TrimSpace(policy) == "" { return errors.New("policy not allow empty") @@ -76,15 +79,15 @@ func parseConfig(json gjson.Result, config *OpaConfig, log wrapper.Log) error { return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config OpaConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config OpaConfig, log log.Log) types.Action { return opaCall(ctx, config, nil, log) } -func onHttpRequestBody(ctx wrapper.HttpContext, config OpaConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config OpaConfig, body []byte, log log.Log) types.Action { return opaCall(ctx, config, body, log) } -func opaCall(ctx wrapper.HttpContext, config OpaConfig, body []byte, log wrapper.Log) types.Action { +func opaCall(ctx wrapper.HttpContext, config OpaConfig, body []byte, log log.Log) types.Action { request := make(map[string]interface{}, 6) headers, _ := proxywasm.GetHttpRequestHeaders() diff --git a/plugins/wasm-go/extensions/replay-protection/config/config.go b/plugins/wasm-go/extensions/replay-protection/config/config.go index b2adabfd8..8f88f41ef 100644 --- a/plugins/wasm-go/extensions/replay-protection/config/config.go +++ b/plugins/wasm-go/extensions/replay-protection/config/config.go @@ -4,7 +4,8 @@ import ( "fmt" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -25,7 +26,7 @@ type RedisConfig struct { KeyPrefix string } -func ParseConfig(json gjson.Result, config *ReplayProtectionConfig, log wrapper.Log) error { +func ParseConfig(json gjson.Result, config *ReplayProtectionConfig, log log.Log) error { // Parse Redis configuration redisConfig := json.Get("redis") if !redisConfig.Exists() { diff --git a/plugins/wasm-go/extensions/replay-protection/go.mod b/plugins/wasm-go/extensions/replay-protection/go.mod index ef3d9742d..d616e6a91 100644 --- a/plugins/wasm-go/extensions/replay-protection/go.mod +++ b/plugins/wasm-go/extensions/replay-protection/go.mod @@ -1,22 +1,18 @@ module replay-protection -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.2 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 github.com/tidwall/gjson v1.18.0 github.com/tidwall/resp v0.1.1 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/tetratelabs/wazero v1.7.1 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect - github.com/wasilibs/go-re2 v1.5.3 // indirect + github.com/tidwall/pretty v1.2.1 // indirect ) diff --git a/plugins/wasm-go/extensions/replay-protection/go.sum b/plugins/wasm-go/extensions/replay-protection/go.sum index 649b2d8b5..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/replay-protection/go.sum +++ b/plugins/wasm-go/extensions/replay-protection/go.sum @@ -1,24 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tetratelabs/wazero v1.7.1 h1:QtSfd6KLc41DIMpDYlJdoMc6k7QTN246DM2+n2Y/Dx8= -github.com/tetratelabs/wazero v1.7.1/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/wasilibs/go-re2 v1.5.3 h1:wiuTcgDZdLhu8NG8oqF5sF5Q3yIU14lPAvXqeYzDK3g= -github.com/wasilibs/go-re2 v1.5.3/go.mod h1:PzpVPsBdFC7vM8QJbbEnOeTmwA0DGE783d/Gex8eCV8= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/replay-protection/main.go b/plugins/wasm-go/extensions/replay-protection/main.go index 25a1a3075..42c3f5153 100644 --- a/plugins/wasm-go/extensions/replay-protection/main.go +++ b/plugins/wasm-go/extensions/replay-protection/main.go @@ -3,15 +3,19 @@ package main import ( "fmt" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" - "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" - "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" - "github.com/tidwall/resp" "replay-protection/config" "replay-protection/util" + + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" + "github.com/tidwall/resp" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "replay-protection", wrapper.ParseConfigBy(config.ParseConfig), @@ -19,7 +23,7 @@ func main() { ) } -func onHttpRequestHeaders(ctx wrapper.HttpContext, cfg config.ReplayProtectionConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, cfg config.ReplayProtectionConfig, log log.Log) types.Action { nonce, _ := proxywasm.GetHttpRequestHeader(cfg.NonceHeader) if cfg.ForceNonce && nonce == "" { // In force mode, reject the request if a required header is missing. diff --git a/plugins/wasm-go/extensions/replay-protection/util/utils.go b/plugins/wasm-go/extensions/replay-protection/util/utils.go index 66f39d597..5c4ac80c6 100644 --- a/plugins/wasm-go/extensions/replay-protection/util/utils.go +++ b/plugins/wasm-go/extensions/replay-protection/util/utils.go @@ -1,6 +1,6 @@ package util -import re "github.com/wasilibs/go-re2" +import re "regexp" // IsValidBase64 checks if a string is a valid base64 encoded string func IsValidBase64(s string) bool { diff --git a/plugins/wasm-go/extensions/request-block/go.mod b/plugins/wasm-go/extensions/request-block/go.mod index e0100ea3b..9419d6f77 100644 --- a/plugins/wasm-go/extensions/request-block/go.mod +++ b/plugins/wasm-go/extensions/request-block/go.mod @@ -1,23 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/request-block -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 - github.com/wasilibs/go-re2 v1.6.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a // indirect - github.com/tetratelabs/wazero v1.7.2 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - golang.org/x/sys v0.21.0 // indirect ) diff --git a/plugins/wasm-go/extensions/request-block/go.sum b/plugins/wasm-go/extensions/request-block/go.sum index fbb4e15de..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/request-block/go.sum +++ b/plugins/wasm-go/extensions/request-block/go.sum @@ -1,29 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a h1:tdPcGgyiH0K+SbsJBBm2oPyEIOTAvLBwD9TuUwVtZho= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= -github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/wasilibs/go-re2 v1.6.0 h1:CLlhDebt38wtl/zz4ww+hkXBMcxjrKFvTDXzFW2VOz8= -github.com/wasilibs/go-re2 v1.6.0/go.mod h1:prArCyErsypRBI/jFAFJEbzyHzjABKqkzlidF0SNA04= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/request-block/main.go b/plugins/wasm-go/extensions/request-block/main.go index 2a43b4df7..0612d0421 100644 --- a/plugins/wasm-go/extensions/request-block/main.go +++ b/plugins/wasm-go/extensions/request-block/main.go @@ -19,15 +19,19 @@ import ( "fmt" "strings" + "regexp" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" "github.com/tidwall/gjson" - regexp "github.com/wasilibs/go-re2" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "request-block", wrapper.ParseConfigBy(parseConfig), @@ -47,7 +51,7 @@ type RequestBlockConfig struct { blockRegExpArray []*regexp.Regexp } -func parseConfig(json gjson.Result, config *RequestBlockConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *RequestBlockConfig, log log.Log) error { code := json.Get("blocked_code").Int() if code != 0 && code > 100 && code < 600 { config.blockedCode = uint32(code) @@ -120,7 +124,7 @@ func parseConfig(json gjson.Result, config *RequestBlockConfig, log wrapper.Log) return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config RequestBlockConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config RequestBlockConfig, log log.Log) types.Action { if len(config.blockUrls) > 0 { requestUrl, err := proxywasm.GetHttpRequestHeader(":path") if err != nil { @@ -176,7 +180,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config RequestBlockConfig, lo return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config RequestBlockConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config RequestBlockConfig, body []byte, log log.Log) types.Action { log.Infof("My request-block body: %s\n", string(body)) bodyStr := string(body) diff --git a/plugins/wasm-go/extensions/request-validation/go.mod b/plugins/wasm-go/extensions/request-validation/go.mod index 298380934..a1fcc3d93 100644 --- a/plugins/wasm-go/extensions/request-validation/go.mod +++ b/plugins/wasm-go/extensions/request-validation/go.mod @@ -1,21 +1,19 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/request-validation -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.1 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 github.com/santhosh-tekuri/jsonschema v1.2.4 - github.com/tidwall/gjson v1.17.3 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/request-validation/go.sum b/plugins/wasm-go/extensions/request-validation/go.sum index 966b2567a..a7b19e313 100644 --- a/plugins/wasm-go/extensions/request-validation/go.sum +++ b/plugins/wasm-go/extensions/request-validation/go.sum @@ -1,27 +1,25 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226065437-8f7a0b3c9071 h1:STb5rOHRZOzoiAa+gTz2LFqO1nYj7U/1eIVUJJadU4A= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226065437-8f7a0b3c9071/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis= github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= -github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/request-validation/main.go b/plugins/wasm-go/extensions/request-validation/main.go index 214711878..329d82388 100644 --- a/plugins/wasm-go/extensions/request-validation/main.go +++ b/plugins/wasm-go/extensions/request-validation/main.go @@ -19,9 +19,10 @@ import ( "fmt" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/santhosh-tekuri/jsonschema" "github.com/tidwall/gjson" ) @@ -32,7 +33,9 @@ const ( defaultRejectedCode = 403 ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "request-validation", wrapper.ProcessRequestHeadersBy(onHttpRequestHeaders), @@ -57,7 +60,7 @@ type Config struct { enableHeaderSchema bool } -func parseConfig(result gjson.Result, config *Config, log wrapper.Log) error { +func parseConfig(result gjson.Result, config *Config, log log.Log) error { headerSchema := result.Get("header_schema").String() bodySchema := result.Get("body_schema").String() enableSwagger := result.Get("enable_swagger").Bool() @@ -119,7 +122,7 @@ func parseConfig(result gjson.Result, config *Config, log wrapper.Log) error { return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log log.Log) types.Action { if !config.enableHeaderSchema { return types.ActionContinue } @@ -161,7 +164,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Lo return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config Config, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config Config, body []byte, log log.Log) types.Action { if !config.enableBodySchema { return types.ActionContinue } diff --git a/plugins/wasm-go/extensions/simple-jwt-auth/go.mod b/plugins/wasm-go/extensions/simple-jwt-auth/go.mod index 24e498a2a..931c8b8d4 100644 --- a/plugins/wasm-go/extensions/simple-jwt-auth/go.mod +++ b/plugins/wasm-go/extensions/simple-jwt-auth/go.mod @@ -1,21 +1,19 @@ module jwt-auth -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0-20230811015533-49269b43032f github.com/dgrijalva/jwt-go v3.2.0+incompatible - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/simple-jwt-auth/go.sum b/plugins/wasm-go/extensions/simple-jwt-auth/go.sum index 056a8d5e7..acfddbd81 100644 --- a/plugins/wasm-go/extensions/simple-jwt-auth/go.sum +++ b/plugins/wasm-go/extensions/simple-jwt-auth/go.sum @@ -1,27 +1,25 @@ 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/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg= -github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/simple-jwt-auth/main.go b/plugins/wasm-go/extensions/simple-jwt-auth/main.go index 6ac63e763..a8d386c89 100644 --- a/plugins/wasm-go/extensions/simple-jwt-auth/main.go +++ b/plugins/wasm-go/extensions/simple-jwt-auth/main.go @@ -4,16 +4,18 @@ import ( "encoding/json" "net/http" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" jwt "github.com/dgrijalva/jwt-go" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) // 自定义插件配置 +func main() {} -func main() { +func init() { wrapper.SetCtx( "simple-jwt-auth", // 配置插件名称 wrapper.ParseConfigBy(parseConfig), @@ -31,14 +33,14 @@ type Res struct { Msg string `json:"msg"` // 返回信息 } -func parseConfig(json gjson.Result, config *Config, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *Config, log log.Log) error { // 解析出配置,更新到config中 config.TokenSecretKey = json.Get("token_secret_key").String() config.TokenHeaders = json.Get("token_headers").String() return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log log.Log) types.Action { var res Res if config.TokenHeaders == "" || config.TokenSecretKey == "" { res.Code = http.StatusBadRequest diff --git a/plugins/wasm-go/extensions/sni-misdirect/go.mod b/plugins/wasm-go/extensions/sni-misdirect/go.mod index 6c4e855aa..e8513e64e 100644 --- a/plugins/wasm-go/extensions/sni-misdirect/go.mod +++ b/plugins/wasm-go/extensions/sni-misdirect/go.mod @@ -1,20 +1,18 @@ module wasm_go/higress/plugins/wasm-go/extensions/sni_misdirect -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.3.1 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/tidwall/gjson v1.17.3 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/sni-misdirect/go.sum b/plugins/wasm-go/extensions/sni-misdirect/go.sum index f0206f83d..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/sni-misdirect/go.sum +++ b/plugins/wasm-go/extensions/sni-misdirect/go.sum @@ -1,25 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/sni-misdirect/main.go b/plugins/wasm-go/extensions/sni-misdirect/main.go index 70a4244a8..9ebb13b57 100644 --- a/plugins/wasm-go/extensions/sni-misdirect/main.go +++ b/plugins/wasm-go/extensions/sni-misdirect/main.go @@ -4,12 +4,15 @@ import ( "net/http" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "sni-misdirect", wrapper.ProcessRequestHeadersBy(onHttpRequestHeaders), @@ -19,7 +22,7 @@ func main() { type Config struct { } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log log.Log) types.Action { // no need to check HTTP/1.0 and HTTP/1.1 protocol, err := proxywasm.GetProperty([]string{"request", "protocol"}) if err != nil { diff --git a/plugins/wasm-go/extensions/streaming-body-example/go.mod b/plugins/wasm-go/extensions/streaming-body-example/go.mod index f4fa40908..cd30b2cad 100644 --- a/plugins/wasm-go/extensions/streaming-body-example/go.mod +++ b/plugins/wasm-go/extensions/streaming-body-example/go.mod @@ -1,20 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/streaming-body-example -go 1.18 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect - github.com/tidwall/gjson v1.17.3 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect ) diff --git a/plugins/wasm-go/extensions/streaming-body-example/go.sum b/plugins/wasm-go/extensions/streaming-body-example/go.sum index f0206f83d..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/streaming-body-example/go.sum +++ b/plugins/wasm-go/extensions/streaming-body-example/go.sum @@ -1,25 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a h1:luYRvxLTE1xYxrXYj7nmjd1U0HHh8pUPiKfdZ0MhCGE= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240226064518-b3dc4646a35a/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/streaming-body-example/main.go b/plugins/wasm-go/extensions/streaming-body-example/main.go index 7a3a8301d..cafe1c760 100644 --- a/plugins/wasm-go/extensions/streaming-body-example/main.go +++ b/plugins/wasm-go/extensions/streaming-body-example/main.go @@ -17,11 +17,14 @@ package main import ( "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "streaming-body-example", wrapper.ProcessRequestHeadersBy(onHttpRequestHeaders), @@ -34,22 +37,22 @@ func main() { type Config struct { } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log log.Log) types.Action { proxywasm.RemoveHttpRequestHeader("content-length") return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config Config, chunk []byte, isLastChunk bool, log wrapper.Log) []byte { +func onHttpRequestBody(ctx wrapper.HttpContext, config Config, chunk []byte, isLastChunk bool, log log.Log) []byte { log.Infof("receive request body chunk:%s, isLastChunk:%v", chunk, isLastChunk) return []byte("test\n") } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config Config, log log.Log) types.Action { proxywasm.RemoveHttpResponseHeader("content-length") return types.ActionContinue } -func onHttpResponseBody(ctx wrapper.HttpContext, config Config, chunk []byte, isLastChunk bool, log wrapper.Log) []byte { +func onHttpResponseBody(ctx wrapper.HttpContext, config Config, chunk []byte, isLastChunk bool, log log.Log) []byte { log.Infof("receive response body chunk:%s, isLastChunk:%v", chunk, isLastChunk) return []byte("test\n") } diff --git a/plugins/wasm-go/extensions/traffic-tag/content.go b/plugins/wasm-go/extensions/traffic-tag/content.go index 4d62c02c9..44db6adfb 100644 --- a/plugins/wasm-go/extensions/traffic-tag/content.go +++ b/plugins/wasm-go/extensions/traffic-tag/content.go @@ -21,11 +21,11 @@ import ( "strconv" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" + "github.com/higress-group/wasm-go/pkg/log" ) -func onContentRequestHeaders(conditionGroups []ConditionGroup, log wrapper.Log) bool { +func onContentRequestHeaders(conditionGroups []ConditionGroup, log log.Log) bool { for _, cg := range conditionGroups { if matchCondition(&cg, log) { addTagHeader(cg.HeaderName, cg.HeaderValue, log) @@ -37,7 +37,7 @@ func onContentRequestHeaders(conditionGroups []ConditionGroup, log wrapper.Log) } // matchCondition matches the single condition group -func matchCondition(conditionGroup *ConditionGroup, log wrapper.Log) bool { +func matchCondition(conditionGroup *ConditionGroup, log log.Log) bool { for _, condition := range conditionGroup.Conditions { conditionKeyValue, err := getConditionValue(condition, log) if err != nil { @@ -143,7 +143,7 @@ func matchCondition(conditionGroup *ConditionGroup, log wrapper.Log) bool { return len(conditionGroup.Conditions) > 0 && conditionGroup.Logic == "and" // all conditions are matched } -func getConditionValue(condition ConditionRule, log wrapper.Log) (string, error) { +func getConditionValue(condition ConditionRule, log log.Log) (string, error) { // log.Debugf("conditionType: %s, key: %s", condition.ConditionType, condition.Key) switch condition.ConditionType { diff --git a/plugins/wasm-go/extensions/traffic-tag/go.mod b/plugins/wasm-go/extensions/traffic-tag/go.mod index fd3da1aa0..1436bff3a 100644 --- a/plugins/wasm-go/extensions/traffic-tag/go.mod +++ b/plugins/wasm-go/extensions/traffic-tag/go.mod @@ -1,24 +1,18 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/traffic-tag -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.1-0.20240612065146-12cc44b3247f - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 - github.com/wasilibs/go-re2 v1.6.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) require ( - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a // indirect - github.com/stretchr/testify v1.9.0 // indirect - github.com/tetratelabs/wazero v1.7.2 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - golang.org/x/sys v0.21.0 // indirect ) diff --git a/plugins/wasm-go/extensions/traffic-tag/go.sum b/plugins/wasm-go/extensions/traffic-tag/go.sum index 8ad4e67af..bc44cf8f0 100644 --- a/plugins/wasm-go/extensions/traffic-tag/go.sum +++ b/plugins/wasm-go/extensions/traffic-tag/go.sum @@ -1,30 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a h1:tdPcGgyiH0K+SbsJBBm2oPyEIOTAvLBwD9TuUwVtZho= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/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/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= -github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= -github.com/wasilibs/go-re2 v1.6.0 h1:CLlhDebt38wtl/zz4ww+hkXBMcxjrKFvTDXzFW2VOz8= -github.com/wasilibs/go-re2 v1.6.0/go.mod h1:prArCyErsypRBI/jFAFJEbzyHzjABKqkzlidF0SNA04= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/traffic-tag/main.go b/plugins/wasm-go/extensions/traffic-tag/main.go index 0e58f9508..5c300550b 100644 --- a/plugins/wasm-go/extensions/traffic-tag/main.go +++ b/plugins/wasm-go/extensions/traffic-tag/main.go @@ -18,8 +18,9 @@ import ( "math/rand" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -84,7 +85,9 @@ type WeightGroup struct { Accumulate int64 } -func main() { +func main() {} + +func init() { wrapper.SetCtx( PluginName, wrapper.ParseConfigBy(parseConfig), @@ -92,7 +95,7 @@ func main() { ) } -func parseConfig(json gjson.Result, config *TrafficTagConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *TrafficTagConfig, log log.Log) error { jsonStr := strings.TrimSpace(json.Raw) if jsonStr == "{}" || jsonStr == "" { @@ -108,7 +111,7 @@ func parseConfig(json gjson.Result, config *TrafficTagConfig, log wrapper.Log) e return parseWeightConfig(json, config, log) } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config TrafficTagConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config TrafficTagConfig, log log.Log) types.Action { add := false if len(config.ConditionGroups) != 0 { diff --git a/plugins/wasm-go/extensions/traffic-tag/parse.go b/plugins/wasm-go/extensions/traffic-tag/parse.go index c41890c1a..632161610 100644 --- a/plugins/wasm-go/extensions/traffic-tag/parse.go +++ b/plugins/wasm-go/extensions/traffic-tag/parse.go @@ -20,16 +20,17 @@ import ( "strconv" "strings" - "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" - regexp "github.com/wasilibs/go-re2" + "regexp" + + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" + "github.com/higress-group/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) var regexCache = map[string]*regexp.Regexp{} -func parseContentConfig(json gjson.Result, config *TrafficTagConfig, log wrapper.Log) error { +func parseContentConfig(json gjson.Result, config *TrafficTagConfig, log log.Log) error { var parseError error config.ConditionGroups = []ConditionGroup{} @@ -79,7 +80,7 @@ func parseContentConfig(json gjson.Result, config *TrafficTagConfig, log wrapper return parseError } -func parseWeightConfig(json gjson.Result, config *TrafficTagConfig, log wrapper.Log) error { +func parseWeightConfig(json gjson.Result, config *TrafficTagConfig, log log.Log) error { var parseError error var accumulatedWeight int64 config.WeightGroups = []WeightGroup{} diff --git a/plugins/wasm-go/extensions/traffic-tag/utils.go b/plugins/wasm-go/extensions/traffic-tag/utils.go index dd33efae8..3d85580d3 100644 --- a/plugins/wasm-go/extensions/traffic-tag/utils.go +++ b/plugins/wasm-go/extensions/traffic-tag/utils.go @@ -19,11 +19,11 @@ import ( "net/url" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" + "github.com/higress-group/wasm-go/pkg/log" ) -func setDefaultTag(k string, v string, log wrapper.Log) { +func setDefaultTag(k string, v string, log log.Log) { if k == "" || v == "" { return } @@ -61,7 +61,7 @@ func getQueryParameter(urlStr, paramKey string) (string, error) { return values[0], nil } -func addTagHeader(key string, value string, log wrapper.Log) { +func addTagHeader(key string, value string, log log.Log) { existValue, _ := proxywasm.GetHttpRequestHeader(key) if existValue != "" { log.Infof("ADD HEADER failed: %s already exists, value: %s", key, existValue) diff --git a/plugins/wasm-go/extensions/traffic-tag/weight.go b/plugins/wasm-go/extensions/traffic-tag/weight.go index f825f1ec7..d3366bf67 100644 --- a/plugins/wasm-go/extensions/traffic-tag/weight.go +++ b/plugins/wasm-go/extensions/traffic-tag/weight.go @@ -14,11 +14,9 @@ package main -import ( - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" -) +import "github.com/higress-group/wasm-go/pkg/log" -func onWeightRequestHeaders(weightGroups []WeightGroup, randomNum uint64, log wrapper.Log) bool { +func onWeightRequestHeaders(weightGroups []WeightGroup, randomNum uint64, log log.Log) bool { randomValue := randomNum % TotalWeight log.Debugf("random value for weighted headers : %d", randomValue) // CDF diff --git a/plugins/wasm-go/extensions/transformer/go.mod b/plugins/wasm-go/extensions/transformer/go.mod index 5ef3cd4f6..0c9da74c5 100644 --- a/plugins/wasm-go/extensions/transformer/go.mod +++ b/plugins/wasm-go/extensions/transformer/go.mod @@ -1,29 +1,24 @@ module github.com/alibaba/higress/plugins/wasm-go/extensions/transformer -go 1.19 +go 1.24.1 -replace github.com/alibaba/higress/plugins/wasm-go => ../.. +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0-20230829022308-8747e1ddadf0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.17.3 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/pretty v1.2.1 github.com/tidwall/sjson v1.2.5 - github.com/wasilibs/go-re2 v1.6.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a // indirect + github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/tetratelabs/wazero v1.7.2 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/resp v0.1.1 // indirect - golang.org/x/sys v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/extensions/transformer/go.sum b/plugins/wasm-go/extensions/transformer/go.sum index 51a239987..f88a953d9 100644 --- a/plugins/wasm-go/extensions/transformer/go.sum +++ b/plugins/wasm-go/extensions/transformer/go.sum @@ -1,26 +1,20 @@ 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f h1:ZIiIBRvIw62gA5MJhuwp1+2wWbqL9IGElQ499rUsYYg= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a h1:tdPcGgyiH0K+SbsJBBm2oPyEIOTAvLBwD9TuUwVtZho= -github.com/magefile/mage v1.15.1-0.20230912152418-9f54e0f83e2a/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= -github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= +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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= -github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -30,11 +24,6 @@ github.com/tidwall/resp v0.1.1 h1:Ly20wkhqKTmDUPlyM1S7pWo5kk0tDu8OoC/vFArXmwE= github.com/tidwall/resp v0.1.1/go.mod h1:3/FrruOBAxPTPtundW0VXgmsQ4ZBA0Aw714lVYgwFa0= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/wasilibs/go-re2 v1.6.0 h1:CLlhDebt38wtl/zz4ww+hkXBMcxjrKFvTDXzFW2VOz8= -github.com/wasilibs/go-re2 v1.6.0/go.mod h1:prArCyErsypRBI/jFAFJEbzyHzjABKqkzlidF0SNA04= -github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/plugins/wasm-go/extensions/transformer/main.go b/plugins/wasm-go/extensions/transformer/main.go index c8fb2a9d8..0d14310bf 100644 --- a/plugins/wasm-go/extensions/transformer/main.go +++ b/plugins/wasm-go/extensions/transformer/main.go @@ -17,17 +17,21 @@ package main import ( "strings" + "regexp" + "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" "github.com/pkg/errors" "github.com/tidwall/gjson" "github.com/tidwall/sjson" - regexp "github.com/wasilibs/go-re2" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" + "github.com/higress-group/wasm-go/pkg/wrapper" ) -func main() { +func main() {} + +func init() { wrapper.SetCtx( "transformer", wrapper.ParseConfigBy(parseConfig), @@ -214,7 +218,7 @@ type Param struct { pathPattern string `yaml:"path_pattern"` } -func parseConfig(json gjson.Result, config *TransformerConfig, log wrapper.Log) (err error) { +func parseConfig(json gjson.Result, config *TransformerConfig, log log.Log) (err error) { reqRulesInJson := json.Get("reqRules") respRulesInJson := json.Get("respRules") @@ -284,7 +288,7 @@ func constructParam(item gjson.Result, op, valueType string) Param { return p } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config TransformerConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config TransformerConfig, log log.Log) types.Action { // because it may be a response transformer, so the setting of host and path have to advance host, path := ctx.Host(), ctx.Path() ctx.SetContext("host", host) @@ -393,7 +397,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config TransformerConfig, log return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config TransformerConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config TransformerConfig, body []byte, log log.Log) types.Action { if config.reqTrans == nil { return types.ActionContinue } @@ -514,7 +518,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config TransformerConfig, body [ return types.ActionContinue } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config TransformerConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config TransformerConfig, log log.Log) types.Action { if config.respTrans == nil { ctx.DontReadResponseBody() return types.ActionContinue @@ -582,7 +586,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, config TransformerConfig, lo return types.ActionContinue } -func onHttpResponseBody(ctx wrapper.HttpContext, config TransformerConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config TransformerConfig, body []byte, log log.Log) types.Action { if config.respTrans == nil { return types.ActionContinue } diff --git a/plugins/wasm-go/extensions/waf/go.mod b/plugins/wasm-go/extensions/waf/go.mod index 65344447c..6277355b2 100644 --- a/plugins/wasm-go/extensions/waf/go.mod +++ b/plugins/wasm-go/extensions/waf/go.mod @@ -1,30 +1,31 @@ module github.com/corazawaf/coraza-proxy-wasm -go 1.19 +go 1.24.1 + +toolchain go1.24.4 require ( - github.com/alibaba/higress/plugins/wasm-go v0.0.0 github.com/corazawaf/coraza-wasilibs v0.0.0-20230408002644-e2e3af21f503 github.com/corazawaf/coraza/v3 v3.0.0-rc.1.0.20230407165813-a18681b1ec28 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/tidwall/gjson v1.17.3 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 + github.com/tidwall/gjson v1.18.0 ) +require github.com/wasilibs/go-re2 v1.0.0 // indirect + require ( github.com/corazawaf/libinjection-go v0.1.2 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/magefile/mage v1.14.0 // indirect github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9 // indirect - github.com/tetratelabs/wazero v1.6.0 // indirect + github.com/tetratelabs/wazero v1.7.2 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/resp v0.1.1 // indirect github.com/wasilibs/go-aho-corasick v0.3.0 // indirect github.com/wasilibs/go-libinjection v0.2.1 // indirect - github.com/wasilibs/go-re2 v1.0.0 // indirect + // indirect golang.org/x/net v0.9.0 // indirect rsc.io/binaryregexp v0.2.0 // indirect ) - -replace github.com/alibaba/higress/plugins/wasm-go => ../.. diff --git a/plugins/wasm-go/extensions/waf/go.sum b/plugins/wasm-go/extensions/waf/go.sum index d58e0ca68..522659064 100644 --- a/plugins/wasm-go/extensions/waf/go.sum +++ b/plugins/wasm-go/extensions/waf/go.sum @@ -5,28 +5,29 @@ github.com/corazawaf/coraza/v3 v3.0.0-rc.1.0.20230407165813-a18681b1ec28/go.mod github.com/corazawaf/libinjection-go v0.1.2 h1:oeiV9pc5rvJ+2oqOqXEAMJousPpGiup6f7Y3nZj5GoM= github.com/corazawaf/libinjection-go v0.1.2/go.mod h1:OP4TM7xdJ2skyXqNX1AN1wN5nNZEmJNuWbNPOItn7aw= 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/foxcpp/go-mockdns v1.0.0 h1:7jBqxd3WDWwi/6WhDvacvH1XsN3rOLXyHM1uhvIx6FI= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43 h1:dCw7F/9ciw4NZN7w68wQRaygZ2zGOWMTIEoRvP1tlWs= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240318034951-d5306e367c43/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240327114451-d6b7174a84fc/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20240711023527-ba358c48772f/go.mod h1:hNFjhrLUIq+kJ9bOcs8QtiplSQ61GZXtd2xHKx4BYRo= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= +github.com/foxcpp/go-mockdns v1.0.0/go.mod h1:lgRN6+KxQBawyIghpnl5CezHFGS9VLzvtVlwxvzXTQ4= +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/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= +github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9 h1:lL+y4Xv20pVlCGyLzNHRC0I0rIHhIL1lTvHizoS/dU8= github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9/go.mod h1:EHPiTAKtiFmrMldLUNswFwfZ2eJIYBHktdaUTZxYWRw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/tetratelabs/wazero v1.6.0 h1:z0H1iikCdP8t+q341xqepY4EWvHEw8Es7tlqiVzlP3g= -github.com/tetratelabs/wazero v1.6.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc= +github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -41,11 +42,16 @@ github.com/wasilibs/go-libinjection v0.2.1/go.mod h1:ZUoVe+HLQYq+QPBNTSgg3fxGvZs github.com/wasilibs/go-re2 v1.0.0 h1:pvrqtMzZgTMHVPfXJrk4YZwiqIXOKdfo5aed6CzUAW4= github.com/wasilibs/go-re2 v1.0.0/go.mod h1:8g69JapfgjSCx49dKOQij1dqA3sOvoH5NteaUy1X0SA= github.com/wasilibs/nottinygc v0.2.0 h1:cXz2Ac9bVMLkpuOlUlPQMWowjw0K2cOErXZOFdAj7yE= +github.com/wasilibs/nottinygc v0.2.0/go.mod h1:oDcIotskuYNMpqMF23l7Z8uzD4TC0WXHK8jetlB3HIo= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/plugins/wasm-go/extensions/waf/magefiles/go.mod b/plugins/wasm-go/extensions/waf/magefiles/go.mod index 8fe61db7b..d69490f12 100644 --- a/plugins/wasm-go/extensions/waf/magefiles/go.mod +++ b/plugins/wasm-go/extensions/waf/magefiles/go.mod @@ -1,6 +1,6 @@ module github.com/corazawaf/coraza-proxy-wasm/magefiles -go 1.19 +go 1.24 require ( github.com/magefile/mage v1.14.0 diff --git a/plugins/wasm-go/extensions/waf/magefiles/go.sum b/plugins/wasm-go/extensions/waf/magefiles/go.sum index 6f53f64cd..694a4737f 100644 --- a/plugins/wasm-go/extensions/waf/magefiles/go.sum +++ b/plugins/wasm-go/extensions/waf/magefiles/go.sum @@ -1,8 +1,12 @@ 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/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/tetratelabs/wabin v0.0.0-20220927005300-3b0fbf39a46a h1:P0R3+CTAT7daT8ig5gh9GEd/eDQ5md1xl4pkYMcwOqg= github.com/tetratelabs/wabin v0.0.0-20220927005300-3b0fbf39a46a/go.mod h1:m9ymHTgNSEjuxvw8E7WWe4Pl4hZQHXONY8wE6dMLaRk= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/wasm-go/extensions/waf/main.go b/plugins/wasm-go/extensions/waf/main.go index 092769078..9f1eecce8 100644 --- a/plugins/wasm-go/extensions/waf/main.go +++ b/plugins/wasm-go/extensions/waf/main.go @@ -5,7 +5,9 @@ import ( wasilibs "github.com/corazawaf/coraza-wasilibs" ) -func main() { +func main() {} + +func init() { wasilibs.RegisterRX() wasilibs.RegisterPM() wasilibs.RegisterSQLi() diff --git a/plugins/wasm-go/extensions/waf/wasmplugin/plugin.go b/plugins/wasm-go/extensions/waf/wasmplugin/plugin.go index f4beb38b0..ef4c960ac 100644 --- a/plugins/wasm-go/extensions/waf/wasmplugin/plugin.go +++ b/plugins/wasm-go/extensions/waf/wasmplugin/plugin.go @@ -5,12 +5,13 @@ import ( "strconv" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/corazawaf/coraza/v3" "github.com/corazawaf/coraza/v3/debuglog" ctypes "github.com/corazawaf/coraza/v3/types" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" ) @@ -31,7 +32,7 @@ type WafConfig struct { //tx ctypes.Transaction } -func parseConfig(json gjson.Result, config *WafConfig, log wrapper.Log) error { +func parseConfig(json gjson.Result, config *WafConfig, log log.Log) error { var secRules []string var value gjson.Result value = json.Get("useCRS") @@ -68,7 +69,7 @@ func parseConfig(json gjson.Result, config *WafConfig, log wrapper.Log) error { return nil } -func onHttpRequestHeaders(ctx wrapper.HttpContext, config WafConfig, log wrapper.Log) types.Action { +func onHttpRequestHeaders(ctx wrapper.HttpContext, config WafConfig, log log.Log) types.Action { ctx.SetContext("skipwaf", false) if ignoreBody() { @@ -148,7 +149,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config WafConfig, log wrapper return types.ActionContinue } -func onHttpRequestBody(ctx wrapper.HttpContext, config WafConfig, body []byte, log wrapper.Log) types.Action { +func onHttpRequestBody(ctx wrapper.HttpContext, config WafConfig, body []byte, log log.Log) types.Action { if ctx.GetContext("interruptionHandled").(bool) { return types.ActionContinue } @@ -200,7 +201,7 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config WafConfig, body []byte, l return types.ActionContinue } -func onHttpResponseHeaders(ctx wrapper.HttpContext, config WafConfig, log wrapper.Log) types.Action { +func onHttpResponseHeaders(ctx wrapper.HttpContext, config WafConfig, log log.Log) types.Action { if ctx.GetContext("skipwaf").(bool) { return types.ActionContinue } @@ -257,7 +258,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, config WafConfig, log wrappe return types.ActionContinue } -func onHttpResponseBody(ctx wrapper.HttpContext, config WafConfig, body []byte, log wrapper.Log) types.Action { +func onHttpResponseBody(ctx wrapper.HttpContext, config WafConfig, body []byte, log log.Log) types.Action { if ctx.GetContext("interruptionHandled").(bool) { // At response body phase, proxy-wasm currently relies on emptying the response body as a way of // interruption the response. See https://github.com/corazawaf/coraza-proxy-wasm/issues/26. @@ -318,7 +319,7 @@ func onHttpResponseBody(ctx wrapper.HttpContext, config WafConfig, body []byte, return types.ActionContinue } -func onHttpStreamDone(ctx wrapper.HttpContext, config WafConfig, log wrapper.Log) { +func onHttpStreamDone(ctx wrapper.HttpContext, config WafConfig, log log.Log) { if ctx.GetContext("skipwaf").(bool) { return } diff --git a/plugins/wasm-go/extensions/waf/wasmplugin/utils.go b/plugins/wasm-go/extensions/waf/wasmplugin/utils.go index 79da47eab..52be3e638 100644 --- a/plugins/wasm-go/extensions/waf/wasmplugin/utils.go +++ b/plugins/wasm-go/extensions/waf/wasmplugin/utils.go @@ -9,10 +9,11 @@ import ( "net" "strconv" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" ctypes "github.com/corazawaf/coraza/v3/types" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/wrapper" ) const noGRPCStream int32 = -1 @@ -21,7 +22,7 @@ const replaceResponseBody int = 10 // retrieveAddressInfo retrieves address properties from the proxy // Expected targets are "source" or "destination" // Envoy ref: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes#connection-attributes -func retrieveAddressInfo(logger wrapper.Log, target string) (string, int) { +func retrieveAddressInfo(logger log.Log, target string) (string, int) { var targetIP, targetPortStr string var targetPort int targetAddressRaw, err := proxywasm.GetProperty([]string{target, "address"}) @@ -68,7 +69,7 @@ func parsePort(b []byte) (int, error) { // parseServerName parses :authority pseudo-header in order to retrieve the // virtual host. -func parseServerName(logger wrapper.Log, authority string) string { +func parseServerName(logger log.Log, authority string) string { host, _, err := net.SplitHostPort(authority) if err != nil { // missing port or bad format @@ -78,7 +79,7 @@ func parseServerName(logger wrapper.Log, authority string) string { return host } -func handleInterruption(ctx wrapper.HttpContext, phase string, interruption *ctypes.Interruption, log wrapper.Log) types.Action { +func handleInterruption(ctx wrapper.HttpContext, phase string, interruption *ctypes.Interruption, log log.Log) types.Action { if ctx.GetContext("interruptionHandled").(bool) { // handleInterruption should never be called more than once panic("Interruption already handled") @@ -105,7 +106,7 @@ func handleInterruption(ctx wrapper.HttpContext, phase string, interruption *cty // replaceResponseBodyWhenInterrupted address an interruption raised during phase 4. // At this phase, response headers are already sent downstream, therefore an interruption // can not change anymore the status code, but only tweak the response body -func replaceResponseBodyWhenInterrupted(logger wrapper.Log, bodySize int) types.Action { +func replaceResponseBodyWhenInterrupted(logger log.Log, bodySize int) types.Action { // TODO(M4tteoP): Update response body interruption logic after https://github.com/corazawaf/coraza-proxy-wasm/issues/26 // Currently returns a body filled with null bytes that replaces the sensitive data potentially leaked err := proxywasm.ReplaceHttpResponseBody(bytes.Repeat([]byte("\x00"), bodySize)) diff --git a/plugins/wasm-go/go.mod b/plugins/wasm-go/go.mod index a78283977..5e3455ea3 100644 --- a/plugins/wasm-go/go.mod +++ b/plugins/wasm-go/go.mod @@ -1,22 +1,22 @@ module github.com/alibaba/higress/plugins/wasm-go -go 1.19 +go 1.24 require ( github.com/google/uuid v1.3.0 - github.com/higress-group/proxy-wasm-go-sdk v1.0.0 - github.com/stretchr/testify v1.8.4 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + // github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + + github.com/stretchr/testify v1.9.0 github.com/tidwall/gjson v1.17.3 github.com/tidwall/resp v0.1.1 + github.com/tidwall/sjson v1.2.5 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 // indirect - github.com/magefile/mage v1.14.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect - github.com/tidwall/sjson v1.2.5 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/go.sum b/plugins/wasm-go/go.sum index 3ce581166..5fce28cca 100644 --- a/plugins/wasm-go/go.sum +++ b/plugins/wasm-go/go.sum @@ -2,16 +2,12 @@ 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520 h1:IHDghbGQ2DTIXHBHxWfqCYQW1fKjyJ/I7W1pMyUDeEA= -github.com/higress-group/nottinygc v0.0.0-20231101025119-e93c4c2f8520/go.mod h1:Nz8ORLaFiLWotg6GeKlJMhv8cci8mM43uEnLA5t8iew= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0 h1:BZRNf4R7jr9hwRivg/E29nkVaKEak5MWjBDhWjuHijU= -github.com/higress-group/proxy-wasm-go-sdk v1.0.0/go.mod h1:iiSyFbo+rAtbtGt/bsefv8GU57h9CCLYGJA74/tF5/0= -github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo= -github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -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/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= diff --git a/plugins/wasm-go/mcp-filters/mcp-router/go.mod b/plugins/wasm-go/mcp-filters/mcp-router/go.mod index 14d2e2f25..450271df5 100644 --- a/plugins/wasm-go/mcp-filters/mcp-router/go.mod +++ b/plugins/wasm-go/mcp-filters/mcp-router/go.mod @@ -3,8 +3,8 @@ module mcp-router go 1.24.1 require ( - github.com/alibaba/higress/plugins/wasm-go v1.4.4-0.20250612125225-016b165a33c9 - github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250402062734-d50d98c305f0 + github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 + github.com/higress-group/wasm-go v1.0.0 github.com/tidwall/gjson v1.18.0 github.com/tidwall/sjson v1.2.5 ) @@ -30,5 +30,6 @@ require ( github.com/tidwall/resp v0.1.1 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect golang.org/x/crypto v0.26.0 // indirect + google.golang.org/protobuf v1.36.6 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/wasm-go/mcp-filters/mcp-router/go.sum b/plugins/wasm-go/mcp-filters/mcp-router/go.sum index 86e6a6d1c..0062a8784 100644 --- a/plugins/wasm-go/mcp-filters/mcp-router/go.sum +++ b/plugins/wasm-go/mcp-filters/mcp-router/go.sum @@ -6,8 +6,6 @@ github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+ github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= -github.com/alibaba/higress/plugins/wasm-go v1.4.4-0.20250612125225-016b165a33c9 h1:MBIjh29Qie+jmPQ9W61wOzyUoulk/lsOjdj6hoYTRpo= -github.com/alibaba/higress/plugins/wasm-go v1.4.4-0.20250612125225-016b165a33c9/go.mod h1:yObZXF1xTx/8peEsSbtHIzz7KlTr/tZCrokIHtwF0Jk= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= @@ -22,8 +20,10 @@ 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/higress-group/gjson_template v0.0.0-20250413075336-4c4161ed428b h1:rRI9+ThQbe+nw4jUiYEyOFaREkXCMMW9k1X2gy2d6pE= github.com/higress-group/gjson_template v0.0.0-20250413075336-4c4161ed428b/go.mod h1:rU3M+Tq5VrQOo0dxpKHGb03Ty0sdWIZfAH+YCOACx/Y= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250402062734-d50d98c305f0 h1:Ta+RBsZYML3hjoenbGJoS2L6aWJN+hqlxKoqzj/Y2SY= -github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250402062734-d50d98c305f0/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80 h1:xqmtTZI0JQ2O+Lg9/CE6c+Tw9KD6FnvWw8EpLVuuvfg= +github.com/higress-group/proxy-wasm-go-sdk v0.0.0-20250611100342-5654e89a7a80/go.mod h1:tRI2LfMudSkKHhyv1uex3BWzcice2s/l8Ah8axporfA= +github.com/higress-group/wasm-go v1.0.0 h1:4Ik5n3FsJ5+r13KLQl2ky+8NuAE8dfWQwoKxXYD2KAw= +github.com/higress-group/wasm-go v1.0.0/go.mod h1:ODBV27sjmhIW8Cqv3R74EUcTnbdkE69bmXBQFuRkY1M= github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E= @@ -65,6 +65,8 @@ github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/ github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/plugins/wasm-go/mcp-filters/mcp-router/main.go b/plugins/wasm-go/mcp-filters/mcp-router/main.go index f98d57615..3cab08898 100644 --- a/plugins/wasm-go/mcp-filters/mcp-router/main.go +++ b/plugins/wasm-go/mcp-filters/mcp-router/main.go @@ -19,11 +19,11 @@ import ( "fmt" "strings" - "github.com/alibaba/higress/plugins/wasm-go/pkg/log" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp" - "github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm" "github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types" + "github.com/higress-group/wasm-go/pkg/log" + "github.com/higress-group/wasm-go/pkg/mcp" + "github.com/higress-group/wasm-go/pkg/wrapper" "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) diff --git a/plugins/wasm-go/mcp-servers/README.md b/plugins/wasm-go/mcp-servers/README.md index dff79f8c0..66e784954 100644 --- a/plugins/wasm-go/mcp-servers/README.md +++ b/plugins/wasm-go/mcp-servers/README.md @@ -80,8 +80,8 @@ import ( "net/http" "my-mcp-server/config" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils" + "github.com/higress-group/wasm-go/pkg/mcp/server" + "github.com/higress-group/wasm-go/pkg/mcp/utils" ) // Define your tool structure with input parameters @@ -145,8 +145,8 @@ For better organization, you can create a separate file to load all your tools: package tools import ( - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server" + "github.com/higress-group/wasm-go/pkg/mcp" + "github.com/higress-group/wasm-go/pkg/mcp/server" ) func LoadTools(server *mcp.MCPServer) server.Server { @@ -170,7 +170,7 @@ import ( amap "amap-tools/tools" quark "quark-search/tools" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp" + "github.com/higress-group/wasm-go/pkg/mcp" ) func main() {} @@ -375,7 +375,7 @@ package main import ( "my-mcp-server/tools" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp" + "github.com/higress-group/wasm-go/pkg/mcp" ) func main() {} diff --git a/plugins/wasm-go/mcp-servers/README_zh.md b/plugins/wasm-go/mcp-servers/README_zh.md index 852d83832..4e055cb57 100644 --- a/plugins/wasm-go/mcp-servers/README_zh.md +++ b/plugins/wasm-go/mcp-servers/README_zh.md @@ -77,8 +77,8 @@ import ( "net/http" "my-mcp-server/config" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils" + "github.com/higress-group/wasm-go/pkg/mcp/server" + "github.com/higress-group/wasm-go/pkg/mcp/utils" ) // 定义带有输入参数的工具结构 @@ -139,8 +139,8 @@ func (t MyTool) Call(ctx server.HttpContext, s server.Server) error { package tools import ( - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server" + "github.com/higress-group/wasm-go/pkg/mcp" + "github.com/higress-group/wasm-go/pkg/mcp/server" ) func LoadTools(server *mcp.MCPServer) server.Server { @@ -164,7 +164,7 @@ import ( amap "amap-tools/tools" quark "quark-search/tools" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp" + "github.com/higress-group/wasm-go/pkg/mcp" ) func main() {} @@ -369,7 +369,7 @@ package main import ( "my-mcp-server/tools" - "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp" + "github.com/higress-group/wasm-go/pkg/mcp" ) func main() {} diff --git a/test/e2e/conformance/tests/go-wasm-ai-cache.yaml b/test/e2e/conformance/tests/go-wasm-ai-cache.yaml index c7d6b0c46..3068441b7 100644 --- a/test/e2e/conformance/tests/go-wasm-ai-cache.yaml +++ b/test/e2e/conformance/tests/go-wasm-ai-cache.yaml @@ -92,7 +92,7 @@ spec: provider: type: "qwen" qwenEnableCompatible: true - apiTokens: + apiTokens: - "{{secret.qwenApiKey}}" timeout: 1200000 modelMapping: @@ -100,4 +100,4 @@ spec: ingress: - higress-conformance-infra/wasmplugin-ai-cache-openai - higress-conformance-infra/wasmplugin-ai-cache-qwen - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-proxy:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-proxy:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-basic-auth-template.yaml b/test/e2e/conformance/tests/go-wasm-basic-auth-template.yaml index 0ea0e3264..1678f690f 100644 --- a/test/e2e/conformance/tests/go-wasm-basic-auth-template.yaml +++ b/test/e2e/conformance/tests/go-wasm-basic-auth-template.yaml @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - apiVersion: v1 kind: Secret metadata: @@ -74,4 +73,4 @@ spec: configDisable: false ingress: - higress-conformance-infra/wasmplugin-basic-auth - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-basic-auth:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-basic-auth:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-basic-auth.yaml b/test/e2e/conformance/tests/go-wasm-basic-auth.yaml index 67baf765c..9bcc19bca 100644 --- a/test/e2e/conformance/tests/go-wasm-basic-auth.yaml +++ b/test/e2e/conformance/tests/go-wasm-basic-auth.yaml @@ -53,4 +53,4 @@ spec: configDisable: false ingress: - higress-conformance-infra/wasmplugin-basic-auth - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-basic-auth:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-basic-auth:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-bot-detect.yaml b/test/e2e/conformance/tests/go-wasm-bot-detect.yaml index bf110ad95..979436233 100644 --- a/test/e2e/conformance/tests/go-wasm-bot-detect.yaml +++ b/test/e2e/conformance/tests/go-wasm-bot-detect.yaml @@ -50,4 +50,4 @@ spec: configDisable: false ingress: - higress-conformance-infra/wasmplugin-bot-detect - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-bot-detect:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-bot-detect:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-cache-control.yaml b/test/e2e/conformance/tests/go-wasm-cache-control.yaml index 9ed454fb1..4a5b3c536 100644 --- a/test/e2e/conformance/tests/go-wasm-cache-control.yaml +++ b/test/e2e/conformance/tests/go-wasm-cache-control.yaml @@ -45,4 +45,4 @@ spec: configDisable: false ingress: - higress-conformance-infra/wasmplugin-cache-control - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/cache-control:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/cache-control:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-custom-response.yaml b/test/e2e/conformance/tests/go-wasm-custom-response.yaml index 39190a0a6..8e97cd972 100644 --- a/test/e2e/conformance/tests/go-wasm-custom-response.yaml +++ b/test/e2e/conformance/tests/go-wasm-custom-response.yaml @@ -71,14 +71,14 @@ spec: defaultConfig: headers: - key1=value1 - "body": "{\"hello\":\"foo\"}" + "body": '{"hello":"foo"}' matchRules: - domain: - bar.com config: headers: - key2=value2 - "body": "{\"hello\":\"bar\"}" + "body": '{"hello":"bar"}' - domain: - baz.com config: @@ -86,15 +86,15 @@ spec: - 401 headers: - key3=value3 - "body": "{\"hello\":\"baz\"}" + "body": '{"hello":"baz"}' - domain: - qux.com config: status_code: 201 headers: - key5=value5 - "body": "{\"hello\":\"qux\"}" - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-custom-response:1.0.0 + "body": '{"hello":"qux"}' + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-custom-response:2.0.0 --- # test enable_on_status 401 apiVersion: extensions.higress.io/v1alpha1 @@ -115,4 +115,4 @@ spec: - consumer1 domain: - baz.com - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/basic-auth:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/basic-auth:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-ip-restriction-allow.yaml b/test/e2e/conformance/tests/go-wasm-ip-restriction-allow.yaml index a100c9220..79b94f5d5 100644 --- a/test/e2e/conformance/tests/go-wasm-ip-restriction-allow.yaml +++ b/test/e2e/conformance/tests/go-wasm-ip-restriction-allow.yaml @@ -43,4 +43,4 @@ spec: allow: - 192.168.0.1/16 - 10.0.0.1 - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ip-restriction:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ip-restriction:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-ip-restriction-deny.yaml b/test/e2e/conformance/tests/go-wasm-ip-restriction-deny.yaml index b47c814a4..a82fbe9b4 100644 --- a/test/e2e/conformance/tests/go-wasm-ip-restriction-deny.yaml +++ b/test/e2e/conformance/tests/go-wasm-ip-restriction-deny.yaml @@ -43,4 +43,4 @@ spec: deny: - 192.168.0.1/16 - 10.0.0.1 - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ip-restriction:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ip-restriction:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-jwt-auth-allow.yaml b/test/e2e/conformance/tests/go-wasm-jwt-auth-allow.yaml index 4f4c27816..ac6aa972a 100644 --- a/test/e2e/conformance/tests/go-wasm-jwt-auth-allow.yaml +++ b/test/e2e/conformance/tests/go-wasm-jwt-auth-allow.yaml @@ -139,4 +139,4 @@ spec: configDisable: false ingress: - higress-conformance-infra/wasmplugin-jwt-auth - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-jwt-auth:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-jwt-auth:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-jwt-auth-deny.yaml b/test/e2e/conformance/tests/go-wasm-jwt-auth-deny.yaml index 080d18a0d..01e81fa85 100644 --- a/test/e2e/conformance/tests/go-wasm-jwt-auth-deny.yaml +++ b/test/e2e/conformance/tests/go-wasm-jwt-auth-deny.yaml @@ -128,4 +128,4 @@ spec: configDisable: false ingress: - higress-conformance-infra/wasmplugin-jwt-auth - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-jwt-auth:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-jwt-auth:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-jwt-auth-single-consumer.yaml b/test/e2e/conformance/tests/go-wasm-jwt-auth-single-consumer.yaml index b3e81a177..d41d3f0f5 100644 --- a/test/e2e/conformance/tests/go-wasm-jwt-auth-single-consumer.yaml +++ b/test/e2e/conformance/tests/go-wasm-jwt-auth-single-consumer.yaml @@ -125,4 +125,4 @@ spec: configDisable: false ingress: - higress-conformance-infra/wasmplugin-jwt-auth - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-jwt-auth:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-jwt-auth:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-key-auth.yaml b/test/e2e/conformance/tests/go-wasm-key-auth.yaml index 4892c9e93..cc7782bb0 100644 --- a/test/e2e/conformance/tests/go-wasm-key-auth.yaml +++ b/test/e2e/conformance/tests/go-wasm-key-auth.yaml @@ -57,4 +57,4 @@ spec: configDisable: false ingress: - higress-conformance-infra/wasmplugin-key-auth - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-key-auth:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-key-auth:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-opa.yaml b/test/e2e/conformance/tests/go-wasm-opa.yaml index 6af333f6d..12f3ae5a7 100644 --- a/test/e2e/conformance/tests/go-wasm-opa.yaml +++ b/test/e2e/conformance/tests/go-wasm-opa.yaml @@ -45,4 +45,4 @@ spec: servicePort: 8181 policy: example1 timeout: 5s - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/opa:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/opa:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-request-block.yaml b/test/e2e/conformance/tests/go-wasm-request-block.yaml index c1468d994..3b6da52ad 100644 --- a/test/e2e/conformance/tests/go-wasm-request-block.yaml +++ b/test/e2e/conformance/tests/go-wasm-request-block.yaml @@ -22,16 +22,16 @@ metadata: spec: ingressClassName: higress rules: - - host: "foo.com" - http: - paths: - - pathType: Prefix - path: "/" - backend: - service: - name: infra-backend-v1 - port: - number: 8080 + - host: "foo.com" + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: infra-backend-v1 + port: + number: 8080 --- apiVersion: networking.k8s.io/v1 kind: Ingress @@ -43,16 +43,16 @@ metadata: spec: ingressClassName: higress rules: - - host: "foo2.com" - http: - paths: - - pathType: Prefix - path: "/" - backend: - service: - name: infra-backend-echo-body-v1 - port: - number: 8080 + - host: "foo2.com" + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: infra-backend-echo-body-v1 + port: + number: 8080 --- apiVersion: extensions.higress.io/v1alpha1 kind: WasmPlugin @@ -62,11 +62,11 @@ metadata: spec: defaultConfig: block_urls: - - "swagger.html" + - "swagger.html" block_regexp_urls: - - "/env.*" + - "/env.*" block_exact_urls: - - "/web/info" + - "/web/info" block_bodies: - - "hello world" - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-request-block:1.0.0 + - "hello world" + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-request-block:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-request-validation.yaml b/test/e2e/conformance/tests/go-wasm-request-validation.yaml index d706a106d..460cc5513 100644 --- a/test/e2e/conformance/tests/go-wasm-request-validation.yaml +++ b/test/e2e/conformance/tests/go-wasm-request-validation.yaml @@ -44,11 +44,11 @@ spec: - enum_payload properties: enum_payload: - type: string - enum: - - "enum_string_1" - - "enum_string_2" - default: "enum_string_1" + type: string + enum: + - "enum_string_1" + - "enum_string_2" + default: "enum_string_1" body_schema: type: object required: @@ -94,4 +94,4 @@ spec: rejected_msg: "customize reject message" enable_swagger: true enable_oas3: false - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/request-validation:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/request-validation:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-simple-jwt-auth.yaml b/test/e2e/conformance/tests/go-wasm-simple-jwt-auth.yaml index 991fb1ac9..cde514084 100644 --- a/test/e2e/conformance/tests/go-wasm-simple-jwt-auth.yaml +++ b/test/e2e/conformance/tests/go-wasm-simple-jwt-auth.yaml @@ -20,16 +20,16 @@ metadata: spec: ingressClassName: higress rules: - - host: "foo.com" - http: - paths: - - pathType: Prefix - path: "/" - backend: - service: - name: infra-backend-v1 - port: - number: 8080 + - host: "foo.com" + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: infra-backend-v1 + port: + number: 8080 --- apiVersion: extensions.higress.io/v1alpha1 kind: WasmPlugin @@ -40,4 +40,4 @@ spec: defaultConfig: token_headers: token token_secret_key: Dav7kfq3iA8S!JUj8&CUkdnQe72E@Cw6 - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/simple-jwt-auth:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/simple-jwt-auth:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-sni-misdirect.yaml b/test/e2e/conformance/tests/go-wasm-sni-misdirect.yaml index f29b8791c..b98d3c4ca 100644 --- a/test/e2e/conformance/tests/go-wasm-sni-misdirect.yaml +++ b/test/e2e/conformance/tests/go-wasm-sni-misdirect.yaml @@ -43,4 +43,4 @@ metadata: name: sni-misdirect namespace: higress-system spec: - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-sni-misdirect:1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-sni-misdirect:2.0.0 diff --git a/test/e2e/conformance/tests/go-wasm-transformer.yaml b/test/e2e/conformance/tests/go-wasm-transformer.yaml index 69ff68bd2..6914cb1bd 100644 --- a/test/e2e/conformance/tests/go-wasm-transformer.yaml +++ b/test/e2e/conformance/tests/go-wasm-transformer.yaml @@ -70,9 +70,8 @@ spec: service: name: infra-backend-v1 port: - number: 8080 + number: 8080 --- - apiVersion: networking.k8s.io/v1 kind: Ingress metadata: @@ -111,10 +110,10 @@ spec: service: name: infra-backend-v1 port: - number: 8080 ---- + number: 8080 --- +--- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: @@ -133,7 +132,7 @@ spec: service: name: infra-backend-v1 port: - number: 8080 + number: 8080 --- apiVersion: networking.k8s.io/v1 kind: Ingress @@ -153,7 +152,7 @@ spec: service: name: infra-backend-v1 port: - number: 8080 + number: 8080 --- apiVersion: networking.k8s.io/v1 kind: Ingress @@ -207,58 +206,58 @@ spec: - higress-conformance-infra/wasmplugin-transform-request configDisable: false config: - reqRules: - - operate: remove - headers: - - key: X-remove - querys: - - key: k1 - - operate: rename - headers: - - oldKey: X-not-renamed - newKey: X-renamed - querys: - - oldKey: k2 - newKey: k2-new - - operate: replace - headers: - - key: X-replace - newValue: replaced - querys: - - key: k2-new - newValue: v2-new - - operate: add - headers: - - key: X-add-append - value: add - querys: - - key: k3 - value: v31 - - operate: append - headers: - - key: X-add-append - appendValue: append - querys: - - key: k3 - appendValue: v32 - - operate: map - headers: - - fromKey: X-add-append - toKey: X-map - querys: - - fromKey: k3 - toKey: k4 - - operate: dedupe - headers: - - key: X-dedupe-first - strategy: RETAIN_FIRST - - key: X-dedupe-last - strategy: RETAIN_LAST - - key: X-dedupe-unique - strategy: RETAIN_UNIQUE - querys: - - key: k4 - strategy: RETAIN_FIRST + reqRules: + - operate: remove + headers: + - key: X-remove + querys: + - key: k1 + - operate: rename + headers: + - oldKey: X-not-renamed + newKey: X-renamed + querys: + - oldKey: k2 + newKey: k2-new + - operate: replace + headers: + - key: X-replace + newValue: replaced + querys: + - key: k2-new + newValue: v2-new + - operate: add + headers: + - key: X-add-append + value: add + querys: + - key: k3 + value: v31 + - operate: append + headers: + - key: X-add-append + appendValue: append + querys: + - key: k3 + appendValue: v32 + - operate: map + headers: + - fromKey: X-add-append + toKey: X-map + querys: + - fromKey: k3 + toKey: k4 + - operate: dedupe + headers: + - key: X-dedupe-first + strategy: RETAIN_FIRST + - key: X-dedupe-last + strategy: RETAIN_LAST + - key: X-dedupe-unique + strategy: RETAIN_UNIQUE + querys: + - key: k4 + strategy: RETAIN_FIRST - ingress: - higress-conformance-infra/wasmplugin-transform-response-header-and-query @@ -422,7 +421,7 @@ spec: headers: - key: X-dedupe-last newValue: X-dedupe-last-replaced - + - operate: rename headers: - oldKey: X-dedupe-unique @@ -436,8 +435,6 @@ spec: - key: X-dedupe-first querys: - key: k1 - - - ingress: - higress-conformance-infra/wasmplugin-transform-response-arbitary-rule-order @@ -475,98 +472,98 @@ spec: - higress-conformance-infra/wasmplugin-transform-request-map-from-querys-to-headers configDisable: false config: - reqRules: - - operate: map - mapSource: querys - headers: - - fromKey: kmap - toKey: X-map - querys: - - fromKey: k3 - toKey: k4 + reqRules: + - operate: map + mapSource: querys + headers: + - fromKey: kmap + toKey: X-map + querys: + - fromKey: k3 + toKey: k4 - ingress: - higress-conformance-infra/wasmplugin-transform-request-map-from-headers-to-querys configDisable: false config: - reqRules: - - operate: map - mapSource: headers - querys: - # 映射来源为headers时,fromKey的匹配不区分大小写 - - fromKey: X-map - toKey: kmap + reqRules: + - operate: map + mapSource: headers + querys: + # 映射来源为headers时,fromKey的匹配不区分大小写 + - fromKey: X-map + toKey: kmap - ingress: - higress-conformance-infra/wasmplugin-transform-request-body configDisable: false config: - reqRules: - - operate: remove - body: - - key: X-removed - - operate: rename - body: - - oldKey: X-not-renamed - newKey: X-renamed - - operate: replace - body: - - key: X-replace - newValue: replaced - - operate: add - body: - - key: X-add-append - value: add - - operate: append - body: - - key: X-add-append - appendValue: append - - operate: map - body: - - fromKey: X-to-be-mapped - toKey: X-map - - operate: dedupe - body: - - key: X-dedupe-first - strategy: RETAIN_FIRST - - key: X-dedupe-last - strategy: RETAIN_LAST - - key: X-dedupe-unique - strategy: RETAIN_UNIQUE + reqRules: + - operate: remove + body: + - key: X-removed + - operate: rename + body: + - oldKey: X-not-renamed + newKey: X-renamed + - operate: replace + body: + - key: X-replace + newValue: replaced + - operate: add + body: + - key: X-add-append + value: add + - operate: append + body: + - key: X-add-append + appendValue: append + - operate: map + body: + - fromKey: X-to-be-mapped + toKey: X-map + - operate: dedupe + body: + - key: X-dedupe-first + strategy: RETAIN_FIRST + - key: X-dedupe-last + strategy: RETAIN_LAST + - key: X-dedupe-unique + strategy: RETAIN_UNIQUE - ingress: - higress-conformance-infra/wasmplugin-transform-response-body configDisable: false config: - respRules: - - operate: remove - body: - - key: X-removed - - operate: rename - body: - - oldKey: X-not-renamed - newKey: X-renamed - - operate: replace - body: - - key: X-replace - newValue: replaced - - operate: add - body: - - key: X-add-append - value: add - - operate: append - body: - - key: X-add-append - appendValue: append - - operate: map - body: - - fromKey: X-to-be-mapped - toKey: X-map - - operate: dedupe - body: - - key: X-dedupe-first - strategy: RETAIN_FIRST - - key: X-dedupe-last - strategy: RETAIN_LAST - - key: X-dedupe-unique - strategy: RETAIN_UNIQUE - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/transformer:1.0.0 + respRules: + - operate: remove + body: + - key: X-removed + - operate: rename + body: + - oldKey: X-not-renamed + newKey: X-renamed + - operate: replace + body: + - key: X-replace + newValue: replaced + - operate: add + body: + - key: X-add-append + value: add + - operate: append + body: + - key: X-add-append + appendValue: append + - operate: map + body: + - fromKey: X-to-be-mapped + toKey: X-map + - operate: dedupe + body: + - key: X-dedupe-first + strategy: RETAIN_FIRST + - key: X-dedupe-last + strategy: RETAIN_LAST + - key: X-dedupe-unique + strategy: RETAIN_UNIQUE + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/transformer:2.0.0 diff --git a/test/e2e/conformance/tests/rust-wasm-ai-data-masking.yaml b/test/e2e/conformance/tests/rust-wasm-ai-data-masking.yaml index 995cc4eb2..0a2852430 100644 --- a/test/e2e/conformance/tests/rust-wasm-ai-data-masking.yaml +++ b/test/e2e/conformance/tests/rust-wasm-ai-data-masking.yaml @@ -56,69 +56,69 @@ spec: config: headers: - Content-Type=application/json - "body": "{\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"ok\"}}],\"usage\":{}}" + "body": '{"choices":[{"index":0,"message":{"role":"assistant","content":"ok"}}],"usage":{}}' - domain: - replace.openai.com config: headers: - Content-Type=application/json - "body": "{\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"***.***.***.*** c11e7177eb60c80cf983ddf8ca98f2dc1272d4c612204ce9bedd2460b18939cc ****@gmail.com\"}}],\"usage\":{}}" - + "body": '{"choices":[{"index":0,"message":{"role":"assistant","content":"***.***.***.*** c11e7177eb60c80cf983ddf8ca98f2dc1272d4c612204ce9bedd2460b18939cc ****@gmail.com"}}],"usage":{}}' + - domain: - system_deny.openai.com config: headers: - Content-Type=application/json - "body": "{\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"fuck\"}}],\"usage\":{}}" + "body": '{"choices":[{"index":0,"message":{"role":"assistant","content":"fuck"}}],"usage":{}}' - domain: - costom_word1.openai.com config: headers: - Content-Type=application/json - "body": "{\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"costom_word1\"}}],\"usage\":{}}" + "body": '{"choices":[{"index":0,"message":{"role":"assistant","content":"costom_word1"}}],"usage":{}}' - domain: - costom_word.openai.com config: headers: - Content-Type=application/json - "body": "{\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"costom_word\"}}],\"usage\":{}}" + "body": '{"choices":[{"index":0,"message":{"role":"assistant","content":"costom_word"}}],"usage":{}}' - domain: - ok.raw.com config: headers: - Content-Type=application/json - "body": "{\"res\":\"ok\"}" + "body": '{"res":"ok"}' - domain: - replace.raw.com config: headers: - Content-Type=application/json - "body": "{\"res\":\"***.***.***.*** c11e7177eb60c80cf983ddf8ca98f2dc1272d4c612204ce9bedd2460b18939cc ****@gmail.com\"}" + "body": '{"res":"***.***.***.*** c11e7177eb60c80cf983ddf8ca98f2dc1272d4c612204ce9bedd2460b18939cc ****@gmail.com"}' - domain: - system_deny.raw.com config: headers: - Content-Type=application/json - "body": "{\"res\":\"fuck\"}" + "body": '{"res":"fuck"}' - domain: - system_no_deny.raw.com config: headers: - Content-Type=application/json - "body": "{\"res\":\"工信处女干事每月经过下属科室都要亲口交代24口交换机等技术性器件的安装工作\"}" + "body": '{"res":"工信处女干事每月经过下属科室都要亲口交代24口交换机等技术性器件的安装工作"}' - domain: - costom_word1.raw.com config: headers: - Content-Type=application/json - "body": "{\"res\":\"costom_word1\"}" + "body": '{"res":"costom_word1"}' - domain: - costom_word.raw.com config: headers: - Content-Type=application/json - "body": "{\"res\":\"costom_word\"}" - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-custom-response:1.0.0 + "body": '{"res":"costom_word"}' + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/go-custom-response:2.0.0 --- apiVersion: extensions.higress.io/v1alpha1 kind: WasmPlugin @@ -135,9 +135,9 @@ spec: deny_raw: true deny_code: 200 deny_message: "提问或回答中包含敏感词,已被屏蔽" - deny_raw_message: "{\"errmsg\":\"提问或回答中包含敏感词,已被屏蔽\"}" + deny_raw_message: '{"errmsg":"提问或回答中包含敏感词,已被屏蔽"}' deny_content_type: "application/json" - deny_words: + deny_words: - "costom_word1" replace_roles: - regex: "%{EMAILLOCALPART}@%{HOSTNAME:domain}" diff --git a/test/e2e/conformance/utils/config/timeout.go b/test/e2e/conformance/utils/config/timeout.go index dbacd08d9..885924b4c 100644 --- a/test/e2e/conformance/utils/config/timeout.go +++ b/test/e2e/conformance/utils/config/timeout.go @@ -56,7 +56,7 @@ func DefaultTimeoutConfig() TimeoutConfig { DeleteTimeout: 10 * time.Second, GetTimeout: 10 * time.Second, ManifestFetchTimeout: 10 * time.Second, - MaxTimeToConsistency: 30 * time.Second, + MaxTimeToConsistency: 300 * time.Second, NamespacesMustBeReady: 300 * time.Second, RequestTimeout: 10 * time.Second, TLSHandshakeTimeout: 10 * time.Second, diff --git a/test/e2e/conformance/utils/kubernetes/helpers.go b/test/e2e/conformance/utils/kubernetes/helpers.go index ed8325ce4..7607c4979 100644 --- a/test/e2e/conformance/utils/kubernetes/helpers.go +++ b/test/e2e/conformance/utils/kubernetes/helpers.go @@ -66,6 +66,7 @@ func NamespacesMustBeAccepted(t *testing.T, c client.Client, timeoutConfig confi } } } + t.Logf("✅ Gateways and Pods in %s namespaces ready", strings.Join(namespaces, ", ")) return true, nil }) diff --git a/tools/hack/build-wasm-plugins.sh b/tools/hack/build-wasm-plugins.sh index 7e4e4c387..6ffb91387 100755 --- a/tools/hack/build-wasm-plugins.sh +++ b/tools/hack/build-wasm-plugins.sh @@ -60,8 +60,8 @@ else echo "🚀 Build all Go WasmPlugins under folder of $EXTENSIONS_DIR" for file in `ls $EXTENSIONS_DIR` do - # TODO: adjust waf build - if [ "$file" == "waf" ]; then + # : adjust waf build + if [ "$file" == "" ]; then continue fi if [ -d $EXTENSIONS_DIR$file ]; then