Syntax¶
mihomo uses yaml
as the configuration file format.
yaml
is case-sensitive and uses indentation to represent hierarchical relationships. Tabs are not allowed for indentation; only spaces are permitted. The number of spaces for indentation is not critical, as long as elements at the same level are left-aligned.
Comments¶
In a yaml
file, comments start with "#" at the beginning of a line and end with the line. "#" must be at the beginning of a line or must have a space in front to be considered a comment.
Objects¶
Key-value pairs in objects are represented using a colon structure key: value. There should be a space after the colon, and indentation is used to show hierarchical relationships.
As yaml is a superset of json, you can directly use json syntax.
Multiline¶
Multiline JSON Extension¶
Single-line JSON Extension¶
Full JSON (Not Recommended)¶
Arrays¶
Lines starting with - form an array and are used for multiple values within an object.
Multiline Arrays¶
Single-line JSON Arrays¶
References¶
&
for anchors and *
for aliases can be used for referencing. &
is used to establish an anchor, <<
is used to merge into the current data, and *
is used to reference an anchor.
In the following example, because the key p does not exist in Clash, it will be ignored when Clash parses the configuration. If there are duplicate keys during merging, the merging process will not occur.
Equivalent to:
IPv6 Addresses¶
In Clash configuration, use []
to frame an IPv6 address.
Domain Wildcards¶
Wildcard *
¶
Clash's *
wildcard can only match one-level domains.
*.baidu.com
only matches tieba.baidu.com
and not 123.tieba.baidu.com
or baidu.com
.
*
only matches hostnames without a .
such as localhost
.
Wildcard +
¶
The +
wildcard is similar to DOMAIN-SUFFIX and can match multiple levels at once.
+.baidu.com
matches tieba.baidu.com
and 123.tieba.baidu.com
or baidu.com
. The +
wildcard can only be used for domain prefix matching.
Wildcard .
¶
The .
wildcard can match multiple levels at once.
.baidu.com
matches tieba.baidu.com
and 123.tieba.baidu.com
but not baidu.com
. The .
wildcard can only be used for domain prefix matching.
Usage Example¶
When using wildcards, be sure to wrap the content in single or double quotes (''
or ""
) to prevent excessive matching.