function FindProxyForURL(url, host) {

// 示例规则 1: 直接访问本地地址 
if (isPlainHostName(host) || 
    dnsDomainIs(host, ".local") || 
    shExpMatch(host, "localhost")) {
    return "DIRECT";
}

// 示例规则 2: 访问特定域名时使用代理 
if (dnsDomainIs(host, ".example.com")  || 
    shExpMatch(url, "*.example.com/*"))  {
    return "PROXY proxy.example.com:8080"; 
}

// 示例规则 3: 访问特定IP段时使用SOCKS代理 
if (isInNet(host, "192.168.1.0", "255.255.255.0")) {
    return "SOCKS socks.example.com:1080"; 
}

// 示例规则 4: 根据时间或星期自动切换代理 
if (weekdayRange("MON", "FRI") && 
    timeRange(9, 17)) {
    return "PROXY work-proxy.example.com:3128"; 
}

// 默认规则: 直接连接 
return "DIRECT";

}

最后修改:2025 年 03 月 10 日
如果觉得我的文章对你有用,请随意赞赏