Skip to content

Commit

Permalink
Allow 'direct' to forward connections to specific destination
Browse files Browse the repository at this point in the history
  • Loading branch information
semigodking committed Dec 29, 2020
1 parent 45c881e commit 1951b49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 8 additions & 3 deletions direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ static void direct_write_cb(struct bufferevent *buffev, void *_arg)

static int direct_connect_relay(redsocks_client *client)
{
char * interface = client->instance->config.interface;
struct timeval tv = {client->instance->config.timeout, 0};
redsocks_instance * instance = client->instance;
char * interface = instance->config.interface;
struct timeval tv = {instance->config.timeout, 0};
struct sockaddr_storage * destaddr = &client->destaddr;

if (instance->config.relay) {
destaddr = &instance->config.relayaddr;
}
// Allowing binding relay socket to specified IP for outgoing connections
client->relay = red_connect_relay(
interface,
&client->destaddr,
destaddr,
NULL,
redsocks_relay_connected,
redsocks_event_error,
Expand Down
9 changes: 8 additions & 1 deletion redsocks.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ redsocks {
// min_accept_backoff = 100;
// max_accept_backoff = 60000;

// `relay' is IP address and port of proxy-server. Domain name is not
// `relay` is IP address and port of proxy-server. Domain name is not
// supported yet.
// Can be:
// [IPv6Address]:port
Expand All @@ -84,6 +84,13 @@ redsocks {

// known types: socks4, socks5, http-connect, http-relay
// New types: direct, shadowsocks, https-connect
// For type direct:
// if `relay` is not specified, connections will be forwarded to
// original destinations.
// if `relay` is filled with valid IP address, connections will be
// forwarded to IP address defined in `relay`. It is useful when you
// just want to forward connections to a specific IP address without
// transparent proxy. E.g. forward IPv4:port to IPv6:port.
type = socks5;

// Specify interface for outgoing connections.
Expand Down

0 comments on commit 1951b49

Please sign in to comment.