diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index 8ab2125..2db7bd0 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -7,12 +7,9 @@ on: branches: [ main ] jobs: - rust: - name: Rust Build and Test (${{ matrix.platform.arch }}, ${{ matrix.platform.os }}) + build_and_test: + name: Build and Test (${{ matrix.platform.arch }}, ${{ matrix.platform.os }}) runs-on: ${{ matrix.platform.os }} - defaults: - run: - working-directory: ./rust strategy: fail-fast: false matrix: @@ -28,6 +25,19 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + cache: false + go-version-file: go/go.mod + + - uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + ~/go/bin + key: go-test-${{ hashFiles('**/go.mod', '**/go.sum') }} + - name: Cache Cargo registry uses: actions/cache@v4 with: @@ -51,58 +61,13 @@ jobs: override: true components: clippy, rustfmt - - name: Check formatting - run: cargo fmt -- --check - - - name: Run Clippy linter - run: cargo clippy -- -D warnings - - - name: Build project - run: cargo build --verbose - - - name: Run tests - run: cargo test --verbose - - go: - name: Go Build and Test (${{ matrix.platform.arch }}, ${{ matrix.platform.os }}) - runs-on: ${{ matrix.platform.os }} - defaults: - run: - working-directory: ./go - strategy: - fail-fast: false - matrix: - platform: - - os: ubuntu-22.04 - arch: amd64 - - os: ubuntu-22.04-arm - arch: arm64 - - os: macos-latest - arch: arm64 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - uses: actions/setup-go@v5 - with: - cache: false - go-version-file: go/go.mod - - - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - ~/go/bin - key: go-test-${{ hashFiles('**/go.mod', '**/go.sum') }} - - - run: CGO_ENABLED=0 go test ./... -v - - run: go build -buildmode=c-shared -o main.so - - run: go tool golangci-lint run + - run: make check + - run: make test + - run: make build + - run: make integration-test docker_build_and_integration_test: - name: Build and Run Integration Tests + name: Integration Test with Docker Image runs-on: ubuntu-latest steps: - name: Checkout @@ -162,9 +127,9 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - integration_test_on_main: + docker_build_and_integration_test_on_main: needs: [docker_build_and_integration_test] - name: Integration Test (${{ matrix.platform.arch }}) + name: Integration Test with Docker Image (${{ matrix.platform.arch }}) # This will only run on push events to the main branch. # Mainly to check the multi-arch image by running the # integration tests on both architectures. diff --git a/Dockerfile b/Dockerfile index 8e227fa..c765f48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ RUN cp /build/target/x86_64-unknown-linux-gnu/debug/librust_module.so /build/amd ##### Build the Go library ##### # We use zig to cross-compile the Go library for both x86_64 and aarch64 architectures. -FROM --platform=$BUILDPLATFORM golang:1.24.2 AS go_builder +FROM --platform=$BUILDPLATFORM golang:1.25.6 AS go_builder # Install zig. ARG ZIG_VERSION=0.14.0 RUN apt update && apt install -y curl xz-utils @@ -46,7 +46,7 @@ RUN CC="zig cc -target aarch64-linux-gnu" CXX="zig c++ -target aarch64-linux-gnu RUN CC="zig cc -target x86_64-linux-gnu" CXX="zig c++ -target x86_64-linux-gnu" CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o /build/amd64_libgo_module.so . ##### Build the final image ##### -FROM envoyproxy/envoy:v1.36.2 AS envoy +FROM envoyproxy/envoy:v1.37.0 AS envoy ARG TARGETARCH ENV ENVOY_DYNAMIC_MODULES_SEARCH_PATH=/usr/local/lib COPY --from=rust_builder /build/${TARGETARCH}_librust_module.so /usr/local/lib/librust_module.so diff --git a/ENVOY_VERSION b/ENVOY_VERSION deleted file mode 100644 index fce2ecc..0000000 --- a/ENVOY_VERSION +++ /dev/null @@ -1 +0,0 @@ -dc2d3098ae5641555f15c71d5bb5ce0060a8015c \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..25627cb --- /dev/null +++ b/Makefile @@ -0,0 +1,108 @@ +CYAN := \033[36m +GREEN := \033[32m +YELLOW := \033[33m +RESET := \033[0m +BOLD := \033[1m + +define print_task + printf "$(BOLD)$(CYAN)[TASK]$(RESET) $(BOLD)%s$(RESET)\n" "$(1)" +endef +define print_subtask + printf " $(YELLOW)→$(RESET) %s\n" "$(1)" +endef +define print_success + printf " $(GREEN)✓$(RESET) %s\n" "$(1)" +endef + +## help: Show this help info. +.PHONY: help +help: + @echo "Envoy Dynamic Modules.\n" + @echo "Usage:\n make \033[36m\033[0m \n\nTargets:" + @awk 'BEGIN {FS = ":.*##"; printf ""} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +# This runs all necessary steps to prepare for a commit. +.PHONY: precommit +precommit: ## Run all necessary steps to prepare for a commit. +precommit: precommit-go precommit-rust + +.PHONY: precommit-go +precommit-go: ## This runs the linter, formatter, and tidy on the Go codebase. + @$(call print_task,Tidying Go modules) + @find . -name "go.mod" \ + | grep go.mod \ + | xargs -I {} bash -c 'dirname {}' \ + | xargs -I {} bash -c 'cd {} && $(call print_subtask,Tidying {}) && go mod tidy -v;' + @$(call print_success,Tidying completed) + @$(call print_task,Running linter) + @$(call print_subtask,Checking ./...) + @cd go && go tool golangci-lint run --build-tags==cgo ./... + @$(call print_success,Linting completed) + @$(call print_task,Formatting code) + @$(call print_subtask,Running gofmt) + @cd go && find . -type f -name '*.go' | xargs gofmt -s -w + @$(call print_subtask,Running gofumpt) + @cd go && find . -type f -name '*.go' | xargs go tool gofumpt -l -w + @$(call print_subtask,Running gci) + @cd go && go tool gci write -s standard -s default -s "prefix(github.com/envoyproxy/dynamic-modules-examples)" `find . -name '*.go'` + @$(call print_success,Formatting completed) + +.PHONY: precommt-rust +precommit-rust: ## This runs the linter, formatter, and tidy on the Rust codebase. + @$(call print_task,Running Rust precommit steps) + @$(call print_subtask,Running cargo fmt) + @cd rust && cargo fmt --all -- --check + @$(call print_subtask,Running cargo clippy) + @cd rust && cargo clippy -- -D warnings + @$(call print_success,Rust precommit steps completed) + +# This runs precommit and checks for any differences in the codebase, failing if there are any. +.PHONY: check +check: precommit ## Run all necessary steps to prepare for a commit and check for any differences in the codebase. + @$(call print_task,Checking for uncommitted changes) + @if [ ! -z "`git status -s`" ]; then \ + echo "$(BOLD)$(YELLOW)The following differences will fail CI until committed:$(RESET)"; \ + git diff --exit-code; \ + echo "$(BOLD)$(YELLOW)Please ensure you have run 'make precommit' and committed the changes.$(RESET)"; \ + exit 1; \ + fi + @$(call print_success,No uncommitted changes found) + +.PHONY: test +test: test-rust test-rust ## Run all tests for the codebase. +.PHONY: test-go +test-go:## Run the unit tests for the Go codebase. This doesn't run the integration tests like test-* targets. + @$(call print_task,Running Go tests) + @cd go && go test -v ./... + @$(call print_success,Go unit tests completed) +.PHONY: test-rust +test-rust: ## Run the unit tests for the Rust codebase. + @$(call print_task,Running Rust tests) + @cd rust && cargo test + @$(call print_success,Rust unit tests completed) + +.PHONY: build +build: build-go build-rust ## Build all dynamic modules. + +.PHONY: build-go +build-go: ## Build the Go dynamic module. + @$(call print_task,Building Go dynamic module) + @cd go && go build -buildmode=c-shared -o libgo_module.so . + @$(call print_success,Go dynamic module built at go/libgo_module.so) + @$(call print_task,Copying Go dynamic module for easier use with Envoy) + @cp go/libgo_module.so integration/libgo_module.so + +.PHONY: build-rust +build-rust: ## Build the Rust dynamic module. + @$(call print_task,Building Rust dynamic module) + @cd rust && cargo build + @$(call print_success,Rust dynamic module built at rust/target/debug/librust_module.so) + @$(call print_task,Copying Rust dynamic module for easier use with Envoy) + @cp rust/target/debug/librust_module.dylib integration/librust_module.so || true + @cp rust/target/debug/librust_module.so integration/librust_module.so || true + +.PHONY: integration-test +integration-test: build-go build-rust ## Run the integration tests. + @$(call print_task,Running integration tests) + @cd integration && go test -v ./... + @$(call print_success,Integration tests completed) diff --git a/README.md b/README.md index 1c9bf17..9150ddb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Dynamic Modules Examples -> Envoy Version: [dc2d3098ae5641555f15c71d5bb5ce0060a8015c] v1.36.2 +> Envoy Version: v1.37.0 > > Since dynamic modules are tied with a specific Envoy version, this repository is based on the specific commit of Envoy. > For examples for a specific Envoy version, please check out `release/v` branches: @@ -29,67 +29,14 @@ The tracking issue for dynamic modules in general is [here](https://github.com/e ## Development -### Rust Dynamic Module - -To build and test the modules locally without Envoy, you can use `cargo` to build them just like any other Rust project: - -``` -cd rust -cargo build -cargo test -cargo clippy -- -D warnings -cargo fmt --all -- --check -``` - -### Go Dynamic Module -To build and test the modules locally without Envoy, you can use `go` to build them just like any other Go project: - -``` -cd go -go test ./... -v -go build -buildmode=c-shared -o libgo_module.so . -go tool golangci-lint run -find . -type f -name '*.go' | xargs go tool gofumpt -l -w -``` - -### Build Envoy + Example Dynamic Module Docker Image - -To build the example modules and bundle them with Envoy, simply run - -``` -docker buildx build . -t envoy-with-dynamic-modules:latest [--platform linux/amd64,linux/arm64] -``` - -where `--platform` is optional and can be used to build for multiple platforms. - -### Run Envoy + Example Dynamic Module Docker Image - -The example Envoy configuration yaml is in [`integration/envoy.yaml`](integration/envoy.yaml) which is also used -to run the integration tests. Assuming you built the Docker image with the tag `envoy-with-dynamic-modules:latest`, you can run Envoy with the following command: - -``` -docker run --network host -v $(pwd):/examples -w /examples/integration envoy-with-dynamic-modules:latest --config-path ./envoy.yaml -``` - -Then execute, for example, the following command to test the passthrough and access log filters: - -``` -curl localhost:1062/uuid -``` - -### Run integration tests with the built example Envoy + Dynamic Module Docker Image. - -The integration tests are in the `integration` directory. Assuming you built the Docker image with the tag `envoy-with-dynamic-modules:latest`, you can run the integration tests with the following command: -``` -cd integration -go test . -v -count=1 -``` - -If you want to explicitly specify the docker image, use `ENVOY_IMAGE` environment variable: ``` -ENVOY_IMAGE=foo-bar-image:latest go test . -v -count=1 +# Run all unit tests +make test +# Build all dynamic modules +make build +# Run integration tests with Envoy via func-e (no local installation required) +make integration-test ``` -[dc2d3098ae5641555f15c71d5bb5ce0060a8015c]: https://github.com/envoyproxy/envoy/tree/dc2d3098ae5641555f15c71d5bb5ce0060a8015c [Envoy]: https://github.com/envoyproxy/envoy [High Level Doc]: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/dynamic_modules diff --git a/go/go.mod b/go/go.mod index 253834e..068e105 100644 --- a/go/go.mod +++ b/go/go.mod @@ -1,12 +1,19 @@ module github.com/envoyproxy/dynamic-modules-examples/go -go 1.24.2 +go 1.25.6 tool ( + github.com/daixiang0/gci github.com/golangci/golangci-lint/cmd/golangci-lint + github.com/tetratelabs/func-e/cmd/func-e mvdan.cc/gofumpt ) +require ( + github.com/dop251/goja v0.0.0-20250630131328-58d95d85e994 + github.com/stretchr/testify v1.11.1 +) + require ( 4d63.com/gocheckcompilerdirectives v1.3.0 // indirect 4d63.com/gochecknoglobals v0.2.2 // indirect @@ -15,7 +22,7 @@ require ( github.com/Antonboom/errname v1.0.0 // indirect github.com/Antonboom/nilnil v1.0.1 // indirect github.com/Antonboom/testifylint v1.5.2 // indirect - github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect + github.com/BurntSushi/toml v1.5.0 // indirect github.com/Crocmagnon/fatcontext v0.7.1 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 // indirect @@ -42,12 +49,13 @@ require ( github.com/charithe/durationcheck v0.0.10 // indirect github.com/chavacava/garif v0.1.0 // indirect github.com/ckaznocha/intrange v0.3.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/curioswitch/go-reassign v0.3.0 // indirect - github.com/daixiang0/gci v0.13.5 // indirect + github.com/daixiang0/gci v0.13.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/dlclark/regexp2 v1.11.4 // indirect - github.com/dop251/goja v0.0.0-20250630131328-58d95d85e994 // indirect + github.com/ebitengine/purego v0.9.0 // indirect github.com/ettle/strcase v0.2.0 // indirect github.com/fatih/color v1.18.0 // indirect github.com/fatih/structtag v1.2.0 // indirect @@ -56,6 +64,7 @@ require ( github.com/fzipp/gocyclo v0.6.0 // indirect github.com/ghostiam/protogetter v0.3.9 // indirect github.com/go-critic/go-critic v0.12.0 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect @@ -106,6 +115,7 @@ require ( github.com/ldez/tagliatelle v0.7.1 // indirect github.com/ldez/usetesting v0.4.2 // indirect github.com/leonklingele/grouper v1.1.2 // indirect + github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect github.com/macabu/inamedparam v0.1.3 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/maratori/testableexamples v1.0.0 // indirect @@ -128,6 +138,7 @@ require ( github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polyfloyd/go-errorlint v1.7.1 // indirect + github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect @@ -140,6 +151,7 @@ require ( github.com/raeperd/recvcheck v0.2.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.14.1 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/ryancurrah/gomodguard v1.3.5 // indirect github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect @@ -147,6 +159,7 @@ require ( github.com/sashamelentyev/interfacebloat v1.1.0 // indirect github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect github.com/securego/gosec/v2 v2.22.2 // indirect + github.com/shirou/gopsutil/v4 v4.25.9 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/sivchari/containedctx v1.0.3 // indirect github.com/sivchari/tenv v1.12.1 // indirect @@ -161,22 +174,28 @@ require ( github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect github.com/stretchr/objx v0.5.2 // indirect - github.com/stretchr/testify v1.10.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/tdakkota/asciicheck v0.4.1 // indirect github.com/tetafro/godot v1.5.0 // indirect + github.com/tetratelabs/func-e v1.3.0 // indirect github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 // indirect github.com/timonwong/loggercheck v0.10.1 // indirect + github.com/tklauser/go-sysconf v0.3.15 // indirect + github.com/tklauser/numcpus v0.10.0 // indirect github.com/tomarrell/wrapcheck/v2 v2.10.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect + github.com/ulikunitz/xz v0.5.15 // indirect github.com/ultraware/funlen v0.2.0 // indirect github.com/ultraware/whitespace v0.2.0 // indirect + github.com/urfave/cli/v2 v2.27.7 // indirect github.com/uudashr/gocognit v1.2.0 // indirect github.com/uudashr/iface v1.3.1 // indirect github.com/xen0n/gosmopolitan v1.2.2 // indirect + github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect github.com/yagipy/maintidx v1.0.0 // indirect github.com/yeya24/promlinter v0.3.0 // indirect github.com/ykadowak/zerologlint v0.1.5 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect gitlab.com/bosi/decorder v0.4.2 // indirect go-simpler.org/musttag v0.13.0 // indirect go-simpler.org/sloglint v0.9.0 // indirect @@ -187,7 +206,7 @@ require ( golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect golang.org/x/mod v0.24.0 // indirect golang.org/x/sync v0.13.0 // indirect - golang.org/x/sys v0.32.0 // indirect + golang.org/x/sys v0.35.0 // indirect golang.org/x/text v0.22.0 // indirect golang.org/x/tools v0.32.0 // indirect google.golang.org/protobuf v1.36.5 // indirect diff --git a/go/go.sum b/go/go.sum index fac4cd9..3aca746 100644 --- a/go/go.sum +++ b/go/go.sum @@ -46,8 +46,8 @@ github.com/Antonboom/nilnil v1.0.1/go.mod h1:CH7pW2JsRNFgEh8B2UaPZTEPhCMuFowP/e8 github.com/Antonboom/testifylint v1.5.2 h1:4s3Xhuv5AvdIgbd8wOOEeo0uZG7PbDKQyKY5lGoQazk= github.com/Antonboom/testifylint v1.5.2/go.mod h1:vxy8VJ0bc6NavlYqjZfmp6EfqXMtBgQ4+mhCojwC1P8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= -github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= +github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Crocmagnon/fatcontext v0.7.1 h1:SC/VIbRRZQeQWj/TcQBS6JmrXcfA+BU4OGSVUt54PjM= github.com/Crocmagnon/fatcontext v0.7.1/go.mod h1:1wMvv3NXEBJucFGfwOJBxSVWcoIO6emV215SMkW9MFU= @@ -123,21 +123,23 @@ github.com/ckaznocha/intrange v0.3.0/go.mod h1:+I/o2d2A1FBHgGELbGxzIcyd3/9l9Duwj github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= +github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+fbBAhrQPs= github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88= -github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c= -github.com/daixiang0/gci v0.13.5/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= +github.com/daixiang0/gci v0.13.7 h1:+0bG5eK9vlI08J+J/NWGbWPTNiXPG4WhNLJOkSxWITQ= +github.com/daixiang0/gci v0.13.7/go.mod h1:812WVN6JLFY9S6Tv76twqmNqevN0pa3SX3nih0brVzQ= 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/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42t4429eC9k8= github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okegmwQ3UgWl4V1D8gjlY= -github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= -github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo= github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dop251/goja v0.0.0-20250630131328-58d95d85e994 h1:aQYWswi+hRL2zJqGacdCZx32XjKYV8ApXFGntw79XAM= github.com/dop251/goja v0.0.0-20250630131328-58d95d85e994/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4= +github.com/ebitengine/purego v0.9.0 h1:mh0zpKBIXDceC63hpvPuGLiJ8ZAa3DfrFTudmfi8A4k= +github.com/ebitengine/purego v0.9.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -171,6 +173,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= @@ -265,6 +269,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -367,6 +372,8 @@ github.com/ldez/usetesting v0.4.2 h1:J2WwbrFGk3wx4cZwSMiCQQ00kjGR0+tuuyW0Lqm4lwA github.com/ldez/usetesting v0.4.2/go.mod h1:eEs46T3PpQ+9RgN9VjpY6qWdiw2/QmfiDeWmdZdrjIQ= github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= +github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= +github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= github.com/macabu/inamedparam v0.1.3 h1:2tk/phHkMlEL/1GNe/Yf6kkR/hkcUdAEY3L0hjYV1Mk= github.com/macabu/inamedparam v0.1.3/go.mod h1:93FLICAIk/quk7eaPPQvbzihUdn/QkGDwIZEoLtpH6I= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= @@ -436,6 +443,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polyfloyd/go-errorlint v1.7.1 h1:RyLVXIbosq1gBdk/pChWA8zWYLsq9UEw7a1L5TVMCnA= github.com/polyfloyd/go-errorlint v1.7.1/go.mod h1:aXjNb1x2TNhoLsk26iv1yl7a+zTnXPhwEMtEXukiLR8= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -478,6 +487,7 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryancurrah/gomodguard v1.3.5 h1:cShyguSwUEeC0jS7ylOiG/idnd1TpJ1LfHGpV3oJmPU= github.com/ryancurrah/gomodguard v1.3.5/go.mod h1:MXlEPQRxgfPQa62O8wzK3Ozbkv9Rkqr+wKjSxTdsNJE= @@ -493,6 +503,8 @@ github.com/sashamelentyev/usestdlibvars v1.28.0 h1:jZnudE2zKCtYlGzLVreNp5pmCdOxX github.com/sashamelentyev/usestdlibvars v1.28.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= github.com/securego/gosec/v2 v2.22.2 h1:IXbuI7cJninj0nRpZSLCUlotsj8jGusohfONMrHoF6g= github.com/securego/gosec/v2 v2.22.2/go.mod h1:UEBGA+dSKb+VqM6TdehR7lnQtIIMorYJ4/9CW1KVQBE= +github.com/shirou/gopsutil/v4 v4.25.9 h1:JImNpf6gCVhKgZhtaAHJ0serfFGtlfIlSC08eaKdTrU= +github.com/shirou/gopsutil/v4 v4.25.9/go.mod h1:gxIxoC+7nQRwUl/xNhutXlD8lq+jxTgpIkEf3rADHL8= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -539,8 +551,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/tdakkota/asciicheck v0.4.1 h1:bm0tbcmi0jezRA2b5kg4ozmMuGAFotKI3RZfrhfovg8= @@ -551,24 +563,36 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= github.com/tetafro/godot v1.5.0 h1:aNwfVI4I3+gdxjMgYPus9eHmoBeJIbnajOyqZYStzuw= github.com/tetafro/godot v1.5.0/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= +github.com/tetratelabs/func-e v1.3.0 h1:u6FS+ec2hs9vn+vX5X2GEB9JeqCajz/A4rvlsdktnQ4= +github.com/tetratelabs/func-e v1.3.0/go.mod h1:zq1g5hXTBV3rNOXruLeMquQvZse0kscUSQg9NvkUz6U= github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 h1:y4mJRFlM6fUyPhoXuFg/Yu02fg/nIPFMOY8tOqppoFg= github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460= github.com/timonwong/loggercheck v0.10.1 h1:uVZYClxQFpw55eh+PIoqM7uAOHMrhVcDoWDery9R8Lg= github.com/timonwong/loggercheck v0.10.1/go.mod h1:HEAWU8djynujaAVX7QI65Myb8qgfcZ1uKbdpg3ZzKl8= +github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= +github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= +github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= +github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= github.com/tomarrell/wrapcheck/v2 v2.10.0 h1:SzRCryzy4IrAH7bVGG4cK40tNUhmVmMDuJujy4XwYDg= github.com/tomarrell/wrapcheck/v2 v2.10.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= +github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY= +github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLkI= github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA= github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g= github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= +github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU= +github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4= github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA= github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU= github.com/uudashr/iface v1.3.1 h1:bA51vmVx1UIhiIsQFSNq6GZ6VPTk3WNMZgRiCe9R29U= github.com/uudashr/iface v1.3.1/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg= github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU= github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg= +github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg= +github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= github.com/yeya24/promlinter v0.3.0 h1:JVDbMp08lVCP7Y6NP3qHroGAO6z2yGKQtS5JsjqtoFs= @@ -582,6 +606,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo= gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8= go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ= @@ -738,6 +764,7 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -759,6 +786,7 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -778,8 +806,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= diff --git a/go/gosdk/abi.go b/go/gosdk/abi.go index 351e0dd..35bb40c 100644 --- a/go/gosdk/abi.go +++ b/go/gosdk/abi.go @@ -3,7 +3,7 @@ package gosdk // Following is a distillation of the Envoy ABI for dynamic modules: -// https://github.com/envoyproxy/envoy/blob/dc2d3098ae5641555f15c71d5bb5ce0060a8015c/source/extensions/dynamic_modules/abi.h +// https://github.com/envoyproxy/envoy/blob/v1.37.0/source/extensions/dynamic_modules/abi.h // // Why not using the header file directly? That is because Go runtime complains // about passing pointers to C code on the boundary. In the following code, we replace @@ -15,81 +15,74 @@ package gosdk #include #include -#cgo noescape envoy_dynamic_module_callback_http_get_request_header -#cgo nocallback envoy_dynamic_module_callback_http_get_request_header -size_t envoy_dynamic_module_callback_http_get_request_header( +typedef enum { + envoy_dynamic_module_type_http_header_type_RequestHeader = 0, + envoy_dynamic_module_type_http_header_type_RequestTrailer = 1, + envoy_dynamic_module_type_http_header_type_ResponseHeader = 2, + envoy_dynamic_module_type_http_header_type_ResponseTrailer = 3, +} envoy_dynamic_module_type_http_header_type; + +typedef struct { + uintptr_t ptr; + size_t length; +} envoy_dynamic_module_type_envoy_buffer; + +typedef struct { + uintptr_t ptr; + size_t length; +} envoy_dynamic_module_type_module_buffer; + +typedef enum { + envoy_dynamic_module_type_http_body_type_ReceivedRequestBody, + envoy_dynamic_module_type_http_body_type_BufferedRequestBody, + envoy_dynamic_module_type_http_body_type_ReceivedResponseBody, + envoy_dynamic_module_type_http_body_type_BufferedResponseBody, +} envoy_dynamic_module_type_http_body_type; + +#cgo noescape envoy_dynamic_module_callback_http_get_header +#cgo nocallback envoy_dynamic_module_callback_http_get_header +bool envoy_dynamic_module_callback_http_get_header( uintptr_t filter_envoy_ptr, - uintptr_t key, size_t key_length, - uintptr_t* result_buffer_ptr, size_t* result_buffer_length_ptr, - size_t index); - -#cgo noescape envoy_dynamic_module_callback_http_set_request_header -#cgo nocallback envoy_dynamic_module_callback_http_set_request_header -bool envoy_dynamic_module_callback_http_set_request_header( + int header_type, + envoy_dynamic_module_type_module_buffer key, + envoy_dynamic_module_type_envoy_buffer* result_buffer, + size_t index, + size_t* optional_size); + +#cgo noescape envoy_dynamic_module_callback_http_set_header +#cgo nocallback envoy_dynamic_module_callback_http_set_header +bool envoy_dynamic_module_callback_http_set_header( uintptr_t filter_envoy_ptr, - uintptr_t key, size_t key_length, - uintptr_t value, size_t value_length); + int header_type, + envoy_dynamic_module_type_module_buffer key, + envoy_dynamic_module_type_module_buffer value); -#cgo noescape envoy_dynamic_module_callback_http_get_response_header -#cgo nocallback envoy_dynamic_module_callback_http_get_response_header -size_t envoy_dynamic_module_callback_http_get_response_header( +#cgo noescape envoy_dynamic_module_callback_http_append_body +#cgo nocallback envoy_dynamic_module_callback_http_append_body +bool envoy_dynamic_module_callback_http_append_body( uintptr_t filter_envoy_ptr, - uintptr_t key, size_t key_length, - uintptr_t* result_buffer_ptr, size_t* result_buffer_length_ptr, - size_t index); + int body_type, + envoy_dynamic_module_type_module_buffer data); -#cgo noescape envoy_dynamic_module_callback_http_set_response_header -#cgo nocallback envoy_dynamic_module_callback_http_set_response_header -bool envoy_dynamic_module_callback_http_set_response_header( +#cgo noescape envoy_dynamic_module_callback_http_drain_body +#cgo nocallback envoy_dynamic_module_callback_http_drain_body +bool envoy_dynamic_module_callback_http_drain_body( uintptr_t filter_envoy_ptr, - uintptr_t key, size_t key_length, - uintptr_t value, size_t value_length); + int body_type, + size_t number_of_bytes); -#cgo noescape envoy_dynamic_module_callback_http_append_request_body -#cgo nocallback envoy_dynamic_module_callback_http_append_request_body -bool envoy_dynamic_module_callback_http_append_request_body( +#cgo noescape envoy_dynamic_module_callback_http_get_body_chunks +#cgo nocallback envoy_dynamic_module_callback_http_get_body_chunks +bool envoy_dynamic_module_callback_http_get_body_chunks( uintptr_t filter_envoy_ptr, - uintptr_t data, size_t length); - -#cgo noescape envoy_dynamic_module_callback_http_drain_request_body -#cgo nocallback envoy_dynamic_module_callback_http_drain_request_body -bool envoy_dynamic_module_callback_http_drain_request_body( - uintptr_t filter_envoy_ptr, - size_t length); - -#cgo noescape envoy_dynamic_module_callback_http_get_request_body_vector -#cgo nocallback envoy_dynamic_module_callback_http_get_request_body_vector -bool envoy_dynamic_module_callback_http_get_request_body_vector( - uintptr_t filter_envoy_ptr, - uintptr_t* result_buffer_vector); - -#cgo noescape envoy_dynamic_module_callback_http_get_request_body_vector_size -#cgo nocallback envoy_dynamic_module_callback_http_get_request_body_vector_size -bool envoy_dynamic_module_callback_http_get_request_body_vector_size( - uintptr_t filter_envoy_ptr, size_t* size); + int body_type, + envoy_dynamic_module_type_envoy_buffer* result_buffer_vector); -#cgo noescape envoy_dynamic_module_callback_http_append_response_body -#cgo nocallback envoy_dynamic_module_callback_http_append_response_body -bool envoy_dynamic_module_callback_http_append_response_body( +#cgo noescape envoy_dynamic_module_callback_http_get_body_chunks_size +#cgo nocallback envoy_dynamic_module_callback_http_get_body_chunks_size +size_t envoy_dynamic_module_callback_http_get_body_chunks_size( uintptr_t filter_envoy_ptr, - uintptr_t data, size_t length); - -#cgo noescape envoy_dynamic_module_callback_http_drain_response_body -#cgo nocallback envoy_dynamic_module_callback_http_drain_response_body -bool envoy_dynamic_module_callback_http_drain_response_body( - uintptr_t filter_envoy_ptr, - size_t length); - -#cgo noescape envoy_dynamic_module_callback_http_get_response_body_vector -#cgo nocallback envoy_dynamic_module_callback_http_get_response_body_vector -bool envoy_dynamic_module_callback_http_get_response_body_vector( - uintptr_t filter_envoy_ptr, - uintptr_t* result_buffer_vector); - -#cgo noescape envoy_dynamic_module_callback_http_get_response_body_vector_size -#cgo nocallback envoy_dynamic_module_callback_http_get_response_body_vector_size -bool envoy_dynamic_module_callback_http_get_response_body_vector_size( - uintptr_t filter_envoy_ptr, size_t* size); + int body_type); #cgo noescape envoy_dynamic_module_callback_http_send_response // Uncomment once https://github.com/envoyproxy/envoy/pull/39206 is merged. @@ -97,36 +90,35 @@ bool envoy_dynamic_module_callback_http_get_response_body_vector_size( void envoy_dynamic_module_callback_http_send_response( uintptr_t filter_envoy_ptr, uint32_t status_code, uintptr_t headers_vector, size_t headers_vector_size, - uintptr_t body, size_t body_length); - -#cgo noescape envoy_dynamic_module_callback_http_get_request_headers_count -#cgo nocallback envoy_dynamic_module_callback_http_get_request_headers_count -size_t envoy_dynamic_module_callback_http_get_request_headers_count( - uintptr_t filter_envoy_ptr); - -#cgo noescape envoy_dynamic_module_callback_http_get_request_headers -#cgo nocallback envoy_dynamic_module_callback_http_get_request_headers -bool envoy_dynamic_module_callback_http_get_request_headers( + envoy_dynamic_module_type_module_buffer body, + envoy_dynamic_module_type_module_buffer details); + +typedef struct { + uintptr_t key_ptr; + size_t key_length; + uintptr_t value_ptr; + size_t value_length; +} envoy_dynamic_module_type_envoy_http_header; + +#cgo noescape envoy_dynamic_module_callback_http_get_headers_size +#cgo nocallback envoy_dynamic_module_callback_http_get_headers_size +size_t envoy_dynamic_module_callback_http_get_headers_size( uintptr_t filter_envoy_ptr, - uintptr_t* result_headers); - -#cgo noescape envoy_dynamic_module_callback_http_get_request_headers_count -#cgo nocallback envoy_dynamic_module_callback_http_get_request_headers_count -size_t envoy_dynamic_module_callback_http_get_response_headers_count( - uintptr_t filter_envoy_ptr); + int header_type); -#cgo noescape envoy_dynamic_module_callback_http_get_request_headers -#cgo nocallback envoy_dynamic_module_callback_http_get_request_headers -bool envoy_dynamic_module_callback_http_get_response_headers( +#cgo noescape envoy_dynamic_module_callback_http_get_headers +#cgo nocallback envoy_dynamic_module_callback_http_get_headers +bool envoy_dynamic_module_callback_http_get_headers( uintptr_t filter_envoy_ptr, - uintptr_t* result_headers); + int header_type, + envoy_dynamic_module_type_envoy_http_header* result_headers); #cgo noescape envoy_dynamic_module_callback_http_filter_get_attribute_string #cgo nocallback envoy_dynamic_module_callback_http_filter_get_attribute_string bool envoy_dynamic_module_callback_http_filter_get_attribute_string( uintptr_t filter_envoy_ptr, size_t attribute_id, - uintptr_t* result, size_t* result_length); + envoy_dynamic_module_type_envoy_buffer* result); #cgo noescape envoy_dynamic_module_callback_http_filter_continue_decoding #cgo nocallback envoy_dynamic_module_callback_http_filter_continue_decoding @@ -156,13 +148,13 @@ void envoy_dynamic_module_callback_http_filter_scheduler_commit( import "C" import ( + "fmt" "io" "runtime" "unsafe" ) -// https://github.com/envoyproxy/envoy/blob/dc2d3098ae5641555f15c71d5bb5ce0060a8015c/source/extensions/dynamic_modules/abi_version.h -var version = append([]byte("ca2be3b80954d2a0e22b41d033b18eff9390c30261c8ec9ffe6e6bf971f41c27"), 0) +var version = append([]byte("4dae397a7c9ff0238d318d57ea656ce8b3fbff595787dcd7ee2ff5b79c9fe10f"), 0) //export envoy_dynamic_module_on_program_init func envoy_dynamic_module_on_program_init() uintptr { @@ -298,72 +290,152 @@ func envoy_dynamic_module_on_http_filter_http_callout_done( func envoy_dynamic_module_on_http_filter_scheduled( filterEnvoyPtr uintptr, filterModulePtr uintptr, - eventID C.uint64_t, + eventID uint64, ) { pinned := unwrapPinnedHttpFilter(uintptr(filterModulePtr)) // Call the Scheduled method of the filter. pinned.obj.Scheduled(envoyFilter{raw: uintptr(filterEnvoyPtr)}, uint64(eventID)) } +//export envoy_dynamic_module_on_http_filter_http_stream_reset +func envoy_dynamic_module_on_http_filter_http_stream_reset( + filterEnvoyPtr uintptr, + filterModulePtr uintptr, + streamID uint64, + reason uint32, +) { +} + +//export envoy_dynamic_module_on_http_filter_http_stream_data +func envoy_dynamic_module_on_http_filter_http_stream_data( + filterEnvoyPtr uintptr, + filterModulePtr uintptr, + streamID uint64, + dataPtr uintptr, + dataCount uint64, + endStream bool, +) { +} + +//export envoy_dynamic_module_on_http_filter_http_stream_trailers +func envoy_dynamic_module_on_http_filter_http_stream_trailers( + filterEnvoyPtr uintptr, + filterModulePtr uintptr, + streamID uint64, + trailersPtr uintptr, + trailersSize uint64, +) { +} + +//export envoy_dynamic_module_on_http_filter_http_stream_complete +func envoy_dynamic_module_on_http_filter_http_stream_complete( + filterEnvoyPtr uintptr, + filterModulePtr uintptr, + streamID uint64, +) { +} + +//export envoy_dynamic_module_on_http_filter_config_scheduled +func envoy_dynamic_module_on_http_filter_config_scheduled( + filterConfigEnvoyPtr uintptr, + filterConfigPtr uintptr, + eventID uint64, +) { +} + +//export envoy_dynamic_module_on_http_filter_downstream_above_write_buffer_high_watermark +func envoy_dynamic_module_on_http_filter_downstream_above_write_buffer_high_watermark( + filterEnvoyPtr uintptr, + filterModulePtr uintptr, +) { +} + +//export envoy_dynamic_module_on_http_filter_downstream_below_write_buffer_low_watermark +func envoy_dynamic_module_on_http_filter_downstream_below_write_buffer_low_watermark( + filterEnvoyPtr uintptr, + filterModulePtr uintptr, +) { +} + +//export envoy_dynamic_module_on_http_filter_http_stream_headers +func envoy_dynamic_module_on_http_filter_http_stream_headers( + filterEnvoyPtr uintptr, + filterModulePtr uintptr, + streamID uint64, + headersPtr uintptr, + headersSize uint64, + endStream bool, +) { +} + // GetRequestHeader implements [EnvoyHttpFilter]. func (e envoyFilter) GetRequestHeader(key string) (string, bool) { - keyPtr := uintptr(unsafe.Pointer(unsafe.StringData(key))) - var resultBufferPtr *byte - var resultBufferLengthPtr C.size_t + keyBuf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.StringData(key)))), + length: C.size_t(len(key)), + } + var resultBuf C.envoy_dynamic_module_type_envoy_buffer - ret := C.envoy_dynamic_module_callback_http_get_request_header( + ret := C.envoy_dynamic_module_callback_http_get_header( C.uintptr_t(e.raw), - C.uintptr_t(keyPtr), - C.size_t(len(key)), - (*C.uintptr_t)(unsafe.Pointer(&resultBufferPtr)), - (*C.size_t)(unsafe.Pointer(&resultBufferLengthPtr)), + C.int(0), // RequestHeader + keyBuf, + &resultBuf, 0, + nil, ) - if ret == 0 { + if !ret { return "", false } - result := unsafe.Slice(resultBufferPtr, resultBufferLengthPtr) + result := unsafe.Slice((*byte)(unsafe.Pointer(uintptr(resultBuf.ptr))), resultBuf.length) runtime.KeepAlive(key) return string(result), true } // GetResponseHeader implements [EnvoyHttpFilter]. func (e envoyFilter) GetResponseHeader(key string) (string, bool) { - keyPtr := uintptr(unsafe.Pointer(unsafe.StringData(key))) - var resultBufferPtr *byte - var resultBufferLengthPtr C.size_t + keyBuf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.StringData(key)))), + length: C.size_t(len(key)), + } + var resultBuf C.envoy_dynamic_module_type_envoy_buffer - ret := C.envoy_dynamic_module_callback_http_get_response_header( + ret := C.envoy_dynamic_module_callback_http_get_header( C.uintptr_t(e.raw), - C.uintptr_t(keyPtr), - C.size_t(len(key)), - (*C.uintptr_t)(unsafe.Pointer(&resultBufferPtr)), - (*C.size_t)(unsafe.Pointer(&resultBufferLengthPtr)), + C.int(2), // ResponseHeader + keyBuf, + &resultBuf, 0, + nil, ) - if ret == 0 { + if !ret { return "", false } - result := unsafe.Slice(resultBufferPtr, resultBufferLengthPtr) + result := unsafe.Slice((*byte)(unsafe.Pointer(uintptr(resultBuf.ptr))), resultBuf.length) runtime.KeepAlive(key) return string(result), true } // SetRequestHeader implements [EnvoyHttpFilter]. func (e envoyFilter) SetRequestHeader(key string, value []byte) bool { - keyPtr := uintptr(unsafe.Pointer(unsafe.StringData(key))) - valuePtr := uintptr(unsafe.Pointer(unsafe.SliceData(value))) + keyBuf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.StringData(key)))), + length: C.size_t(len(key)), + } + valueBuf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.SliceData(value)))), + length: C.size_t(len(value)), + } - ret := C.envoy_dynamic_module_callback_http_set_request_header( + ret := C.envoy_dynamic_module_callback_http_set_header( C.uintptr_t(e.raw), - C.uintptr_t(keyPtr), - C.size_t(len(key)), - C.uintptr_t(valuePtr), - C.size_t(len(value)), + C.int(0), // RequestHeader + keyBuf, + valueBuf, ) runtime.KeepAlive(key) @@ -373,15 +445,20 @@ func (e envoyFilter) SetRequestHeader(key string, value []byte) bool { // SetResponseHeader implements [EnvoyHttpFilter]. func (e envoyFilter) SetResponseHeader(key string, value []byte) bool { - keyPtr := uintptr(unsafe.Pointer(unsafe.StringData(key))) - valuePtr := uintptr(unsafe.Pointer(unsafe.SliceData(value))) + keyBuf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.StringData(key)))), + length: C.size_t(len(key)), + } + valueBuf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.SliceData(value)))), + length: C.size_t(len(value)), + } - ret := C.envoy_dynamic_module_callback_http_set_response_header( + ret := C.envoy_dynamic_module_callback_http_set_header( C.uintptr_t(e.raw), - C.uintptr_t(keyPtr), - C.size_t(len(key)), - C.uintptr_t(valuePtr), - C.size_t(len(value)), + C.int(2), // ResponseHeader + keyBuf, + valueBuf, ) runtime.KeepAlive(key) @@ -477,27 +554,29 @@ func (e envoyFilter) GetDestinationAddress() string { } func (e envoyFilter) getStringAttribute(id int) string { - var resultBufferPtr *byte - var resultBufferLengthPtr int + var result C.envoy_dynamic_module_type_envoy_buffer ret := C.envoy_dynamic_module_callback_http_filter_get_attribute_string( C.uintptr_t(e.raw), C.size_t(id), - (*C.uintptr_t)(unsafe.Pointer(&resultBufferPtr)), - (*C.size_t)(unsafe.Pointer(&resultBufferLengthPtr)), + &result, ) if !ret { return "" } - return string(unsafe.Slice(resultBufferPtr, resultBufferLengthPtr)) // Copy the result to a Go string. + return string(unsafe.Slice((*byte)(unsafe.Pointer(uintptr(result.ptr))), result.length)) // Copy the result to a Go string. } // GetRequestHeaders implements EnvoyHttpFilter. func (e envoyFilter) GetRequestHeaders() map[string][]string { - count := C.envoy_dynamic_module_callback_http_get_request_headers_count(C.uintptr_t(e.raw)) - raw := make([][2]envoySlice, count) - ret := C.envoy_dynamic_module_callback_http_get_request_headers( + count := C.envoy_dynamic_module_callback_http_get_headers_size( + C.uintptr_t(e.raw), + C.int(0), // RequestHeader + ) + raw := make([]C.envoy_dynamic_module_type_envoy_http_header, count) + ret := C.envoy_dynamic_module_callback_http_get_headers( C.uintptr_t(e.raw), - (*C.uintptr_t)(unsafe.Pointer(&raw[0])), + C.int(0), // RequestHeader + &raw[0], ) if !ret { return nil @@ -506,8 +585,8 @@ func (e envoyFilter) GetRequestHeaders() map[string][]string { headers := make(map[string][]string, count) // The count is the number of (key, value) pairs, so this might be larger than the number of unique names. for i := range count { // Copy the Envoy owner data to a Go string. - key := string(unsafe.Slice((*byte)(unsafe.Pointer(raw[i][0].data)), raw[i][0].length)) - value := string(unsafe.Slice((*byte)(unsafe.Pointer(raw[i][1].data)), raw[i][1].length)) + key := string(unsafe.Slice((*byte)(unsafe.Pointer(uintptr(raw[i].key_ptr))), raw[i].key_length)) + value := string(unsafe.Slice((*byte)(unsafe.Pointer(uintptr(raw[i].value_ptr))), raw[i].value_length)) headers[key] = append(headers[key], value) } return headers @@ -515,11 +594,15 @@ func (e envoyFilter) GetRequestHeaders() map[string][]string { // GetResponseHeaders implements [EnvoyHttpFilter]. func (e envoyFilter) GetResponseHeaders() map[string][]string { - count := C.envoy_dynamic_module_callback_http_get_response_headers_count(C.uintptr_t(e.raw)) - raw := make([][2]envoySlice, count) - ret := C.envoy_dynamic_module_callback_http_get_response_headers( + count := C.envoy_dynamic_module_callback_http_get_headers_size( + C.uintptr_t(e.raw), + C.int(2), // ResponseHeader + ) + raw := make([]C.envoy_dynamic_module_type_envoy_http_header, count) + ret := C.envoy_dynamic_module_callback_http_get_headers( C.uintptr_t(e.raw), - (*C.uintptr_t)(unsafe.Pointer(&raw[0])), + C.int(2), // ResponseHeader + &raw[0], ) if !ret { return nil @@ -528,8 +611,8 @@ func (e envoyFilter) GetResponseHeaders() map[string][]string { headers := make(map[string][]string, count) // The count is the number of (key, value) pairs, so this might be larger than the number of unique names. for i := range count { // Copy the Envoy owner data to a Go string. - key := string(unsafe.Slice((*byte)(unsafe.Pointer(raw[i][0].data)), raw[i][0].length)) - value := string(unsafe.Slice((*byte)(unsafe.Pointer(raw[i][1].data)), raw[i][1].length)) + key := string(unsafe.Slice((*byte)(unsafe.Pointer(uintptr(raw[i].key_ptr))), raw[i].key_length)) + value := string(unsafe.Slice((*byte)(unsafe.Pointer(uintptr(raw[i].value_ptr))), raw[i].value_length)) headers[key] = append(headers[key], value) } return headers @@ -539,15 +622,22 @@ func (e envoyFilter) GetResponseHeaders() map[string][]string { func (e envoyFilter) SendLocalReply(statusCode uint32, headers [][2]string, body []byte) { headersVecPtr := uintptr(unsafe.Pointer(unsafe.SliceData(headers))) headersVecSize := len(headers) - bodyPtr := uintptr(unsafe.Pointer(unsafe.SliceData(body))) - bodySize := len(body) + bodyBuf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.SliceData(body)))), + length: C.size_t(len(body)), + } + // Empty details buffer (v1.37 addition) + detailsBuf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(0), + length: C.size_t(0), + } C.envoy_dynamic_module_callback_http_send_response( C.uintptr_t(e.raw), C.uint32_t(statusCode), C.uintptr_t(headersVecPtr), C.size_t(headersVecSize), - C.uintptr_t(bodyPtr), - C.size_t(bodySize), + bodyBuf, + detailsBuf, ) runtime.KeepAlive(headers) runtime.KeepAlive(body) @@ -555,11 +645,14 @@ func (e envoyFilter) SendLocalReply(statusCode uint32, headers [][2]string, body // AppendRequestBody implements [EnvoyHttpFilter]. func (e envoyFilter) AppendRequestBody(data []byte) bool { - dataPtr := uintptr(unsafe.Pointer(unsafe.SliceData(data))) - ret := C.envoy_dynamic_module_callback_http_append_request_body( + buf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.SliceData(data)))), + length: C.size_t(len(data)), + } + ret := C.envoy_dynamic_module_callback_http_append_body( C.uintptr_t(e.raw), - C.uintptr_t(dataPtr), - C.size_t(len(data)), + C.int(C.envoy_dynamic_module_type_http_body_type_BufferedRequestBody), + buf, ) runtime.KeepAlive(data) return bool(ret) @@ -567,8 +660,9 @@ func (e envoyFilter) AppendRequestBody(data []byte) bool { // DrainRequestBody implements [EnvoyHttpFilter]. func (e envoyFilter) DrainRequestBody(n int) bool { - ret := C.envoy_dynamic_module_callback_http_drain_request_body( + ret := C.envoy_dynamic_module_callback_http_drain_body( C.uintptr_t(e.raw), + C.int(C.envoy_dynamic_module_type_http_body_type_BufferedRequestBody), C.size_t(n), ) return bool(ret) @@ -576,19 +670,19 @@ func (e envoyFilter) DrainRequestBody(n int) bool { // GetRequestBody implements [EnvoyHttpFilter]. func (e envoyFilter) GetRequestBody() (io.Reader, bool) { - var vectorSize int - ret := C.envoy_dynamic_module_callback_http_get_request_body_vector_size( + vectorSize := C.envoy_dynamic_module_callback_http_get_body_chunks_size( C.uintptr_t(e.raw), - (*C.size_t)(unsafe.Pointer(&vectorSize)), + C.int(C.envoy_dynamic_module_type_http_body_type_BufferedRequestBody), ) - if !ret { + if vectorSize == 0 { return nil, false } chunks := make([]envoySlice, vectorSize) - ret = C.envoy_dynamic_module_callback_http_get_request_body_vector( + ret := C.envoy_dynamic_module_callback_http_get_body_chunks( C.uintptr_t(e.raw), - (*C.uintptr_t)(unsafe.Pointer(&chunks[0])), + C.int(C.envoy_dynamic_module_type_http_body_type_BufferedRequestBody), + (*C.envoy_dynamic_module_type_envoy_buffer)(unsafe.Pointer(&chunks[0])), ) if !ret { return nil, false @@ -598,11 +692,14 @@ func (e envoyFilter) GetRequestBody() (io.Reader, bool) { // AppendResponseBody implements [EnvoyHttpFilter]. func (e envoyFilter) AppendResponseBody(data []byte) bool { - dataPtr := uintptr(unsafe.Pointer(unsafe.SliceData(data))) - ret := C.envoy_dynamic_module_callback_http_append_response_body( + buf := C.envoy_dynamic_module_type_module_buffer{ + ptr: C.uintptr_t(uintptr(unsafe.Pointer(unsafe.SliceData(data)))), + length: C.size_t(len(data)), + } + ret := C.envoy_dynamic_module_callback_http_append_body( C.uintptr_t(e.raw), - C.uintptr_t(dataPtr), - C.size_t(len(data)), + C.int(C.envoy_dynamic_module_type_http_body_type_BufferedResponseBody), + buf, ) runtime.KeepAlive(data) return bool(ret) @@ -610,8 +707,9 @@ func (e envoyFilter) AppendResponseBody(data []byte) bool { // DrainResponseBody implements [EnvoyHttpFilter]. func (e envoyFilter) DrainResponseBody(n int) bool { - ret := C.envoy_dynamic_module_callback_http_drain_response_body( + ret := C.envoy_dynamic_module_callback_http_drain_body( C.uintptr_t(e.raw), + C.int(C.envoy_dynamic_module_type_http_body_type_BufferedResponseBody), C.size_t(n), ) return bool(ret) @@ -619,18 +717,19 @@ func (e envoyFilter) DrainResponseBody(n int) bool { // GetResponseBody implements [EnvoyHttpFilter]. func (e envoyFilter) GetResponseBody() (io.Reader, bool) { - var vectorSize int - ret := C.envoy_dynamic_module_callback_http_get_response_body_vector_size( + vectorSize := C.envoy_dynamic_module_callback_http_get_body_chunks_size( C.uintptr_t(e.raw), - (*C.size_t)(unsafe.Pointer(&vectorSize)), + C.int(C.envoy_dynamic_module_type_http_body_type_BufferedResponseBody), ) - if !ret { + if vectorSize == 0 { + fmt.Println("GetResponseBody: vectorSize is 0") return nil, false } chunks := make([]envoySlice, vectorSize) - ret = C.envoy_dynamic_module_callback_http_get_response_body_vector( + ret := C.envoy_dynamic_module_callback_http_get_body_chunks( C.uintptr_t(e.raw), - (*C.uintptr_t)(unsafe.Pointer(&chunks[0])), + C.int(C.envoy_dynamic_module_type_http_body_type_BufferedResponseBody), + (*C.envoy_dynamic_module_type_envoy_buffer)(unsafe.Pointer(&chunks[0])), ) if !ret { return nil, false diff --git a/go/javascript.go b/go/javascript.go index 2629b78..5b19052 100644 --- a/go/javascript.go +++ b/go/javascript.go @@ -9,6 +9,7 @@ import ( "sync" "github.com/dop251/goja" + "github.com/envoyproxy/dynamic-modules-examples/go/gosdk" ) diff --git a/go/javascript_test.go b/go/javascript_test.go index eff303b..ff1c490 100644 --- a/go/javascript_test.go +++ b/go/javascript_test.go @@ -4,8 +4,9 @@ import ( "bytes" "testing" - "github.com/envoyproxy/dynamic-modules-examples/go/gosdk" "github.com/stretchr/testify/require" + + "github.com/envoyproxy/dynamic-modules-examples/go/gosdk" ) func Test_newJavaScriptFilterConfig(t *testing.T) { diff --git a/integration/.envoy-version b/integration/.envoy-version new file mode 100644 index 0000000..e4dce85 --- /dev/null +++ b/integration/.envoy-version @@ -0,0 +1 @@ +1.37.0 \ No newline at end of file diff --git a/integration/go.mod b/integration/go.mod index cc0cbe3..c9da86e 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -1,6 +1,6 @@ module github.com/envoyproxy/dynamic-modules-examples/integration -go 1.24.0 +go 1.25.6 require ( github.com/mccutchen/go-httpbin/v2 v2.18.0 @@ -10,11 +10,28 @@ require ( ) require ( + github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/kr/pretty v0.3.1 // indirect + github.com/ebitengine/purego v0.9.0 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/shirou/gopsutil/v4 v4.25.9 // indirect + github.com/tetratelabs/func-e v1.3.0 // indirect + github.com/tklauser/go-sysconf v0.3.15 // indirect + github.com/tklauser/numcpus v0.10.0 // indirect + github.com/ulikunitz/xz v0.5.15 // indirect + github.com/urfave/cli/v2 v2.27.7 // indirect + github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect go.yaml.in/yaml/v2 v2.4.2 // indirect + golang.org/x/sys v0.35.0 // indirect google.golang.org/protobuf v1.36.8 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +tool github.com/tetratelabs/func-e/cmd/func-e diff --git a/integration/go.sum b/integration/go.sum index 11b3c9d..e98bd36 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -1,30 +1,61 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= +github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 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/ebitengine/purego v0.9.0 h1:mh0zpKBIXDceC63hpvPuGLiJ8ZAa3DfrFTudmfi8A4k= +github.com/ebitengine/purego v0.9.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= 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/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= +github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= github.com/mccutchen/go-httpbin/v2 v2.18.0 h1:WFU1OELp3nHYLvXct/3nrGVIgxU0X+RJfDPYRBnvicY= github.com/mccutchen/go-httpbin/v2 v2.18.0/go.mod h1:GBy5I7XwZ4ZLhT3hcq39I4ikwN9x4QUt6EAxNiR8Jus= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= 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/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs= github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shirou/gopsutil/v4 v4.25.9 h1:JImNpf6gCVhKgZhtaAHJ0serfFGtlfIlSC08eaKdTrU= +github.com/shirou/gopsutil/v4 v4.25.9/go.mod h1:gxIxoC+7nQRwUl/xNhutXlD8lq+jxTgpIkEf3rADHL8= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/tetratelabs/func-e v1.3.0 h1:u6FS+ec2hs9vn+vX5X2GEB9JeqCajz/A4rvlsdktnQ4= +github.com/tetratelabs/func-e v1.3.0/go.mod h1:zq1g5hXTBV3rNOXruLeMquQvZse0kscUSQg9NvkUz6U= +github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= +github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= +github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= +github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= +github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY= +github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU= +github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4= +github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg= +github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/integration/main_test.go b/integration/main_test.go index 332849f..b773d7c 100644 --- a/integration/main_test.go +++ b/integration/main_test.go @@ -3,6 +3,7 @@ package main import ( "bytes" "cmp" + "context" "encoding/json" "io" "net/http" @@ -20,20 +21,38 @@ import ( ) func TestIntegration(t *testing.T) { - envoyImage := cmp.Or(os.Getenv("ENVOY_IMAGE"), "envoy-with-dynamic-modules:latest") - cwd, err := os.Getwd() require.NoError(t, err) // Setup the httpbin upstream local server. httpbinHandler := httpbin.New() - server := &http.Server{Addr: ":1234", Handler: httpbinHandler} + server := &http.Server{Addr: ":1234", Handler: httpbinHandler, + ReadHeaderTimeout: 5 * time.Second, IdleTimeout: 5 * time.Second, + WriteTimeout: 5 * time.Second, + } go func() { - if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed { + if err = server.ListenAndServe(); err != nil && err != http.ErrServerClosed { t.Logf("HTTP server error: %v", err) } }() - t.Cleanup(func() { _ = server.Close() }) + defer func() { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + _ = server.Shutdown(ctx) + }() + + // Health check to ensure the server is up before starting tests. + require.Eventually(t, func() bool { + resp, err := http.Get("http://localhost:1234/uuid") + if err != nil { + t.Logf("httpbin server not ready yet: %v", err) + return false + } + defer func() { + _ = resp.Body.Close() + }() + return resp.StatusCode == 200 + }, 10*time.Second, 500*time.Millisecond) // Create a directory for the access logs to be written to. accessLogsDir := cwd + "/access_logs" @@ -41,22 +60,48 @@ func TestIntegration(t *testing.T) { require.NoError(t, os.Mkdir(accessLogsDir, 0o700)) require.NoError(t, os.Chmod(accessLogsDir, 0o777)) - cmd := exec.Command( - "docker", - "run", - "--network", "host", - "-v", cwd+":/integration", - "-w", "/integration", - "--rm", - envoyImage, - "--concurrency", "1", - "--config-path", "/integration/envoy.yaml", - "--base-id", strconv.Itoa(time.Now().Nanosecond()), - ) - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - require.NoError(t, cmd.Start()) - t.Cleanup(func() { require.NoError(t, cmd.Process.Signal(os.Interrupt)) }) + if envoyImage := cmp.Or(os.Getenv("ENVOY_IMAGE")); envoyImage != "" { + cmd := exec.Command( + "docker", + "run", + "--network", "host", + "-v", cwd+":/integration", + "-w", "/integration", + "--rm", + envoyImage, + "--concurrency", "1", + "--config-path", "/integration/envoy.yaml", + "--component-log-level", "dynamic_modules:debug", + "--base-id", strconv.Itoa(time.Now().Nanosecond()), + ) + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + require.NoError(t, cmd.Start()) + t.Cleanup(func() { require.NoError(t, cmd.Process.Signal(os.Interrupt)) }) + } else { + // Now run Envoy with the env variable set for dynamic modules. + cmd := exec.Command("go", // nolint: gosec + "tool", "func-e", "run", + "-c", "envoy.yaml", + "--log-level", "warn", + "--concurrency", "1", + "--component-log-level", "dynamic_modules:debug", + "--base-id", strconv.Itoa(time.Now().Nanosecond()), + ) + + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Env = append(os.Environ(), "ENVOY_DYNAMIC_MODULES_SEARCH_PATH="+cwd) + require.NoError(t, cmd.Start()) + defer func() { + // Send SIGTERM for graceful shutdown + if err := cmd.Process.Signal(os.Interrupt); err != nil { + t.Logf("failed to interrupt envoy: %v", err) + } + time.Sleep(3 * time.Second) + require.NoError(t, cmd.Process.Kill()) + }() + } t.Run("http_access_logger", func(t *testing.T) { t.Run("health checking", func(t *testing.T) { @@ -224,13 +269,12 @@ func TestIntegration(t *testing.T) { defer func() { require.NoError(t, resp.Body.Close()) }() - + body, err := io.ReadAll(resp.Body) + require.NoError(t, err) if resp.StatusCode != http.StatusUnauthorized { t.Logf("unexpected status code: %d", resp.StatusCode) return false } - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) t.Logf("response: status=%d body=%s", resp.StatusCode, string(body)) require.Contains(t, string(body), "Unauthorized by Go Module") return true diff --git a/rust/Cargo.lock b/rust/Cargo.lock index c0460b5..e3e8ee8 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -84,7 +84,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "envoy-proxy-dynamic-modules-rust-sdk" version = "0.1.0" -source = "git+https://github.com/envoyproxy/envoy?rev=dc2d3098ae5641555f15c71d5bb5ce0060a8015c#dc2d3098ae5641555f15c71d5bb5ce0060a8015c" +source = "git+https://github.com/envoyproxy/envoy?rev=6d9bb7d9a85d616b220d1f8fe67b61f82bbdb8d3#6d9bb7d9a85d616b220d1f8fe67b61f82bbdb8d3" dependencies = [ "bindgen", "mockall", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 590df81..3a1c4fc 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/envoyproxy/dynamic-modules-example" [dependencies] # The SDK version must match the Envoy version due to the strict compatibility requirements. -envoy-proxy-dynamic-modules-rust-sdk = { git = "https://github.com/envoyproxy/envoy", rev = "dc2d3098ae5641555f15c71d5bb5ce0060a8015c" } +envoy-proxy-dynamic-modules-rust-sdk = { git = "https://github.com/envoyproxy/envoy", rev = "6d9bb7d9a85d616b220d1f8fe67b61f82bbdb8d3" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" rand = "0.9.0" diff --git a/rust/src/http_access_logger.rs b/rust/src/http_access_logger.rs index e98a0e0..6bc072a 100644 --- a/rust/src/http_access_logger.rs +++ b/rust/src/http_access_logger.rs @@ -77,7 +77,7 @@ impl FilterConfig { impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { + fn new_http_filter(&self, _envoy: &mut EHF) -> Box> { let tx = self.tx.clone(); Box::new(Filter { tx, diff --git a/rust/src/http_header_mutation.rs b/rust/src/http_header_mutation.rs index af3fabc..a066f90 100644 --- a/rust/src/http_header_mutation.rs +++ b/rust/src/http_header_mutation.rs @@ -31,7 +31,7 @@ impl FilterConfig { impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { + fn new_http_filter(&self, _envoy: &mut EHF) -> Box> { Box::new(Filter { request_headers: self.request_headers.clone(), remove_request_headers: self.remove_request_headers.clone(), diff --git a/rust/src/http_metrics.rs b/rust/src/http_metrics.rs index ba1db89..357723b 100644 --- a/rust/src/http_metrics.rs +++ b/rust/src/http_metrics.rs @@ -38,7 +38,7 @@ impl FilterConfig { impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { + fn new_http_filter(&self, _envoy: &mut EHF) -> Box> { Box::new(Filter { version: self.config.version.clone(), start_time: None, diff --git a/rust/src/http_passthrough.rs b/rust/src/http_passthrough.rs index 91d51c2..2a3d1e9 100644 --- a/rust/src/http_passthrough.rs +++ b/rust/src/http_passthrough.rs @@ -21,7 +21,7 @@ impl FilterConfig { impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { + fn new_http_filter(&self, _envoy: &mut EHF) -> Box> { Box::new(Filter {}) } } diff --git a/rust/src/http_random_auth.rs b/rust/src/http_random_auth.rs index 3d697f5..59db1af 100644 --- a/rust/src/http_random_auth.rs +++ b/rust/src/http_random_auth.rs @@ -18,7 +18,7 @@ impl FilterConfig { impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { + fn new_http_filter(&self, _envoy: &mut EHF) -> Box> { Box::new(Filter {}) } } @@ -37,7 +37,7 @@ impl HttpFilter for Filter { ) -> abi::envoy_dynamic_module_type_on_http_filter_request_headers_status { let reject = rand::rng().random::(); if reject { - envoy_filter.send_response(403, vec![], Some(b"Access forbidden")); + envoy_filter.send_response(403, vec![], Some(b"Access forbidden"), None); return abi::envoy_dynamic_module_type_on_http_filter_request_headers_status::StopIteration; } abi::envoy_dynamic_module_type_on_http_filter_request_headers_status::Continue diff --git a/rust/src/http_zero_copy_regex_waf.rs b/rust/src/http_zero_copy_regex_waf.rs index aee115a..7d0f29a 100644 --- a/rust/src/http_zero_copy_regex_waf.rs +++ b/rust/src/http_zero_copy_regex_waf.rs @@ -30,7 +30,7 @@ impl FilterConfig { impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { + fn new_http_filter(&self, _envoy: &mut EHF) -> Box> { Box::new(Filter { re: self.re.clone(), }) @@ -61,7 +61,7 @@ impl HttpFilter for Filter { // [`EnvoyMutBuffer`]s. Each [`EnvoyMutBuffer`] is a mutable buffer that can be // used to read the body data. let data = envoy_filter - .get_request_body() + .get_buffered_request_body() .expect("Failed to get request body"); let mut body_reader = BodyReader::new(data); let matched = self @@ -70,7 +70,7 @@ impl HttpFilter for Filter { .expect("Failed to do regex match"); if matched { // If the regex matches, we send a 403 response. - envoy_filter.send_response(403, vec![], Some(b"Access forbidden")); + envoy_filter.send_response(403, vec![], Some(b"Access forbidden"), None); return abi::envoy_dynamic_module_type_on_http_filter_request_body_status::StopIterationNoBuffer; } abi::envoy_dynamic_module_type_on_http_filter_request_body_status::Continue @@ -136,7 +136,7 @@ mod tests { // End of stream and matching regex, so we should send a 403 response. envoy_filter - .expect_get_request_body() + .expect_get_buffered_request_body() .returning(|| { static mut HELLO: [u8; 6] = *b"Hello "; static mut WORLD: [u8; 6] = *b"World!"; @@ -148,14 +148,14 @@ mod tests { .times(1); envoy_filter .expect_send_response() - .withf(|status, _, _| *status == 403) - .returning(|_, _, _| {}) + .withf(|status, _, _, _| *status == 403) + .returning(|_, _, _, _| {}) .times(1); assert_eq!(filter.on_request_body(&mut envoy_filter, true), abi::envoy_dynamic_module_type_on_http_filter_request_body_status::StopIterationNoBuffer); // End of stream and not matching regex, so we should continue. envoy_filter - .expect_get_request_body() + .expect_get_buffered_request_body() .returning(|| { static mut GOOD: [u8; 5] = *b"Good "; static mut MORNING: [u8; 8] = *b"Morning!";