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.3。 Windows 全量测试 176 项通过(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 bash scripts/bootstrap-server.sh

(脚本在仓库里保留了可执行位,sudo ./scripts/bootstrap-server.sh 同样可用; 用 bash 调用可以避免因 clone/拷贝丢失可执行位而失败。)

已经装好 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.3

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.3
File Size Uploaded Provenance Actions
norain-0.2.3.tar.gz 193.1 kB With provenance Details for norain-0.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 367.8 kB

Release files / norain-0.2.3.tar.gz

Download URL norain-0.2.3.tar.gz
Size 193.1 kB
Tags Source
SHA-256 checksum
How to use checksums
51d2e7b305e8b31b4344eca94402e74237aa9e8ebcc0a441c3b79ff932334709
BLAKE2b-256 checksum
How to use checksums
a61bea03076e6cc451adba905ef55157f30d3893c3d9f4da9cb6c68e66e9ddce
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 19, 2026.

Transparency log

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

Download URL norain-0.2.3-py3-none-any.whl
Size 174.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe8b93482827a8a4ceef537d8b831e78b140a07248e1ab57d67653dd6e507a37
BLAKE2b-256 checksum
How to use checksums
34fcdeb50292385e2da611d142eabe40cc244930ec912d6b868229b9f00fc790
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 19, 2026.

Transparency log

Security for norain 0.2.3

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.3.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 19, 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