SunnyNet - 网络中间件
SunnyNet 是一个强大的 Python 网络中间件库,提供 HTTP/HTTPS、TCP、UDP 和 WebSocket 代理功能。
功能特性
- 🌐 HTTP/HTTPS 代理: 支持 HTTP 和 HTTPS 请求拦截和修改
- 🔐 SSL/TLS 支持: 内置证书管理,支持 HTTPS 解密
- 🔌 TCP/UDP 代理: 完整的 TCP 和 UDP 连接管理
- 💬 WebSocket 支持: WebSocket 连接拦截和数据处理
- 🎯 进程过滤: 可按进程名称或 PID 进行网络捕获
- 🔧 驱动支持: 支持 NFAPI 和 Proxifier 驱动
- 🎲 JA3 指纹伪装: 支持随机 JA3 指纹,绕过指纹识别
- 📝 脚本支持: 内置脚本编辑器,支持动态脚本
安装
方法 1: 一键安装(推荐,全局可用)
# 安装 Python 包
pip install SunnyNet
# 安装库文件到全局目录(类似 playwright install)
sunnynet install
# 或简写
sunnynet i
优点:
- ✅ 全局安装,所有项目都能使用
- ✅ 类似 Playwright 的使用体验
- ✅ Windows 安装到
%APPDATA%\SunnyNet\lib - ✅ Linux/Mac 安装到
~/.sunnynet/lib
方法 2: 自动安装(项目级别)
pip install SunnyNet
安装时会自动下载库文件到包目录(仅当前虚拟环境可用)
查看安装信息
sunnynet info
显示库文件安装位置和状态。
离线安装
也可以手动放置库文件:
- 下载对应平台的库文件
- 找到安装目录:
python -c "import SunnyNet; import os; print(os.path.dirname(SunnyNet.__file__))"
- 将库文件复制到该目录
支持的库文件:
- Windows:
SunnyNet64.dll/SunnyNet.dll(32位) - Linux:
SunnyNet64.so/SunnyNet.so(32位) - macOS:
SunnyNet64.dylib/SunnyNet.dylib(32位)
快速开始
from SunnyNet.SunnyNet import SunnyNet
from SunnyNet.Event import HTTPEvent
def http_callback(conn: HTTPEvent):
if conn.get_event_type() == conn.EVENT_TYPE_REQUEST:
print(f"请求: {conn.get_url()}")
elif conn.get_event_type() == conn.EVENT_TYPE_RESPONSE:
print(f"响应: {conn.get_url()}")
# 创建实例
app = SunnyNet()
app.set_port(2025)
app.install_cert_to_system()
# 设置回调
app.set_callback(http_callback=http_callback)
# 启动服务
if app.start():
print("SunnyNet 已启动")
app.set_ie_proxy() # 设置系统代理
else:
print(f"启动失败: {app.error()}")
主要模块
SunnyNet - 主中间件类
from SunnyNet.SunnyNet import SunnyNet
app = SunnyNet()
app.set_port(2025) # 设置端口
app.start() # 启动服务
app.stop() # 停止服务
HTTPClient - HTTP 客户端
from SunnyNet.HTTPClient import SunnyHTTPClient
client = SunnyHTTPClient()
client.set_random_tls(True) # 启用随机 TLS 指纹
client.open("GET", "https://example.com")
client.send()
print(client.get_body_string())
CertManager - 证书管理
from SunnyNet.CertManager import CertManager
cert = CertManager()
cert.create("example.com")
print(cert.export_pub_key())
Queue - 消息队列
from SunnyNet.Queue import Queue
queue = Queue("queue_name")
queue.create()
queue.push("message")
print(queue.pull_string())
进阶功能
进程过滤
# 捕获指定进程
app.process_add_name("chrome.exe")
app.process_add_pid(1234)
# 捕获所有进程
app.process_all(True, False)
上游代理
# 设置代理
app.set_proxy("http://127.0.0.1:8888", 30000)
# 设置代理规则
app.set_proxy_rules(".*google.*|.*facebook.*")
驱动模式
# 加载 NFAPI 驱动(需要管理员权限)
if app.open_drive(True):
print("驱动加载成功")
app.process_all(True, False)
事件回调
HTTP 事件
def http_callback(conn: HTTPEvent):
if conn.get_event_type() == conn.EVENT_TYPE_REQUEST:
# 修改请求
conn.get_request().set_header("User-Agent", "Custom UA")
elif conn.get_event_type() == conn.EVENT_TYPE_RESPONSE:
# 处理响应
body = conn.get_response().body_auto_str()
TCP 事件
def tcp_callback(conn: TCPEvent):
if conn.get_event_type() == conn.EVENT_TYPE_SEND:
print(f"TCP 发送: {len(conn.get_body())} 字节")
elif conn.get_event_type() == conn.EVENT_TYPE_RECEIVE:
print(f"TCP 接收: {len(conn.get_body())} 字节")
WebSocket 事件
def ws_callback(conn: WebSocketEvent):
if conn.get_event_type() == conn.EVENT_TYPE_SEND:
print(f"WS 发送: {conn.get_body()}")
elif conn.get_event_type() == conn.EVENT_TYPE_RECEIVE:
print(f"WS 接收: {conn.get_body()}")
系统要求
Windows
- Windows 7 及以上(需要 KB3033929 补丁用于 NFAPI 驱动)
- Python 3.7+
- 管理员权限(驱动模式需要)
Linux
- Python 3.7+
- 需要 SunnyNet64.so 共享库文件
- 注意:Linux版本目前暂不支持驱动模式
macOS
- Python 3.7+
- 需要 SunnyNet64.dylib 动态库文件
- 注意:macOS版本目前暂不支持驱动模式
注意事项
- HTTPS 拦截需要安装证书:
app.install_cert_to_system() - 驱动模式需要管理员权限(仅 Windows)
- NFAPI 驱动在 Windows 7 上需要 KB3033929 补丁
- Proxifier 驱动不支持 UDP 和 32 位系统
- Linux 和 macOS 版本需要相应的共享库文件(.so 或 .dylib)
- 跨平台支持:代码会自动检测操作系统并加载对应的库文件
许可证
MIT License
联系方式
- QQ 群: 751406884
更新日志
v1.3.3 (2025-10-20)
- 🚀 新增 GitHub 镜像加速支持(解决国内下载问题)
- 📊 改进下载进度显示(显示进度条和文件大小)
- 🔄 自动切换镜像源(支持 6 个镜像站,自动重试)
- ⚡ 优化下载体验(更快、更稳定)
- 💡 更友好的错误提示(提供手动下载指引)
v1.3.2 (2025-10-20)
- 🐛 修复 CLI 模块循环依赖问题
- ✅ CLI 工具可独立运行,不触发 DLL 加载
v1.3.1 (2025-10-20)
- 🐛 修复命令行工具加载问题
- ✅ 优化库文件延迟加载机制
- 🔧 修复
pyproject.toml配置,确保命令行工具正确安装 - 💡 改进错误提示,引导用户使用
sunnynet install
v1.3.0 (2025-10-20)
- 🎯 新增 CLI 命令行工具(类似 Playwright)
- ✨ 支持
sunnynet install全局安装库文件 - 🌍 库文件全局可用,所有项目共享
- 📍 Windows:
%APPDATA%\SunnyNet\lib - 📍 Linux/Mac:
~/.sunnynet/lib - 🔍 新增
sunnynet info查看安装状态
v1.2.0 (2025-10-20)
- 🚀 使用 GitHub Releases 下载库文件(无文件大小限制)
- ✅ 完整支持 Windows 和 Linux 平台自动下载
- 🔧 优化下载脚本,支持文件自动重命名
- 📦 改进大文件下载体验
- 🐛 修复 jsDelivr CDN 文件大小限制问题
v1.1.0 (2025-10-20)
- ✨ 新增跨平台支持(Windows、Linux、macOS)
- 🔧 自动检测操作系统并加载对应的库文件
- 📝 优化错误提示,显示详细的平台和路径信息
- 🐛 修复库文件路径查找逻辑
- 📚 更新文档,添加跨平台使用说明
v1.0.0 (2025-04-13)
- 首次发布
- 支持 HTTP/HTTPS、TCP、UDP、WebSocket
- 支持进程过滤
- 支持驱动模式
- 支持 JA3 指纹伪装
Metadata
Release files for SunnyNet 1.5.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sunnynet-1.5.18.tar.gz | 14.9 MB | Without provenance | Details for sunnynet-1.5.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sunnynet-1.5.18-py3-none-any.whl | Python 3 | none | any | Details for sunnynet-1.5.18-py3-none-any.whl |
Total release size: 29.9 MB
Release files / sunnynet-1.5.18.tar.gz
| Download URL | sunnynet-1.5.18.tar.gz |
|---|---|
| Size | 14.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e72acc449ffac5c2765a0ba6cffb72919881fd2e27fddc551f67640ca46b24e5
|
|
BLAKE2b-256 checksum How to use checksums |
4708cc78a2498703bcf9d9a96b82c57018f96bd27d534bff1f37c1c4a3a19464
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / sunnynet-1.5.18-py3-none-any.whl
| Download URL | sunnynet-1.5.18-py3-none-any.whl |
|---|---|
| Size | 15.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
77dc709e5b35e6238e46f1574ef844c50d8510c06e5c2a6d5d662f7c3453267c
|
|
BLAKE2b-256 checksum How to use checksums |
db12b5807de3593d3050ebe604ab27242c03a9110f0249455cd35d8e60e155b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Security for SunnyNet 1.5.18
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.