Skip to content

soga-client-v1 节点接口文档 ​

介绍 ​

客户端通过本接口获取节点的连接配置和分流规则,不请求订阅地址。

请求头、返回格式、错误处理等通用约定见 soga-client-v1 API 文档。

获取节点配置 GET <base_url>/api/v1/servers ​

需要登录

节点中的认证信息(uuid、password 等)为当前用户的认证信息,调用 subscription/reset 后本接口返回新的认证信息

订阅不可用(未购买、已过期、已封禁)时 servers 为空列表

返回数据 ​

json
{
  "success": true,
  "data": {
    "servers": [                            // 节点列表,顺序即客户端的展示顺序
      {
        "id": 1,                            // 唯一,修改节点后保持不变
        "name": "香港 01",
        "type": "vless",                    // 协议,可选: shadowsocks vmess vless trojan anytls hysteria2 mieru socks
        "address": "hk01.website.com",      // 域名或 IP,IPv6 不带方括号
        "port": 443,
        "settings": {},                     // 协议参数,按 type 不同,见 settings
        "transport": null,                  // 传输层,null 表示直接使用 TCP,见 transport
        "tls": null                         // null 表示不启用,见 tls
      }
    ],
    "router": {}                            // 分流规则,见 router
  }
}

settings ​

shadowsocks ​

transport 可选 null ws,tls 仅在 transport 为 ws 时可选,只使用其中的 server_name

json
{
  "method": "2022-blake3-aes-128-gcm",      // 可选: aes-128-gcm aes-256-gcm chacha20-poly1305 chacha20-ietf-poly1305 2022-blake3-aes-128-gcm 2022-blake3-aes-256-gcm
  "password": "MTIzNDU2Nzg5MGFiY2RlZg==:YWJjZGVmMDEyMzQ1Njc4OQ==",
  "obfs": {                                 // simple-obfs 混淆,null 表示不使用,不能与 transport 同时使用
    "mode": "http",                         // 可选: http tls
    "host": "www.bing.com"
  }
}

method 为 2022-blake3-* 时 password 为 服务端密钥:用户密钥,每段是标准 Base64,解码后 aes-128 为 16 字节,aes-256 为 32 字节

transport 为 ws 时相当于 v2ray-plugin 的 websocket 模式,不使用多路复用

vmess ​

transport 可选 null ws grpc xhttp,tls 可选,不支持 reality

json
{
  "uuid": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11"
}

只支持 AEAD 认证,即 alterId 为 0

vless ​

transport 可选 null ws grpc xhttp,tls 可选

json
{
  "uuid": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11",
  "flow": "xtls-rprx-vision",               // null 表示不使用,可选: xtls-rprx-vision
  "encryption": null                        // null 表示不使用,格式为 mlkem768x25519plus.native.0rtt.<公钥>
}

flow 仅在 transport 为 null 且 tls、encryption 至少有一个不为 null 时可用

trojan ​

transport 可选 null ws grpc xhttp,tls 必填

json
{
  "password": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11"
}

anytls ​

transport 为 null,tls 必填

json
{
  "password": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11",
  "idle_session_check_interval": 30,        // 检查空闲会话的间隔,秒,null 表示使用客户端默认值
  "idle_session_timeout": 30,               // 空闲会话的关闭时间,秒,null 表示使用客户端默认值
  "min_idle_session": null                  // 保留的空闲会话数,null 表示使用客户端默认值
}

hysteria2 ​

transport 为 null,tls 必填,只使用其中的 server_name 和 insecure

json
{
  "password": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11",
  "obfs_password": null,                    // salamander 混淆密码,null 表示不使用混淆
  "ports": "443,20000-30000",               // 端口跳跃的端口列表,null 表示不使用,设置后不使用节点的 port
  "hop_interval": 30,                       // 端口跳跃间隔,秒,最小 5,null 时为 30
  "up_mbps": null,                          // 上行带宽,null 表示不指定
  "down_mbps": 200                          // 下行带宽,null 表示不指定
}

mieru ​

transport 和 tls 都为 null

