配置说明 · 使用指南

Outbound 出站的协议字段、策略组和代理列表如何配合

出站配置需要同时核对协议、认证和传输选项。可先找到对应协议的字段示例,再理解策略组如何分配请求,以及代理列表怎样通过文件或远程来源载入。

  • Shadowsocks
  • ShadowsocksR
  • VMess
  • Trojan
  • SOCKS5
章节索引

使用旧配置前先确认内核

先确认正在使用的内核,再决定是否采用旧配置;历史版本的限制不能直接套用到其他实现。涉及权限或平台能力时,应核对对应项目说明。

现用内核的字段说明可查阅 配置字段参考;界面操作、安装步骤和授权方式见 客户端使用指引,按各自说明操作。

请求离开内核时,需要选定出站目标及其参数。理解配置时,可先看协议设置,再看策略组如何接收规则交来的请求,最后查看列表的载入方式。

Proxies 出站设置

Proxies 用来描述可用的出站目标;连接地址与协议参数共同决定请求如何交给远端处理。

Shadowsocks

Shadowsocks 配置中的加密字段可对照下表选择,并与服务端保持一致:

类型算法标识
AEADaes-128-gcm, aes-192-gcm, aes-256-gcm, chacha20-ietf-poly1305, xchacha20-ietf-poly1305
流加密aes-128-cfb, aes-192-cfb, aes-256-cfb, rc4-md5, chacha20-ietf, xchacha20
块加密aes-128-ctr, aes-192-ctr, aes-256-ctr

使用插件时,示例涉及 obfs 以及 v2ray-plugin;插件选项也需与远端设置匹配。

yaml
- name: "ss1"
  type: ss
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  cipher: chacha20-ietf-poly1305
  password: "password"
  # udp: true
yaml
- name: "ss2"
  type: ss
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  cipher: chacha20-ietf-poly1305
  password: "password"
  plugin: obfs
  plugin-opts:
    mode: tls # or http
    # host: bing.com
yaml
- name: "ss3"
  type: ss
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  cipher: chacha20-ietf-poly1305
  password: "password"
  plugin: v2ray-plugin
  plugin-opts:
    mode: websocket # 此处的旧实现未提供 QUIC
    # tls: true # wss
    # skip-cert-verify: true
    # host: bing.com
    # path: "/"
    # mux: true
    # headers:
    #   custom: value

ShadowsocksR

使用 ShadowsocksR 时,需要同时核对加密、混淆和协议选项,不能仅填写连接地址。

其加密选项在下表列出:

类型算法标识
流加密aes-128-cfb, aes-192-cfb, aes-256-cfb, rc4-md5, chacha20-ietf, xchacha20

混淆字段可用的标识如下:

  • plain
  • http_simple
  • http_post
  • random_head
  • tls1.2_ticket_auth
  • tls1.2_ticket_fastauth

协议字段对应的标识如下:

  • origin
  • auth_sha1_v4
  • auth_aes128_md5
  • auth_aes128_sha1
  • auth_chain_a
  • auth_chain_b
yaml
- name: "ssr"
  type: ssr
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  cipher: chacha20-ietf
  password: "password"
  obfs: tls1.2_ticket_auth
  protocol: auth_sha1_v4
  # obfs-param: domain.tld
  # protocol-param: "#"
  # udp: true

Vmess

Vmess 的加密字段可按以下标识填写:

  • auto
  • aes-128-gcm
  • chacha20-poly1305
  • none
yaml
- name: "vmess"
  type: vmess
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  uuid: uuid
  alterId: 32
  cipher: auto
  # udp: true
  # tls: true
  # skip-cert-verify: true
  # servername: example.com # 握手名称先采用此处设置,再考虑 wss 主机
  # network: ws
  # ws-opts:
  #   path: /path
  #   headers:
  #     Host: v2ray.com
  #   max-early-data: 2048
  #   early-data-header-name: Sec-WebSocket-Protocol
yaml
- name: "vmess-http"
  type: vmess
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  uuid: uuid
  alterId: 32
  cipher: auto
  # udp: true
  # network: http
  # http-opts:
  #   # method: "GET"
  #   # path:
  #   #   - '/'
  #   #   - '/video'
  #   # headers:
  #   #   Connection:
  #   #     - keep-alive
yaml
- name: "vmess-h2"
  type: vmess
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  uuid: uuid
  alterId: 32
  cipher: auto
  network: h2
  tls: true
  h2-opts:
    host:
      - http.example.com
      - http-alt.example.com
    path: /
