🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

socks5-proxy-server

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socks5-proxy-server

create local socks5

1.0.7
latest
Source
npm
Version published
Weekly downloads
9
350%
Maintainers
0
Weekly downloads
 
Created
Source

SOCKS5 Proxy Server

This module provides a SOCKS5 proxy server with optional authentication and support for forwarding requests through an upstream SOCKS5 proxy.

Features

  • SOCKS5 proxy server with authentication
  • Upstream SOCKS5 proxy support
  • Automatic port allocation
  • Error handling mechanisms

Dependencies

  • socksv5
  • socks
  • net
  • ipv6
  • ipv4

Installation

npm install socks5-proxy-server

Usage

(async () => {
    const proxyServer = await app({ port: 1080, user: "test", password: "pass" });
    console.log(
        `Socks5 server running on localhost:${proxyServer.port}, ${
            proxyServer.user && proxyServer.password ? `user:${proxyServer.user}, password:${proxyServer.password}` : "no authentication"
        }`
    );
})();

Usage Without Authenticasion

(async () => {
    const proxyServer = await app({ port: 1080 });
    console.log(
        `Socks5 server running on localhost:${proxyServer.port}, ${
            proxyServer.user && proxyServer.password ? `user:${proxyServer.user}, password:${proxyServer.password}` : "no authentication"
        }`
    );
})();

Usage With Random Port

(async () => {
    const proxyServer = await app({ user: "test", password: "pass" });
    console.log(
        `Socks5 server running on localhost:${proxyServer.port}, ${
            proxyServer.user && proxyServer.password ? `user:${proxyServer.user}, password:${proxyServer.password}` : "no authentication"
        }`
    );
})();

Using an Upstream Proxy

(async () => {
    const proxyServer = await app(
        { port: 1080, user: "test", password: "pass" },
        { hostProxy: "172.31.24.202", portProxy: 2001, userProxy: "gemink", passwordProxy: "proxys" }
    );
    console.log(
        `Socks5 server running on localhost:${proxyServer.port}, ${
            proxyServer.user && proxyServer.password ? `user:${proxyServer.user}, password:${proxyServer.password}` : "no authentication"
        }`
    );
})();

Stopping the Proxy Server

To stop the proxy server, you can simply terminate the process running the script:

CTRL + C

If running as a background process, use:

kill $(lsof -t -i:1080)

Replace 1080 with the actual port if different.

Alternatively, you can stop the server within the script:

proxyServer.server.close(() => {
    console.log("Proxy server closed.");
});

Handling Errors

process.on('uncaughtException', (err) => {
    console.error("Unhandled exception:", err);
});

process.on('unhandledRejection', (reason, promise) => {
    console.error("Unhandled rejection:", reason);
});

API

findFreePort()

Finds an available port.

validateConfig(config)

Validates the user configuration.

validateProxy(proxy)

Validates the proxy settings.

app(config, proxy)

Starts the SOCKS5 proxy server.

Response:

  • { server: Object, port: number, user: null, password: null } if successful.
  • { server: Object, port: number, user: string, password: string } if successful.
  • { server: null, port: null, user: null, password: null } if an error occurs.

Keywords

socks5

FAQs

Package last updated on 15 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts