Skip to content

端点

endpoints 承载同时是入站与出站的协议栈:一个 WireGuard 或 Tailscale 实例既接受经隧道到达的连接,也向隧道内发起连接。条目形状与入站、出站相同 — 扁平的 type / tag 信封加上所选类型自身的字段,处于同一层级。

信封

字段类型默认值允许值描述
typestringwireguard | tailscale端点类型。决定对象其余部分解码到哪个选项结构体。
tagstring该端点的唯一名称。凡是可以使用出站 tag 的地方都能用它,入站方向也可被路由规则匹配。

源码: option/endpoint.go:16-20 · 锚定版本 v1.13.15 (3708fa1)

各类型字段见 WireGuardTailscale

最简示例

json
{
  "endpoints": [
    {
      "type": "wireguard",
      "tag": "wg-ep",
      "address": ["10.0.0.2/32"],
      "private_key": "<base64-private-key>",
      "peers": [
        {
          "address": "wg.example.com",
          "port": 51820,
          "public_key": "<base64-public-key>",
          "allowed_ips": ["0.0.0.0/0"]
        }
      ]
    }
  ],
  "route": { "final": "wg-ep" }
}

说明

  • 端点在 1.13.0 取代了被移除的 wireguard 出站 — 同一结构体现在覆盖隧道的两个方向。
  • wireguard 需要带 with_wireguard 标签的构建,tailscale 需要 with_tailscale(官方发布的二进制两者都包含)。
  • 路由规则可以像匹配入站 tag 一样匹配从端点流出的流量。

跨内核说明

  • Xray-core 把 WireGuard 保留为普通的入站出站协议(protocol: "wireguard"IsClient 由所在位置决定)。见 Xray WireGuard
  • mihomo 仅把 WireGuard 建模为代理(出站)。见 mihomo WireGuard

源码: option/endpoint.go:16-20 · v1.13.15 (3708fa1)

由 Argsment 出品的 Core Tutorial