socks-proxy-agent

A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS

MIT 35 个版本
安装
npm install socks-proxy-agent
yarn add socks-proxy-agent
pnpm add socks-proxy-agent
bun add socks-proxy-agent
README

socks-proxy-agent

A SOCKS proxy http.Agent implementation for HTTP and HTTPS

This module provides an http.Agent implementation that connects to a specified SOCKS proxy server, and can be used with the built-in http 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.

Examples

import https from 'https';
import { SocksProxyAgent } from 'socks-proxy-agent';

const agent = new SocksProxyAgent(
	'socks://your-name%40gmail.com:abcdef12345124@br41.nordvpn.com'
);

https.get('https://ipinfo.io', { agent }, (res) => {
	console.log(res.headers);
	res.pipe(process.stdout);
});

ws WebSocket connection example

import WebSocket from 'ws';
import { SocksProxyAgent } from 'socks-proxy-agent';

const agent = new SocksProxyAgent(
	'socks://your-name%40gmail.com:abcdef12345124@br41.nordvpn.com'
);

var socket = new WebSocket('ws://echo.websocket.events', { agent });

socket.on('open', function () {
	console.log('"open" event!');
	socket.send('hello world');
});

socket.on('message', function (data, flags) {
	console.log('"message" event! %j %j', data, flags);
	socket.close();
});
版本列表
10.1.0 2026-06-08
10.0.0 2026-04-01
9.0.0 2026-03-11
8.0.5 2024-12-07
8.0.4 2024-06-28
8.0.3 2024-03-30
8.0.2 2023-09-04
8.0.1 2023-05-05
8.0.0 2023-05-04
7.0.0 2022-05-31
6.2.1 2022-05-31
6.2.0-beta.1 2022-02-15
6.2.0-beta.0 2022-02-12
6.2.0 2022-04-17
6.1.1 2021-11-22
6.1.0 2021-09-15
6.0.0 2021-07-04
5.0.1 2021-06-21
5.0.0 2020-02-04
4.0.2 2019-03-09
4.0.1 2018-04-13
4.0.0 2018-03-29
3.0.1 2017-09-18
3.0.0 2017-06-13
2.1.1 2017-06-13
2.1.0 2017-05-25
2.0.0 2015-07-11
1.0.2 2015-07-01
1.0.1 2015-03-02
1.0.0 2015-02-12
0.1.2 2014-06-11
0.1.1 2014-04-09
0.1.0 2013-11-19
0.0.2 2013-07-24
0.0.1 2013-07-11