node-https-socks5-proxy

1.1.1 • Public • Published

node-https-socks5-proxy

###简介 使用 socks5 代理转发 nodejs 的 http/https 请求 ###安装

npm i node-https-socks5-proxy

###使用

import * as https from "https";
import * as ProxySocket from "node-https-socks5-proxy";

const HOST = "www.google.com";
const PORT = 443;
const PATH = "/";
//转发到本地的ssr客户端
const PROXY_HOST = "127.0.0.1";
const PROXY_PORT = 1086;

const req = https.request(
  {
    host: HOST,
    path: PATH,
    port: PORT,
    createConnection: (opt, oncreate) => {
      ProxySocket.createConnection(
        {
          proxyHost: PROXY_HOST,
          proxyPort: PROXY_PORT,
          port: PORT,
          host: HOST,
          https: true,
        },
        oncreate
      );
      return null;
    },
  },
  (res) => {
    console.log(res.headers);
    console.log(res.statusCode);
    console.log(res.statusMessage);
    res.on("data", (buf) => {
      console.log(buf.toString("utf-8"));
    });
  }
);
req.end();

Readme

Keywords

Package Sidebar

Install

npm i node-https-socks5-proxy

Weekly Downloads

10

Version

1.1.1

License

ISC

Unpacked Size

6.93 kB

Total Files

5

Last publish

Collaborators

  • tongzyang