Skip to content

Instantly share code, notes, and snippets.

@szy0syz
Last active January 2, 2024 13:45
Show Gist options
  • Save szy0syz/8c9bc0feccaebad85d5bbe6dc758a1a1 to your computer and use it in GitHub Desktop.
Save szy0syz/8c9bc0feccaebad85d5bbe6dc758a1a1 to your computer and use it in GitHub Desktop.
MAC ShadowSocks 自定义规则

ShadowSocks 自定义规则

ShadowSocks 规则格式说明

ShadowSocks 默认使用的 GFWList 规则,这里有一份 gfwlist2pac

ShadowSocks 默认使用的是 adblock plus 的引擎,要想自己添加规则最好熟悉一下其规则,下面是ShadowSocks 的 pac 规则。

中文版: Adblock Plus 过滤规则 英文版: Adblock Plus filters explained

  • 规则大概描述如下:
    1. 通配符支持,如*.example.com/*实际书写时可省略 * 如.example.com/意即*.example.com/*
    2. 正则表达式支持,以\开始和结束,如\[\w]+:\/\/example.com\
    3. 例外规则@@,如@@*.example.com/*满足@@后规则的地址不使用代理
    4. 匹配地址开始和结尾|,如|http://example.com、example.com|分别表示以http://example.com开始和以example.com结束的地址
    5. ||标记,如||example.comhttp://example.comhttps://example.comftp://example.com等地址均满足条件,只用于匹配地址开头
    6. 注释!! Comment
    7. 分隔符^,表示除了字母、数字或者 _ - . % 之外的任何字符。如http://example.com^http://example.com/http://example.com:8000/均满足条件,而http://example.com.ar/不满足条件

如何使用自定义规则

如果 GFWList 的自带规则无法满足你的需求,你可以点击 ShadowSocks 选择『编辑GFWList的用户规则』项,使用编辑器打开user-rule.txt文件,在文件中加入你的规则,格式如下:

! Put user rules line by line in this file.
! See https://adblockplus.org/en/filter-cheatsheet
||gist.github.com

copy to: http://honglu.me/2015/06/26/ShadowSocks%E8%87%AA%E5%AE%9A%E4%B9%89%E8%A7%84%E5%88%99/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment