pub struct ClashConfigDef {
Show 26 fields pub port: Option<u16>, pub socks_port: Option<u16>, pub mixed_port: Option<u16>, pub authentication: Vec<String, Global>, pub allow_lan: bool, pub bind_address: String, pub mode: RunMode, pub log_level: LogLevel, pub dns: DNS, pub profile: Profile, pub proxy: Vec<HashMap<String, Value, RandomState>, Global>, pub proxy_group: Vec<HashMap<String, Value, RandomState>, Global>, pub rule: Vec<String, Global>, pub hosts: HashMap<String, String, RandomState>, pub mmdb: String, pub mmdb_download_url: Option<String>, pub ipv6: Option<bool>, pub external_controller: Option<String>, pub external_ui: Option<String>, pub secret: Option<String>, pub interface: Option<String>, pub routing_mask: Option<u32>, pub proxy_provider: Option<HashMap<String, HashMap<String, Value, RandomState>, RandomState>>, pub rule_provider: Option<HashMap<String, HashMap<String, Value, RandomState>, RandomState>>, pub experimental: Option<Experimental>, pub tun: Option<HashMap<String, Value, RandomState>>, /* private fields */
}
Expand description

docs for clash Example

---
port: 8888
socks-port: 8889
mixed-port: 8899
tun:
  enable: false
  device-id: "dev://utun1989"
dns:
  enable: true
  listen: 127.0.0.1:53553
  #   udp: 127.0.0.1:53553
  #   tcp: 127.0.0.1:53553
  #   dot: 127.0.0.1:53554
  #   doh: 127.0.0.1:53555
  # 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.2/16 # Fake IP addresses pool CIDR
  # use-hosts: true # lookup hosts and return IP 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
    - 1.1.1.1 # default value
    - tls://1.1.1.1:853 # DNS over TLS
    - https://1.1.1.1/dns-query # DNS over HTTPS
#    - dhcp://en0 # dns from dhcp
allow-lan: true
mode: rule
log-level: debug
external-controller: 127.0.0.1:9090
external-ui: "public"
# secret: "clash-rs"
experimental:
  ignore-resolve-fail: true
profile:
  store-selected: true
  store-fake-ip: false
proxy-groups:
  - name: "relay"
    type: relay
    proxies:
      - "plain-vmess"
      - "ws-vmess"
      - "auto"
      - "fallback-auto"
      - "load-balance"
      - "select"
      - DIRECT
  - name: "relay-one"
    type: relay
    use:
      - "file-provider"
  - name: "auto"
    type: url-test
    use:
      - "file-provider"
    proxies:
      - DIRECT
    url: "http://www.gstatic.com/generate_204"
    interval: 300
  - name: "fallback-auto"
    type: fallback
    use:
      - "file-provider"
    proxies:
      - DIRECT
    url: "http://www.gstatic.com/generate_204"
    interval: 300
  - name: "load-balance"
    type: load-balance
    use:
      - "file-provider"
    proxies:
      - DIRECT
    strategy: round-robin
    url: "http://www.gstatic.com/generate_204"
    interval: 300
  - name: select
    type: select
    use:
      - "file-provider"
  - name: test 🌏
    type: select
    use:
      - "file-provider"
    proxies:
      - DIRECT
proxies:
  - name: plain-vmess
    type: vmess
    server: 10.0.0.13
    port: 16823
    uuid: b831381d-6324-4d53-ad4f-8cda48b30811
    alterId: 0
    cipher: auto
    udp: true
    skip-cert-verify: true
  - name: ws-vmess
    type: vmess
    server: 10.0.0.13
    port: 16824
    uuid: b831381d-6324-4d53-ad4f-8cda48b30811
    alterId: 0
    cipher: auto
    udp: true
    skip-cert-verify: true
    network: ws
    ws-opts:
      path: /api/v3/download.getFile
      headers:
        Host: www.amazon.com
  - name: tls-vmess
    type: vmess
    server: 10.0.0.13
    port: 8443
    uuid: 23ad6b10-8d1a-40f7-8ad0-e3e35cd38297
    alterId: 0
    cipher: auto
    udp: true
    skip-cert-verify: true
    tls: true
  - name: h2-vmess
    type: vmess
    server: 10.0.0.13
    port: 8444
    uuid: b831381d-6324-4d53-ad4f-8cda48b30811
    alterId: 0
    cipher: auto
    udp: true
    skip-cert-verify: true
    tls: true
    network: h2
    h2-opts:
      path: /ray
  - name: vmess-altid
    type: vmess
    server: tw-1.ac.laowanxiang.com
    port: 153
    uuid: 46dd0dd3-2cc0-3f55-907c-d94e54877687
    alterId: 64
    cipher: auto
    udp: true
    network: ws
    ws-opts:
      path: /api/v3/download.getFile
      headers:
        Host: 5607b9d187e655736f563fee87d7283994721.laowanxiang.com
  - name: "ss-simple"
    type: ss
    server: 10.0.0.13
    port: 8388
    cipher: aes-256-gcm
    password: "password"
    udp: true
  - name: "trojan"
    type: trojan
    server: 10.0.0.13
    port: 9443
    password: password1
    udp: true
    # sni: example.com # aka server name
    alpn:
      - h2
      - http/1.1
    skip-cert-verify: true