json
{
  "username": "user1",                      // 1 到 64 字节
  "password": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11",
  "network": "tcp",                         // 可选: tcp udp
  "ports": null                             // 格式同 hysteria2 的 ports,null 表示只使用节点的 port
}

socks ​

transport 为 null,tls 可选,不支持 reality

json
{
  "username": "user1",                      // null 表示不需要认证
  "password": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11"
}

transport ​

ws ​

json
{
  "type": "ws",
  "path": "/ws",
  "host": "cdn.website.com"                 // 请求头 Host,null 表示不指定
}

grpc ​

json
{
  "type": "grpc",
  "service_name": "GunService"
}

xhttp ​

json
{
  "type": "xhttp",
  "path": "/xhttp",
  "host": null,                             // null 时使用 tls.server_name
  "mode": "auto",                           // 可选: auto packet-up stream-up stream-one
  "headers": {                              // 附加的请求头,null 表示没有,其中的 Host 不生效
    "User-Agent": "Mozilla/5.0"
  },
  "no_grpc_header": false,                  // 不发送 gRPC 请求头
  "x_padding_bytes": {                      // 填充长度的范围,null 表示使用客户端默认值
    "from": 100,
    "to": 1000
  },
  "sc_max_each_post_bytes": null,           // 单次上行请求最大字节数的范围,格式同 x_padding_bytes
  "sc_min_posts_interval_ms": null,         // 上行请求最小间隔的范围,毫秒,格式同 x_padding_bytes
  "uplink_http_method": null,               // null 时为 POST
  "download": {                             // 下行单独使用的连接,null 表示上下行使用同一地址,不能与 stream-one 同时使用
    "address": "dl.website.com",
    "port": 443,
    "path": null,                           // null 时使用外层的 path
    "host": null,                           // null 时使用外层的 host
    "headers": null,                        // null 时使用外层的 headers
    "tls": null                             // 格式同节点的 tls,null 表示不启用
  }
}

mode 为 auto 时,使用 Reality 的节点按 stream-one 连接(设置了 download 时按 stream-up),其余节点按 packet-up 连接

tls ​

json
{
  "server_name": "www.website.com",         // SNI
  "insecure": false,                        // 不校验服务端证书
  "alpn": ["h2", "http/1.1"],               // [] 表示不指定,transport 为 grpc、xhttp 时客户端固定使用 h2
  "ech": {                                  // null 表示不启用
    "config": null                          // Base64 编码的 ECHConfigList,null 时客户端从 DNS 查询
  },
  "reality": {                              // null 表示使用普通 TLS,不为 null 时 insecure、alpn、ech 不生效
    "public_key": "7xhH4b_VkliBxGulljcyPOH-bYUA2dl-XAdZAsfhk04",     // 32 字节,URL-safe Base64(不带填充)或十六进制
    "short_id": "6ba85179e30d4fc2",         // 十六进制,最长 16 个字符,可为空字符串
    "spider_x": null                        // null 表示不指定
  }
}

router ​

json
{
  "domain_resolve": true,                   // 域名没有命中任何规则时,解析成 IP 再匹配一次
  "rules": [                                // 按顺序匹配,命中后不再匹配后面的规则
    {
      "target": "direct",                   // 命中后的去向,可选: proxy(用户选中的节点) direct(直连) reject(拒绝连接)
      "domain": ["www.website.com"],        // 完整域名
      "domain_suffix": ["website.com"],     // 匹配 website.com 和它的所有子域名
      "domain_keyword": ["website"],        // 域名中包含的关键字
      "domain_regex": ["^ad[0-9]+\\."],     // 不区分大小写
      "geosite": ["cn"],                    // 域名分类
      "port": ["443", "8000-9000"],         // 目标端口或端口范围
      "network": ["tcp"]                    // 可选: tcp udp
    },
    {
      "target": "direct",
      "ip": ["203.0.113.0/24", "2001:db8::/32"],
      "geoip": ["cn"]                       // 国家代码
    }
  ]
}

除 target 外的字段都是匹配条件,不使用的条件可以省略

