luminati-tunnel
Version:
HTTP/HTTPS tunnel proxy for luminati.io using round robin strategy.
110 lines (71 loc) • 3.23 kB
Markdown
# luminati-tunnel

[](https://travis-ci.org/Kikobeats/luminati-tunnel)
[](https://coveralls.io/github/Kikobeats/luminati-tunnel)
[](https://david-dm.org/Kikobeats/luminati-tunnel)
[](https://david-dm.org/Kikobeats/luminati-tunnel#info=devDependencies)
[](https://www.npmjs.org/package/luminati-tunnel)
> HTTP/HTTPS tunnel proxy for luminati.io using round robin strategy.
## Install
```bash
$ npm install luminati-tunnel --save
```
## Usage
The instance is a function that returns a different proxy tunnel every time you call it, using [round robin](https://en.wikipedia.org/wiki/Round-robin_DNS) algorithm.
```js
const luminatiTunnel = require('luminati-tunnel')
const proxies = [ 'proxy1', 'proxy2', 'proxy3' ]
const tunnel = createTunnel(proxies)
const url = 'http://lumtest.com/echo.json'
;(async () => {
// => it uses 'proxy1'
await got(url, {
agent: tunnel(),
json: true
})
// => it uses 'proxy2'
await got(url, {
agent: tunnel(),
json: true
})
// => it uses 'proxy3'
await got(url, {
agent: tunnel(),
json: true
})
// => it uses 'proxy1'
await got(url, {
agent: tunnel(),
json: true
})
})()
```
## API
### `tunnel = luminatiTunnel(proxies, [fromIndex])`
#### proxies
*Required*<br>
Type: `array`
A collection of the proxy IPs to use.
You can get it from your [luminati.io](https://luminati.io/) control panel.

Read more at [documentation](https://luminati.io/faq#download-ips).
#### fromIndex
Type: `number`<br>
Default: `0`
It specifies the position of the `proxies` collection to start.
### `tunnel`
The instance is a function that returns a different proxy tunnel every time you call it, using [round robin](https://en.wikipedia.org/wiki/Round-robin_DNS) 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
**luminati-tunnel** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/luminati-tunnel/blob/master/LICENSE.md) License.<br>
Authored and maintained by Kiko Beats with help from [contributors](https://github.com/Kikobeats/luminati-tunnel/contributors).
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · Twitter [@Kikobeats](https://twitter.com/Kikobeats)