3 个版本
0.1.2 | 2023 年 10 月 8 日 |
---|---|
0.1.1 | 2023 年 5 月 8 日 |
0.1.0 | 2023 年 5 月 6 日 |
#1930 在 网络编程
20KB
313 行
logged-tcp-proxy
目录
描述
此仓库提供了一个命令行界面,用于将带有负载输出的 TCP 连接代理到控制台。负载输出可以以不同的方式格式化:十六进制(小写和大写)、十进制、八进制和二进制。
安装
从 crates.io (推荐)
运行以下命令并等待 crate 编译完成
$ cargo install logged_tcp_proxy
现在您可以运行编译后的二进制文件
$ logged_tcp_proxy --bind-listener-addr 127.0.0.1:20502 --remote-addr 127.0.0.1:20582
从 Git 仓库
首先使用以下命令克隆项目
$ git clone [email protected]:qwerty541/logged-tcp-proxy.git
然后您需要在项目目录中运行以下命令来编译 crate
$ cargo build
现在您可以运行编译后的二进制文件
$ ./target/debug/logged_tcp_proxy --bind-listener-addr 127.0.0.1:20502 --remote-addr 127.0.0.1:20582
选项
以下是当前支持选项的列表。
$ logged_tcp_proxy --help
Command line interface for proxying TCP connections with payload output into console which can be formatted different ways.
Usage: logged_tcp_proxy [OPTIONS] --bind-listener-addr <BIND_LISTENER_ADDR> --remote-addr <REMOTE_ADDR>
Options:
-l, --level <LEVEL>
Application logging level [default: debug] [possible values: trace, debug, info, warn, error, off]
-b, --bind-listener-addr <BIND_LISTENER_ADDR>
Address on which TCP listener should be binded
-r, --remote-addr <REMOTE_ADDR>
Address of remote server
-t, --timeout <TIMEOUT>
Incoming connection reading timeout [default: 60]
-f, --formatting <FORMATTING>
Formatting of console payload output, [default: lowerhex] [possible values: decimal, lowerhex, upperhex, binary, octal]
-s, --separator <SEPARATOR>
Console payload output bytes separator [default: :]
-p, --precision <PRECISION>
Timestamp precision [default: seconds] [possible values: seconds, milliseconds, microseconds, nanoseconds]
-h, --help
Print help
-V, --version
Print version
示例
以下是一个使用此命令行工具作为设备和数据存储服务器之间代理的示例,包括命令和控制台输出。
$ logged_tcp_proxy --bind-listener-addr 127.0.0.1:20502 --remote-addr 127.0.0.1:20582
[2023-05-04T02:39:33Z INFO] Listener binded, waiting for incoming connections...
[2023-05-04T02:39:37Z INFO] Incoming connection from 127.0.0.1:50376
[2023-05-04T02:39:37Z DEBUG] < 00:00:00:00:00:19:6f:03:16:00:1f:00:20:00:11:00:22:00:33:00:44:00:55:00:66:00:01:00:00:00:00
[2023-05-04T02:39:37Z DEBUG] > 00:00:00:00:00:0b:6f:10:03:f1:00:02:04:00:00:00:00
[2023-05-04T02:39:37Z DEBUG] < 00:00:00:00:00:06:6f:10:03:f1:00:02
[2023-05-04T02:39:37Z DEBUG] > 00:01:00:00:00:06:6f:03:00:7a:00:01:00:02:00:00:00:06:6f:03:00:7b:00:02
[2023-05-04T02:39:37Z DEBUG] < 00:01:00:00:00:05:6f:03:02:02:ff:00:02:00:00:00:07:6f:03:04:00:00:00:01
[2023-05-04T02:39:37Z DEBUG] > 00:03:00:00:00:06:01:01:00:01:00:01:00:04:00:00:00:06:01:02:00:01:00:01:00:05:00:00:00:06:01:03:00:01:00:10:00:06:00:00:00:06:01:03:00:11:00:01:00:07:00:00:00:06:01:03:00:7b:00:01:00:08:00:00:00:06:01:03:0f:a0:00:01:00:09:00:00:00:06:01:03:13:88:00:03:00:0a:00:00:00:06:01:04:00:01:00:01
[2023-05-04T02:39:37Z DEBUG] < 00:03:00:00:00:04:01:01:01:01:00:04:00:00:00:04:01:02:01:01:00:05:00:00:00:23:01:03:20:00:7b:00:0c:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:01:36:40:49:0f:db:40:09:21:fb:54:44:2d:18:ff:ff:00:06:00:00:00:05:01:03:02:ff:ff:00:07:00:00:00:05:01:03:02:00:01:00:08:00:00:00:03:01:83:02:00:09:00:00:00:09:01:03:06:00:01:00:02:00:03:00:0a:00:00:00:05:01:04:02:00:7b
[2023-05-04T02:40:18Z DEBUG] > 00:0b:00:00:00:06:6f:03:03:e8:00:01
[2023-05-04T02:40:18Z DEBUG] < 00:0b:00:00:00:05:6f:03:02:00:00
许可证
许可协议为以下之一
- Apache 许可协议第 2 版 (LICENSE-APACHE 或 https://www.apache.org/licenses/LICENSE-2.0)
- MIT 许可协议 (LICENSE-MIT 或 https://opensource.org/licenses/MIT)
由您选择。
贡献
除非您明确声明,否则您有意提交以包含在作品中的任何贡献,根据 Apache-2.0 许可证的定义,将双重许可如上所述,不附加任何额外条款或条件。
依赖项
~8–19MB
~230K SLoC