teamgram-gnetway-gateway

Documents the gnetway network gateway layer in Teamgram Server, covering TCP/WS/HTTP listeners, connection lifecycle, MTProto decryption, QuickAck, and session dispatch.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "teamgram-gnetway-gateway" with this command: npx skills add zhihang9978/teamgram-gnetway-gateway

网络层:gnetway(interface.gateway)

监听端口与协议

来自配置 teamgramd/etc/gnetway.yaml

Gnetway:
  Server:
    - Proto: tcp
      Addresses:
        - 0.0.0.0:10443
        - 0.0.0.0:5222
    - Proto: websocket
      Addresses:
        - 0.0.0.0:11443
协议端口说明
TCP0.0.0.0:10443主要 MTProto TCP 端口
TCP0.0.0.0:5222备用 TCP 端口
WebSocket0.0.0.0:11443WebSocket 连接入口
  • gnetway 通过 etcd 发现 session:Key: interface.session

连接生命周期

OnOpen

  • 根据本地监听地址判断连接类型(tcp/ws/http)
  • 创建 connContext
  • 设置 closeDate
  • 放入 timewheel 管理超时

OnClose

  • 对非 HTTP 连接,如果已存在 perm_auth_key
  • 通知 session.CloseSession(回收会话、清理在线状态等)

加密消息处理流程

收到加密数据
  → authKey.AesIgeDecrypt 解密
  → 提取 salt、sessionId、msgId
  → SessionDispatcher.SendData (gRPC) 转发给 session 服务

核心点:

  • 通过 authKey.AesIgeDecrypt 解密
  • 从解密后 payload 头部提取:saltsessionIdmsgId
  • 通过 SessionDispatcher.SendData(gRPC)把 payload[16:] 转发给 session

auth_key 缓存与 QueryAuthKey

当 connContext 中没有 authKey(首次连接或缓存未命中):

  1. 异步调用 session 的 QueryAuthKey
  2. 获取 authKey 后存入 connContext
  3. 执行 onEncryptedMessage 处理加密消息

QuickAck

QuickAck token 通过 SHA256(authKey[88:120] + encryptedData) 前 4 字节计算,最高位置 1。 必须通过 codec 编码发送,否则 obfuscated CTR 计数器不同步,导致客户端解密失败。

关键代码路径

  • 主服务入口:app/interface/gnetway/
  • gnet 服务器实现:app/interface/gnetway/internal/server/gnet/server_gnet.go
  • 配置文件:teamgramd/etc/gnetway.yaml

Source Code References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Google Classroom

Google Classroom API integration with managed OAuth. Manage courses, assignments, students, teachers, and announcements. Use this skill when users want to cr...

Registry SourceRecently Updated
General

GetResponse

GetResponse API integration with managed OAuth. Manage email marketing campaigns, contacts, newsletters, autoresponders, and segments. Use this skill when us...

Registry SourceRecently Updated
General

Antenna

Inter-host OpenClaw session messaging over reachable HTTPS using built-in gateway webhook hooks. Use when: (1) sending a message from this OpenClaw instance...

Registry SourceRecently Updated
General

Buffer

Buffer API integration with managed authentication. Schedule and manage social media posts across multiple platforms. Use this skill when users want to sched...

Registry SourceRecently Updated