Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
socks-proxy-v5
Advanced tools
Readme
Implementation of socks 5 version on node js
Does't support ipv6 address and udp/bind methods
npm install socks-proxy-v5
const { createServer } = require("socks-proxy-v5");
const server = createServer();
server.listen(1080); // any port
const { createServer } = require("socks-proxy-v5");
const server = createServer({
authenticate(login, password) {
// verify name/password
if (login !== "foo" || password !== "bar") {
console.log("authentication failed", login);
return false;
// authentication failed
}
console.log(`user ${login} connect`);
// return successful authentication
return true;
}
});
server.listen(1080);
const { createServer } = require("socks-proxy-v5");
const setAddr = new Set(["tools.ietf.org", "github.com", "2ip.ru"]);
const server = createServer({
filter(addr) {
const result = !setAddr.has(addr);
if(!result) console.log(`host ${addr} unreachable`);
return result;
}
});
options
- is an object that describes how to use a proxy server. (optional
)
timeout - type number
. Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Default set 2 minute. If timeout is 0, then the existing idle timeout is disabled
const { createServer } = require("socks-proxy-v5");
const server = createServer({
timeout: 10000 // 10 second
});
After timeout the socket will be destroyed
authenticate(login, password) - type function
. Have two argument type string
.Returns true
if the user is authenticated, else false
You can make queries to the database, create arrays of data, log users, you are limited only by your imagination
filter(address) - type function
. Have one argument, type string
. Returns true
if the user has been filtered, else false
You can use regular expressions, iterating over an array, or using new data types as an example (new Set), queries to the data base
optional
)connect
Emitted when a socket connection is successfully established
server.on("connect", info =>
console.log(`connected to remote server at ${info.addr}:${info.port}`)
);
connection
Emitted when a new connection is made. socket is an instance of net.Socket
server.on("connection", socket => {
console.log("new socks connection", socket.remoteAddress, socket.remotePort);
});
error
Emitted when an error occurs.
server.on("error", error => {
console.error(error);
});
data
Emitted when data is received. The argument data will be a Buffer or String
server.on("data", data => console.log(data));
listening
Emitted when the server has been bound after calling server.listen()
server.listen(1080);
server.on("listening", () => {
console.log(
`server listening ${server.address().address}:${server.address().port}`
);
});
work like server.listen()
FAQs
Implementation of socks 5 version on node js
The npm package socks-proxy-v5 receives a total of 8 weekly downloads. As such, socks-proxy-v5 popularity was classified as not popular.
We found that socks-proxy-v5 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.