myesn

myEsn2E9

hi
github

Clash for Windows takes into account Profiles (Subscription) updates and custom rules.

Edit the "Parsers" field:
image

Fill in the following configuration (YAML syntax):

parsers:
  - url: https://example.com/example.yaml
    code: |
      module.exports.parse = (raw, { yaml }) => {
        const { rules = [], ...rest } = yaml.parse(raw) || {}
        const removeList = [
          'DOMAIN-SUFFIX,notion.so,KELECLOUD',
          'MATCH,KELECLOUD'
        ]
        const addList = [
          'MATCH,DIRECT'
        ]

        const newRules = rules.filter(x => !removeList.includes(x))
        newRules.push(...addList)

        return yaml.stringify({ ...rest, rules: newRules })
      }

Then make the following modifications to the above configuration:

  1. Change the value of the url configuration to your own subscription address.
  2. Fill in the array of rules to be removed in the removeList, and fill in the array of rules to be added in the addList. For rule syntax, please refer to: Rule Editing | Clash for Windows (lbyczf.com). Common matching rules include:
    Assuming the domain to be proxied is "baidubce.com":
    • DOMAIN-SUFFIX: Domain suffix matching, for example: it will proxy requests for "baidubce.com" and all domains under "*.baidubce.com", i.e., all domains with a suffix of "a.com".
    • DOMAIN: Domain matching, for example: only proxy requests under the specified domain "baidubce.com".
      Examples:
    • "DOMAIN,baidubce.com,DIRECT" means proxy requests for the specified domain "a.com", and requests that match the rule will use the DIRECT strategy, which means direct connection without going through the proxy. "DIRECT" and "REJECT" are built-in policies in Clash for Windows, while others are custom policies. The names of "proxy-groups" configured by the subscription and the airport owner may vary, depending on the configuration of "proxy-groups" in your subscription, and "proxy-groups" will group the values of the "proxies" field.
    • "DOMAIN-SUFFIX,baidubce.com,KELECLOUD" means proxy requests for the domain "baidubce.com" and "*.baidubce.com", and requests that match the rule will use the "KELECLOUD" strategy (a custom strategy defined by the airport owner), and the value of this strategy is taken from the "proxy-groups" field in the subscription content.
  3. Update the subscription, because the js code rules configured in parsers will only be executed after each subscription update.

After configuring, you can test whether the rules meet expectations by searching for the IP keyword on Baidu. The IP query module of Baidu calls the interface domain suffix "baidubce.com" in the example above:
image

References#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.