Skip to main content

Norain

PyPI Python License: MIT

基于 sing-box 的 Hysteria2 / Trojan 代理:客户端 norain 和服务端 norain-server,Python 做控制层, sing-box 做数据面,兼容 Windows 和 Linux。

安装

pip install norain

同一个包提供两个命令:norain(客户端)和 norain-server(服务端)。

当前状态:0.2.1。两端模块代码齐备;测试套件在 Windows 上 117 项通过(3 项仅 POSIX 跳过)。 已在真实环境验证过的部分:生成配置通过真实 sing-box 1.14.4 check、本地端到端隧道、TUN 路由接管与还原、 Windows 防火墙阻断与解除、nftables 阻断、系统代理写入与还原、服务端 install/reload/fix/update/uninstall、 systemd 开机自启(真实重启)、真实 ACME 签发。仍未验证:客户端与 Linux 的安装流程、TUN 的实际流量、 监控错误码、自维持互拉、分流学习闭环。逐项见 docs/pending.md。

优先级:以最初目标 docs/reference/original-goals.md 为准,除非有硬性 bug。

客户端(九个模块)

代理、分流、监控、自维持、阻断、修复、启动、内控制、外控制。

norain install --server example.com     # 部署:sing-box、配置、norain 命令、环境变量、开机自启动
norain start | stop | restart | status
norain config protocol auto             # 自适应 / hysteria2 / trojan
norain config mode safe                 # 安全模式:不开机自启动
norain list white add example.com       # 白名单 / black 黑名单 / blue 蓝名单 / monitor 监控名单
norain module monitor restart           # 启动 / 结束 / 重启单个模块
norain repair file|builtin|full|reload  # 四种修复
norain block status|off                 # 阻断模式;off = 手动解除(未修复时需 --force)
norain once monitor                     # 一次性执行某个模块的某个功能
norain status -t                        # -t:显示每个模块的运行情况和返回结果
norain uninstall

服务端

干净机器上可以直接用引导脚本(系统依赖 → 虚拟环境 → 安装包 → norain-server install):

sudo ./scripts/bootstrap-server.sh

已经装好 Python 与 venv 时,照常手动安装:

NORAIN_DOMAIN=example.com NORAIN_PASSWORD=… norain-server install
norain-server start | stop | restart | reload | status
norain-server config validate|show|edit
norain-server cert check | cert self-signed --domain <域名>
norain-server firewall open|close|status
norain-server fix
norain-server update | uninstall [--purge]

文档

开发

需要 Python ≥ 3.11,以及 pydantic、cryptography、psutil。

pip install -e ".[dev]"
python3 -m pytest -q

Metadata

Release files for norain 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for norain 0.2.1
File Size Uploaded Provenance Actions
norain-0.2.1.tar.gz 165.0 kB With provenance Details for norain-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for norain 0.2.1
File Interpreter ABI Platform Actions
norain-0.2.1-py3-none-any.whl Python 3 none any Details for norain-0.2.1-py3-none-any.whl

Total release size: 329.1 kB

Release files / norain-0.2.1.tar.gz

Download URL norain-0.2.1.tar.gz
Size 165.0 kB
Tags Source
SHA-256 checksum
How to use checksums
da434da5f0ae149481b8ce5ca69c16aa22c1dded771c64f6bc5135b945a43760
BLAKE2b-256 checksum
How to use checksums
72900fd0abefd6edaf9f36d164d9c891d5d93ba7c45874d0fa7431aba0afa38a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / norain-0.2.1-py3-none-any.whl

Download URL norain-0.2.1-py3-none-any.whl
Size 164.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f54fdf5911b51d1aa0ac7a5c9ee5ce80e18794af004614417b77d9a8407fbacd
BLAKE2b-256 checksum
How to use checksums
87f265cf2fcb217e4dfa1ab978cc330f0dffed28677308fcf66ddede34a15997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for norain 0.2.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for norain-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page