Socket
Book a DemoInstallSign in
Socket

proxychooser

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxychooser

A simple proxy chooser to choose proxies from a list or test proxies, only supports http/https proxies.

1.0.8
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ProxyChooser

A simple proxy chooser to choose proxies from a list or test proxies, only supports http/https proxies.

GitHub: https://github.com/DemonMartin/proxychooser/

Installation

npm install proxychooser

Usage

const ProxyChooser = require("proxychooser");

const proxyList = [
  "proxy1:port1",
  "name:pw@proxy:port"
];
const proxyChooser = new ProxyChooser(proxyList, {
  verbose: true,
  maxTimeout: 1000,
  forceRetry: false
});

proxyChooser.getProxy().then(proxy => {
  console.log(proxy);
});

const singleProxy = new ProxyChooser([], {
  verbose: true,
  maxTimeout: 1000
});

singleProxy.testProxy(proxyList[0]).then(proxy => {
  console.log(proxy);
});

API

Class: ProxyChooser

constructor(proxyList, options)

  • proxyList (Array): List of proxies to use.
  • options (Object): Options to use.
    • verbose (boolean, optional): If true, will log to console. Default: false.
    • verboseIdentifier (string, optional): Identifier for verbose. Default: "[proxyChooser]".
    • maxTimeout (number, optional): Max timeout for a request. Default: 1000.
    • pingUrl (string, optional): URL to use to check proxy. Default: "http://myexternalip.com/raw".
    • forceRetry (boolean, optional): Whether function getProxy should continue searching even on error. Default: false.

resetList()

Resets the proxy list.

  • Returns: boolean - Whether it failed or not.

addProxies(proxies)

Adds proxies to the proxy list.

  • proxies (Array): List of proxies to add.
  • Returns: boolean - Whether it failed or not.

getPing()

Gets the ping between the client and the pingUrl.

  • Returns: Promise<number> - Ping in ms.

testProxy(proxy)

Tests the given proxy for connectivity.

  • proxy (string): Proxy to test.
  • Returns: Promise<boolean> - Whether the proxy is working or not.

resetCache()

Resets the cache of tested proxies.

  • Returns: boolean - Whether the cache was reset or not.

getProxy()

Gets the next working proxy from the proxy list.

  • Returns: Promise<string|null> - Next working proxy or null if no proxy is available.

License

MIT License

Author

Demon Martin

FAQs

Package last updated on 15 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.