yaml
- name: vmess-grpc
  type: vmess
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  uuid: uuid
  alterId: 32
  cipher: auto
  network: grpc
  tls: true
  servername: example.com
  # skip-cert-verify: true
  grpc-opts:
    grpc-service-name: "example"

Socks5

SOCKS5 出站的连接与认证字段可参考下例。

yaml
- name: "socks"
  type: socks5
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  # username: username
  # password: password
  # tls: true
  # skip-cert-verify: true
  # udp: true

HTTP

HTTP 出站可区分是否使用 TLS,分别查看对应配置:

yaml
- name: "http"
  type: http
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  # username: username
  # password: password
yaml
- name: "http"
  type: http
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  # username: username
  # password: password
  tls: true
  skip-cert-verify: true

Snell

Snell 出站通过下方字段描述连接及混淆设置。

yaml
# 此处的旧实现未提供 UDP
- name: "snell"
  type: snell
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 44046
  psk: yourpsk
  # version: 2
  # obfs-opts:
    # mode: http # or tls
    # host: bing.com

Trojan

Trojan 的认证与传输配置可按下列示例核对:

yaml
- name: "trojan"
  type: trojan
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  password: yourpsk
  # udp: true
  # sni: example.com # aka server name
  # alpn:
  #   - h2
  #   - http/1.1
  # skip-cert-verify: true
yaml
- name: trojan-grpc
  type: trojan
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  password: "example"
  network: grpc
  sni: example.com
  # skip-cert-verify: true
  udp: true
  grpc-opts:
    grpc-service-name: "example"
yaml
- name: trojan-ws
  type: trojan
  # interface-name: eth0
  # routing-mark: 1234
  server: server
  port: 443
  password: "example"
  network: ws
  sni: example.com
  # skip-cert-verify: true
  udp: true
  # ws-opts:
    # path: /path
    # headers:
    #   Host: example.com

Proxy Groups 请求分配

规则把请求交给策略组后,由组内方式决定实际出站。组还可以引用其他组,最终由规则指向承接请求的上层组。

relay 串联转发

relay 会按列表顺序逐段转交请求;旧实现不处理 UDP,列表内也不能再嵌入 relay 组。

url-test 响应探查

url-test 按配置的时间间隔访问目标地址,以 HTTP HEAD 请求比较各出站的响应耗时;目标 URL、执行间隔及容忍范围都由配置指定。

fallback 连接候选

fallback 使用 HTTP HEAD 请求判断候选地址的连通状态,并按列表顺序选择能够工作的目标。

load-balance 请求分配

load-balance 以 eTLD+1 为分配依据,相同归属的请求会交给同一出站处理。

select 自行指定

select 在启动时先采用组内首项,之后可经 RESTful API 切换目标。候选列表既能直接写入配置,也能通过 Proxy Providers 载入。

需要让请求直接连接目标地址时,可选用 DIRECT 作为出站方式。

若要指定发出请求的网络接口,可在策略组中选用 DIRECT,同时填写 interface-name 以关联目标接口。

yaml
- name: "My Wireguard Outbound"
  type: select
  interface-name: wg0
  proxies: [ 'DIRECT' ]

Proxy Providers 列表载入

Proxy Providers 将服务器列表与主配置分开管理。下列方式分别从远程地址和本地文件取得内容:

  • http:启动时访问指定地址读取列表;需要周期更新时,再设置 interval,由该字段控制再次拉取的间隔。
  • file:启动时从给定的本地路径读取列表。

列表的健康检查可用于远程和本地来源,处理方式与 fallback 一致;列表内的条目仍沿用主配置中对应的格式。

yaml
proxy-providers:
  provider1:
    type: http
    url: "url"
    interval: 3600
    path: ./provider1.yaml
    # filter: 'a|b' # 按 Go 正则语法筛选列表
    health-check:
      enable: true
      interval: 600
      # lazy: true
      url: http://www.gstatic.com/generate_204
  test:
    type: file
    path: /test.yaml
    health-check:
      enable: true
      interval: 36000
      url: http://www.gstatic.com/generate_204
yaml
proxies:
  - name: "ss1"
    type: ss
    server: server
    port: 443
    cipher: chacha20-ietf-poly1305
    password: "password"

  - name: "ss2"
    type: ss
    server: server
    port: 443
    cipher: chacha20-ietf-poly1305
    password: "password"
    plugin: obfs
    plugin-opts:
      mode: tls