ADP Operator
C2C 连接首包
C2C TCP 连接建立后,双方必须先交换固定长度的二进制首包。首包校验通过后,连接才允许继续处理 JSON 业务指令。
首包固定为 512 bit,结构如下:
| bit 偏移 | bit 长度 | 字段 | 规则 |
|---|---|---|---|
| 0 | 24 | 固定标识 | 三个 ASCII 字符 ADP |
| 24 | 16 | 协议版本 | 16-bit 无符号整数,使用大端序,当前版本为 7 |
| 40 | 256 | 实例编号 | 当前节点的 instance_id,固定32字节 |
| 296 | 8 | 功能控制区 | bit 0–2为功能开关,bit 3–7为保留位 |
| 304 | 208 | 全零保留区 | 必须全部为 0 |
字符串字段统一使用 UTF-8 编码。字段长度不足时在尾部使用 0x00 填充,超过字段长度时按字段长度截断。
功能控制区
功能控制区固定为8 bit,每个功能占用一个 bit:
| bit | 功能 | 0 |
1 |
当前默认值 |
|---|---|---|---|---|
| 0 | UDP 主动发现 | 关闭 | 开启 | 1 |
| 1 | 额外 channel 通道 | 不支持 | 支持 | 1 |
| 2 | WebSocket 业务端口 | 关闭 | 开启 | 1 |
| 3–7 | 保留位 | 必须为零 | 不允许 | 0 |
当前默认控制区的二进制内容为:
00000111
握手流程
- TCP 客户端连接 C2C 服务端。
- 客户端发送自己的 512 bit 二进制首包。
- 服务端读取并校验完整首包。
- 服务端校验通过后,向客户端返回自己的 512 bit 二进制首包。
- 客户端校验服务端首包。
- 双方校验均通过后,才开始发送 JSON 业务指令。
服务端会拒绝以下连接:
- 首包长度不足 512 bit;
- 固定标识不是
ADP; - 目标节点协议版本低于发起连接节点的协议版本;
instance_id为空;- 字符串字段的补零格式错误;
- 功能控制区保留位非零;
- 208 bit 全零保留区存在非零数据。
该首包适用于 C2C 直连、反向连接、多跳转发、额外 channel 通道、外部 C2CSession 和本地服务探测。未实现该二进制首包的旧节点无法与新协议节点建立连接,因此升级时需要同时更新同一网络中的全部 C2C 节点。
协议版本字段固定为16 bit,使用大端序表示无符号整数,取值范围为 0–65535。客户端收到服务端首包后比较版本:目标节点版本大于或等于本机版本时允许连接,目标节点版本低于本机版本时拒绝连接。例如本机版本为 4、目标版本为 5 时允许连接;本机版本为 5、目标版本为 4 时拒绝连接。
Metadata
Release files for adp-operator 1.0.8
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 |
|---|---|---|---|---|
| adp_operator-1.0.8.tar.gz | 88.7 kB | Without provenance | Details for adp_operator-1.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adp_operator-1.0.8-py3-none-any.whl | Python 3 | none | any | Details for adp_operator-1.0.8-py3-none-any.whl |
Total release size: 202.5 kB
Release files / adp_operator-1.0.8.tar.gz
| Download URL | adp_operator-1.0.8.tar.gz |
|---|---|
| Size | 88.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
777581644a68f93a70c4272a7aa812516342f1d1788527409b49e228a08d3b1d
|
|
BLAKE2b-256 checksum How to use checksums |
7d062143c00809c8d7e45f176fa3a692abf6d9e30be6bbadbb86e25ee5d51f49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.13
|
Release files / adp_operator-1.0.8-py3-none-any.whl
| Download URL | adp_operator-1.0.8-py3-none-any.whl |
|---|---|
| Size | 113.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
804a8e3c15c0c36d4d442812cdeb7a82a1bcfaf11ab2cbc67ba2729f94165074
|
|
BLAKE2b-256 checksum How to use checksums |
55a559b813f4a64b0ba7de4220057c52e7cef1e2538acffb15ba48a949cc71bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.13
|
Security for adp-operator 1.0.8
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.