source: trip-planner-front/node_modules/socks-proxy-agent/README.md@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.5 KB
Line 
1socks-proxy-agent
2================
3### A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
4[![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)
5
6This module provides an `http.Agent` implementation that connects to a
7specified SOCKS proxy server, and can be used with the built-in `http`
8and `https` modules.
9
10It can also be used in conjunction with the `ws` module to establish a WebSocket
11connection over a SOCKS proxy. See the "Examples" section below.
12
13Installation
14------------
15
16Install with `npm`:
17
18``` bash
19$ npm install socks-proxy-agent
20```
21
22
23Examples
24--------
25
26#### TypeScript example
27
28```ts
29import https from 'https';
30import { SocksProxyAgent } from 'socks-proxy-agent';
31
32const info = {
33 host: 'br41.nordvpn.com',
34 userId: 'your-name@gmail.com',
35 password: 'abcdef12345124'
36};
37const agent = new SocksProxyAgent(info);
38
39https.get('https://jsonip.org', { agent }, (res) => {
40 console.log(res.headers);
41 res.pipe(process.stdout);
42});
43```
44
45#### `http` module example
46
47```js
48var url = require('url');
49var http = require('http');
50var SocksProxyAgent = require('socks-proxy-agent');
51
52// SOCKS proxy to connect to
53var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080';
54console.log('using proxy server %j', proxy);
55
56// HTTP endpoint for the proxy to connect to
57var endpoint = process.argv[2] || 'http://nodejs.org/api/';
58console.log('attempting to GET %j', endpoint);
59var opts = url.parse(endpoint);
60
61// create an instance of the `SocksProxyAgent` class with the proxy server information
62var agent = new SocksProxyAgent(proxy);
63opts.agent = agent;
64
65http.get(opts, function (res) {
66 console.log('"response" event!', res.headers);
67 res.pipe(process.stdout);
68});
69```
70
71#### `https` module example
72
73```js
74var url = require('url');
75var https = require('https');
76var SocksProxyAgent = require('socks-proxy-agent');
77
78// SOCKS proxy to connect to
79var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080';
80console.log('using proxy server %j', proxy);
81
82// HTTP endpoint for the proxy to connect to
83var endpoint = process.argv[2] || 'https://encrypted.google.com/';
84console.log('attempting to GET %j', endpoint);
85var opts = url.parse(endpoint);
86
87// create an instance of the `SocksProxyAgent` class with the proxy server information
88var agent = new SocksProxyAgent(proxy);
89opts.agent = agent;
90
91https.get(opts, function (res) {
92 console.log('"response" event!', res.headers);
93 res.pipe(process.stdout);
94});
95```
96
97#### `ws` WebSocket connection example
98
99``` js
100var WebSocket = require('ws');
101var SocksProxyAgent = require('socks-proxy-agent');
102
103// SOCKS proxy to connect to
104var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080';
105console.log('using proxy server %j', proxy);
106
107// WebSocket endpoint for the proxy to connect to
108var endpoint = process.argv[2] || 'ws://echo.websocket.org';
109console.log('attempting to connect to WebSocket %j', endpoint);
110
111// create an instance of the `SocksProxyAgent` class with the proxy server information
112var agent = new SocksProxyAgent(proxy);
113
114// initiate the WebSocket connection
115var socket = new WebSocket(endpoint, { agent: agent });
116
117socket.on('open', function () {
118 console.log('"open" event!');
119 socket.send('hello world');
120});
121
122socket.on('message', function (data, flags) {
123 console.log('"message" event! %j %j', data, flags);
124 socket.close();
125});
126```
127
128License
129-------
130
131(The MIT License)
132
133Copyright (c) 2013 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
134
135Permission is hereby granted, free of charge, to any person obtaining
136a copy of this software and associated documentation files (the
137'Software'), to deal in the Software without restriction, including
138without limitation the rights to use, copy, modify, merge, publish,
139distribute, sublicense, and/or sell copies of the Software, and to
140permit persons to whom the Software is furnished to do so, subject to
141the following conditions:
142
143The above copyright notice and this permission notice shall be
144included in all copies or substantial portions of the Software.
145
146THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
147EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
148MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
149IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
150CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
151TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
152SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.