@pavlovcik/proxy-handler
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

ProxyHandler

Typings and interface definitions for a manager of a list of proxies.

Quickstart

import path from "path";
import ProxyHandler from "@pavlovcik/proxy-handler";

const handler = new ProxyHandler({
  location: path.join(process.cwd(), `test`, `successes.json`),  //  Filepath allows it to persist.
  //  Can also use variable ( i.e. an array [] ) which can only stay in RAM, and of course, is temporary.
  persist: true  //  Write to disk
});

console.log(handler);
console.log(handler.storage.proxies); //  Shows the list of proxies in the handler
console.log(handler.storage.proxies.flattened()); //  Handy flatten function to return only the proxies.

Context

Building a botnet is no joke. In the parent application, the software must be able to aggregate free proxies from various sources; then test each proxy's performance; then finally make good use of the functional proxies.

This object acts as a way to more easily manage the large lists of acquired proxies, along with all of their respective and deeply nested metadata.


Interfaces to be aware of

A single proxy is represented as follows:

interface IProxy {
	id: IParsedURL;
	details: any;
	origin?: string;
	performance?: IPerformance;
}

IParsedURL is actually URLParse from url-parse

interface URLParse {
    readonly auth: string;
    readonly hash: string;
    readonly host: string;
    readonly hostname: string;
    readonly href: string;
    readonly origin: string;
    readonly password: string;
    readonly pathname: string;
    readonly port: string;
    readonly protocol: string;
    readonly query: { [key: string]: string | undefined };
    readonly slashes: boolean;
    readonly username: string;
    set(part: URLParse.URLPart, value: string | object | number | undefined, fn?: boolean | URLParse.QueryParser): URLParse;
    toString(stringify?: URLParse.StringifyQuery): string;
}

See an example proxy list structure here.

Package Sidebar

Install

npm i @pavlovcik/proxy-handler

Weekly Downloads

0

Version

1.1.2

License

ISC

Unpacked Size

68.6 kB

Total Files

19

Last publish

Collaborators

  • pavlovcik