Skip to content

Instantly share code, notes, and snippets.

@m2kar
Created December 7, 2024 16:14
Show Gist options
  • Save m2kar/90687a1326542b8c7f5ec2e8cd78af99 to your computer and use it in GitHub Desktop.
Save m2kar/90687a1326542b8c7f5ec2e8cd78af99 to your computer and use it in GitHub Desktop.
safari pac file debug
// 在macOS Safari中调试代理pac文件的方法
// 思路:把调试信息转换为域名,并使用Wireshark抓包
// Wireshark规则: (dns) && (dns.qry.name contains "test-pac.local")
function sanitizeAndConvertToDomain(input) {
// 去除非法字符,只保留字母、数字、点和连字符
const sanitized = input.replace(/[^a-zA-Z0-9.-]/g, '');
// 确保字符串以域名格式返回
const parts = sanitized.split('.');
const domain = parts.filter(part => part.length > 0).join('.');
return domain;
}
function proxyify(input) {
return "PROXY " + sanitizeAndConvertToDomain(input)+".test-pac.local;";
}
var proxy = "SOCKS5 XXX:7890;";
var direct = "DIRECT";
function FindProxyForURL(url, host) {
var debugInfo;
debugInfo="debug."+"hosteq."+host+".";
debugInfo+="urleq."+url+".";
var remote = dnsResolve(host);
debugInfo+="remoteeq."+remote+".";
return proxyify(debugInfo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment