Skip to main content

度朔·服务端

度朔山、度灵欢,引入鬼门关。

上古之人,有神荼、鬱壘者,昆弟二人,性能執鬼,居東海度朔山上,立桃樹下,簡閱百鬼。 —— 汉·王充《論衡·亂龍》

度朔是一个通过监控数字活动来进行生死判断并执行亡语命令的系统。

若我在某一刻停止了一切数字生活,这样的情况达到一定的时间,则我便已死亡。若我死亡,我的亡语将被执行。

本仓库为度朔系统的服务端,提供纯后端 HTTP 接口。

若需使用,应搭配度朔系统的客户端。

功能

客户端监测用户的数字活动数据,将数据上传至服务端,服务端收到任意客户端的数字活动之后,会刷新一个死亡判定倒计时。

当倒计时结束,服务端将执行客户端上传的命令作为最终任务。

启动

安装依赖

  1. 使用 uv:
uv sync # 可通过 `--extra dev` 参数安装开发测试依赖

启动服务

  1. 使用 uv:
uv run dushuoserver
  1. 纯 Python:
python -m dushuoserver
  1. 也可以直接使用 Uvicorn:
uvicorn dushuoserver.app:app --app-dir src --host 0.0.0.0 --port 18470
  1. 也可以通过 pip 安装本项目,并使用命令行入口启动:
pip install .
dushuoserver --help

查看参数

在启动指令后增加 --help 参数查看参数说明,例如:

dushuoserver --help

配置

服务端启动时,读取配置参数的优先级为:默认配置 < 配置文件 < 命令行参数 < 服务端现有数据库

其中,数据库仅会存储运行时参数。以下是默认配置文件:

host_address = "0.0.0.0"    # 服务端地址
host_port    = 18470        # 服务端端口
log_level    = "info"      # 全局日志等级,可以是 DEBUG, INFO, WARNING, ERROR, CRITICAL
db_path      = "dushuodb.sqlite3" # 数据库路径

[uvicron]
    workers    = 1  # uvicorn 工作进程数
    hot_reload  = false  # 是否开启热重载
    access_log = true   # 是否开启访问日志

[runtime]   # 运行时参数可在服务端启动后更改,从配置文件读取之后,也会在数据库中重新读取一遍,优先级为 数据库 > 命令行传参 > 配置文件 > 默认参数
    activity_cache_duration = 86400 # 客户端活动消息的缓存时长(秒)
    death_countdown         = 86400 # 死亡判定倒计时(秒)
    execution_task          = ""    # 最终任务执行命令
    message_cache_duration  = 3600  # 短报文缓存时长(秒)
    pairing_window_time     = 300   # 配对窗口时长(秒)
    signature_time_tolerance = 300  # 签名时间容差(秒)

启动服务时,可以在命令行通过 --config 参数指定配置文件路径,例如:

dushuoserver --config /path/to/config.toml

执行服务端程序时,可通过 --help 查看参数说明。

API

详见 接口文档 。除 /health 与配对相关接口外,所有业务接口均需要先在配对窗口内完成配对,之后以客户端私钥对请求签名(签名置于 X-Client-Id、X-Timestamp、X-Signature 三个请求头中),由服务端以配对时登记的公钥校验。

Metadata

Release files for DushuoServer 0.1.0

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

Source distribution (sdist)

Source distribution for DushuoServer 0.1.0
File Size Uploaded Provenance Actions
dushuoserver-0.1.0.tar.gz 27.0 kB Without provenance Details for dushuoserver-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 54.9 kB

Release files / dushuoserver-0.1.0.tar.gz

Download URL dushuoserver-0.1.0.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
330d3b2cd10df46d801c1a2141580b0b0a5bab78925184e8e3203a5ef1192d22
BLAKE2b-256 checksum
How to use checksums
9251e5a88114ba6764f50a9d3228e19c27bc9cd71f48026942f91fdf58421b8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / dushuoserver-0.1.0-py3-none-any.whl

Download URL dushuoserver-0.1.0-py3-none-any.whl
Size 28.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f90c5fad6560483bacb9d42436711fe85a7ac27878a6970e1819a2f54fa5c0d
BLAKE2b-256 checksum
How to use checksums
1cc640887495bbb83685d8d9d4a853eae8d1996944a3acac2634a7ee795af5f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for DushuoServer 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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