This repository has been archived by the owner on May 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25b90e8
commit 2993928
Showing
1 changed file
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,15 +23,36 @@ $ 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: '[email protected]', | ||
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 | ||
|
@@ -51,13 +72,13 @@ http.get(opts, function (res) { | |
|
||
#### `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 | ||
|
@@ -82,7 +103,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 | ||
|