Token导航 LogoToken导航TokenDH.com
研究检索需要联网clawhub未标认证来源可访问clear审计通过

teamgram-mtproto-protocolteamgram mtproto 协议

Agent Skill

teamgram-mtproto-protocol 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

6,288

周安装

262

GitHub Stars

公开资料未说明

下载量

2,096
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:teamgram-mtproto-protocol(teamgram mtproto 协议)
来源仓库:https://github.com/zhihang9978/teamgram-mtproto-protocol
安装命令:
openclaw skills install teamgram-mtproto-protocol
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install teamgram-mtproto-protocol

简介

记录 MTProto 协议握手、加解密与密钥缓存逻辑。

  • 包含 QuickAck 机制与消息转发路由规则。
  • 适合实现 Telegram 兼容客户端或服务端开发。
  • 涉及密码学算法需谨慎处理密钥安全存储。
  • 不提供第三方库集成方案推荐。teamgram-mtproto-protocol 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

name
teamgram-mtproto-protocol
description
Documents the MTProto protocol handling layer in Teamgram Server, including handshake, AES-IGE decryption, QuickAck, auth_key caching, and message forwarding to session service. Reference-only knowledge skill for developers working on Telegram-compatible backends.
compatibility
This is a documentation/knowledge skill only. No executable code is included. It describes Teamgram Server internals for developer reference.
metadata
author
zhihang9978
version
1.0.1
source
https://github.com/teamgram/teamgram-server
homepage
https://github.com/teamgram/teamgram-server
openclaw
requires
env
[]
bins
[]
securityNotes
|

MTProto Protocol Layer in Teamgram Server

Skill Type

This is a reference/knowledge skill. It contains no executable code. It documents the MTProto protocol handling internals of Teamgram Server (open-source, Apache-2.0 licensed) for developers who need to understand, debug, or extend the protocol layer.

Overview

KHF client and Teamgram Server communicate via Telegram's MTProto binary protocol. The Teamgram gateway layer (gnetway) performs 3 key operations:

  1. Handshake / auth_key generation (unauthenticated phase: auth_key_id=0 -> handshake)
  2. Authenticated message decryption (AES-IGE)
  3. Forward decrypted payload (TLMessage2.Object) to session service via gRPC

Runtime Environment (for Teamgram Server operators)

If you are deploying Teamgram Server (not just reading this skill), the MTProto layer requires:

ComponentPurposeConfiguration
gnetway serviceTCP/WS gateway, listens on ports 10443/5222/11443app/interface/gnetway/etc/gnetway.yaml
session serviceManages auth sessions, routes RPCsapp/interface/session/etc/session.yaml
MySQLStores auth_key records (auth_keys, auth_key_infos tables)Configured in service YAML files
RedisCaches auth_key for fast lookupConfigured in service YAML files
etcdService discovery between gnetway and sessionetcd.hosts in YAML config

No credentials are required to read or install this skill. The above table is for reference only when operating the actual Teamgram Server.

Core Data Structure

The decrypted data structure is mtproto.TLMessage2, whose Object field contains the specific TL RPC call (e.g., auth.sendCode, messages.sendMessage, etc.).

QuickAck Mechanism

gnetway implements QuickAck token computation. ACKs must be encoded through the codec to avoid obfuscated CTR counter desync (otherwise Android clients will fail at decryptServerResponse).

Reference function (from app/interface/gnetway/internal/server/gnet/server_gnet.go:298-305 in teamgram-server):

func computeQuickAckToken(authKey []byte, encryptedData []byte) uint32 {
    h := sha256.New()
    h.Write(authKey[88 : 88+32])
    h.Write(encryptedData)
    var sum [32]byte
    h.Sum(sum[:0])
    return binary.LittleEndian.Uint32(sum[:4]) | 0x80000000
}

Encrypted Message Processing Flow

  1. Decrypt via authKey.AesIgeDecrypt
  2. Extract from decrypted payload header: salt, sessionId, msgId
  3. Forward payload[16:] to session service via SessionDispatcher.SendData (gRPC)

auth_key Caching and QueryAuthKey

When connContext lacks an authKey, gnetway asynchronously calls the session service's QueryAuthKey RPC, then proceeds with onEncryptedMessage after receiving the key.

Key management note: auth_keys are generated during the DH handshake, stored in MySQL (auth_keys table), and cached in Redis. They are never exposed outside the server process. The gnetway service holds keys only in memory during active connections.

KHF Client Protocol Constants (must match server)

Extracted from KHF client source code:

  • TLRPC.LAYER = 222
  • BuildVars.APP_ID = 4
  • BuildVars.APP_HASH = "014b35b6184100b085b0d0572f9b5103"

These are public application identifiers, not secrets. They must match between client and server for TL schema compatibility.

Important Notes

  • QuickAck must be encoded through codec, otherwise obfuscated CTR counter will desync
  • Messages with auth_key_id=0 go through handshake flow; non-zero go through decryption flow
  • After AES-IGE decryption, the first 16 bytes of payload are salt+sessionId, followed by TLMessage2 data

Source Code References

All code referenced in this skill is from the open-source Teamgram Server project:

  • Repository: https://github.com/teamgram/teamgram-server
  • License: Apache-2.0
  • Gateway code: app/interface/gnetway/
  • Session code: app/interface/session/
  • MTProto codec: mtproto/ package

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

97.05%
按下载量换算2,034

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills