8个版本

0.2.1 2023年8月6日
0.2.0 2020年5月10日
0.1.5 2020年2月6日
0.1.4 2018年5月19日
0.1.1 2018年4月23日

#57 in WebSocket

每月 23 次下载

MIT 许可证

44KB
1K SLoC

wstcp

wstcp Documentation Actions Status License: MIT

用Rust编写的WebSocket到TCP代理。

安装

预编译的二进制文件

Linux环境下的预编译二进制文件可在发布页面找到。

$ curl -L https://github.com/sile/wstcp/releases/download/0.2.0/wstcp-0.2.0.linux -o wstcp
$ chmod +x wstcp
$ ./wstcp -h
wstcp 0.2.0
WebSocket to TCP proxy server

USAGE:
    wstcp [OPTIONS] <REAL_SERVER_ADDR>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --bind-addr <BIND_ADDR>    TCP address to which the WebSocket proxy bind [default: 0.0.0.0:13892]
        --log-level <LOG_LEVEL>     [default: info]  [possible values: debug, info, warning, error]

ARGS:
    <REAL_SERVER_ADDR>    The TCP address of the real server

使用Cargo

如果您已经安装了Cargo,您可以使用以下命令轻松安装wstcp

$ cargo install wstcp

示例

在终端中运行wstcp

$ wstcp 127.0.0.1:3000
Apr 22 23:21:20.717 INFO Starts a WebSocket proxy server, server_addr: 127.0.0.1:3000, proxy_addr: 0.0.0.0:13892

在另一个终端中运行TCP服务器(在这个例子中使用了nc

$ nc -l 127.0.0.1 -p 3000

使用ws启动WebSocket客户端

$ ws ws://127.0.0.1:13892/
> foo # Enter "foo" and press the Enter key

然后,"foo"字符串将在运行nc的终端上显示。

参考

依赖项

~14–29MB
~393K SLoC