proxy-master
v1.5.5
Published
π Proxy toolkit: parse, check, fetch from services
Downloads
49
Maintainers
Readme
Proxy Master
Node.JS proxy toolkit: Fetch, check, connect
π¦ 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)
});
}