proxy-master
TypeScript icon, indicating that this package has built-in type declarations

1.5.5ย โ€ขย Publicย โ€ขย Published

Proxy Master

Node.JS proxy toolkit: Fetch, check, connect

Test Status Downloads last commit codecov GitHub proxy-master Known Vulnerabilities Quality npm license MIT Size

๐Ÿ“ฆ Installation

  • Using npm
    npm i proxy-master
  • Using Yarn
    yarn add proxy-master
  • Using pnpm
    pnpm add proxy-master

โš™๏ธ Usage

import { fetchers, getAgent, isSocks, getDispatcher } from "proxy-master";

const fetcher = fetchers.combine({
  fetchers: [
    fetchers.file({ path: "./proxy.txt" }),

    // Get some free ones from github
    fetchers.file({ path: "https://raw.githubusercontent.com/proxifly/free-proxy-list/main/proxies/all/data.txt" }),
    fetchers.file({ path: "https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt", defaultProxyType: "http" }),
    fetchers.file({ path: "https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks4.txt", defaultProxyType: "socks4" }),
    fetchers.file({ path: "https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks5.txt", defaultProxyType: "socks5" }),
  ]
});

// fetch proxies initially
await fetcher.fetch();

// refetch every 5 minutes
fetcher.refetchOnInterval(300_000);

// get random proxy
const proxy = fetcher.random();

// create custom agent
const agent = getAgent(proxy);

{
  // fetch with native (node.js fetch/undici)
  await fetch("https://example.com", { dispatcher: getDispatcher(proxy) })
}

{
  // fetch directly (node-fetch)
  await fetch("https://example.com", { agent });
}

{
  // create new vk
  const vk = new VK({ agent });
}

{
  // use in minecraft bot
  // minecraft protocol is TCP based, to http proxies don't work

  if (!isSocks(proxy)) {
    return;
  }

  const bot = mineflayer.createBot({
    stream: await createSocksSocket(proxy, "play.dicraft.net", 25565)
  });
}

Package Sidebar

Install

npm i proxy-master

Weekly Downloads

35

Version

1.5.5

License

MIT

Unpacked Size

260 kB

Total Files

104

Last publish

Collaborators

  • alexxandergrib