域名类条件(domain domain_suffix domain_keyword domain_regex geosite)命中其中任意一个值即可,IP 类条件(ip geoip)同样

一条规则同时有域名类或 IP 类条件、port、network 时需要全部命中

一条规则里不能同时有域名类和 IP 类条件

没有命中任何规则的连接走用户选中的节点

内网地址和节点自身的地址固定直连,不需要写规则

兼容约定 ​

客户端忽略不认识的字段,规则中的字段除外

节点的 type、transport.type 或其他可选值客户端不认识,或 transport、tls 的组合不符合该协议的要求时,客户端忽略该节点,其余节点不受影响

规则的 target 或条件字段客户端不认识,或规则没有任何条件时,客户端忽略该规则,其余规则不受影响

示例 ​

json
{
  "success": true,
  "data": {
    "servers": [
      {
        "id": 1,
        "name": "香港 01",
        "type": "vless",
        "address": "hk01.website.com",
        "port": 443,
        "settings": {
          "uuid": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11",
          "flow": "xtls-rprx-vision",
          "encryption": null
        },
        "transport": null,
        "tls": {
          "server_name": "www.website.com",
          "insecure": false,
          "alpn": [],
          "ech": null,
          "reality": {
            "public_key": "7xhH4b_VkliBxGulljcyPOH-bYUA2dl-XAdZAsfhk04",
            "short_id": "6ba85179e30d4fc2",
            "spider_x": null
          }
        }
      },
      {
        "id": 2,
        "name": "日本 01",
        "type": "vmess",
        "address": "jp01.website.com",
        "port": 443,
        "settings": {
          "uuid": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11"
        },
        "transport": {
          "type": "ws",
          "path": "/ws",
          "host": "jp01.website.com"
        },
        "tls": {
          "server_name": "jp01.website.com",
          "insecure": false,
          "alpn": [],
          "ech": null,
          "reality": null
        }
      },
      {
        "id": 3,
        "name": "美国 01",
        "type": "shadowsocks",
        "address": "203.0.113.10",
        "port": 8388,
        "settings": {
          "method": "2022-blake3-aes-128-gcm",
          "password": "MTIzNDU2Nzg5MGFiY2RlZg==:YWJjZGVmMDEyMzQ1Njc4OQ==",
          "obfs": null
        },
        "transport": null,
        "tls": null
      },
      {
        "id": 4,
        "name": "新加坡 01",
        "type": "hysteria2",
        "address": "sg01.website.com",
        "port": 443,
        "settings": {
          "password": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11",
          "obfs_password": null,
          "ports": "443,20000-30000",
          "hop_interval": 30,
          "up_mbps": null,
          "down_mbps": 200
        },
        "transport": null,
        "tls": {
          "server_name": "sg01.website.com",
          "insecure": false,
          "alpn": [],
          "ech": null,
          "reality": null
        }
      },
      {
        "id": 5,
        "name": "台湾 01",
        "type": "vless",
        "address": "tw01.website.com",
        "port": 443,
        "settings": {
          "uuid": "3f0c1e8a-6b1d-4c57-9a52-0e3a7d5b9c11",
          "flow": null,
          "encryption": null
        },
        "transport": {
          "type": "xhttp",
          "path": "/xhttp",
          "host": null,
          "mode": "auto",
          "headers": null,
          "no_grpc_header": false,
          "x_padding_bytes": null,
          "sc_max_each_post_bytes": null,
          "sc_min_posts_interval_ms": null,
          "uplink_http_method": null,
          "download": null
        },
        "tls": {
          "server_name": "tw01.website.com",
          "insecure": false,
          "alpn": [],
          "ech": null,
          "reality": null
        }
      }
    ],
    "router": {
      "domain_resolve": true,
      "rules": [
        {
          "target": "reject",
          "domain_keyword": ["adservice"]
        },
        {
          "target": "direct",
          "domain_suffix": ["cn"],
          "geosite": ["cn"]
        },
        {
          "target": "direct",
          "geoip": ["cn"]
        }
      ]
    }
  }
}