参考 Python 脚本如下,
```
# -*- coding: utf-8 -*-
# 2023/2/7
# create by: snower
import sevent
PORT = 80
SSH_ADDRES = ("127.0.0.1", 2222)
HTTP_ADDRES = ("127.0.0.1", 8080)
HTTPS_ADDRES = ("127.0.0.1", 4443)
async def do_tcp_port_forward(conn):
buffer = await conn.recv()
data = buffer.join()
forward_address = HTTP_ADDRES
if b'SSH' == data[:3]:
forward_address = SSH_ADDRES
elif b'\x16\x03' == data[:2]:
forward_address = HTTPS_ADDRES
pconn = sevent.tcp.Socket()
pconn.enable_nodelay()
pconn.connect(forward_address)
conn.link(pconn)
async def tcp_port_forward_server():
server = sevent.tcp.Server()
server.enable_reuseaddr()
server.enable_nodelay()
server.listen(("0.0.0.0", PORT))
while True:
conn = await server.accept()
sevent.go(do_tcp_port_forward, conn)
sevent.run(tcp_port_forward_server)
```
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传