proxy-providers:
  file-provider:
    type: file
    path: ./ss.yaml
    interval: 300
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300
rule-providers:
  file-provider:
    type: file
    path: ./rule-set.yaml
    interval: 300
    behavior: domain
rules:
  - DOMAIN,ipinfo.io,relay
  - RULE-SET,file-provider,trojan
  - GEOIP,CN,relay
  - DOMAIN-SUFFIX,facebook.com,REJECT
  - DOMAIN-KEYWORD,google,select
  - DOMAIN,google.com,select
  - SRC-IP-CIDR,192.168.1.1/24,DIRECT
  - GEOIP,CN,DIRECT
  - DST-PORT,53,trojan
  - SRC-PORT,7777,DIRECT
  - MATCH, DIRECT
...

Fields§

§port: Option<u16>

The HTTP proxy port

§socks_port: Option<u16>

The SOCKS5 proxy port

§mixed_port: Option<u16>

The HTTP/SOCKS5 mixed proxy port

Example

mixed-port: 7892
§authentication: Vec<String, Global>

HTTP and SOCKS5 proxy authentication

§allow_lan: bool
👎Deprecated: dont use. see bind_address

Allow connections to the local-end server from other LAN IP addresses

§bind_address: String

The address that the inbound listens on

Note

  • setting this to * will listen on all interfaces, which is essentially the same as setting it to 0.0.0.0
  • setting this to non local IP will enable allow_lan automatically
  • and if you don’t want allow_lan to be enabled, you should set this to localhost or 127.1
§mode: RunMode

Clash router working mode Either rule, global or direct

§log_level: LogLevel

Log level Either debug, info, warning, error or off

§dns: DNS

DNS client/server settings

§profile: Profile

Profile settings

§proxy: Vec<HashMap<String, Value, RandomState>, Global>

Proxy settings

§proxy_group: Vec<HashMap<String, Value, RandomState>, Global>

Proxy group settings

§rule: Vec<String, Global>

Rule settings

§hosts: HashMap<String, String, RandomState>

Hosts

§mmdb: String

Country database path relative to the $CWD

§mmdb_download_url: Option<String>

Country database download url

§ipv6: Option<bool>
👎Deprecated: this is essentially just dns.ipv6 in original clash

these options has default vals, and needs extra processing

§external_controller: Option<String>

external controller address

§external_ui: Option<String>

dashboard folder path relative to the $CWD

§secret: Option<String>

external controller secret

§interface: Option<String>

outbound interface name

Note

  • not implemented yet
§routing_mask: Option<u32>

fwmark on Linux only

Note

  • not implemented yet
§proxy_provider: Option<HashMap<String, HashMap<String, Value, RandomState>, RandomState>>

proxy provider settings

§rule_provider: Option<HashMap<String, HashMap<String, Value, RandomState>, RandomState>>

rule provider settings

§experimental: Option<Experimental>

experimental settings, if any

§tun: Option<HashMap<String, Value, RandomState>>

tun settings

Example

tun:
  enable: true
  device-id: "dev://utun1989"

Trait Implementations§

§

impl Default for Config

§

fn default() -> Config

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for Configwhere Config: Default,

§

fn deserialize<__D>( __deserializer: __D ) -> Result<Config, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl FromStr for Config

§

type Err = Error

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<Config, <Config as FromStr>::Err>

Parses a string s to return a value of this type. Read more
§

impl Serialize for Config

§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> Serialize for Twhere T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,