Docs: new documentation site (#2723)
This commit adds a VitePress build to the main repository, aiming to ditch GitHub Wiki. Moving further, we're going to host our own documentation site eithor on GitHub Pages or something alike.
This commit is contained in:
parent
10dcb7a3ad
commit
ca42ca2ca8
42
.github/workflows/deploy-docs.yml
vendored
Normal file
42
.github/workflows/deploy-docs.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: Deploy
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20]
|
||||
permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: latest
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Install dependencies
|
||||
working-directory: docs
|
||||
run: pnpm install --frozen-lockfile=false
|
||||
- name: Build
|
||||
working-directory: docs
|
||||
run: pnpm run docs:build
|
||||
- uses: actions/configure-pages@v2
|
||||
- uses: actions/upload-pages-artifact@v1
|
||||
with:
|
||||
path: docs/.vitepress/dist
|
||||
- name: Deploy
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v1
|
11
.gitignore
vendored
11
.gitignore
vendored
@ -23,3 +23,14 @@ vendor
|
||||
|
||||
# test suite
|
||||
test/config/cache*
|
||||
|
||||
# docs site generator
|
||||
node_modules
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
|
||||
# docs site cache
|
||||
docs/.vitepress/cache
|
||||
|
||||
# docs site build files
|
||||
docs/.vitepress/dist
|
||||
|
104
docs/.vitepress/config.ts
Normal file
104
docs/.vitepress/config.ts
Normal file
@ -0,0 +1,104 @@
|
||||
import { defineConfig } from 'vitepress'
|
||||
import directoryTree from 'directory-tree'
|
||||
import fs from 'fs'
|
||||
import metadataParser from 'markdown-yaml-metadata-parser'
|
||||
|
||||
function getMetadataFromDoc(path: string): { sidebarTitle?: string, sidebarOrder?: number } {
|
||||
const fileContents = fs.readFileSync(path, 'utf8')
|
||||
|
||||
return metadataParser(fileContents).metadata
|
||||
}
|
||||
|
||||
function generateSidebarChapter(chapterDirName: string): any {
|
||||
const chapterPath = `./docs/${chapterDirName}`
|
||||
const tree = directoryTree(chapterPath)
|
||||
|
||||
if (!tree || !tree.children) {
|
||||
console.error(tree)
|
||||
throw new Error(`Could not genereate sidebar: invalid chapter at ${chapterPath}`)
|
||||
}
|
||||
|
||||
let items: { sidebarOrder: number, text: string, link: string }[] = []
|
||||
|
||||
// Look into files in the chapter
|
||||
for (const doc of tree.children) {
|
||||
// make sure it's a .md file
|
||||
if (doc.children || !doc.name.endsWith('.md'))
|
||||
continue
|
||||
|
||||
const { sidebarOrder, sidebarTitle } = getMetadataFromDoc(doc.path)
|
||||
|
||||
if (!sidebarOrder)
|
||||
throw new Error('Cannot find sidebarOrder in doc metadata: ' + doc.path)
|
||||
|
||||
if (!sidebarTitle)
|
||||
throw new Error('Cannot find sidebarTitle in doc metadata: ' + doc.path)
|
||||
|
||||
items.push({
|
||||
sidebarOrder,
|
||||
text: sidebarTitle,
|
||||
link: doc.path.replace(/^docs/, '')
|
||||
})
|
||||
}
|
||||
|
||||
items = items.sort((a, b) => a.sidebarOrder - b.sidebarOrder)
|
||||
|
||||
// remove dash and capitalize first character of each word as chapter title
|
||||
const text = chapterDirName.split('-').join(' ').replace(/\b\w/g, l => l.toUpperCase())
|
||||
|
||||
return {
|
||||
text,
|
||||
items,
|
||||
}
|
||||
}
|
||||
|
||||
const chapters = [
|
||||
'introduction',
|
||||
'configuration',
|
||||
'premium',
|
||||
'runtime',
|
||||
'advanced-usages',
|
||||
].map(generateSidebarChapter)
|
||||
|
||||
// Override index page link
|
||||
chapters[0]['items'][0]['link'] = '/'
|
||||
|
||||
// https://vitepress.dev/reference/site-config
|
||||
export default defineConfig({
|
||||
title: "Clash",
|
||||
description: "Rule-based Tunnel",
|
||||
|
||||
themeConfig: {
|
||||
outline: 'deep',
|
||||
|
||||
search: {
|
||||
provider: 'local'
|
||||
},
|
||||
|
||||
editLink: {
|
||||
pattern: 'https://github.com/Dreamacro/clash/edit/master/docs/:path',
|
||||
text: 'Edit this page on GitHub'
|
||||
},
|
||||
|
||||
logo: '/logo.png',
|
||||
|
||||
// https://vitepress.dev/reference/default-theme-config
|
||||
nav: [
|
||||
{ text: 'Home', link: '/' },
|
||||
{ text: 'Configuration', link: '/configuration/configuration-reference.md' },
|
||||
{
|
||||
text: 'Download',
|
||||
items: [
|
||||
{ text: 'Open-source Edition', link: 'https://github.com/Dreamacro/clash/releases/' },
|
||||
{ text: 'Premium Edition', link: 'https://github.com/Dreamacro/clash/releases/tag/premium' },
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
socialLinks: [
|
||||
{ icon: 'github', link: 'https://github.com/Dreamacro/clash' },
|
||||
],
|
||||
|
||||
sidebar: chapters
|
||||
}
|
||||
})
|
59
docs/advanced-usages/golang-api.md
Normal file
59
docs/advanced-usages/golang-api.md
Normal file
@ -0,0 +1,59 @@
|
||||
---
|
||||
sidebarTitle: Integrating Clash in Golang Programs
|
||||
sidebarOrder: 3
|
||||
---
|
||||
|
||||
# Integrating Clash in Golang Programs
|
||||
|
||||
If clash does not fit your own usage, you can use Clash in your own Golang code.
|
||||
|
||||
There is already basic support:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
"github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/clash/listener/socks"
|
||||
)
|
||||
|
||||
func main() {
|
||||
in := make(chan constant.ConnContext, 100)
|
||||
defer close(in)
|
||||
|
||||
l, err := socks.New("127.0.0.1:10000", in)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer l.Close()
|
||||
|
||||
println("listen at:", l.Address())
|
||||
|
||||
direct := outbound.NewDirect()
|
||||
|
||||
for c := range in {
|
||||
conn := c
|
||||
metadata := conn.Metadata()
|
||||
fmt.Printf("request incoming from %s to %s\n", metadata.SourceAddress(), metadata.RemoteAddress())
|
||||
go func () {
|
||||
remote, err := direct.DialContext(context.Background(), metadata)
|
||||
if err != nil {
|
||||
fmt.Printf("dial error: %s\n", err.Error())
|
||||
return
|
||||
}
|
||||
relay(remote, conn.Conn())
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func relay(l, r net.Conn) {
|
||||
go io.Copy(l, r)
|
||||
io.Copy(r, l)
|
||||
}
|
||||
```
|
93
docs/advanced-usages/openconnect.md
Normal file
93
docs/advanced-usages/openconnect.md
Normal file
@ -0,0 +1,93 @@
|
||||
---
|
||||
sidebarTitle: Rule-based OpenConnect
|
||||
sidebarOrder: 2
|
||||
---
|
||||
|
||||
# Rule-based OpenConnect
|
||||
|
||||
OpenConnect supports Cisco AnyConnect SSL VPN, Juniper Network Connect, Palo Alto Networks (PAN) GlobalProtect SSL VPN, Pulse Connect Secure SSL VPN, F5 BIG-IP SSL VPN, FortiGate SSL VPN and Array Networks SSL VPN.
|
||||
|
||||
For example, there would be a use case where your company uses Cisco AnyConnect for internal network access. Here I'll show you how you can use OpenConnect with policy routing powered by Clash.
|
||||
|
||||
First, [install vpn-slice](https://github.com/dlenski/vpn-slice#requirements). This tool overrides default routing table behaviour of OpenConnect. Simply saying, it stops the VPN from overriding your default routes.
|
||||
|
||||
Next you would have a script (let's say `tun0.sh`) similar to this:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
ANYCONNECT_HOST="vpn.example.com"
|
||||
ANYCONNECT_USER="john"
|
||||
ANYCONNECT_PASSWORD="foobar"
|
||||
ROUTING_TABLE_ID="6667"
|
||||
TUN_INTERFACE="tun0"
|
||||
|
||||
# Add --no-dtls if the server is in mainland China. UDP in China is choppy.
|
||||
echo "$ANYCONNECT_PASSWORD" | \
|
||||
openconnect \
|
||||
--non-inter \
|
||||
--passwd-on-stdin \
|
||||
--protocol=anyconnect \
|
||||
--interface $TUN_INTERFACE \
|
||||
--script "vpn-slice
|
||||
if [ \"\$reason\" = 'connect' ]; then
|
||||
ip rule add from \$INTERNAL_IP4_ADDRESS table $ROUTING_TABLE_ID
|
||||
ip route add default dev \$TUNDEV scope link table $ROUTING_TABLE_ID
|
||||
elif [ \"\$reason\" = 'disconnect' ]; then
|
||||
ip rule del from \$INTERNAL_IP4_ADDRESS table $ROUTING_TABLE_ID
|
||||
ip route del default dev \$TUNDEV scope link table $ROUTING_TABLE_ID
|
||||
fi" \
|
||||
--user $ANYCONNECT_USER \
|
||||
https://$ANYCONNECT_HOST
|
||||
```
|
||||
|
||||
After that, we configure it as a systemd service. Create `/etc/systemd/system/tun0.service`:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Cisco AnyConnect VPN
|
||||
After=network-online.target
|
||||
Conflicts=shutdown.target sleep.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/path/to/tun0.sh
|
||||
KillSignal=SIGINT
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Then we enable & start the service.
|
||||
|
||||
```shell
|
||||
chmod +x /path/to/tun0.sh
|
||||
systemctl daemon-reload
|
||||
systemctl enable tun0
|
||||
systemctl start tun0
|
||||
```
|
||||
|
||||
From here you can look at the logs to see if it's running properly. Simple way is to look at if `tun0` interface has been created.
|
||||
|
||||
Similar to the Wireguard one, having an outbound to a TUN device is simple as adding a proxy group:
|
||||
|
||||
```yaml
|
||||
proxy-groups:
|
||||
- name: Cisco AnyConnect VPN
|
||||
type: select
|
||||
interface-name: tun0
|
||||
proxies:
|
||||
- DIRECT
|
||||
```
|
||||
|
||||
... and it's ready to use! Add the desired rules:
|
||||
|
||||
```yaml
|
||||
rules:
|
||||
- DOMAIN-SUFFIX,internal.company.com,Cisco AnyConnect VPN
|
||||
```
|
||||
|
||||
You should look at the debug level logs when something does not seem right.
|
||||
|
40
docs/advanced-usages/wireguard.md
Normal file
40
docs/advanced-usages/wireguard.md
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
sidebarTitle: Rule-based Wireguard
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
# Rule-based Wireguard
|
||||
|
||||
Suppose your kernel supports Wireguard and you have it enabled. The `Table` option stops _wg-quick_ from overriding default routes.
|
||||
|
||||
Example `wg0.conf`:
|
||||
|
||||
```ini
|
||||
[Interface]
|
||||
PrivateKey = ...
|
||||
Address = 172.16.0.1/32
|
||||
MTU = ...
|
||||
Table = off
|
||||
PostUp = ip rule add from 172.16.0.1/32 table 6666
|
||||
|
||||
[Peer]
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
AllowedIPs = ::/0
|
||||
PublicKey = ...
|
||||
Endpoint = ...
|
||||
```
|
||||
|
||||
Then in Clash you would only need to have a DIRECT proxy group that has a specific outbound interface:
|
||||
|
||||
```yaml
|
||||
proxy-groups:
|
||||
- name: Wireguard
|
||||
type: select
|
||||
interface-name: wg0
|
||||
proxies:
|
||||
- DIRECT
|
||||
rules:
|
||||
- DOMAIN,google.com,Wireguard
|
||||
```
|
||||
|
||||
This should perform better than whereas if Clash implemented its own userspace Wireguard client. Wireguard is supported in the kernel.
|
BIN
docs/assets/connection-flow.png
Normal file
BIN
docs/assets/connection-flow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 78 KiB |
480
docs/configuration/configuration-reference.md
Normal file
480
docs/configuration/configuration-reference.md
Normal file
@ -0,0 +1,480 @@
|
||||
---
|
||||
sidebarTitle: Configuration Reference
|
||||
sidebarOrder: 7
|
||||
---
|
||||
|
||||
# Configuration Reference
|
||||
|
||||
```yaml
|
||||
# Port of HTTP(S) proxy server on the local end
|
||||
port: 7890
|
||||
|
||||
# Port of SOCKS5 proxy server on the local end
|
||||
socks-port: 7891
|
||||
|
||||
# Transparent proxy server port for Linux and macOS (Redirect TCP and TProxy UDP)
|
||||
# redir-port: 7892
|
||||
|
||||
# Transparent proxy server port for Linux (TProxy TCP and TProxy UDP)
|
||||
# tproxy-port: 7893
|
||||
|
||||
# HTTP(S) and SOCKS4(A)/SOCKS5 server on the same port
|
||||
# mixed-port: 7890
|
||||
|
||||
# authentication of local SOCKS5/HTTP(S) server
|
||||
# authentication:
|
||||
# - "user1:pass1"
|
||||
# - "user2:pass2"
|
||||
|
||||
# Set to true to allow connections to the local-end server from
|
||||
# other LAN IP addresses
|
||||
# allow-lan: false
|
||||
|
||||
# This is only applicable when `allow-lan` is `true`
|
||||
# '*': bind all IP addresses
|
||||
# 192.168.122.11: bind a single IPv4 address
|
||||
# "[aaaa::a8aa:ff:fe09:57d8]": bind a single IPv6 address
|
||||
# bind-address: '*'
|
||||
|
||||
# Clash router working mode
|
||||
# rule: rule-based packet routing
|
||||
# global: all packets will be forwarded to a single endpoint
|
||||
# direct: directly forward the packets to the Internet
|
||||
mode: rule
|
||||
|
||||
# Clash by default prints logs to STDOUT
|
||||
# info / warning / error / debug / silent
|
||||
# log-level: info
|
||||
|
||||
# When set to false, resolver won't translate hostnames to IPv6 addresses
|
||||
# ipv6: false
|
||||
|
||||
# RESTful web API listening address
|
||||
external-controller: 127.0.0.1:9090
|
||||
|
||||
# A relative path to the configuration directory or an absolute path to a
|
||||
# directory in which you put some static web resource. Clash core will then
|
||||
# serve it at `http://{{external-controller}}/ui`.
|
||||
# external-ui: folder
|
||||
|
||||
# Secret for the RESTful API (optional)
|
||||
# Authenticate by spedifying HTTP header `Authorization: Bearer ${secret}`
|
||||
# ALWAYS set a secret if RESTful API is listening on 0.0.0.0
|
||||
# secret: ""
|
||||
|
||||
# Outbound interface name
|
||||
# interface-name: en0
|
||||
|
||||
# fwmark on Linux only
|
||||
# routing-mark: 6666
|
||||
|
||||
# Static hosts for DNS server and connection establishment (like /etc/hosts)
|
||||
#
|
||||
# Wildcard hostnames are supported (e.g. *.clash.dev, *.foo.*.example.com)
|
||||
# Non-wildcard domain names have a higher priority than wildcard domain names
|
||||
# e.g. foo.example.com > *.example.com > .example.com
|
||||
# P.S. +.foo.com equals to .foo.com and foo.com
|
||||
# hosts:
|
||||
# '*.clash.dev': 127.0.0.1
|
||||
# '.dev': 127.0.0.1
|
||||
# 'alpha.clash.dev': '::1'
|
||||
|
||||
# profile:
|
||||
# Store the `select` results in $HOME/.config/clash/.cache
|
||||
# set false If you don't want this behavior
|
||||
# when two different configurations have groups with the same name, the selected values are shared
|
||||
# store-selected: true
|
||||
|
||||
# persistence fakeip
|
||||
# store-fake-ip: false
|
||||
|
||||
# DNS server settings
|
||||
# This section is optional. When not present, the DNS server will be disabled.
|
||||
dns:
|
||||
enable: false
|
||||
listen: 0.0.0.0:53
|
||||
# ipv6: false # when the false, response to AAAA questions will be empty
|
||||
|
||||
# These nameservers are used to resolve the DNS nameserver hostnames below.
|
||||
# Specify IP addresses only
|
||||
default-nameserver:
|
||||
- 114.114.114.114
|
||||
- 8.8.8.8
|
||||
# enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16 # Fake IP addresses pool CIDR
|
||||
# use-hosts: true # lookup hosts and return IP record
|
||||
|
||||
# search-domains: [local] # search domains for A/AAAA record
|
||||
|
||||
# Hostnames in this list will not be resolved with fake IPs
|
||||
# i.e. questions to these domain names will always be answered with their
|
||||
# real IP addresses
|
||||
# fake-ip-filter:
|
||||
# - '*.lan'
|
||||
# - localhost.ptlogin2.qq.com
|
||||
|
||||
# Supports UDP, TCP, DoT, DoH. You can specify the port to connect to.
|
||||
# All DNS questions are sent directly to the nameserver, without proxies
|
||||
# involved. Clash answers the DNS question with the first result gathered.
|
||||
nameserver:
|
||||
- 114.114.114.114 # default value
|
||||
- 8.8.8.8 # default value
|
||||
- tls://dns.rubyfish.cn:853 # DNS over TLS
|
||||
- https://1.1.1.1/dns-query # DNS over HTTPS
|
||||
- dhcp://en0 # dns from dhcp
|
||||
# - '8.8.8.8#en0'
|
||||
|
||||
# When `fallback` is present, the DNS server will send concurrent requests
|
||||
# to the servers in this section along with servers in `nameservers`.
|
||||
# The answers from fallback servers are used when the GEOIP country
|
||||
# is not `CN`.
|
||||
# fallback:
|
||||
# - tcp://1.1.1.1
|
||||
# - 'tcp://1.1.1.1#en0'
|
||||
|
||||
# If IP addresses resolved with servers in `nameservers` are in the specified
|
||||
# subnets below, they are considered invalid and results from `fallback`
|
||||
# servers are used instead.
|
||||
#
|
||||
# IP address resolved with servers in `nameserver` is used when
|
||||
# `fallback-filter.geoip` is true and when GEOIP of the IP address is `CN`.
|
||||
#
|
||||
# If `fallback-filter.geoip` is false, results from `nameserver` nameservers
|
||||
# are always used if not match `fallback-filter.ipcidr`.
|
||||
#
|
||||
# This is a countermeasure against DNS pollution attacks.
|
||||
# fallback-filter:
|
||||
# geoip: true
|
||||
# geoip-code: CN
|
||||
# ipcidr:
|
||||
# - 240.0.0.0/4
|
||||
# domain:
|
||||
# - '+.google.com'
|
||||
# - '+.facebook.com'
|
||||
# - '+.youtube.com'
|
||||
|
||||
# Lookup domains via specific nameservers
|
||||
# nameserver-policy:
|
||||
# 'www.baidu.com': '114.114.114.114'
|
||||
# '+.internal.crop.com': '10.0.0.1'
|
||||
|
||||
proxies:
|
||||
# Shadowsocks
|
||||
# The supported ciphers (encryption methods):
|
||||
# aes-128-gcm aes-192-gcm aes-256-gcm
|
||||
# aes-128-cfb aes-192-cfb aes-256-cfb
|
||||
# aes-128-ctr aes-192-ctr aes-256-ctr
|
||||
# rc4-md5 chacha20-ietf xchacha20
|
||||
# chacha20-ietf-poly1305 xchacha20-ietf-poly1305
|
||||
- name: "ss1"
|
||||
type: ss
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
# udp: true
|
||||
|
||||
- name: "ss2"
|
||||
type: ss
|
||||
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
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
plugin: v2ray-plugin
|
||||
plugin-opts:
|
||||
mode: websocket # no QUIC now
|
||||
# tls: true # wss
|
||||
# skip-cert-verify: true
|
||||
# host: bing.com
|
||||
# path: "/"
|
||||
# mux: true
|
||||
# headers:
|
||||
# custom: value
|
||||
|
||||
# vmess
|
||||
# cipher support auto/aes-128-gcm/chacha20-poly1305/none
|
||||
- name: "vmess"
|
||||
type: vmess
|
||||
server: server
|
||||
port: 443
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
# udp: true
|
||||
# tls: true
|
||||
# skip-cert-verify: true
|
||||
# servername: example.com # priority over wss host
|
||||
# network: ws
|
||||
# ws-opts:
|
||||
# path: /path
|
||||
# headers:
|
||||
# Host: v2ray.com
|
||||
# max-early-data: 2048
|
||||
# early-data-header-name: Sec-WebSocket-Protocol
|
||||
|
||||
- name: "vmess-h2"
|
||||
type: vmess
|
||||
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-http"
|
||||
type: vmess
|
||||
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-grpc
|
||||
server: server
|
||||
port: 443
|
||||
type: vmess
|
||||
uuid: uuid
|
||||
alterId: 32
|
||||
cipher: auto
|
||||
network: grpc
|
||||
tls: true
|
||||
servername: example.com
|
||||
# skip-cert-verify: true
|
||||
grpc-opts:
|
||||
grpc-service-name: "example"
|
||||
|
||||
# socks5
|
||||
- name: "socks"
|
||||
type: socks5
|
||||
server: server
|
||||
port: 443
|
||||
# username: username
|
||||
# password: password
|
||||
# tls: true
|
||||
# skip-cert-verify: true
|
||||
# udp: true
|
||||
|
||||
# http
|
||||
- name: "http"
|
||||
type: http
|
||||
server: server
|
||||
port: 443
|
||||
# username: username
|
||||
# password: password
|
||||
# tls: true # https
|
||||
# skip-cert-verify: true
|
||||
# sni: custom.com
|
||||
|
||||
# Snell
|
||||
# Beware that there's currently no UDP support yet
|
||||
- name: "snell"
|
||||
type: snell
|
||||
server: server
|
||||
port: 44046
|
||||
psk: yourpsk
|
||||
# version: 2
|
||||
# obfs-opts:
|
||||
# mode: http # or tls
|
||||
# host: bing.com
|
||||
|
||||
# Trojan
|
||||
- name: "trojan"
|
||||
type: trojan
|
||||
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
|
||||
server: server
|
||||
port: 443
|
||||
type: trojan
|
||||
password: "example"
|
||||
network: grpc
|
||||
sni: example.com
|
||||
# skip-cert-verify: true
|
||||
udp: true
|
||||
grpc-opts:
|
||||
grpc-service-name: "example"
|
||||
|
||||
- name: trojan-ws
|
||||
server: server
|
||||
port: 443
|
||||
type: trojan
|
||||
password: "example"
|
||||
network: ws
|
||||
sni: example.com
|
||||
# skip-cert-verify: true
|
||||
udp: true
|
||||
# ws-opts:
|
||||
# path: /path
|
||||
# headers:
|
||||
# Host: example.com
|
||||
|
||||
# ShadowsocksR
|
||||
# The supported ciphers (encryption methods): all stream ciphers in ss
|
||||
# The supported obfses:
|
||||
# plain http_simple http_post
|
||||
# random_head tls1.2_ticket_auth tls1.2_ticket_fastauth
|
||||
# The supported supported protocols:
|
||||
# origin auth_sha1_v4 auth_aes128_md5
|
||||
# auth_aes128_sha1 auth_chain_a auth_chain_b
|
||||
- name: "ssr"
|
||||
type: ssr
|
||||
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
|
||||
|
||||
proxy-groups:
|
||||
# relay chains the proxies. proxies shall not contain a relay. No UDP support.
|
||||
# Traffic: clash <-> http <-> vmess <-> ss1 <-> ss2 <-> Internet
|
||||
- name: "relay"
|
||||
type: relay
|
||||
proxies:
|
||||
- http
|
||||
- vmess
|
||||
- ss1
|
||||
- ss2
|
||||
|
||||
# url-test select which proxy will be used by benchmarking speed to a URL.
|
||||
- name: "auto"
|
||||
type: url-test
|
||||
proxies:
|
||||
- ss1
|
||||
- ss2
|
||||
- vmess1
|
||||
# tolerance: 150
|
||||
# lazy: true
|
||||
url: 'http://www.gstatic.com/generate_204'
|
||||
interval: 300
|
||||
|
||||
# fallback selects an available policy by priority. The availability is tested by accessing an URL, just like an auto url-test group.
|
||||
- name: "fallback-auto"
|
||||
type: fallback
|
||||
proxies:
|
||||
- ss1
|
||||
- ss2
|
||||
- vmess1
|
||||
url: 'http://www.gstatic.com/generate_204'
|
||||
interval: 300
|
||||
|
||||
# load-balance: The request of the same eTLD+1 will be dial to the same proxy.
|
||||
- name: "load-balance"
|
||||
type: load-balance
|
||||
proxies:
|
||||
- ss1
|
||||
- ss2
|
||||
- vmess1
|
||||
url: 'http://www.gstatic.com/generate_204'
|
||||
interval: 300
|
||||
# strategy: consistent-hashing # or round-robin
|
||||
|
||||
# select is used for selecting proxy or proxy group
|
||||
# you can use RESTful API to switch proxy is recommended for use in GUI.
|
||||
- name: Proxy
|
||||
type: select
|
||||
# disable-udp: true
|
||||
# filter: 'someregex'
|
||||
proxies:
|
||||
- ss1
|
||||
- ss2
|
||||
- vmess1
|
||||
- auto
|
||||
|
||||
# direct to another interfacename or fwmark, also supported on proxy
|
||||
- name: en1
|
||||
type: select
|
||||
interface-name: en1
|
||||
routing-mark: 6667
|
||||
proxies:
|
||||
- DIRECT
|
||||
|
||||
- name: UseProvider
|
||||
type: select
|
||||
use:
|
||||
- provider1
|
||||
proxies:
|
||||
- Proxy
|
||||
- DIRECT
|
||||
|
||||
proxy-providers:
|
||||
provider1:
|
||||
type: http
|
||||
url: "url"
|
||||
interval: 3600
|
||||
path: ./provider1.yaml
|
||||
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
|
||||
|
||||
tunnels:
|
||||
# one line config
|
||||
- tcp/udp,127.0.0.1:6553,114.114.114.114:53,proxy
|
||||
- tcp,127.0.0.1:6666,rds.mysql.com:3306,vpn
|
||||
# full yaml config
|
||||
- network: [tcp, udp]
|
||||
address: 127.0.0.1:7777
|
||||
target: target.com
|
||||
proxy: proxy
|
||||
|
||||
rules:
|
||||
- DOMAIN-SUFFIX,google.com,auto
|
||||
- DOMAIN-KEYWORD,google,auto
|
||||
- DOMAIN,google.com,auto
|
||||
- DOMAIN-SUFFIX,ad.com,REJECT
|
||||
- SRC-IP-CIDR,192.168.1.201/32,DIRECT
|
||||
# optional param "no-resolve" for IP rules (GEOIP, IP-CIDR, IP-CIDR6)
|
||||
- IP-CIDR,127.0.0.0/8,DIRECT
|
||||
- GEOIP,CN,DIRECT
|
||||
- DST-PORT,80,DIRECT
|
||||
- SRC-PORT,7777,DIRECT
|
||||
- RULE-SET,apple,REJECT # Premium only
|
||||
- MATCH,auto
|
||||
```
|
72
docs/configuration/dns.md
Normal file
72
docs/configuration/dns.md
Normal file
@ -0,0 +1,72 @@
|
||||
---
|
||||
sidebarTitle: Clash DNS
|
||||
sidebarOrder: 6
|
||||
---
|
||||
|
||||
# Clash DNS
|
||||
|
||||
Since some parts of Clash run on the Layer 3 (Network Layer), they would've been impossible to obtain domain names of the packets for rule-based routing.
|
||||
|
||||
*Enter fake-ip*. It enables rule-based routing, minimises the impact of DNS pollution attack and improves network performance, sometimes drastically.
|
||||
|
||||
## fake-ip
|
||||
|
||||
The concept of "fake IP" addresses is originated from [RFC 3089](https://tools.ietf.org/rfc/rfc3089):
|
||||
|
||||
> A "fake IP" address is used as a key to look up the corresponding "FQDN" information.
|
||||
|
||||
The default CIDR for the fake-ip pool is `198.18.0.1/16`, a reserved IPv4 address space, which can be changed in `dns.fake-ip-range`.
|
||||
|
||||
When a DNS request is sent to the Clash DNS, the core allocates a *free* fake-ip address from the pool, by managing an internal mapping of domain names and their fake-ip addresses.
|
||||
|
||||
Take an example of accessing `http://google.com` with your browser.
|
||||
|
||||
1. The browser asks Clash DNS for the IP address of `google.com`
|
||||
2. Clash checks the internal mapping and returned `198.18.1.5`
|
||||
3. The browser sends an HTTP request to `198.18.1.5` on `80/tcp`
|
||||
4. When receiving the inbound packet for `198.18.1.5`, Clash looks up the internal mapping and realises the client is actually sending a packet to `google.com`
|
||||
5. Depending on the rules:
|
||||
|
||||
1. Clash may just send the domain name to an outbound proxy like SOCKS5 or shadowsocks and establish the connection with the proxy server
|
||||
|
||||
2. or Clash might look for the real IP address of `google.com`, in the case of encountering a `SCRIPT`, `GEOIP`, `IP-CIDR` rule, or the case of DIRECT outbound
|
||||
|
||||
Being a confusing concept, I'll take another example of accessing `http://google.com` with the cURL utility:
|
||||
|
||||
```txt{2,3,5,6,8,9}
|
||||
$ curl -v http://google.com
|
||||
<---- cURL asks your system DNS (Clash) about the IP address of google.com
|
||||
----> Clash decided 198.18.1.70 should be used as google.com and remembers it
|
||||
* Trying 198.18.1.70:80...
|
||||
<---- cURL connects to 198.18.1.70 tcp/80
|
||||
----> Clash will accept the connection immediately, and..
|
||||
* Connected to google.com (198.18.1.70) port 80 (#0)
|
||||
----> Clash looks up in its memory and found 198.18.1.70 being google.com
|
||||
----> Clash looks up in the rules and sends the packet via the matching outbound
|
||||
> GET / HTTP/1.1
|
||||
> Host: google.com
|
||||
> User-Agent: curl/8.0.1
|
||||
> Accept: */*
|
||||
>
|
||||
< HTTP/1.1 301 Moved Permanently
|
||||
< Location: http://www.google.com/
|
||||
< Content-Type: text/html; charset=UTF-8
|
||||
< Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-ahELFt78xOoxhySY2lQ34A' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
|
||||
< Date: Thu, 11 May 2023 06:52:19 GMT
|
||||
< Expires: Sat, 10 Jun 2023 06:52:19 GMT
|
||||
< Cache-Control: public, max-age=2592000
|
||||
< Server: gws
|
||||
< Content-Length: 219
|
||||
< X-XSS-Protection: 0
|
||||
< X-Frame-Options: SAMEORIGIN
|
||||
<
|
||||
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<TITLE>301 Moved</TITLE></HEAD><BODY>
|
||||
<H1>301 Moved</H1>
|
||||
The document has moved
|
||||
<A HREF="http://www.google.com/">here</A>.
|
||||
</BODY></HTML>
|
||||
* Connection #0 to host google.com left intact
|
||||
```
|
||||
|
||||
<!-- TODO: nameserver, fallback, fallback-filter, hosts, search-domains, fake-ip-filter, nameserver-policy -->
|
64
docs/configuration/getting-started.md
Normal file
64
docs/configuration/getting-started.md
Normal file
@ -0,0 +1,64 @@
|
||||
---
|
||||
sidebarTitle: Getting Started
|
||||
sidebarOrder: 2
|
||||
---
|
||||
|
||||
# Getting Started
|
||||
|
||||
It's recommended that you read the [Introduction](/configuration/introduction) before proceeding. After you have a brief understanding of how Clash works, you can start writing your own configuration.
|
||||
|
||||
## Configuration Files
|
||||
|
||||
The main configuration file is called `config.yaml`. By default, Clash reads the configuration files at `$HOME/.config/clash`. If it doesn't exist, Clash will generate a minimal configuration file at that location.
|
||||
|
||||
If you want to place your configurations elsewhere (e.g. `/etc/clash`), you can use command-line option `-d` to specify a configuration directory:
|
||||
|
||||
```shell
|
||||
clash -d . # current directory
|
||||
clash -d /etc/clash
|
||||
```
|
||||
|
||||
Or, you can use option `-f` to specify a configuration file:
|
||||
|
||||
```shell
|
||||
clash -f ./config.yaml
|
||||
clash -f /etc/clash/config.yaml
|
||||
```
|
||||
|
||||
## Special Syntaxes
|
||||
|
||||
There are some special syntaxes in Clash configuration files, of which you might want to be aware:
|
||||
|
||||
### IPv6 Addresses
|
||||
|
||||
You should wrap IPv6 addresses in square brackets, for example:
|
||||
|
||||
```txt
|
||||
[aaaa::a8aa:ff:fe09:57d8]
|
||||
```
|
||||
|
||||
### DNS Wildcard Domain Matching
|
||||
|
||||
In some cases, you will need to match against wildcard domains. For example, when you're setting up [Clash DNS](/configuration/dns), you might want to match against all subdomains of `localdomain`.
|
||||
|
||||
Clash do offer support on matching different levels of wildcard domains in the DNS configuration, while the syntaxes defined below:
|
||||
|
||||
::: tip
|
||||
Any domain with these characters should be wrapped with single quotes (`'`). For example, `'*.google.com'`.
|
||||
:::
|
||||
|
||||
Use an astrisk (`*`) to match against a single-level wildcard subdomain.
|
||||
|
||||
| Expression | Matches | Does Not Match |
|
||||
| ---------- | ------- | -------------- |
|
||||
| `*.google.com` | `www.google.com` | `google.com` |
|
||||
| `*.bar.google.com` | `foo.bar.google.com` | `bar.google.com` |
|
||||
| `*.*.google.com` | `thoughtful.sandbox.google.com` | `one.two.three.google.com` |
|
||||
|
||||
Use a plus sign (`+`) to match against multi-level wildcard subdomains.
|
||||
|
||||
| Expression | Matches | Does Not Match |
|
||||
| ---------- | ------- | -------------- |
|
||||
| `+.google.com` | `www.google.com` | `www.google.com` |
|
||||
| `+.google.com` | `thoughtful.sandbox.google.com` | `www.google.com` |
|
||||
| `+.google.com` | `one.two.three.google.com` | `www.google.com` |
|
69
docs/configuration/inbound.md
Normal file
69
docs/configuration/inbound.md
Normal file
@ -0,0 +1,69 @@
|
||||
---
|
||||
sidebarTitle: Inbound
|
||||
sidebarOrder: 3
|
||||
---
|
||||
|
||||
# Inbound
|
||||
|
||||
Clash supports multiple inbound protocols, including:
|
||||
|
||||
- SOCKS5
|
||||
- HTTP(S)
|
||||
- Redirect TCP
|
||||
- TProxy TCP
|
||||
- TProxy UDP
|
||||
- Linux TUN device (Premium only)
|
||||
|
||||
Connections to any inbound protocol listed above will be handled by the same internal rule-matching engine. That is to say, Clash does not (currently) support different rule sets for different inbounds.
|
||||
|
||||
## Configuration
|
||||
|
||||
```yaml
|
||||
# Port of HTTP(S) proxy server on the local end
|
||||
# port: 7890
|
||||
|
||||
# Port of SOCKS5 proxy server on the local end
|
||||
# socks-port: 7891
|
||||
|
||||
# HTTP(S) and SOCKS4(A)/SOCKS5 server on the same port
|
||||
mixed-port: 7890
|
||||
|
||||
# Transparent proxy server port for Linux and macOS (Redirect TCP and TProxy UDP)
|
||||
# redir-port: 7892
|
||||
|
||||
# Transparent proxy server port for Linux (TProxy TCP and TProxy UDP)
|
||||
# tproxy-port: 7893
|
||||
|
||||
# Allow clients other than 127.0.0.1 to connect to the inbounds
|
||||
allow-lan: false
|
||||
```
|
||||
|
||||
## The Mixed Port
|
||||
|
||||
The mixed port is a special port that supports both HTTP(S) and SOCKS5 protocols. You can have any programs that support either HTTP or SOCKS proxy to connect to this port, for example:
|
||||
|
||||
```shell
|
||||
$ curl -x socks5h://127.0.0.1:7890 -v http://connect.rom.miui.com/generate_204
|
||||
* Trying 127.0.0.1:7890...
|
||||
* SOCKS5 connect to connect.rom.miui.com:80 (remotely resolved)
|
||||
* SOCKS5 request granted.
|
||||
* Connected to (nil) (127.0.0.1) port 7890 (#0)
|
||||
> GET /generate_204 HTTP/1.1
|
||||
> Host: connect.rom.miui.com
|
||||
> User-Agent: curl/7.81.0
|
||||
> Accept: */*
|
||||
>
|
||||
* Mark bundle as not supporting multiuse
|
||||
< HTTP/1.1 204 No Content
|
||||
< Date: Thu, 11 May 2023 06:18:22 GMT
|
||||
< Connection: keep-alive
|
||||
< Content-Type: text/plain
|
||||
<
|
||||
* Connection #0 to host (nil) left intact
|
||||
```
|
||||
|
||||
## Redirect and TProxy
|
||||
|
||||
Redirect and TProxy are two different ways of implementing transparent proxying. They are both supported by Clash.
|
||||
|
||||
However, you most likely don't need to mess with these two inbounds - we recommend using [Clash Premium](/premium/introduction) if you want to use transparent proxying, as it has built-in support of the automatic management of the route table, rules and nftables.
|
38
docs/configuration/introduction.md
Normal file
38
docs/configuration/introduction.md
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
sidebarTitle: Introduction
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
# Introduction
|
||||
|
||||
In this chapter, we'll cover the common features of Clash and how they should be used and configured.
|
||||
|
||||
Clash uses [YAML](https://yaml.org), _YAML Ain't Markup Language_, for configuration files. YAML is designed to be easy to be read, be written, and be interpreted by computers, and is commonly used for exact configuration files.
|
||||
|
||||
## Understanding how Clash works
|
||||
|
||||
Before proceeding, it's important to understand how Clash works, in which there are two critical components:
|
||||
|
||||
![](/assets/connection-flow.png)
|
||||
|
||||
<!-- https://excalidraw.com/clash-connection-flow#json=OHsOdaqAUPuuN7VPvdZ9Z,NT7rRrtzRgbVIM0tpkPnGA -->
|
||||
|
||||
### Inbound
|
||||
|
||||
Inbound is the component that listens on the local end. It works by opening a local port and listening for incoming connections. When a connection comes in, Clash looks up the rules that are configured in the configuration file, and decides which outbound that the connection should go next.
|
||||
|
||||
### Outbound
|
||||
|
||||
Outbound is the component that connects to the remote end. Depending on the configuration, it can be a specific network interface, a proxy server, or a [proxy group](#proxy-groups).
|
||||
|
||||
## Rule-based Routing
|
||||
|
||||
Clash supports rule-based routing, which means you can route packets to different outbounds based on the a variety of contraints. The rules can be defined in the `rules` section of the configuration file.
|
||||
|
||||
There's a number of available rule types, and each rule type has its own syntax. The general syntax of a rule is:
|
||||
|
||||
```txt
|
||||
TYPE,ARGUMENT,POLICY(,no-resolve)
|
||||
```
|
||||
|
||||
In the upcoming guides, you will learn more about how rules can be configured.
|
432
docs/configuration/outbound.md
Normal file
432
docs/configuration/outbound.md
Normal file
@ -0,0 +1,432 @@
|
||||
---
|
||||
sidebarTitle: Outbound
|
||||
sidebarOrder: 4
|
||||
---
|
||||
|
||||
# Outbound
|
||||
|
||||
There are several types of outbound targets in Clash. Each type has its own features and usage scenarios. In this page, we'll cover the common features of each type and how they should be used and configured.
|
||||
|
||||
[[toc]]
|
||||
|
||||
## Proxies
|
||||
|
||||
Proxies are the basic type of outbound targets.
|
||||
|
||||
### Shadowsocks
|
||||
|
||||
Clash supports the following ciphers (encryption methods) for Shadowsocks:
|
||||
|
||||
| Family | Ciphers |
|
||||
| ------ | ------- |
|
||||
| AEAD | aes-128-gcm, aes-192-gcm, aes-256-gcm, chacha20-ietf-poly1305, xchacha20-ietf-poly1305 |
|
||||
| Stream | aes-128-cfb, aes-192-cfb, aes-256-cfb, rc4-md5, chacha20-ietf, xchacha20 |
|
||||
| Block | aes-128-ctr, aes-192-ctr, aes-256-ctr |
|
||||
|
||||
In addition, Clash also supports popular Shadsocks plugins `obfs` and `v2ray-plugin`.
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [basic]
|
||||
- name: "ss1"
|
||||
type: ss
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: "password"
|
||||
# udp: true
|
||||
```
|
||||
|
||||
```yaml [obfs]
|
||||
- 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 [ws (websocket)]
|
||||
- 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 # no QUIC now
|
||||
# tls: true # wss
|
||||
# skip-cert-verify: true
|
||||
# host: bing.com
|
||||
# path: "/"
|
||||
# mux: true
|
||||
# headers:
|
||||
# custom: value
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### ShadowsocksR
|
||||
|
||||
Clash supports the infamous anti-censorship protocol ShadowsocksR as well. The supported ciphers:
|
||||
|
||||
| Family | Ciphers |
|
||||
| ------ | ------- |
|
||||
| Stream | aes-128-cfb, aes-192-cfb, aes-256-cfb, rc4-md5, chacha20-ietf, xchacha20 |
|
||||
|
||||
Supported obfuscation methods:
|
||||
|
||||
- plain
|
||||
- http_simple
|
||||
- http_post
|
||||
- random_head
|
||||
- tls1.2_ticket_auth
|
||||
- tls1.2_ticket_fastauth
|
||||
|
||||
Supported protocols:
|
||||
|
||||
- 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
|
||||
|
||||
Clash supports the following ciphers (encryption methods) for Vmess:
|
||||
|
||||
- auto
|
||||
- aes-128-gcm
|
||||
- chacha20-poly1305
|
||||
- none
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [basic]
|
||||
- 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 # priority over wss host
|
||||
# network: ws
|
||||
# ws-opts:
|
||||
# path: /path
|
||||
# headers:
|
||||
# Host: v2ray.com
|
||||
# max-early-data: 2048
|
||||
# early-data-header-name: Sec-WebSocket-Protocol
|
||||
```
|
||||
|
||||
```yaml [HTTP]
|
||||
- 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 [HTTP/2]
|
||||
- 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 [gRPC]
|
||||
- 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
|
||||
|
||||
In addition, Clash supports SOCKS5 outbound as well:
|
||||
|
||||
```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
|
||||
|
||||
Clash also supports HTTP outbound:
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [HTTP]
|
||||
- name: "http"
|
||||
type: http
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
# username: username
|
||||
# password: password
|
||||
```
|
||||
|
||||
```yaml [HTTPS]
|
||||
- name: "http"
|
||||
type: http
|
||||
# interface-name: eth0
|
||||
# routing-mark: 1234
|
||||
server: server
|
||||
port: 443
|
||||
tls: true
|
||||
# skip-cert-verify: true
|
||||
# sni: custom.com
|
||||
# username: username
|
||||
# password: password
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Snell
|
||||
|
||||
Being an alternative protocol for anti-censorship, Clash has integrated support for Snell as well.
|
||||
|
||||
```yaml
|
||||
# No UDP support yet
|
||||
- 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
|
||||
|
||||
Clash has built support for the popular protocol Trojan:
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [basic]
|
||||
- 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 [gRPC]
|
||||
- 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 [ws (websocket)]
|
||||
- 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
|
||||
|
||||
Proxy Groups are groups of proxies that you can use directly as a rule policy.
|
||||
|
||||
### relay
|
||||
|
||||
The request sent to this proxy group will be relayed through the specified proxy servers sequently. There's currently no UDP support on this. The specified proxy servers should not contain another relay.
|
||||
|
||||
### url-test
|
||||
|
||||
Clash benchmarks each proxy servers in the list, by sending HTTP HEAD requests to a specified URL through these servers periodically. It's possible to set a maximum tolerance value, benchmarking interval, and the target URL.
|
||||
|
||||
### fallback
|
||||
|
||||
Clash periodically tests the availability of servers in the list with the same mechanism of `url-test`. The first available server will be used.
|
||||
|
||||
### load-balance
|
||||
|
||||
The request to the same eTLD+1 will be dialed with the same proxy.
|
||||
|
||||
### select
|
||||
|
||||
The first server is by default used when Clash starts up. Users can choose the server to use with the RESTful API. In this mode, you can hardcode servers in the config or use [Proxy Providers](/configuration/outbound#proxy-providers).
|
||||
|
||||
Either way, sometimes you might as well just route packets with a direct connection. In this case, you can use the `DIRECT` outbound.
|
||||
|
||||
To use a different network interface, you will need to use a Proxy Group that contains a `DIRECT` outbound with the `interface-name` option set.
|
||||
|
||||
```yaml
|
||||
- name: "My Wireguard Outbound"
|
||||
type: select
|
||||
interface-name: wg0
|
||||
proxies: [ 'DIRECT' ]
|
||||
```
|
||||
|
||||
## Proxy Providers
|
||||
|
||||
Proxy Providers give users the power to load proxy server lists dynamically, instead of hardcoding them in the configuration file. There are currently two sources for a proxy provider to load server list from:
|
||||
|
||||
- `http`: Clash loads the server list from a specified URL on startup. Clash periodically pulls the server list from remote if the `interval` option is set.
|
||||
- `file`: Clash loads the server list from a specified location on the filesystem on startup.
|
||||
|
||||
Health check is available for both modes, and works exactly like `fallback` in Proxy Groups. The configuration format for the server list files is also exactly the same in the main configuration file:
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [config.yaml]
|
||||
proxy-providers:
|
||||
provider1:
|
||||
type: http
|
||||
url: "url"
|
||||
interval: 3600
|
||||
path: ./provider1.yaml
|
||||
# filter: 'a|b' # golang regex string
|
||||
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 [test.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
|
||||
```
|
||||
|
||||
:::
|
153
docs/configuration/rules.md
Normal file
153
docs/configuration/rules.md
Normal file
@ -0,0 +1,153 @@
|
||||
---
|
||||
sidebarTitle: Rules
|
||||
sidebarOrder: 5
|
||||
---
|
||||
|
||||
# Rules
|
||||
|
||||
In the Getting Started guide, we covered the basics of rule-based matching in Clash. In this chapter, we'll cover all available rule types in the latest version of Clash.
|
||||
|
||||
```txt
|
||||
TYPE,ARGUMENT,POLICY(,no-resolve)
|
||||
```
|
||||
|
||||
The `no-resolve` option is optional, and it's used to skip DNS resolution for the rule. It's useful when you want to use `GEOIP`, `IP-CIDR`, `IP-CIDR6`, `SCRIPT` rules, but don't want to resolve the domain name to an IP address just yet.
|
||||
|
||||
[[toc]]
|
||||
|
||||
## Policy
|
||||
|
||||
There are four types of POLICY for now, in which:
|
||||
|
||||
- DIRECT: directly connects to the target through `interface-name` (does not lookup system route table)
|
||||
- REJECT: drops the packet
|
||||
- Proxy: routes the packet to the specified proxy server
|
||||
- Proxy Group: routes the packet to the specified proxy group
|
||||
|
||||
## Types of rules
|
||||
|
||||
There are a number of rules where one might find useful. The following section covers each rule type and how they should be used.
|
||||
|
||||
### DOMAIN
|
||||
|
||||
`DOMAIN,www.google.com,policy` routes only `www.google.com` to `policy`.
|
||||
|
||||
### DOMAIN-SUFFIX
|
||||
|
||||
`DOMAIN-SUFFIX,youtube.com,policy` routes any domain names that ends with `youtube.com`.
|
||||
|
||||
In this case, `www.youtube.com` and `foo.bar.youtube.com` will be routed to `policy`.
|
||||
|
||||
### DOMAIN-KEYWORD
|
||||
|
||||
`DOMAIN-KEYWORD,google,policy` routes any domain names to policy that contains `google`.
|
||||
|
||||
In this case, `www.google.com` or `googleapis.com` are routed to `policy`.
|
||||
|
||||
### GEOIP
|
||||
|
||||
GEOIP rules are used to route packets based on the **country code** of the target IP address. Clash uses [MaxMind GeoLite2](https://dev.maxmind.com/geoip/geoip2/geolite2/) database for this feature.
|
||||
|
||||
::: warning
|
||||
When encountering this rule, Clash will resolve the domain name to an IP address and then look up the country code of the IP address. If you want to skip the DNS resolution, use `no-resolve` option.
|
||||
:::
|
||||
|
||||
`GEOIP,CN,policy` routes any packets destined to a China IP address to `policy`.
|
||||
|
||||
### IP-CIDR
|
||||
|
||||
IP-CIDR rules are used to route packets based on the **destination IPv4 address** of the packet.
|
||||
|
||||
::: warning
|
||||
When encountering this rule, Clash will resolve the domain name to an IP address and then look up the country code of the IP address. If you want to skip the DNS resolution, use `no-resolve` option.
|
||||
:::
|
||||
|
||||
`IP-CIDR,127.0.0.0/8,DIRECT` routes any packets destined to `127.0.0.0/8` to the `DIRECT` outbound.
|
||||
|
||||
### IP-CIDR6
|
||||
|
||||
IP-CIDR6 rules are used to route packets based on the **destination IPv6 address** of the packet.
|
||||
|
||||
::: warning
|
||||
When encountering this rule, Clash will resolve the domain name to an IP address and then look up the country code of the IP address. If you want to skip the DNS resolution, use `no-resolve` option.
|
||||
:::
|
||||
|
||||
`IP-CIDR6,2620:0:2d0:200::7/32,policy` routes any packets destined to `2620:0:2d0:200::7/32` to `policy`.
|
||||
|
||||
### SRC-IP-CIDR
|
||||
|
||||
SRC-IP-CIDR rules are used to route packets based on the **source IPv4 address** of the packet.
|
||||
|
||||
`SRC-IP-CIDR,192.168.1.201/32,DIRECT` routes any packets **from** `192.168.1.201/32` to the `DIRECT` policy.
|
||||
|
||||
### SRC-PORT
|
||||
|
||||
SRC-PORT rules are used to route packets based on the **source port** of the packet.
|
||||
|
||||
`SRC-PORT,80,policy` routes any packets **from** the port 80 to `policy`.
|
||||
|
||||
### DST-PORT
|
||||
|
||||
DST-PORT rules are used to route packets based on the **destination port** of the packet.
|
||||
|
||||
`DST-PORT,80,policy` routes any packets **to** the port 80 to `policy`.
|
||||
|
||||
### PROCESS-NAME
|
||||
|
||||
PROCESS-NAME rules are used to route packets based on the name of process that is sending the packet.
|
||||
|
||||
::: warning
|
||||
Currently, only macOS, Linux, FreeBSD and Windows are supported.
|
||||
:::
|
||||
|
||||
`PROCESS-NAME,nc,DIRECT` routes all packets from the process `nc` to the `DIRECT` outbound.
|
||||
|
||||
### PROCESS-PATH
|
||||
|
||||
PROCESS-PATH rules are used to route packets based on the PATH of process that is sending the packet.
|
||||
|
||||
::: warning
|
||||
Currently, only macOS, Linux, FreeBSD and Windows are supported.
|
||||
:::
|
||||
|
||||
`PROCESS-PATH,/bin/sh,DIRECT` routes all packets from the process `/bin/sh` to the `DIRECT` outbound.
|
||||
|
||||
### IPSET
|
||||
|
||||
IPSET rules are used to match against an IP set and route packets based on the result. According to the [official website of IPSET](https://ipset.netfilter.org/):
|
||||
|
||||
> IP sets are a framework inside the Linux kernel, which can be administered by the ipset utility. Depending on the type, an IP set may store IP addresses, networks, (TCP/UDP) port numbers, MAC addresses, interface names or combinations of them in a way, which ensures lightning speed when matching an entry against a set.
|
||||
|
||||
::: warning
|
||||
This feature only works on Linux and requires `ipset` to be installed.
|
||||
:::
|
||||
|
||||
`PROCESS-PATH,/bin/sh,DIRECT` routes all packets from the process `/bin/sh` to the `DIRECT` outbound.
|
||||
|
||||
### RULE-SET
|
||||
|
||||
::: info
|
||||
This feature is only available in the [Premium](/premium/introduction) edtion.
|
||||
:::
|
||||
|
||||
RULE-SET rules are used to route packets based on the result of a [rule provider](/premium/rule-providers). When Clash encounters this rule, it loads the rules from the specified rule provider and then matches the packet against the rules. If the packet matches any of the rules, the packet will be routed to the specified policy, otherwise the rule is skipped.
|
||||
|
||||
`RULE-SET,my-rule-provider,DIRECT` loads all rules from `my-rule-provider` and sends the matched packets to the `DIRECT` outbound.
|
||||
|
||||
### SCRIPT
|
||||
|
||||
::: info
|
||||
This feature is only available in the [Premium](/premium/introduction) edtion.
|
||||
:::
|
||||
|
||||
SCRIPT rules are special rules that are used to route packets based on the result of a [script shortcut](/premium/script-shortcuts). When Clash encounters this rule, it evaluates the expression. If it returns `true`, the packet will be routed to the specified policy, otherwise the rule is skipped.
|
||||
|
||||
::: warning
|
||||
When encountering this rule, Clash will resolve the domain name to an IP address and then look up the country code of the IP address. If you want to skip the DNS resolution, use `no-resolve` option.
|
||||
:::
|
||||
|
||||
`SCRIPT,SHORTCUT-NAME,policy` routes any packets to `policy` if they have the shortcut evaluated `true`.
|
||||
|
||||
### MATCH
|
||||
|
||||
`MATCH,policy` routes the rest of the packets to `policy`. This rule is **required**.
|
38
docs/index.md
Normal file
38
docs/index.md
Normal file
@ -0,0 +1,38 @@
|
||||
<!-- This is the index page, linked by the dummy sidebar item at Introduction/_dummy-index.md -->
|
||||
# What is Clash?
|
||||
|
||||
Welcome to the official knowledge base of the Clash core project ("Clash").
|
||||
|
||||
Clash is a cross-platform rule-based proxy utility that runs on the network and application layer, supporting various proxy and anti-censorship protocols out-of-the-box.
|
||||
|
||||
It has been adopted widely by the Internet users in some countries and regions where the Internet is heavily censored or blocked. Either way, Clash can be used by anyone who wants to improve their Internet experience.
|
||||
|
||||
There are currently two editions of Clash:
|
||||
|
||||
- [Clash](https://github.com/Dreamacro/clash): the open-source version released at [github.com/Dreamacro/clash](https://github.com/Dreamacro/clash)
|
||||
- [Clash Premium](https://github.com/Dreamacro/clash/releases/tag/premium): proprietary core with [TUN support and more](/premium/introduction) (free of charge)
|
||||
|
||||
While this wiki covers both, however, the use of Clash could be challenging for the average users. Those might want to consider using a GUI client instead, and we do have some recommendations:
|
||||
|
||||
- [Clash for Windows](https://github.com/Fndroid/clash_for_windows_pkg/releases) (Windows and macOS)
|
||||
- [Clash for Android](https://github.com/Kr328/ClashForAndroid)
|
||||
- [ClashX](https://github.com/yichengchen/clashX) or [ClashX Pro](https://install.appcenter.ms/users/clashx/apps/clashx-pro/distribution_groups/public) (macOS)
|
||||
|
||||
## Feature Overview
|
||||
|
||||
- Inbound: HTTP, HTTPS, SOCKS5 server, TUN device*
|
||||
- Outbound: Shadowsocks(R), VMess, Trojan, Snell, SOCKS5, HTTP(S), Wireguard*
|
||||
- Rule-based Routing: dynamic scripting, domain, IP addresses, process name and more*
|
||||
- Fake-IP DNS: minimises impact on DNS pollution and improves network performance
|
||||
- Transparent Proxy: Redirect TCP and TProxy TCP/UDP with automatic route table/rule management*
|
||||
- Proxy Groups: automatic fallback, load balancing or latency testing
|
||||
- Remote Providers: load remote proxy lists dynamically
|
||||
- RESTful API: update configuration in-place via a comprehensive API
|
||||
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
<small>\*: Only available in the free-of-charge Premium edition.</small>
|
||||
<!-- markdownlint-enable MD033 -->
|
||||
|
||||
## License
|
||||
|
||||
Clash is released under the [GPL-3.0](https://github.com/Dreamacro/clash/blob/master/LICENSE) open-source license. Prior to [v0.16.0](https://github.com/Dreamacro/clash/releases/tag/v0.16.0) or commit [e5284c](https://github.com/Dreamacro/clash/commit/e5284cf647717a8087a185d88d15a01096274bc2), it was licensed under the MIT license.
|
6
docs/introduction/_dummy-index.md
Normal file
6
docs/introduction/_dummy-index.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
sidebarTitle: What is Clash?
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
<!-- This file is used as a dummy sidebar item that always links to / -->
|
73
docs/introduction/faq.md
Normal file
73
docs/introduction/faq.md
Normal file
@ -0,0 +1,73 @@
|
||||
---
|
||||
sidebarTitle: Frequently Asked Questions
|
||||
sidebarOrder: 4
|
||||
---
|
||||
|
||||
# Frequently Asked Questions
|
||||
|
||||
Here we have some common questions people ask. If you have any questions not listed here, feel free to [open an issue](https://github.com/Dreamacro/clash/issues/new/choose).
|
||||
|
||||
[[toc]]
|
||||
|
||||
## Which release should I use for my system?
|
||||
|
||||
Here are some common systems that people use Clash on, and the recommended release for each of them:
|
||||
|
||||
- NETGEAR WNDR3700v2: mips-hardfloat [#846](https://github.com/Dreamacro/clash/issues/846)
|
||||
- NETGEAR WNDR3800: mips-softfloat [#579](https://github.com/Dreamacro/clash/issues/579)
|
||||
- ASUS RT-AC5300: armv5 [#2356](https://github.com/Dreamacro/clash/issues/2356)
|
||||
- MediaTek MT7620A, MT7621A: mipsle-softfloat ([#136](https://github.com/Dreamacro/clash/issues/136))
|
||||
- mips_24kc: [#192](https://github.com/Dreamacro/clash/issues/192)
|
||||
|
||||
If your device is not listed here, you can check the CPU architecture of your device with `uname -m` and find the corresponding release in the release page.
|
||||
|
||||
## List of wontfix
|
||||
|
||||
The official Clash core project will not implement/fix these things:
|
||||
|
||||
- [Snell](https://github.com/Dreamacro/clash/issues/2466)
|
||||
- [Custom CA](https://github.com/Dreamacro/clash/issues/2333)
|
||||
- [VMess Mux](https://github.com/Dreamacro/clash/issues/450)
|
||||
- [VLess](https://github.com/Dreamacro/clash/issues/1185)
|
||||
- [KCP](https://github.com/Dreamacro/clash/issues/16)
|
||||
- [mKCP](https://github.com/Dreamacro/clash/issues/2308)
|
||||
- [TLS Encrypted Client Hello](https://github.com/Dreamacro/clash/issues/2295)
|
||||
- [TCP support for Clash DNS server](https://github.com/Dreamacro/clash/issues/368)
|
||||
- [MITM](https://github.com/Dreamacro/clash/issues/227#issuecomment-508693628)
|
||||
|
||||
The following will be considered implementing when the official Go QUIC library releases.
|
||||
|
||||
- [TUIC](https://github.com/Dreamacro/clash/issues/2222)
|
||||
- [Hysteria](https://github.com/Dreamacro/clash/issues/1863)
|
||||
|
||||
## Proxies work on my local machine, but not on my router or in a container
|
||||
|
||||
Your system might be out of sync in time. Refer to your platform documentations about time synchronisation - things will break if time is not in sync.
|
||||
|
||||
## Time complexity of rule matching
|
||||
|
||||
Refer to this discussion: [#422](https://github.com/Dreamacro/clash/issues/422)
|
||||
|
||||
## Clash Premium unable to access Internet
|
||||
|
||||
You can refer to these relevant discussions:
|
||||
|
||||
- [#432](https://github.com/Dreamacro/clash/issues/432#issuecomment-571634905)
|
||||
- [#2480](https://github.com/Dreamacro/clash/issues/2480)
|
||||
|
||||
## error: unsupported rule type RULE-SET
|
||||
|
||||
If you stumbled on this error message:
|
||||
|
||||
```txt
|
||||
FATA[0000] Parse config error: Rules[0] [RULE-SET,apple,REJECT] error: unsupported rule type RULE-SET
|
||||
```
|
||||
|
||||
You're using Clash open-source edition. Rule Providers is currently only available in the [Premium core](https://github.com/Dreamacro/clash/releases/tag/premium). (it's free)
|
||||
|
||||
## DNS Hijack does not work
|
||||
|
||||
Since `tun.auto-route` does not intercept LAN traffic, if your system DNS is set to servers in private subnets, DNS hijack will not work. You can either:
|
||||
|
||||
1. Use a non-private DNS server as your system DNS like `1.1.1.1`
|
||||
2. Or manually set up your system DNS to the Clash DNS (by default, `198.18.0.1`)
|
50
docs/introduction/getting-started.md
Normal file
50
docs/introduction/getting-started.md
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
sidebarTitle: Getting Started
|
||||
sidebarOrder: 2
|
||||
---
|
||||
|
||||
# Getting Started
|
||||
|
||||
To get started with Clash, you can either build it from source or download pre-built binaries.
|
||||
|
||||
## Using pre-built binaries
|
||||
|
||||
You can download Clash core binaries here: [https://github.com/Dreamacro/clash/releases](https://github.com/Dreamacro/clash/releases)
|
||||
|
||||
## Install from source
|
||||
|
||||
You can build Clash on your own device with Golang 1.19+:
|
||||
|
||||
```shell
|
||||
$ go install github.com/Dreamacro/clash@latest
|
||||
go: downloading github.com/Dreamacro/clash v1.15.1
|
||||
```
|
||||
|
||||
The binary is built under `$GOPATH/bin`:
|
||||
|
||||
```shell
|
||||
$ $GOPATH/bin/clash -v
|
||||
Clash unknown version darwin arm64 with go1.20.3 unknown time
|
||||
```
|
||||
|
||||
## Build for a different arch/os
|
||||
|
||||
Golang supports cross-compilation, so you can build for a device on a different architecture or operating system. You can use _make_ to build them easily - for example:
|
||||
|
||||
```shell
|
||||
$ git clone --depth 1 https://github.com/Dreamacro/clash
|
||||
Cloning into 'clash'...
|
||||
remote: Enumerating objects: 359, done.
|
||||
remote: Counting objects: 100% (359/359), done.
|
||||
remote: Compressing objects: 100% (325/325), done.
|
||||
remote: Total 359 (delta 25), reused 232 (delta 17), pack-reused 0
|
||||
Receiving objects: 100% (359/359), 248.99 KiB | 1.63 MiB/s, done.
|
||||
Resolving deltas: 100% (25/25), done.
|
||||
$ cd clash && make darwin-arm64
|
||||
fatal: No names found, cannot describe anything.
|
||||
GOARCH=arm64 GOOS=darwin CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=unknown version" -X "github.com/Dreamacro/clash/constant.BuildTime=Mon May 8 16:47:10 UTC 2023" -w -s -buildid=' -o bin/clash-darwin-arm64
|
||||
$ file bin/clash-darwin-arm64
|
||||
bin/clash-darwin-arm64: Mach-O 64-bit executable arm64
|
||||
```
|
||||
|
||||
For other build targets, check out the [Makefile](https://github.com/Dreamacro/clash/blob/master/Makefile).
|
132
docs/introduction/service.md
Normal file
132
docs/introduction/service.md
Normal file
@ -0,0 +1,132 @@
|
||||
---
|
||||
sidebarTitle: Clash as a Service
|
||||
sidebarOrder: 3
|
||||
---
|
||||
|
||||
# Clash as a Service
|
||||
|
||||
While Clash is meant to be run in the background, there's currently no elegant way to implement daemons with Golang, hence we recommend you to daemonize Clash with third-party tools.
|
||||
|
||||
## systemd
|
||||
|
||||
Copy Clash binary to `/usr/local/bin` and configuration files to `/etc/clash`:
|
||||
|
||||
```shell
|
||||
cp clash /usr/local/bin
|
||||
cp config.yaml /etc/clash/
|
||||
cp Country.mmdb /etc/clash/
|
||||
```
|
||||
|
||||
Create the systemd configuration file at `/etc/systemd/system/clash.service`:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Clash daemon, A rule-based proxy in Go.
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecStart=/usr/local/bin/clash -d /etc/clash
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
After that you're supposed to reload systemd:
|
||||
|
||||
```shell
|
||||
systemctl daemon-reload
|
||||
```
|
||||
|
||||
Launch clashd on system startup with:
|
||||
|
||||
```shell
|
||||
systemctl enable clash
|
||||
```
|
||||
|
||||
Launch clashd immediately with:
|
||||
|
||||
```shell
|
||||
systemctl start clash
|
||||
```
|
||||
|
||||
Check the health and logs of Clash with:
|
||||
|
||||
```shell
|
||||
systemctl status clash
|
||||
journalctl -xe
|
||||
```
|
||||
|
||||
Credits to [ktechmidas](https://github.com/ktechmidas) for this guide. ([#754](https://github.com/Dreamacro/clash/issues/754))
|
||||
|
||||
## Docker
|
||||
|
||||
We provide pre-built images of Clash and Clash Premium. Therefore you can deploy Clash with [Docker Compose](https://docs.docker.com/compose/) if you're on Linux. However, you should be advised that it's [not recommended](https://github.com/Dreamacro/clash/issues/2249#issuecomment-1203494599) to run **Clash Premium** in a container.
|
||||
|
||||
::: warning
|
||||
This setup will not work on macOS systems due to the lack of [host networking and TUN support](https://github.com/Dreamacro/clash/issues/770#issuecomment-650951876) in Docker for Mac.
|
||||
:::
|
||||
|
||||
|
||||
::: code-group
|
||||
|
||||
```yaml [Clash]
|
||||
services:
|
||||
clash:
|
||||
image: ghcr.io/dreamacro/clash
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config.yaml:/root/.config/clash/config.yaml:ro
|
||||
# - ./ui:/ui:ro # dashboard volume
|
||||
ports:
|
||||
- "7890:7890"
|
||||
- "7891:7891"
|
||||
# - "8080:8080" # The External Controller (RESTful API)
|
||||
network_mode: "bridge"
|
||||
```
|
||||
|
||||
```yaml [Clash Premium]
|
||||
services:
|
||||
clash:
|
||||
image: ghcr.io/dreamacro/clash-premium
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config.yaml:/root/.config/clash/config.yaml:ro
|
||||
# - ./ui:/ui:ro # dashboard volume
|
||||
ports:
|
||||
- "7890:7890"
|
||||
- "7891:7891"
|
||||
# - "8080:8080" # The External Controller (RESTful API)
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
devices:
|
||||
- /dev/net/tun
|
||||
network_mode: "host"
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
Save as `docker-compose.yaml` and place your `config.yaml` in the same directory.
|
||||
|
||||
::: tip
|
||||
Before proceeding, refer to your platform documentations about time synchronisation - things will break if time is not in sync.
|
||||
:::
|
||||
|
||||
When you're ready, run the following commands to bring up Clash:
|
||||
|
||||
```shell
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
You can view the logs with:
|
||||
|
||||
```shell
|
||||
docker-compose logs
|
||||
```
|
||||
|
||||
Stop Clash with:
|
||||
|
||||
```shell
|
||||
docker-compose stop
|
||||
```
|
13
docs/package.json
Normal file
13
docs/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"scripts": {
|
||||
"docs:dev": "vitepress dev docs",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:preview": "vitepress preview docs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.1.4",
|
||||
"directory-tree": "^3.5.1",
|
||||
"markdown-yaml-metadata-parser": "^3.0.0",
|
||||
"vitepress": "^1.0.0-alpha.75"
|
||||
}
|
||||
}
|
22
docs/premium/ebpf.md
Normal file
22
docs/premium/ebpf.md
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
sidebarTitle: "Feature: eBPF Redirect to TUN"
|
||||
sidebarOrder: 3
|
||||
---
|
||||
|
||||
# eBPF Redirect to TUN
|
||||
|
||||
eBPF redirect to TUN is a feature that intercepts all network traffic on a specific network interface and redirects it to the TUN interface.
|
||||
|
||||
::: warning
|
||||
This feature conflicts with `tun.auto-route`.
|
||||
:::
|
||||
|
||||
It requires [kernel support](https://github.com/iovisor/bcc/blob/master/INSTALL.md#kernel-configuration) and is less tested, however it would bring better performance compared to `tun.auto-redir` and `tun.auto-route`.
|
||||
|
||||
## Configuration
|
||||
|
||||
```yaml
|
||||
ebpf:
|
||||
redirect-to-tun:
|
||||
- eth0
|
||||
```
|
19
docs/premium/experimental-features.md
Normal file
19
docs/premium/experimental-features.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
sidebarTitle: Experimental Features
|
||||
sidebarOrder: 9
|
||||
---
|
||||
|
||||
# Experimental Features
|
||||
|
||||
Occasionally we make new features that would require a fair amount of testing before having it in the main release. These features are marked as experimental and are disabled by default.
|
||||
|
||||
::: warning
|
||||
Some features listed here can be unstable, and might get removed in any future version - we do not recommend using them unless you have a specific reason to do so.
|
||||
:::
|
||||
|
||||
## Sniff TLS SNI
|
||||
|
||||
```yaml
|
||||
experimental:
|
||||
sniff-tls-sni: true
|
||||
```
|
26
docs/premium/introduction.md
Normal file
26
docs/premium/introduction.md
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
sidebarTitle: Introduction
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
# Introduction
|
||||
|
||||
In the past, there was only one open-source version of Clash, until some [improper uses and redistributions](https://github.com/Dreamacro/clash/issues/541#issuecomment-672029110) of Clash arose. From that, we decided to fork Clash and develop the more advanced features in a private GitHub repository.
|
||||
|
||||
Don't worry just yet - the Premium core will stay free of charge, and the security is enforced with peer reviews from multiple credible developers.
|
||||
|
||||
## What's the difference?
|
||||
|
||||
The Premium core is a fork of the open-source Clash core with the addition of the following features:
|
||||
|
||||
- [TUN Device](/premium/tun-device) with the support of `auto-redir` and `auto-route`
|
||||
- [eBPF Redirect to TUN](/premium/ebpf)
|
||||
- [Rule Providers](/premium/rule-providers)
|
||||
- [Script](/premium/script)
|
||||
- [Script Shortcuts](/premium/script-shortcuts)
|
||||
- [Userspace Wireguard](/premium/userspace-wireguard)
|
||||
- [The Profiling Engine](/premium/the-profiling-engine)
|
||||
|
||||
## Obtaining a Copy
|
||||
|
||||
You can download the latest Clash Premium binaries from [GitHub Releases](https://github.com/Dreamacro/clash/releases/tag/premium).
|
100
docs/premium/rule-providers.md
Normal file
100
docs/premium/rule-providers.md
Normal file
@ -0,0 +1,100 @@
|
||||
---
|
||||
sidebarTitle: "Feature: Rule Providers"
|
||||
sidebarOrder: 4
|
||||
---
|
||||
|
||||
# Rule Providers
|
||||
|
||||
Rule Providers are pretty much the same compared to Proxy Providers. It enables users to load rules from external sources and overall cleaner configuration. This feature is currently Premium core only.
|
||||
|
||||
To define a Rule Provider, add the `rule-providers` field to the main configuration:
|
||||
|
||||
```yaml
|
||||
rule-providers:
|
||||
apple:
|
||||
behavior: "domain" # domain, ipcidr or classical (premium core only)
|
||||
type: http
|
||||
url: "url"
|
||||
# format: 'yaml' # or 'text'
|
||||
interval: 3600
|
||||
path: ./apple.yaml
|
||||
microsoft:
|
||||
behavior: "domain"
|
||||
type: file
|
||||
path: /microsoft.yaml
|
||||
|
||||
rules:
|
||||
- RULE-SET,apple,REJECT
|
||||
- RULE-SET,microsoft,policy
|
||||
```
|
||||
|
||||
There are three behavior types available:
|
||||
|
||||
## `domain`
|
||||
|
||||
yaml:
|
||||
|
||||
```yaml
|
||||
payload:
|
||||
- '.blogger.com'
|
||||
- '*.*.microsoft.com'
|
||||
- 'books.itunes.apple.com'
|
||||
```
|
||||
|
||||
text:
|
||||
|
||||
```txt
|
||||
# comment
|
||||
.blogger.com
|
||||
*.*.microsoft.com
|
||||
books.itunes.apple.com
|
||||
```
|
||||
|
||||
## `ipcidr`
|
||||
|
||||
yaml
|
||||
|
||||
```yaml
|
||||
payload:
|
||||
- '192.168.1.0/24'
|
||||
- '10.0.0.0.1/32'
|
||||
```
|
||||
|
||||
text:
|
||||
|
||||
```txt
|
||||
# comment
|
||||
192.168.1.0/24
|
||||
10.0.0.0.1/32
|
||||
```
|
||||
|
||||
## `classical`
|
||||
|
||||
yaml:
|
||||
|
||||
```yaml
|
||||
payload:
|
||||
- DOMAIN-SUFFIX,google.com
|
||||
- DOMAIN-KEYWORD,google
|
||||
- DOMAIN,ad.com
|
||||
- SRC-IP-CIDR,192.168.1.201/32
|
||||
- IP-CIDR,127.0.0.0/8
|
||||
- GEOIP,CN
|
||||
- DST-PORT,80
|
||||
- SRC-PORT,7777
|
||||
# MATCH is not necessary here
|
||||
```
|
||||
|
||||
text:
|
||||
|
||||
```txt
|
||||
# comment
|
||||
DOMAIN-SUFFIX,google.com
|
||||
DOMAIN-KEYWORD,google
|
||||
DOMAIN,ad.com
|
||||
SRC-IP-CIDR,192.168.1.201/32
|
||||
IP-CIDR,127.0.0.0/8
|
||||
GEOIP,CN
|
||||
DST-PORT,80
|
||||
SRC-PORT,7777
|
||||
```
|
38
docs/premium/script-shortcuts.md
Normal file
38
docs/premium/script-shortcuts.md
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
sidebarTitle: "Feature: Script Shortcuts"
|
||||
sidebarOrder: 6
|
||||
---
|
||||
|
||||
# Script Shortcuts
|
||||
|
||||
Clash Premium implements the Scripting feature powered by Python3, enableing users to programmatically select policies for the packets with dynamic flexibility.
|
||||
|
||||
You can either controll the entire rule-matching engine with a single Python script, or define a number of shortcuts and use them in companion with the regular rules. This page refers to the latter feature, for the former, see [Script](./script.md).
|
||||
|
||||
This feature enables the use of script in `rules` mode. By default, DNS resolution takes place for SCRIPT rules. `no-resolve` can be appended to the rule to prevent the resolution. (i.e.: `SCRIPT,quic,DIRECT,no-resolve`)
|
||||
|
||||
**NOTE: ****`src_port`**** and ****`dst_port`**** are number**
|
||||
|
||||
```yaml
|
||||
mode: Rule
|
||||
|
||||
script:
|
||||
shortcuts:
|
||||
quic: network == 'udp' and dst_port == 443
|
||||
curl: resolve_process_name() == 'curl'
|
||||
# curl: resolve_process_path() == '/usr/bin/curl'
|
||||
|
||||
rules:
|
||||
- SCRIPT,quic,REJECT
|
||||
```
|
||||
|
||||
## Function Definitions
|
||||
|
||||
```ts
|
||||
type resolve_ip = (host: string) => string // ip string
|
||||
type in_cidr = (ip: string, cidr: string) => boolean // ip in cidr
|
||||
type geoip = (ip: string) => string // country code
|
||||
type match_provider = (name: string) => boolean // in rule provider
|
||||
type resolve_process_name = () => string // find process name (curl .e.g)
|
||||
type resolve_process_path = () => string // find process path (/usr/bin/curl .e.g)
|
||||
```
|
70
docs/premium/script.md
Normal file
70
docs/premium/script.md
Normal file
@ -0,0 +1,70 @@
|
||||
---
|
||||
sidebarTitle: "Feature: Script"
|
||||
sidebarOrder: 5
|
||||
---
|
||||
|
||||
# Script
|
||||
|
||||
Clash Premium implements the Scripting feature powered by Python3, enableing users to programmatically select policies for the packets with dynamic flexibility.
|
||||
|
||||
You can either controll the entire rule-matching engine with a single Python script, or define a number of shortcuts and use them in companion with the regular rules. This page refers to the first feature, for the latter, see [Script Shortcuts](./script-shortcuts.md).
|
||||
|
||||
## Scripting the entire rule-matching engine
|
||||
|
||||
```yaml
|
||||
mode: Script
|
||||
|
||||
# https://lancellc.gitbook.io/clash/clash-config-file/script
|
||||
script:
|
||||
code: |
|
||||
def main(ctx, metadata):
|
||||
ip = metadata["dst_ip"] = ctx.resolve_ip(metadata["host"])
|
||||
if ip == "":
|
||||
return "DIRECT"
|
||||
|
||||
code = ctx.geoip(ip)
|
||||
if code == "LAN" or code == "CN":
|
||||
return "DIRECT"
|
||||
|
||||
return "Proxy" # default policy for requests which are not matched by any other script
|
||||
```
|
||||
|
||||
If you want to use ip rules (i.e.: IP-CIDR, GEOIP, etc), you will first need to manually resolve IP addresses and assign them to metadata:
|
||||
|
||||
```python
|
||||
def main(ctx, metadata):
|
||||
# ctx.rule_providers["geoip"].match(metadata) return false
|
||||
|
||||
ip = ctx.resolve_ip(metadata["host"])
|
||||
if ip == "":
|
||||
return "DIRECT"
|
||||
metadata["dst_ip"] = ip
|
||||
|
||||
# ctx.rule_providers["iprule"].match(metadata) return true
|
||||
|
||||
return "Proxy"
|
||||
```
|
||||
|
||||
Interface definition for Metadata and Context:
|
||||
|
||||
```ts
|
||||
interface Metadata {
|
||||
type: string // socks5、http
|
||||
network: string // tcp
|
||||
host: string
|
||||
src_ip: string
|
||||
src_port: string
|
||||
dst_ip: string
|
||||
dst_port: string
|
||||
}
|
||||
|
||||
interface Context {
|
||||
resolve_ip: (host: string) => string // ip string
|
||||
resolve_process_name: (metadata: Metadata) => string
|
||||
resolve_process_path: (metadata: Metadata) => string
|
||||
geoip: (ip: string) => string // country code
|
||||
log: (log: string) => void
|
||||
proxy_providers: Record<string, Array<{ name: string, alive: boolean, delay: number }>>
|
||||
rule_providers: Record<string, { match: (metadata: Metadata) => boolean }>
|
||||
}
|
||||
```
|
13
docs/premium/the-profiling-engine.md
Normal file
13
docs/premium/the-profiling-engine.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
sidebarTitle: "Feature: The Profiling Engine"
|
||||
sidebarOrder: 8
|
||||
---
|
||||
|
||||
# The Profiling Engine
|
||||
|
||||
https://github.com/Dreamacro/clash-tracing
|
||||
|
||||
```yaml
|
||||
profile:
|
||||
tracing: true
|
||||
```
|
65
docs/premium/tun-device.md
Normal file
65
docs/premium/tun-device.md
Normal file
@ -0,0 +1,65 @@
|
||||
---
|
||||
sidebarTitle: "Feature: TUN Device"
|
||||
sidebarOrder: 2
|
||||
---
|
||||
|
||||
# TUN Device
|
||||
|
||||
The Premium core has out-of-the-box support of TUN device. Being a Network layer device, it can be used to handle TCP, UDP, ICMP traffic. It has been extensively tested and used in production environments - you can even play competitive games with it.
|
||||
|
||||
One of the biggest advantage of using Clash TUN is the built-in support of the *automagic* management of the route table, routing rules and nftable. You can enable it with the options `tun.auto-route` and `tun.auto-redir`. It's a drop-in replacement of the ancient configuration option `redir-port` (TCP) for the sake of easier configuration and better stability.
|
||||
|
||||
::: tip
|
||||
`tun.auto-route` and `tun.auto-redir` are only available on macOS, Windows, Linux and Android, and only receives IPv4 traffic.
|
||||
:::
|
||||
|
||||
There are two options of TCP/IP stack available: `system` or `gvisor`. In order to get the best performance available, we recommend that you always use `system` stack unless you have a specific reason or compatibility issue to use `gvisor`. If that's the case, do not hesitate to [submit an issue](https://github.com/Dreamacro/clash/issues/new/choose).
|
||||
|
||||
## Technical Limitations
|
||||
|
||||
* For Android, the control device is at `/dev/tun` instead of `/dev/net/tun`, you will need to create a symbolic link first (i.e. `ln -sf /dev/tun /dev/net/tun`)
|
||||
|
||||
* DNS hijacking might result in a failure, if the system DNS is at a private IP address (since `auto-route` does not capture private network traffic).
|
||||
|
||||
## Linux, macOS or Android
|
||||
|
||||
This is an example configuration of the TUN feature:
|
||||
|
||||
```yaml
|
||||
interface-name: en0 # conflict with `tun.auto-detect-interface`
|
||||
|
||||
tun:
|
||||
enable: true
|
||||
stack: system # or gvisor
|
||||
# dns-hijack:
|
||||
# - 8.8.8.8:53
|
||||
# - tcp://8.8.8.8:53
|
||||
# - any:53
|
||||
# - tcp://any:53
|
||||
auto-route: true # manage `ip route` and `ip rules`
|
||||
auto-redir: true # manage nftable REDIRECT
|
||||
auto-detect-interface: true # conflict with `interface-name`
|
||||
```
|
||||
|
||||
Be advised, since the use of TUN device and manipulation of system route/nft settings, Clash will need superuser privileges to run.
|
||||
|
||||
```shell
|
||||
sudo ./clash
|
||||
```
|
||||
|
||||
If your device already has some TUN device, Clash TUN might not work - you will have to check the route table and routing rules manually. In this case, `fake-ip-filter` may helpful as well.
|
||||
|
||||
## Windows
|
||||
|
||||
You will need to visit the [WinTUN website](https://www.wintun.net) and download the latest release. After that, copy `wintun.dll` into Clash home directory. Example configuration:
|
||||
|
||||
```yaml
|
||||
tun:
|
||||
enable: true
|
||||
stack: gvisor # or system
|
||||
dns-hijack:
|
||||
- 198.18.0.2:53 # when `fake-ip-range` is 198.18.0.1/16, should hijack 198.18.0.2:53
|
||||
auto-route: true # auto set global route for Windows
|
||||
# It is recommended to use `interface-name`
|
||||
auto-detect-interface: true # auto detect interface, conflict with `interface-name`
|
||||
```
|
25
docs/premium/userspace-wireguard.md
Normal file
25
docs/premium/userspace-wireguard.md
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
sidebarTitle: "Feature: Userspace Wireguard"
|
||||
sidebarOrder: 7
|
||||
---
|
||||
|
||||
# Userspace Wireguard
|
||||
|
||||
Due to the dependency on gvisor TCP/IP stack, Wireguard outbound is currently only available in the Premium core.
|
||||
|
||||
```yaml
|
||||
proxies:
|
||||
- name: "wg"
|
||||
type: wireguard
|
||||
server: 127.0.0.1
|
||||
port: 443
|
||||
ip: 172.16.0.2
|
||||
# ipv6: your_ipv6
|
||||
private-key: eCtXsJZ27+4PbhDkHnB923tkUn2Gj59wZw5wFA75MnU=
|
||||
public-key: Cr8hWlKvtDt7nrvf+f0brNQQzabAqrjfBvas9pmowjo=
|
||||
# preshared-key: base64
|
||||
# remote-dns-resolve: true # remote resolve DNS with `dns` field, default is true
|
||||
# dns: [1.1.1.1, 8.8.8.8]
|
||||
# mtu: 1420
|
||||
udp: true
|
||||
```
|
130
docs/runtime/external-controller.md
Normal file
130
docs/runtime/external-controller.md
Normal file
@ -0,0 +1,130 @@
|
||||
---
|
||||
sidebarTitle: The External Controller
|
||||
sidebarOrder: 1
|
||||
---
|
||||
|
||||
# The External Controller
|
||||
|
||||
## Introduction
|
||||
|
||||
External Controller enables users to control Clash programmatically with the HTTP RESTful API. The third-party Clash GUIs are heavily based on this feature. Enable this feature by specifying an address in `external-controller`.
|
||||
|
||||
## Authentication
|
||||
|
||||
- External Controllers Accept `Bearer Tokens` as access authentication method.
|
||||
- Use `Authorization: Bearer <Your Secret>` as your request header in order to pass credentials.
|
||||
|
||||
## RESTful API Documentation
|
||||
|
||||
### Logs
|
||||
|
||||
- `/logs`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /logs`
|
||||
- Description: Get real-time logs
|
||||
|
||||
### Traffic
|
||||
|
||||
- `/traffic`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /traffic`
|
||||
- Description: Get real-time traffic data
|
||||
|
||||
### Version
|
||||
|
||||
- `/version`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /version`
|
||||
- Description: Get clash version
|
||||
|
||||
### Configs
|
||||
|
||||
- `/configs`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /configs`
|
||||
- Description: Get base configs
|
||||
|
||||
- Method: `PUT`
|
||||
- Full Path: `PUT /configs`
|
||||
- Description: Reloading base configs
|
||||
|
||||
- Method: `PATCH`
|
||||
- Full Path: `PATCH /configs`
|
||||
- Description: Update base configs
|
||||
|
||||
### Proxies
|
||||
|
||||
- `/proxies`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /proxies`
|
||||
- Description: Get proxies information
|
||||
|
||||
- `/proxies/:name`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /proxies/:name`
|
||||
- Description: Get specific proxy information
|
||||
|
||||
- Method: `PUT`
|
||||
- Full Path: `PUT /proxies/:name`
|
||||
- Description: Select specific proxy
|
||||
|
||||
- `/proxies/:name/delay`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /proxies/:name/delay`
|
||||
- Description: Get specific proxy delay test information
|
||||
|
||||
### Rules
|
||||
|
||||
- `/rules`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /rules`
|
||||
- Description: Get rules information
|
||||
|
||||
### Connections
|
||||
|
||||
- `/connections`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /connections`
|
||||
- Description: Get connections information
|
||||
|
||||
- Method: `DELETE`
|
||||
- Full Path: `DELETE /connections`
|
||||
- Description: Close all connections
|
||||
|
||||
- `/connections/:id`
|
||||
- Method: `DELETE`
|
||||
- Full Path: `DELETE /connections/:id`
|
||||
- Description: Close specific connection
|
||||
|
||||
### Providers
|
||||
|
||||
- `/providers/proxies`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /providers/proxies`
|
||||
- Description: Get all proxies information for all proxy-providers
|
||||
|
||||
- `/providers/proxies/:name`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /providers/proxies/:name`
|
||||
- Description: Get proxies information for specific proxy-provider
|
||||
|
||||
- Method: `PUT`
|
||||
- Full Path: `PUT /providers/proxies/:name`
|
||||
- Description: Select specific proxy-provider
|
||||
|
||||
- `/providers/proxies/:name/healthcheck`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /providers/proxies/:name/healthcheck`
|
||||
- Description: Get proxies information for specific proxy-provider
|
||||
|
||||
### DNS Query
|
||||
|
||||
- `/dns/query`
|
||||
- Method: `GET`
|
||||
- Full Path: `GET /dns/query?name={name}[&type={type}]`
|
||||
- Description: Get DNS query data for a specified name and type.
|
||||
- Parameters:
|
||||
- `name` (required): The domain name to query.
|
||||
- `type` (optional): The DNS record type to query (e.g., A, MX, CNAME, etc.). Defaults to `A` if not provided.
|
||||
|
||||
- Example: `GET /dns/query?name=example.com&type=A`
|
Loading…
Reference in New Issue
Block a user