diff options
Diffstat (limited to 'deps/npm/node_modules/socks-proxy-agent/README.md')
-rw-r--r-- | deps/npm/node_modules/socks-proxy-agent/README.md | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/deps/npm/node_modules/socks-proxy-agent/README.md b/deps/npm/node_modules/socks-proxy-agent/README.md index 36028ad9f6..4df184ffaa 100644 --- a/deps/npm/node_modules/socks-proxy-agent/README.md +++ b/deps/npm/node_modules/socks-proxy-agent/README.md @@ -1,11 +1,11 @@ socks-proxy-agent ================ ### A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS -[![Build Status](https://travis-ci.org/TooTallNate/node-socks-proxy-agent.svg?branch=master)](https://travis-ci.org/TooTallNate/node-socks-proxy-agent) +[![Build Status](https://github.com/TooTallNate/node-socks-proxy-agent/workflows/Node%20CI/badge.svg)](https://github.com/TooTallNate/node-socks-proxy-agent/actions?workflow=Node+CI) This module provides an `http.Agent` implementation that connects to a specified SOCKS proxy server, and can be used with the built-in `http` -or `https` modules. +and `https` modules. It can also be used in conjunction with the `ws` module to establish a WebSocket connection over a SOCKS proxy. See the "Examples" section below. @@ -23,15 +23,34 @@ $ npm install socks-proxy-agent Examples -------- +#### TypeScript example + +```ts +import https from 'https'; +import { SocksProxyAgent } from 'socks-proxy-agent'; + +const info = { + host: 'br41.nordvpn.com', + userId: 'your-name@gmail.com', + password: 'abcdef12345124' +}; +const agent = new SocksProxyAgent(info); + +https.get('https://jsonip.org', { agent }, (res) => { + console.log(res.headers); + res.pipe(process.stdout); +}); +``` + #### `http` module example -``` js +```js var url = require('url'); var http = require('http'); var SocksProxyAgent = require('socks-proxy-agent'); // SOCKS proxy to connect to -var proxy = process.env.socks_proxy || 'socks://127.0.0.1:9050'; +var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080'; console.log('using proxy server %j', proxy); // HTTP endpoint for the proxy to connect to @@ -44,20 +63,20 @@ var agent = new SocksProxyAgent(proxy); opts.agent = agent; http.get(opts, function (res) { - console.log('"response" event!', res.headers); - res.pipe(process.stdout); + console.log('"response" event!', res.headers); + res.pipe(process.stdout); }); ``` #### `https` module example -``` js +```js var url = require('url'); var https = require('https'); var SocksProxyAgent = require('socks-proxy-agent'); // SOCKS proxy to connect to -var proxy = process.env.socks_proxy || 'socks://127.0.0.1:9050'; +var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080'; console.log('using proxy server %j', proxy); // HTTP endpoint for the proxy to connect to @@ -70,8 +89,8 @@ var agent = new SocksProxyAgent(proxy); opts.agent = agent; https.get(opts, function (res) { - console.log('"response" event!', res.headers); - res.pipe(process.stdout); + console.log('"response" event!', res.headers); + res.pipe(process.stdout); }); ``` @@ -82,7 +101,7 @@ var WebSocket = require('ws'); var SocksProxyAgent = require('socks-proxy-agent'); // SOCKS proxy to connect to -var proxy = process.env.socks_proxy || 'socks://127.0.0.1:9050'; +var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080'; console.log('using proxy server %j', proxy); // WebSocket endpoint for the proxy to connect to @@ -96,13 +115,13 @@ var agent = new SocksProxyAgent(proxy); var socket = new WebSocket(endpoint, { agent: agent }); socket.on('open', function () { - console.log('"open" event!'); - socket.send('hello world'); + console.log('"open" event!'); + socket.send('hello world'); }); socket.on('message', function (data, flags) { - console.log('"message" event! %j %j', data, flags); - socket.close(); + console.log('"message" event! %j %j', data, flags); + socket.close(); }); ``` |