npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pac-proxy-cli

v1.2.2

Published

node pac proxy and web control panel

Readme

pac-proxy-cli

本机运行的 PAC / 全局代理 / 抓包工具,提供 Web 控制台与本地代理服务。支持内置代理客户端、系统代理自动设置、PAC 规则管理、HTTPS 抓包与流量记录。

功能特性

  • 多种代理模式:全局代理、PAC 代理、抓包代理,一键切换
  • 内置代理客户端:托管上游代理进程生命周期,自动作为上游代理,无需手动启动
  • PAC 规则:按域名/URL 规则匹配,选择「代理」或「直连」,支持优先级、搜索、导入/导出
  • 上游代理:支持 SOCKS5 / HTTP 上游,本地将 SOCKS5 转为 HTTP 代理并按规则转发
  • 流量记录:查看经本机代理的请求;抓包模式下可查看解密后的请求/响应、搜索与筛选
  • 抓包代理 (MITM):HTTPS 解密、自动生成 CA 证书供下载安装
  • 本地 / 远程模式:本地模式配置仅存本机;远程模式需登录,PAC 规则可同步云端

环境要求

  • Node.js >= 18
  • 系统代理自动设置支持:macOSWindowsLinux(GNOME,gsettings)

启动

npx pac-proxy-cli serve --port 5174

不指定 --port 时默认使用 5174。启动后会输出控制台地址:

控制台已启动: http://127.0.0.1:5174

在浏览器中打开该地址即可使用。如需长期使用,可全局安装:

npm install -g pac-proxy-cli
pac-proxy serve --port 5174

命令行配置

与 Web 控制台读写同一目录(默认 ~/.pac-proxy,可用环境变量 PAC_PROXY_HOME 覆盖)。

| 命令 | 说明 | |------|------| | pac-proxy config --print | 打印当前配置 JSON(sslocal.password 脱敏为 ***),无需交互,适合脚本与 CI | | pac-proxy config | 交互式编辑运行模式、代理、内置客户端;结束后可选合并导入 PAC 或追加一条规则。保存后会尝试向运行中的 serve 同步代理(同 proxy-mode) | | pac-proxy config proxy-mode | 交互式选择代理模式(与 Web「代理设置」一致)。若本机已有 pac-proxy serve 在运行,会在写盘后自动请求控制台 PUT /api/local/proxy,与 Web 保存同样立即应用代理与系统设置;否则仅写配置文件。非默认控制台端口可设环境变量 PAC_PROXY_CONSOLE_PORT | | pac-proxy config init | 首次使用向导,确认摘要后写入 | | pac-proxy config rules | 交互式增删改查 PAC 规则 | | pac-proxy config import <file.json> | 从 JSON 数组合并导入 PAC 规则(同 Web「导入」:相同 pattern 覆盖) |

非 TTY 环境(如管道)下,除 config --printconfig import 外会报错退出,避免进程挂起。

使用说明

1. 选择运行模式

首次访问会进入「选择运行模式」:

  • 本地模式:无需登录,所有配置保存在本机(默认目录 ~/.pac-proxy
  • 远程模式:需注册/登录,PAC 规则与云端同步(依赖远程服务地址配置)

选择后进入控制台,之后可在侧边栏底部「切换模式」中更改。

2. 代理设置

代理设置 页可进行:

| 操作 | 说明 | |------|------| | 全局代理 | 系统代理指向本机代理端口,所有 HTTP/HTTPS 经本地转发 | | PAC 代理 | 系统使用自动代理配置(PAC),按规则决定代理或直连 | | 抓包代理 | 流量经 MITM 解密,可查看请求/响应内容;需安装 CA 证书 | | 清除代理 | 关闭系统代理并停止本地代理服务 |

  • 上游代理地址:如 socks5://127.0.0.1:1080http://proxy.example.com:8080
  • HTTP/HTTPS 代理端口:本地代理监听端口,默认 5175 / 5176
  • 若启用了内置代理客户端,上游代理地址会自动托管,无需手动填写

3. 代理客户端

代理客户端 页可配置并托管上游代理进程:

  • 填写服务器地址、端口、密码、加密方式、本地 SOCKS5 端口
  • 启用后,node-cli 会自动启动代理进程并将其 SOCKS5 输出作为上游代理
  • 页面实时显示进程状态(运行中 / 已停止)、PID 及最近日志
  • 可手动启动 / 停止进程

代理客户端二进制按平台按需安装(仅下载当前平台对应的 ~10MB 文件):

| 平台 | 对应包 | |------|--------| | Windows x64 | pac-proxy-client-win32-x64 | | macOS x64 | pac-proxy-client-darwin-x64 | | Linux x64 | pac-proxy-client-linux-x64 |

4. PAC 规则

PAC 规则 页管理「代理 / 直连」规则:

  • 每条规则包含:匹配模式(如 *.google.com)、动作(代理 / 直连)、优先级
  • 按优先级从高到低匹配,命中则按该条动作执行
  • 支持搜索、导入 JSON 文件(合并模式)、导出、复制规则列表
  • 本地模式下规则保存在本机;远程模式下规则与云端同步

5. 流量记录

流量记录 页可查看经本机代理的请求:

  • 非抓包模式:列表展示时间、类型、方法、URL、动作,最多保留 500 条;支持自动刷新(每 5 秒)
  • 抓包模式:支持按 URL 搜索、按方法/状态码/类型筛选、排序与分页;点击行可查看请求/响应头与 body

6. 抓包代理与 CA 证书

选择「抓包代理」并保存后:

  1. 系统代理指向本机抓包代理端口
  2. 首次产生 HTTPS 请求后,在数据目录下自动生成根 CA
  3. 在代理设置页点击 下载 CA 证书,安装到系统或浏览器「受信任的根证书」
  4. 安装后可在「流量记录」中查看解密后的请求/响应

CA 仅限本机抓包使用,请勿安装到他人设备或生产环境。

系统代理支持

| 平台 | 说明 | |------|------| | macOS | 通过 networksetup 设置;遇权限问题可手动在「系统设置 → 网络 → 代理」中配置 | | Windows | 通过注册表写入;失败时可手动在「设置 → 网络和 Internet → 代理」中配置 | | Linux | 仅支持 GNOMEgsettings);KDE / XFCE 等请手动在系统设置中配置 |

环境变量

| 变量 | 说明 | |------|------| | PAC_PROXY_HOME | 数据与配置根目录,默认 ~/.pac-proxy | | REMOTE_SERVER_URL | 远程模式服务端地址(在运行目录的 .env.env.local 中配置) |

许可证

MIT