1.0.3 • Published 3 years ago

@devhigley/parse-proxy v1.0.3

Weekly downloads
56
License
MIT
Repository
github
Last release
3 years ago

parse-proxy Build Status

Description

parse-proxy is a lightweight Node.js proxy string parsing library

What it does:

  • parses a string of proxies into an array of proxy objects
  • supports multiple delimiters (comma, newline, space)
  • supports proxy authentication
  • supports proxy protocols

Installation

npm install @devhigley/parse-proxy
yarn add @devhigley/parse-proxy

Usage

Basic example delimited by comma and space:

const parseProxy = require("@devhigley/parse-proxy");

parseProxy(`1.1.1.1:80, 2.2.2.2:80, 3.3.3.3:80`);

Result:

[
  { host: '1.1.1.1', port: 80, protocol: 'http' },
  { host: '2.2.2.2', port: 80, protocol: 'http' },
  { host: '3.3.3.3', port: 80, protocol: 'http' }
]

Example with protocol and authentication, delimited by new line:

const parseProxy = require("@devhigley/parse-proxy");

parseProxy(`https://user:pass@104.236.55.48:8080
            https://user:pass@213.105.29.14:3128`);

Result:

[
  {
    host: '104.236.55.48',
    port: 8080,
    protocol: 'https',
    auth: { username: 'user', password: 'pass' }
  },
  {
    host: '213.105.29.14',
    port: 3128,
    protocol: 'https',
    auth: { username: 'user', password: 'pass' }
  }
]