
// InitSDK 初始化SDK// 参数:// - disableLogEncrypt: 是否关闭日志加密,1表示关闭日志加密,0表示开启日志加密// 返回: 0表示初始化成功(可重入),-1表示失败int InitSDK(int disableLogEncrypt);
// StartSDK 启动SDK服务// 返回: 0表示启动成功(可重入),-1表示启动失败,-2表示SDK未初始化int StartSDK();
// StopSDK 停止SDK服务// 返回: 0表示停止成功,-1表示SDK未启动int StopSDK();
// IsSDKRunning 检查SDK是否正在运行// 返回: 1表示运行中,0表示未运行int IsSDKRunning();
api | 说明 |
/api/v2/client/mp-speeder | 配置加速参数 |
/api/v2/client/mp-speeder/start | 开始加速 |
/api/v2/client/mp-speeder/stop | 停止加速 |
/api/v2/client/mp-speeder/restart | 重启加速 |
/api/v2/client/mp-speeder | 查询加速状态 |
/api/v2/client/flowStatistics | 查询加速流量信息 |
/api/v2/client/multi-mode | 配置流转发策略 |
/api/v2/diagnosis/log | 日志上报 |
/api/v2/client/t2Statistics | 查询下车点测速信息 |
curl -X POST "http://127.0.0.1:9801/api/v2/client/mp-speeder" ^-H "accept: */*" ^-H "Content-Type: application/json" ^-d "{\\"serviceMode\\":0,\\"dataKey\\":\\"xxxxxxx\\",\\"scheduleMode\\":\\"rtc\\",\\"registerEnv\\":-2,\\"tunInterfaceName\\":\\"mp_tun0\\",\\"t2Probe\\":true}"
curl -X POST "http://127.0.0.1:9801/api/v2/client/mp-speeder" ^-H "accept: */*" ^-H "Content-Type: application/json" ^-d "{\\"serviceMode\\": 0,\\"appId\\":\\"app-0eoo3vpctx\\",\\"appSign\\":\\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2VOYW1lIjoiamFja3ktdGVzdC0yMC0xIn0.TleKYrzBL1dyp2i8WTBgs8Y8UvBJQv-n2A2BRMT1xuQ\\",\\"scheduleMode\\":\\"rtc\\"}"
curl -X POST "http://127.0.0.1:9801/api/v2/client/mp-speeder" ^-H "accept: */*" ^-H "Content-Type: application/json" ^-d "{\\"serviceMode\\": 0,\\"gwId\\":\\"mpgw-n96i24ugbd\\",\\"appId\\":\\"zone-359h792djt7h\\",\\"appSign\\":\\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2VOYW1lIjoiamFja3ktdGVzdC0yMC0xIn0.RWGNKp_DXqnrg7SJ2yR5UV_MDs3_KWDccBURQfBfiYg\\",\\"scheduleMode\\":\\"rtc\\",\\"enableEoSch\\":true}"
名称 | 类型 | 说明 |
dataKey | string | 必选:上述激活模式三选一,设备 dataKey。 |
vendor | string | 必选:上述激活模式三选一,设备厂商型号。 |
sn | string | 必选:上述激活模式三选一,设备厂商提供的设备唯一序列号。 |
registerEnv | integer | 必选。取值:1。 |
appId | string | 可选:上述激活模式三选一,app 模式+ eo 模式注册下使用,eo 模式下填对应的 zoneId。 |
appSign | string | 可选:上述激活模式三选一,app 模式+ eo 模式注册下使用。 |
enableEoSch | boolean | 可选:eo 模式下需为 true。 |
gwId | string | 可选:eo 模式下使用,填写对应的 gatewayId。 |
lineType | [int] | 可选:eo 模式开启指定线路使用。 0:直连。 1:eo。 2:第三方。 |
enableObfuscated | string | 可选:是否开启 ip 混淆功能。 |
encryptSign | string | 可选:开启 ip 混淆时需要填写,加解密 ip 使用,需要和客户侧 ip 加密的 sign 一致,推荐使用 appSign,加密算法见附录。 |
scheduleMode | string | 可选:Windows 默认加速模式 "rtc"。 |
accGateway | string | 可选:指定加速网关 IP,多个 IP 使用逗号分隔。如果不指定该参数,SDK 将自动就近接入。否则强制连接指定加速网关,例如:"120.30.39.129"。 |
gwPort | string | 可选。网关端口,默认:"443"。 |
UUID | string | 可选:硬件指纹,如果不指定该参数,SDK 会自动根据硬件生成。 |
disableCrypto | integer | 可选:允许客户在启动加速时,选择是否要进行加密。默认开启流量加密,关闭加密可以降低流量消耗。 0:开启流量加密(默认)。 1:关闭流量加密。 |
flowStatisticsInterval | integer | 可选:链路加速流量统计频率,默认3秒。 |
maxRttDisableAggregation | integer | 可选:链路聚合最高时延,默认460ms。 |
maxRttThreshold | integer | 可选:链路故障检测启动时延,默认460ms。 |
minSwitchRTT | integer | 可选:链路快切敏感度,默认20ms。 |
maxDelayUntilFailed | integer | 可选:链路切换最高时延,默认460ms。 |
t2Probe | boolean | 可选:true:打开 t2 测速 false:关闭 t2 测速。 |
authCode | string | 可选:开启免流。 |
curl -X POST "http://127.0.0.1:9801/api/v2/client/socks5" ^-H "accept: application/json" ^-H "Content-Type: application/json" ^-d "{\\"enable\\": true, \\"port\\": 12345, \\"userName\\": \\"xxxxx\\", \\"passWord\\": \\"xxxxx\\"}"
名称 | 类型 | 说明 |
enable | bool | 必选:是否自定义 socks5 server。 |
port | int | 必选:socks5 server port。 |
userName | string | 必选:socks5 server username。 |
passWord | string | 必选:socks5 server password。 |
curl -X GET "http://127.0.0.1:9801/api/v2/client/socks5" ^-H "accept: application/json" ^-H "Content-Type: application/json"
curl -X POST "http://127.0.0.1:9801/api/v2/client/mp-speeder/start" -H "accept: */*" -H "Content-Type: application/json"
curl -X POST "http://127.0.0.1:9801/api/v2/client/mp-speeder/stop" -H "accept: */*" -H "Content-Type: application/json"
curl -X POST "http://127.0.0.1:9801/api/v2/client/mp-speeder/restart" -H "accept: */*" -H "Content-Type: application/json"
curl -X GET "http://127.0.0.1:9801/api/v2/client/mp-speeder" -H "accept: */*" -H "Content-Type: application/json"
名称 | 类型 | 说明 |
ready | boolean | 加速进程是否正常启动。 |
UUID | string | 设备硬件指纹。 |
dataKey | string | 设备 dataKey。 |
swVersion | string | sdk 软件版本。 |
accGateway | string | 加速网关 IP 地址。 |
gatewayPort | string | 加速网关端口。 |
interfaces | [string] | 参与多网聚合的接口列表。 |
scheduleMode | string | 默认加速模式,"bonding", "redundant", "rtc"。 |
curl -X GET "http://127.0.0.1:9801/api/v2/client/flowStatistics" -H "accept: application/json" -H "all: true"
名称 | 类型 | 说明 |
interface | string | 链路网卡名称。 |
state | integer | 当前链路工作状态: -2:链路不可用。 60:链路被临时禁用。 100:链路正常。 |
totalReceivedBytes | integer | 接收方向的累计加速流量,单位 Bytes。 |
totalSendBytes | integer | 发送方向的累计加速流量,单位 Bytes。 |
receivedRate | float | 当前网卡加速通道的接收速率,单位 bit/s。 |
sendRate | float | 当前网卡加速通道的发送速率,单位 bit/s。 |
loss | float | 当前网卡加速通道的丢包率。丢包率以小数形式表示,例如0.1表示丢包率为10%, 1表示丢包率为100%。 |
rtt | integer | 当前网卡加速通道的 rtt,单位 ms。 注:-1 表示当前链路不可用。 |
curl -X GET "http://127.0.0.1:9801/api/v2/client/t2Statistics" -H "accept: application/json" -H "all: true"
名称 | 类型 | 说明 |
area | string | 下车点名称。 |
rttAccelerated | int | sdk 到下车点时延。 |
rttDirect | int | sdk 直连下车点时延。 |
curl -X POST "http://127.0.0.1:9801/api/v2/client/multi-mode" ^-H "accept: application/json" ^-H "Content-Type: application/json" ^-d "{\\"area\\": \\"hongkong\\",\\"speedMode\\": 35}"
名称 | 类型 | 说明 |
appId | string | 可选:基于指定的 appId 规则进行加速。 |
area | string | auto: 自动根据 dip 所属地域自动选取下车点。 Frankfurt :法兰克福。 SiliconValley :美国-硅谷。 SaoPaulo :巴西-圣保罗。 Tokyo :日本。 Bangkok :泰国(东南亚服)。 Singapore :新加坡。 HongKong:香港。 Seoul:韩国首尔。 |
speedMode | integer | 0 - "DEFAULT":复用默认加速模式。 1 - "DIRECT":不加速,走系统默认网卡。 2 - "bonding":聚合模式。 3 - "rtc":实时音视频模式。 4 - "redundant":多发选收模式。 25 -(保留配置)。 35 - "T2 rtc": 先做 rtc 快切,再做 T2全路径加速。 45 - (保留配置)。 |
curl -X POST "http://127.0.0.1:9801/api/v2/client/enableCMCCRightsVerify" ^-H "accept: application/json" ^-H "Content-Type: application/json" ^-d "{\\"token\\": \\"xxxxx\\"}"
名称 | 类型 | 说明 |
token | string | 必选:校验 token。 |
guid | string | 必选:校验 guid,搭配 token 一起使用。 |
salt | string | 必选:盐值,加密使用。 |
名称 | 类型 | 说明 |
status | bool | 必选:token 是否认证成功。 |
authCode | string | 可选:如果校验成功,则返回免流认证码。 |
error | string | 可选:当校验失败时通过 error 返回错误。 |
curl -X POST "http://127.0.0.1:9801/api/v2/diagnosis/log" ^-H "accept: application/json" ^-H "Content-Type: application/json" ^-d "{\\"logLevel\\": \\"debug\\", \\"upload\\": false, \\"uploadInterval\\": 10}"
名称 | 类型 | 说明 |
logLevel | string | 可选:程序日志级别,默认"info",支持配置 "info", "debug", "warn"。 |
autoUpload | boolean | 可选:自动上传开关,默认 false,为 true 时日志自动上传。 |
uploadInterval | integer | 可选:自动上传间隔,默认10分钟,不开启自动上传时不生效。 |
curl -X POST "http://127.0.0.1:9801/api/v2/diagnosis/log"
using System;using System.Runtime.InteropServices;using System.Threading;class Program{[DllImport("linkboost.dll", CallingConvention = CallingConvention.Cdecl)]static extern int InitSDK(int disableLogEncrypt);[DllImport("linkboost.dll", CallingConvention = CallingConvention.Cdecl)]static extern int StartSDK();[DllImport("linkboost.dll", CallingConvention = CallingConvention.Cdecl)]static extern int StopSDK();[DllImport("linkboost.dll", CallingConvention = CallingConvention.Cdecl)]static extern int IsSDKRunning();private static bool keepRunning = true;static void Main(){// 注册 Ctrl+C 事件处理Console.CancelKeyPress += (sender, e) =>{e.Cancel = true; // 阻止立即退出keepRunning = false;Console.WriteLine("\\n正在停止程序...");};try{Console.WriteLine("正在初始化 SDK...");// 初始化sdk,不加密日志InitSDK(1);Console.WriteLine("正在启动 SDK...");// 启动sdkStartSDK();Console.WriteLine($"SDK Running: {IsSDKRunning()}");Console.WriteLine("\\nSDK 已启动,程序将持续运行");Console.WriteLine("按 Ctrl+C 可以手动结束程序\\n");// 持续运行,直到按 Ctrl+Cwhile (keepRunning){Thread.Sleep(1000); // 每秒检查一次}}finally{Console.WriteLine("正在停止 SDK...");// 停止sdkStopSDK();Console.WriteLine("SDK 已停止,程序退出");}}}
curl -X POST "http://127.0.0.1:9801/api/v2/client/mp-speeder/start" -H "accept: */*" -H "Content-Type: application/json"
import jwtfrom datetime import datetime, timedeltafrom typing import Tupleclass JWTGenerator:EXPIRE_HOURS = 72 # 过期时间,单位小时SECRET_KEY = "shCrVLKq/Hp6UdtVpw8lBqu6ZDcLwOABf2Az67e/pjI=" # APP密钥@classmethoddef generate_sign(cls, device_name: str) -> Tuple[str, int]:"""生成JWT签名"""now = datetime.utcnow()expire_time = now + timedelta(hours=cls.EXPIRE_HOURS)payload = {"nbf": now,"exp": expire_time,"deviceName": device_name}token = jwt.encode(payload,cls.SECRET_KEY,algorithm="HS256")return token, int(expire_time.timestamp())if __name__ == "__main__":try:sign, expire_ts = JWTGenerator.generate_sign("tencent-test")print(f"Signature: {sign}")print(f"Expire Time: {expire_ts}")except Exception as e:print(f"Error generating token: {str(e)}")
package mainimport ("fmt""github.com/dgrijalva/jwt-go/v4""time")func main() {sign, expireTime, err := GenerateSign("tencent-test")if err != nil {panic(err)}println(sign, expireTime)}// SignClaims JwtCustomClaimstype SignClaims struct {jwt.StandardClaimsDeviceName string `json:"deviceName"`}var (ExpireTime = 72 // 过期时间, 单位小时SecretKey = []byte("shCrVLKq/Hp6UdtVpw8lBqu6ZDcLwOABf2Az67e/pjI=") // APP密钥)// GenerateSign 生成签名func GenerateSign(deviceName string) (string, int64, error) {expireTime := time.Now().Add(time.Duration(ExpireTime) * time.Hour)claims := &SignClaims{StandardClaims: jwt.StandardClaims{NotBefore: jwt.Now(),ExpiresAt: jwt.At(expireTime),},DeviceName: deviceName,}println(fmt.Sprintf("%#v", claims))token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)sign, err := token.SignedString(SecretKey)if err != nil {return "", 0, err}return sign, expireTime.Unix(), nil}
package org.example;import io.jsonwebtoken.Jwts;import io.jsonwebtoken.SignatureAlgorithm;import java.security.Key;import java.util.Date;import javax.crypto.spec.SecretKeySpec;/*** generate sign*/public class SignGenerate {private static final long EXPIRE_TIME = 72 * 60 * 60 * 1000; // 过期时间, 单位毫秒private static final String SECRET_KEY = "shCrVLKq/Hp6UdtVpw8lBqu6ZDcLwOABf2Az67e/pjI="; // APP密钥public static void main(String[] args) {String deviceName = "tencent-test";String sign = generateSign(deviceName);System.out.println(sign);}public static String generateSign(String deviceName) {Date now = new Date();Date expireDate = new Date(now.getTime() + EXPIRE_TIME);Key key = new SecretKeySpec(SECRET_KEY.getBytes(), SignatureAlgorithm.HS256.getJcaName());return Jwts.builder().claim("deviceName", deviceName).notBefore(now).expiration(expireDate).signWith(key).compact();}}
package mainimport ("crypto/sha256""fmt""golang.org/x/crypto/chacha20""net")func main(ip net.IP, psk []byte) ([]byte, error) {if ip.To4() == nil {return nil, fmt.Errorf("invalid ipv4 address")}key := sha256.Sum256(psk)encryptKey := key[:32]nonce := make([]byte, 12)cipher, err := chacha20.NewUnauthenticatedCipher(encryptKey, nonce)if err != nil {return nil, err}// 原地加密(32bit精确输出)ciphertext := make([]byte, net.IPv4len)cipher.XORKeyStream(ciphertext, ip.To4())return ciphertext, nil}
文档反馈