Outbound 出站
Clash 中有幾種類型的出站. 每種類型都有自己的特點和使用場景. 在本頁中, 我們將介紹每種類型的通用特點以及如何使用和配置它們.
Proxies 代理節點
Proxies 代理節點是您可以配置的一些出站目標. 就像代理服務器一樣, 您在這裡為數據包定義目的地.
Shadowsocks
Clash 支持以下 Shadowsocks 的加密方法:
| 系列 | 加密方法 |
|---|---|
| AEAD | aes-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 |
此外, Clash 還支持流行的 Shadowsocks 插件 obfs 和 v2ray-plugin.
- name: "ss1"
type: ss
# interface-name: eth0
# routing-mark: 1234
server: server
port: 443
cipher: chacha20-ietf-poly1305
password: "password"
# udp: true- 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- 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: valueShadowsocksR
Clash 也支持聲名狼藉的反審查協議 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
- 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: trueVmess
Clash 支持以下 Vmess 的加密方法:
- auto
- aes-128-gcm
- chacha20-poly1305
- none
- 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- 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- 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: /- 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
此外, Clash 還支持 Socks5 代理.
- 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: trueHTTP
Clash 也支持 HTTP 代理:
- name: "http"
type: http
# interface-name: eth0
# routing-mark: 1234
server: server
port: 443
# username: username
# password: password- name: "http"
type: http
# interface-name: eth0
# routing-mark: 1234
server: server
port: 443
# username: username
# password: password
tls: true
skip-cert-verify: trueSnell
作為可選的反審查協議, Clash也集成了對Snell的支持.
# 暫不支持 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.comTrojan
Clash 內置了對流行協議 Trojan 的支持:
- 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- 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"- 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.comProxy Groups 策略組
Proxy Groups 策略組用於根據不同策略分發規則傳遞過來的請求, 其可以直接被規則引用, 也可以被其他策略組引用, 而最上級策略組被規則引用.
relay 中繼
請求將依次通過指定的代理服務器進行中繼, 目前不支持 UDP. 指定的代理服務器不應包含另一個 relay 中繼.
url-test 延遲測試
Clash 會週期性地通過指定的 URL 向列表中的代理服務器發送 HTTP HEAD 請求來測試每個代理服務器的延遲. 可以設置最大容忍值、測試間隔和目標 URL.
fallback 可用性測試
Clash 會週期性地通過指定的 URL 向列表中的代理服務器發送 HTTP HEAD 請求來測試每個代理服務器的可用性. 第一個可用的服務器將被使用.
load-balance 負載均衡
相同 eTLD+1 的請求將使用同一個代理服務器.
select 手動選擇
Clash 啟動時默認使用策略組中的第一個代理服務器. 用戶可以使用 RESTful API 選擇要使用的代理服務器. 在此模式下, 您可以在配置中硬編碼服務器或使用 Proxy Providers 代理集 動態添加服務器.
無論哪種方式, 有時您也可以使用直接連接來路由數據包. 在這種情況下, 您可以使用 DIRECT 直連出站.
要使用不同的網絡接口, 您需要使用包含 DIRECT 直連出站的策略組, 並設置 interface-name 選項.
- name: "My Wireguard Outbound"
type: select
interface-name: wg0
proxies: [ 'DIRECT' ]Proxy Providers 代理集
代理集使用戶可以動態加載代理服務器列表, 而不是在配置文件中硬編碼. 目前有兩種代理集可以加載服務器列表:
http: Clash 會在啟動時從指定的 URL 加載服務器列表. 如果設置了interval選項, Clash 會定期從遠程拉取服務器列表.file: Clash 會在啟動時從指定的文件位置加載服務器列表. 健康檢查對兩種模式都可用, 並且與策略組中的fallback完全相同. 服務器列表文件的配置格式在主配置文件中也完全相同:
proxy-providers:
provider1:
type: http
url: "url"
interval: 3600
path: ./provider1.yaml
# filter: 'a|b' # golang regex 正則表達式
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_204proxies:
- 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