Skip to content

Commit

Permalink
Merge pull request #4 from vearne/dev
Browse files Browse the repository at this point in the history
update README
  • Loading branch information
vearne authored Oct 17, 2022
2 parents 85a3357 + 36edba7 commit e2d8989
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
```
Expand Down
81 changes: 81 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e2d8989

Please sign in to comment.