Open 54chen opened 3 years ago
https://github.com/Cenmrev/V2RayX/blob/3551c3eb496d403a96c7bd5ef8c31988636e4a4f/V2RayX/simple.pac#L201
If you have a domain in list like '138.com', 'ip138.com' will be matched in MacOS.
The better way is setting the list like '*.138.com', using shExpMatch instead of dnsDomainIs.
BTW: be careful, you must add 'twitter.com' in list, '.twitter.com' will NOT* hit it.
Here is an auto generating shell file enclosed.
#!/bin/bash # # 从 gfwlist 更新 pac.js readonly GFWLIST_PATH="https://gitlab.com/gfwlist/gfwlist/raw/master/gfwlist.txt" # 扩展域名,添加额外需要代理的域名 declare -a EXTEND_DOMAINS EXTEND_DOMAINS=( github.com githubusercontent.com ) echo -e "下载 gfwlist.txt..." # 开头 cat << 'EOF' > pac.js var V2Ray = "SOCKS5 127.0.0.1:1081; SOCKS 127.0.0.1:1081; DIRECT;"; var domains = [ EOF # 域名 for line in "${EXTEND_DOMAINS[@]}"; do echo " \"*.${line}\"," >> pac.js echo " \"${line}\"," >> pac.js done; while IFS= read -r line; do if [[ "${line}" == .* ]]; then echo " \"*.${line:1}\"," >> pac.js echo " \"${line:1}\"," >> pac.js fi if [[ "${line}" == \|\|* ]]; then echo " \"*.${line:2}\"," >> pac.js echo " \"${line:2}\"," >> pac.js fi #done < <(curl -sSfL "${GFWLIST_PATH}" | tr -d '\n' | base64 --decode) done < <(curl -sSfL "${GFWLIST_PATH}" | tr -d '\n' | base64 --decode | sort | uniq) # 结尾 cat << 'EOF' >> pac.js ]; function FindProxyForURL(url, host) { for (var i = domains.length - 1; i >= 0; i--) { if (shExpMatch(host, domains[i])) { return V2Ray; } } return "DIRECT"; } EOF echo -e "\n\033[32m更新完成 pac.js\033[0m\n"
Reference: https://opensource.apple.com/source/CFNetwork/CFNetwork-128/PACSupport.js.auto.html
其实pac已经可以功成身退了
https://github.com/Cenmrev/V2RayX/blob/3551c3eb496d403a96c7bd5ef8c31988636e4a4f/V2RayX/simple.pac#L201
If you have a domain in list like '138.com', 'ip138.com' will be matched in MacOS.
The better way is setting the list like '*.138.com', using shExpMatch instead of dnsDomainIs.
BTW: be careful, you must add 'twitter.com' in list, '.twitter.com' will NOT* hit it.
Here is an auto generating shell file enclosed.
Reference: https://opensource.apple.com/source/CFNetwork/CFNetwork-128/PACSupport.js.auto.html