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

nesting-proxy

v0.3.0

Published

Worker-first IP diversity route pool with local SOCKS5 crawling

Readme

nesting-proxy

English | 中文

Worker-first IP diversity route pool。通过本机 SOCKS5 爬源、可选 SNI 中继和 CF Worker,将请求路由到不同 CF 机房,获取互不重叠的出口 IP 池。零依赖,Node.js 18+。

直连            -> Colo A -> IP 池 A
经 SOCKS5 代理  -> Colo B -> IP 池 B
经 SNI 中继     -> Colo C -> IP 池 C

安装

npm install nesting-proxy

使用

import { createPool } from 'nesting-proxy';

const pool = await createPool({
  worker: 'https://your-worker.workers.dev',
  token: process.env.PROXY_TOKEN,
  sni: ['203.0.113.10'],
  crawl: true,
  prefilter: 'cloudflare-trace',
  perColo: 3,
  reputationFile: './proxy-reputation.json',
  requireProxyRoutes: true,
});

const res = await pool.fetch('https://api.example.com/data');
console.log(res.status, res.body, res.route, res.worker, res.colo);
pool.destroy();

API

  • createPool(opts) — 一行创建路线池(SNI / 代理爬取 / 自动刷新)
  • pool.fetch(url, opts?) — 代理请求,自动轮询 + 重试;opts.route 可锁定路线
  • pool.status() — 路线状态概览
  • crawlProxies(opts) — 本机抓取并验证 SOCKS5 代理
  • parseProxy(url) — 解析代理 URL,返回协议、host、端口和 /16 网段
  • scoreProxyCandidate(meta, opts?) — 按端口、网段、来源数和历史信誉给代理候选打分
  • createProxyReputationStore(opts?) — 创建内存信誉库,可选 filePath 持久化
  • validateCloudflareTrace(proxy, opts?) — 通过代理请求 Cloudflare trace,返回 colo
  • deployCfWorkers(config) — 通过 API 部署 Worker

子路径导入:nesting-proxy/authnesting-proxy/validationnesting-proxy/deploynesting-proxy/worker

createPool 选项

代理路线默认先做 Cloudflare trace 预筛,再检查 Worker /health,避免无效代理消耗 Worker 请求。刷新默认间隔为 15 分钟,刷新失败或新代理全部不健康时会保留旧的健康代理路线。

常用选项:

  • worker — 单 Worker URL,保持最简单用法
  • workers — 多 Worker 配置,支持 string[]{ name?, url, weight? }[];不要和 worker 同时传
  • refreshInterval — 代理刷新间隔,默认 15 * 60 * 1000,传 0 禁用自动刷新
  • perColo — 每个 CF colo 保留的健康代理路线数,默认 3,传 0 禁用 colo 限额
  • candidateLimit — 进入 Worker 健康检查的候选代理上限,默认 Math.max(maxProxyRoutes * 10, 300)
  • reputationFile — 可选 JSON 文件,用于持久化代理成功/失败信誉
  • reputationStore — 自定义信誉库,适合应用自行管理存储
  • preferredPatterns — 自定义优选规则;默认优先 :4145156.244:20002192.111/192.25268.71/142.54 等稳定池特征
  • direct — 默认 false;设为 true 时为每个 Worker 创建 direct route
  • proxyWorkerMode — 默认 'assign',代理路线按 Worker 轮询/权重分配;'cross-product' 才生成 workers x proxies
  • sniWorkerMode — 默认 'cross-product'
  • workerStrategy — route 生成阶段的 Worker 分配策略,支持 'round-robin''weighted'
  • crawlWorkerStrategycrawlViaWorker 时使用 'primary''round-robin' 抓源

多 Worker 示例:

const pool = await createPool({
  workers: [
    { name: 'jp', url: 'https://jp.example.workers.dev', weight: 2 },
    { name: 'us', url: 'https://us.example.workers.dev' },
  ],
  direct: true,
  sni: ['203.0.113.10', '203.0.113.11'],
  crawl: true,
  proxyWorkerMode: 'assign',
  sniWorkerMode: 'cross-product',
  crawlViaWorker: true,
  crawlWorkerStrategy: 'round-robin',
});

pool.status().routes[] 会包含 workerworkerUrlworkerHosttypepool.fetch() 返回值会包含 routeworkerworkerUrl

License

MIT