Skip to main content

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

握手流程

  1. TCP 客户端连接 C2C 服务端。
  2. 客户端发送自己的 512 bit 二进制首包。
  3. 服务端读取并校验完整首包。
  4. 服务端校验通过后,向客户端返回自己的 512 bit 二进制首包。
  5. 客户端校验服务端首包。
  6. 双方校验均通过后,才开始发送 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.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 adp-operator 1.1.0
File Size Uploaded Provenance Actions
adp_operator-1.1.0.tar.gz 108.5 kB Without provenance Details for adp_operator-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adp-operator 1.1.0
File Interpreter ABI Platform Actions
adp_operator-1.1.0-py3-none-any.whl Python 3 none any Details for adp_operator-1.1.0-py3-none-any.whl

Total release size: 251.9 kB

Release files / adp_operator-1.1.0.tar.gz

Download URL adp_operator-1.1.0.tar.gz
Size 108.5 kB
Tags Source
SHA-256 checksum
How to use checksums
89c753c79ee8c9431a9d45aecc1fb0de1f5de3d881ee70c1a091b3cd757d9afb
BLAKE2b-256 checksum
How to use checksums
1d086d054bb7c628379c51eadce90a2473dc0708dce344d3c217059b5de62a86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.13

Release files / adp_operator-1.1.0-py3-none-any.whl

Download URL adp_operator-1.1.0-py3-none-any.whl
Size 143.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbc96663b6b67b6f8ef605628f6b1cc1f23ae81131da9b6cd99a026c335fd176
BLAKE2b-256 checksum
How to use checksums
b388daee1ff7639ee7b5ed8ce67d69492cba6f548c84474b24858b8102a56f1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.13

Security for adp-operator 1.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.

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