用于运行描述每个帧的http/2代理的python库和cli
tcp-h2-describe的Python项目详细描述
tcp-h2-describe
Python library and CLI for running an HTTP/2 proxy that describes each frame
安装
python3 -m pip install --upgrade tcp-h2-describe
用法
例如,在运行本地HTTP/2服务器的计算机上 端口50051:
$ tcp-h2-describe --server-port 50051
Starting tcp-h2-describe proxy server on port 24909
Proxying server located at localhost:50051
...
$ # OR
$ python -m tcp_h2_describe --server-port 50051
Starting tcp-h2-describe proxy server on port 24909
Proxying server located at localhost:50051
...
选项还存在自定义^ ^ {CD1>}代理的端口 运行以及代理的远程服务器:
$ python -m tcp_h2_describe --help
usage: tcp-h2-describe [-h] [--proxy-port PROXY_PORT]
[--server-host SERVER_HOST] [--server-port SERVER_PORT]
Run `tcp-h2-describe` reverse proxy server. This will forward traffic to a
proxy port along to an already running HTTP/2 server. For each HTTP/2 frame
forwarded (either client->server or server->client) a description will be
printed to the console explaining what each byte in the frame means.
optional arguments:
-h, --help show this help message and exit
--proxy-port PROXY_PORT
The port that will be used for running the "describe"
proxy. (default: 24909)
--server-host SERVER_HOST
The hostname for the server that is being proxied.
(default: None)
--server-port SERVER_PORT
The port for the server that is being proxied.
(default: 80)
直接从python代码中使用
importtcp_h2_describeproxy_port=13370server_port=50051tcp_h2_describe.serve_proxy(proxy_port,server_port)# OR: Spawn a thread to avoid blockingimportthreadingserver_thread=threading.Thread(target=tcp_h2_describe.serve_proxy,args=(proxy_port,server_port),)server_thread.start()
代理HTTP server和gRPC server时请参见示例输出。
另外,tcp-h2-describe
代理支持proxy protocol。
开发
要添加功能或运行测试,请参见DEVELOPMENT doc 有关如何开始的详细信息。
许可证
tcp-h2-describe
在apache 2.0许可下可用。更多
详细信息,请参见LICENSE。