跳转到主要内容

Python库和CLI,用于运行描述每个帧的HTTP/2代理

项目描述

tcp-h2-describe

Python库和CLI,用于运行描述每个帧的HTTP/2代理

安装

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
...

还可以自定义tcp-h2-describe代理运行的端口以及被代理的远程服务器

$ 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代码中使用

import tcp_h2_describe

proxy_port = 13370
server_port = 50051
tcp_h2_describe.serve_proxy(proxy_port, server_port)

# OR: Spawn a thread to avoid blocking
import threading

server_thread = threading.Thread(
    target=tcp_h2_describe.serve_proxy,
    args=(proxy_port, server_port),
)
server_thread.start()

请参阅代理HTTP服务器gRPC服务器时的示例输出。此外,tcp-h2-describe代理支持代理协议

开发

要添加功能或运行测试,请参阅开发文档以获取有关如何开始的更多信息。

许可证

tcp-h2-describe在Apache 2.0许可证下提供。有关更多详细信息,请参阅许可证

项目详情


下载文件

下载您平台对应的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

tcp-h2-describe-0.1.0.tar.gz (19.1 kB 查看哈希值)

上传于

构建分布

tcp_h2_describe-0.1.0-py2.py3-none-any.whl (24.2 kB 查看哈希值)

上传于 Python 2 Python 3

支持