| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Thanks to the Apache Traffic Server (https://github.com/apache/trafficserver) implementation - i took most of the code from there!
This project (proxy-wasm-cpp-host) provides the host utilities to allow working with runtimes to implement the proxy wasm ABI. The only way to see this code working is integrate it with a proxy (or run the tests). The idea behind writing the proxy-wasm-cli is to create a simple stand-alone utility that can demonstrate the usage of the proxm-wasm-cpp-host code. This was done as an exercise to understand the functionality. The source code for this stand-alone is under src/proxy-wasm-cli and specifically in src/proxy-wasm-cli/proxy_wasm_cli.cc
A real proxy server would be serving HTTP protocol. Adding HTTP support would be a lot more work - so the proxy-wasm-cli utility listens on GRPC (see src/proxy-wasm-cli/proto/proxy_wasm_cli.proto). A client can send GRPC request to create, destroy, modify-settings and also a simple emulation of sending traffic to the VM(s). The proxy_wasm_cli.py client provides a menu driven interface to talk to the GRPC server and demonstrate simple functions. An example application .wasm file is also provided.
The example wasm cpp program is in src/proxy-wasm-cli/example/myproject.cc and the compiled wasm in src/proxy-wasm-cli/example/myproject.wasm
The myproject.wasm was built using these steps:
# First build the builder Docker (one time) git clone https://github.com/proxy-wasm/proxy-wasm-cpp-sdk.git cd /path/to/proxy-wasm-cpp-sdk root@bhakta-ngx-build-vm:/home/bhakta/dev/wasm/proxy-wasm-cpp-sdk# docker build -t wasmsdk:v2 -f Dockerfile-sdk . then build the example (copied from trafficserver repo with some changes): cd src/proxy-wasm-cli/example/ docker run -v $PWD:/work -w /work wasmsdk:v2 /build_wasm.sh
Here are the top-level steps:
Note: You will need to setup the necessary dependencies
run: bazel build //src/proxy-wasm-cli:proxy-wasm-cli
First build the builder image (the docker image that has the necessary dependencies to build the proxy-wasm-cli)
docker build -t proxy-wasm-cli-builder:1.0 .
The above step should build the docker image : 'proxy-wasm-cli-builder:1.0'
Ensure you are in the current folder and the run. The idea of mounting the .bazel-cache is to speed up subsequent builds:
docker run --name proxy-wasm-cli-builder -v $(pwd):/opt/proxy-wasm-cli -v $(pwd)/.bazel-cache:/opt/bazel-cache proxy-wasm-cli-builder:1.0
This should produce the binary in src/proxy-wasm-cli/dist/
The binary can be run on the localhost, or better use the other docker that bundles the proxm-wasm-cli + the necessary python client along with its dependencies.
Follow the steps in src/proxy-wasm-cli/README.md
service WasmHost {
rpc ListInstances (WasmListInstanceRequest) returns (WasmListInstanceReply) {}
rpc LaunchInstance (WasmLaunchInstanceRequest) returns (WasmLaunchInstanceReply) {}
rpc SendTraffic (WasmSendTrafficRequest) returns (WasmSendTrafficReply) {}
rpc WasmSettings (WasmSettingsRequest) returns (WasmSettingsReply) {}
}
[
{"sip": "10.0.0.2", "sp": "50124", "dip": "10.0.0.1", "dp": "443", "scheme": "https", "uri_path": "/content/web/index.html", "method": "GET", "query_params": {"a": "1"}, "headers": {"h1": "v1", "h2": "v2", "D": "5"}, "forward_direction": true, "delta_ms": 0},
{"sip": "10.0.0.1", "sp": "443", "dip": "10.0.0.2", "dp": "50124", "scheme": "https", "uri_path": "/content/web/index.html", "headers": {"rh1": "rv1"}, "forward_direction": false, "delta_ms": 5, "body": "Hello World!"},
{"sip": "10.0.0.2", "sp": "50125", "dip": "10.0.0.1", "dp": "443", "scheme": "https", "uri_path": "/content/web/10bytes.txt", "method": "GET", "headers": {"h11": "v11", "h21": "v21"}, "forward_direction": true, "delta_ms": 10},
{"sip": "10.0.0.1", "sp": "443", "dip": "10.0.0.2", "dp": "50125", "scheme": "https", "uri_path": "/content/web/index.html", "headers": {"rh1": "rv1"}, "forward_direction": false, "delta_ms": 15, "body": "ABCDEFGHI"}
]
| Back | FazBrowse Home | New Git URL |