iptv/wwwroot/proxy/my.pac
2025-07-16 15:07:06 +08:00

36 lines
1.2 KiB
JavaScript

function FindProxyForURL(url,host)
{
var socks = "socks5 bsppo.com:30086"
// Declare a variable to store the result of DNS resolution
// Avoids multiple lookups (even from cache) and DNS A records with multiple mappings
var host_ip = dnsResolve(host);
// Declare a variable to store the protocol of the request
// Extract the protocol from the URL using the substring and indexOf methods
var protocol = url.substring(0, url.indexOf(":") - 1);
// No proxy for private (RFC 1918) IP addresses (intranet sites)
// Using host_ip variable simplifies code for easier reading
if (host == "atvoe.com"){
return "DIRECT";
}
if (isInNet(host_ip, "10.0.0.0", "255.0.0.0") ||
isInNet(host_ip, "172.16.0.0", "255.240.0.0") ||
isInNet(host_ip, "192.168.0.0", "255.255.0.0")) {
return "DIRECT";
}
// No proxy for localhost
if (isInNet(host, "127.0.0.0", "255.0.0.0")) {
return "DIRECT";
}
//Choose a proxy based on the URL's protocol
if (protocol == "ftp" || protocol == "ftps") {
return socks;
} else if (protocol == "https") {
return socks;
} else {
return socks;
}
}