socks5-http

a http cliet that can send http request through socks5 proxy like shadowsocks.

Usage no npm install needed!

<script type="module">
  import socks5Http from 'https://cdn.skypack.dev/socks5-http';
</script>

README

node-socks5-http

installation

npm install --save socks5-http

it can only send GET request now

const socks5http = require('socks5-http');

// set socks5 proxy port and host
// 1080 and "localhost" is default
socks5http.setSocks5(1080, "localhost")

// https GET
socks5http.get("https://www.google.com", (res) => {
    let s = "";
    res.on('data', (buffer) => {
        s += buffer.toString();
    });
    res.on('end', () => {
        console.log(s);
    })
})

// http GET
socks5http.get("http://www.google.com", (res) => {
    let s = "";
    res.on('data', (buffer) => {
        s += buffer.toString();
    });
    res.on('end', () => {
        console.log(s);
    })
})

// ip and custom port
socks5http.get("http://47.98.223.187:3000", (res) => {
    let s = "";
    res.on('data', (buffer) => {
        s += buffer.toString();
    });
    res.on('end', () => {
        console.log(s);
    })
})