proxies-pool

2.0.0 • Public • Published

proxies-pool

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status

Simple way to handle a pool of proxies using round robin strategy.

Install

$ npm install proxies-pool --save

Usage

The instance is a function that returns a different proxy every time you call it, using round robin algorithm.

const proxiesPool = require('proxies-pool')
const proxies = ['proxy1', 'proxy2', 'proxy3']
const proxyPool = proxiesPool(proxies)
const url = 'http://lumtest.com/echo.json'
 
const createAgent = proxy => ({
  agent: {
    http: tunnel.httpOverHttp({ proxy })
  }
})
 
;(async () => {
  // => it uses 'proxy1'
  await got(url, { agent: createAgent(proxyPool()) })
 
  // => it uses 'proxy2'
  await got(url, { agent: createAgent(proxyPool()) })
 
  // => it uses 'proxy3'
  await got(url, { agent: createAgent(proxyPool()) })
 
  // => it uses 'proxy1'
  await got(url, { agent: createAgent(proxyPool()) })
})()

API

proxyPool = proxiesPool(proxies, [fromIndex])

proxies

Required
Type: array

A collection of proxies to use.

You can get it from your luminati.io control panel or any compatible provider.

Read more at documentation.

fromIndex

Type: number
Default: 0

It specifies the position of the proxies collection to start.

proxyPool

The instance is a function that returns a different proxy every time you call it, using round robin algorithm.

.current()

Returns the current proxy tunnel credential.

.index()

Returns the current proxy tunnel index from the proxies provided.

.next()

Returns the next proxy tunnel credential.

.previous()

Returns the previous proxy tunnel credential.

.size()

Returns the number of proxies in the pool.

License

proxies-pool © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats

Package Sidebar

Install

npm i proxies-pool

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

9.86 kB

Total Files

5

Last publish

Collaborators

  • kikobeats