Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I create multiple instances with different IP's but always primary IP is used for connections made from the server to WAN #47

Open
Ozguner opened this issue May 28, 2021 · 4 comments

Comments

@Ozguner
Copy link

Ozguner commented May 28, 2021

I have eth0 and eth0:1, eth0:2 total of 3 different IP's.

I have for example proxy server instances running on 10.0.0.1 and 10.0.0.2 and 10.0.0.3.
However, regardless of which socks5 server IP I connect to from a client, I get assigned 10.0.0.1

@brozeph
Copy link
Owner

brozeph commented Jan 29, 2022

@Ozguner, can you show how you are instantiating the module with code?

@Ozguner
Copy link
Author

Ozguner commented Jul 9, 2022

@Ozguner, can you show how you are instantiating the module with code?

Hello @brozeph !

I set these IPs in listening part. My expectation was, outgoing connection would go from the IP we listen to.
Basically I am looking for an option to specify outgoing IP.
Is this possible with simple socks?

import socks5 from 'simple-socks';

const server = socks5.createServer();

server.listen(1080, '66.249.70.28', function () {
  console.log('SOCKS5 proxy server started on 66.249.70.28:1080');
});

@e9x
Copy link
Contributor

e9x commented Aug 12, 2022

@Ozguner, can you show how you are instantiating the module with code?

Hello @brozeph !

I set these IPs in listening part. My expectation was, outgoing connection would go from the IP we listen to. Basically I am looking for an option to specify outgoing IP. Is this possible with simple socks?

import socks5 from 'simple-socks';

const server = socks5.createServer();

server.listen(1080, '66.249.70.28', function () {
  console.log('SOCKS5 proxy server started on 66.249.70.28:1080');
});

Although I am late to respond, this may be good for reference. I have a fork of simple-socks that can do what you're looking for. The API is very different (promises, different method names). It can be found here.

import { createProxyServer, waitForConnect } from '@e9x/simple-socks';
import { connect } from 'net';

const ip = '66.249.70.28';

const server = createProxyServer({
	async connect(port, host) {
		// create unconnected socket
		const socket = connect({
			port,
			host,
			localAddress: ip,
		});

		await waitForConnect(socket);

		return socket;
	},
});

server.listen(1080, ip, () => {
	console.log('SOCKS5 proxy server started on %s:1080', ip);
});

@krm35
Copy link

krm35 commented Aug 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants