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"]
        }
      ]
    }
  }
}