diff --git a/README.md b/README.md index ef6a59b..862c923 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # grpcreplay GrpcReplay 是一个网络监控工具,可以记录您的 grpc流量(Unary RPC),并将其用于灰度测试、压测或者流量分析。 + +* [English README](https://github.com/vearne/grpcreplay/blob/main/README_en.md) + ## 特性 * 支持过滤器 * 可以解析Protobuf,需要grpc反射,参考[GRPC Server Reflection Protocol](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md#grpc-server-reflection-protocol) @@ -21,7 +24,7 @@ GrpcReplay 是一个网络监控工具,可以记录您的 grpc流量(Unary RPC 参考[encoding](https://github.com/grpc/grpc-go/blob/master/Documentation/encoding.md) 3. gPRC服务端需要开启反射 [GRPC Server Reflection Protocol](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md#grpc-server-reflection-protocol) 4. 只支持Unary RPC,不支持Streaming RPC -5. 需要macOS上需要sudo +5. macOS上需要sudo ``` sudo -s ``` diff --git a/README_en.md b/README_en.md new file mode 100644 index 0000000..6ecd1be --- /dev/null +++ b/README_en.md @@ -0,0 +1,81 @@ +# grpcreplay +GrpcReplay is a network monitoring tool that can record your grpc traffic (Unary RPC) +and use it for grayscale testing, stress testing or traffic analysis. + +## Feature +* support filter +* support to parse Protobuf, requires grpc reflection [GRPC Server Reflection Protocol](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md#grpc-server-reflection-protocol) +* Supports various input and output plugins +* Supports multiple encoding forms of gRPC requests (can be easily extended) +* Support gRPC request replay + +## Principle +1. Since gRPC uses Hpack to compress the header, in order to solve this problem, a mechanism similar to tcpkill +is used to kill the old connection and force the client to initiate a new connection. +2. Use gRPC's reflection mechanism to get the definition of Message so that gRPC requests can be parsed. + +## Architecture +![architecture](https://github.com/vearne/grpcreplay/raw/main/img/grpc.svg) + +## Notice +1. Temporarily only supports h2c, not h2 +2. The current gRPC encoding only supports Protobuf and does not support the use of Compressor. + refer to [encoding](https://github.com/grpc/grpc-go/blob/master/Documentation/encoding.md) +3. The gRPC server needs to enable reflection [GRPC Server Reflection Protocol](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md#grpc-server-reflection-protocol) +4. Only supports Unary RPC, not Streaming RPC +5. Root permissions required on macOS +``` +sudo -s +``` + +## Usage +``` +./grpcr --input-raw="0.0.0.0:35001" --output-stdout +``` +``` +./grpcr --input-raw="127.0.0.1:35001" --output-stdout +``` +``` +./grpcr --input-raw="127.0.0.1:35001" --output-stdout --output-grpc="grpc://127.0.0.1:35002" +``` + +Set the value of codec, optional value: "simple" | "json" +``` +./grpcr --input-raw="127.0.0.1:35001" --output-stdout --codec="simple" +``` +The directory must already exist and be available for writing +``` +./grpcr --input-raw="127.0.0.1:35001" --output-file-directory="/tmp/mycapture" --output-file-max-size=500 +``` +``` +./grpcr --input-file-directory="/tmp/mycapture" --output-stdout --output-grpc="grpc://127.0.0.1:35002" +``` + +## Debug +Set the log level +Optional value: debug | info | warn | error +``` +export SIMPLE_LOG_LEVEL=debug +``` + +## Dependency +This project uses [google/gopacket](https://github.com/google/gopacket) and therefore depends on `libpcap` + +### Thanks +inspired by [fullstorydev/grpcurl](https://github.com/fullstorydev/grpcurl) +and [buger/goreplay](https://github.com/buger/goreplay) + +## TODO +* [x] 1)Discover all connections associated with the target port +* [x] 2)Use bypass blocking to end these connections one by one +* [x] 3)Grab the request on the target port and parse it +* [x] 4)GRPC request replay +* [x] 5)Supports writing GRPC requests to the console +* [x] 6)Support for writing GRPC requests to files +* [ ] 7)Support for writing GRPC requests to kafka +* [ ] 8)Support for writing GRPC requests to RocketMQ +* [x] 9)Support for reading GRPC requests from files +* [ ] 10)Support reading GRPC requests from kafka +* [ ] 11)Support for reading GRPC requests from RocketMQ +* [ ] 12)Support custom filter +* [ ] 13)support TLS