Git Product home page Git Product logo

pac's Introduction

pac

PAC scripts for proxies

特点

基于 IP 地址白名单设计,位于白名单中的 IP 地址走直连,白名单以外的 IP 地址走代理。

另有 GFWList 版本从 gfwlist/gfwlist 获取域名及 URL 列表,优先匹配列表中的黑白名单,有效防止 DNS 污染。

每周六 12:00 (UTC) 会自动使用 GitHub Actions 运行生成脚本从数据源获取 IP 地址列表并生成 PAC 文件。

本项目暂不支持 IPv6,有 IPv6 需求的用户请参见由 @wits-fe 维护的 fork

使用

获取方式:本仓库的 Releases

  • pac-<name>.txt 包含从数据源 <name> 获取的 IP 地址列表(白名单)
  • pac-gfwlist-<name>.txt 在 IP 白名单的基础上添加了 GFWList 的匹配

本代码是为 Shadowsocks Windows 4.1.9 及以上版本设计的,若要在旧版本或使用其他代理软件中使用,请手动修改文件第 5 行 __PROXY__ 为你的代理地址,详情见 shadowsocks-windows#2761

贡献

本项目包含两部分

  1. 从数据源获取 IP 地址列表并转换为 PAC 文件适用的格式,该部分代码位于 build.py 文件
  2. PAC 文件的其他部分(例如解析域名和匹配 IP 地址等),该部分代码位于 code.js 文件

pac's People

Contributors

gshmu avatar ibug avatar zhwt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pac's Issues

新出的pac在trojan-qt5里用不了了

我之前用的老pac显示是去年8月20日创建的,当时我改了如下内容就可以用

var proxy = "SOCKS5 127.0.0.1:51837; SOCKS 127.0.0.1:51837; PROXY 127.0.0.1:58591";
var direct = "DIRECT";

但是最新的改了上面两处也不能用在trojan-qt5里,不知道是什么原因

Preprocess not working

Hi, thank you for this code. It works with your example data but not with newly added subnets.

If i add this subnet the result is always false, also for the other ones.

[0x58cd6368, 0x1e000000], // 88.205.99.104/30

What is wrong?

关于v2rayN客户端的PAC文件

我发现从这里下载下来的pac文件改名后是无法直接使用的
但是把第5行
var proxy = PROXY;
改为
var proxy = "PROXY";
加个双引号就可以使用了

请教代码相关问题

  1. belongsToSubnet里用了二分查找的算法,能否考虑使用Set.prototype.has()来代替,记得书上说has涉及到的是hash算法,O(1)之类的,去考虑一下吧
  2. ip = 0x1000000 * Number(ip[0]) + 0x10000 * Number(ip[1]) +0x100 * Number(ip[2]) + Number(ip[3]);能否加点注释解释下这是什么操作,什么原理,谢谢!

Binary search for longer lists

Hello!
Thank you for providing the code.
We defined a list of subnet ranges and is is working well.
Now we added a bunch of single IP addresses to the list with subnet mask 32 and for those the belongsToSubnet function is returning false.
I debugged the sorted list and I think that the issue seems to be in the binary search, because for those IP addresses which returned false, the wrong list entry was compared. So it compares the list entry which is assigned to the x variable, but the actual IP list entry is stored in the y variable. The list has 69 elements.
So now I just check both variables and it is working:

// Binary search
    var x = 0, y = list.length, middle;
    while (y - x > 1) {
      middle = Math.floor((x + y) / 2);
      if (list[middle][0] < ip)
        x = middle;
      else
        y = middle;
    }
    // Match
    var maskedX = ip & list[x][1];
    var maskedY = ip & list[y][1];
    // check x and y value
    if(((maskedX ^ list[x][0]) === 0) || ((maskedY ^ list[y][0]) === 0)) {
        return true;
    } else {
        return false;
    }

But shouldn't the results of the binary search (x & y) actually be the same? So that you can always just check the x value. Do you know the reason for this behaviour? Maybe this has to do with the fact that the middle value is always rounded down?

Thank you!

大佬,这个release 对脚本不友好,还要计算日期。。。

还是我使用方式不对?

假设 release 永远是最近一次生成的结果,即可省略时间计算


# 获取当前日期
current_date=$(date +%Y-%m-%d)

# 获取当前日期是星期几
day_of_week=$(date -d "$current_date" +%u)  # 1 (Monday) to 7 (Sunday)

# 计算目标日期
if [ "$day_of_week" -lt 6 ]; then
    target_date=$(date -d "$current_date -$(($day_of_week + 1)) days" +%Y%m%d)
else
    days_until_saturday=$((6 - $day_of_week))
    target_date=$(date -d "$current_date +$days_until_saturday days" +%Y%m%d)
fi

# 构建GitHub链接
github_link="https://ghps.cc/https://github.com/iBug/pac/releases/download/release-$target_date/pac-gfwlist-17mon.txt.gz"

# 下载文件
wget "$github_link" -O pac-gfwlist-17mon.txt.gz

# 解压文件
gzip -d pac-gfwlist-17mon.txt.gz

# 其他步骤省略

V2rayN无法正常工作,主要是百度网站无法走直连

配置方法:
去ibugone网站生成并下载pac.txt,手动覆盖到V2rayN的根目录,在GUI里重启V2rayN服务。V2rayN设置为启用PAC模式,并未使用软件自带更新PAC功能。

Bug表现:
生成PAC时候,如果勾选4.1.9兼容模式,则全部走代理服务器;如果不勾选4.1.9兼容模式,则全部走直连,无法通过PAC实现分流。

更新1:
经过测试,发现PAC在大部分网站是正常工作的,唯独百度不行,因为一开始以百度作为判断依据,所以出现了偏差。在其他大陆网站都直连的情况下,唯独百度还是走代理,实在是奇怪。怀疑是百度在日本有业务,Google的DNS便将我这个日本IP优先连入百度。

更新2:
更换美国节点后,百度搜索”IP“依然识别为美国,而其他大陆网站识别正常,都是直连。

无法正常下载

网页生成器那里,按了生成之后有看到生成一些代码,但是按下载就没有反应,是不是有点问题?
我在mac os上使用 ShadowsocksX-NG客户端(1.9.4版本), 请问兼容使用吗?

关于SSR客户端的PAC文件

将第五行代码
var proxy = PROXY;
改为
var proxy = "PROXY";
就能正常使用(同v2rayN客户端处理办法)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.