From 5d9c93a6d4f51300b373497c1d6a6c962862f105 Mon Sep 17 00:00:00 2001 From: Guizai Date: Mon, 25 Nov 2013 15:14:37 +0800 Subject: [PATCH] Add local bind address config specific local address to bind in `config.json`: `"local": "127.0.0.1"` --- src/jconf.c | 4 ++++ src/jconf.h | 1 + src/local.c | 1 + src/redir.c | 1 + 4 files changed, 7 insertions(+) diff --git a/src/jconf.c b/src/jconf.c index f1a14d9a..72c915af 100644 --- a/src/jconf.c +++ b/src/jconf.c @@ -137,6 +137,10 @@ jconf_t *read_jconf(const char* file) { conf.remote_port = to_string(value); } + else if (strcmp(name, "local") == 0) + { + conf.local_addr = to_string(value); + } else if (strcmp(name, "local_port") == 0) { conf.local_port = to_string(value); diff --git a/src/jconf.h b/src/jconf.h index ca99142e..2a9e9bba 100644 --- a/src/jconf.h +++ b/src/jconf.h @@ -17,6 +17,7 @@ typedef struct int remote_num; remote_addr_t remote_addr[MAX_REMOTE_NUM]; char *remote_port; + char *local_addr; char *local_port; char *password; char *method; diff --git a/src/local.c b/src/local.c index 052a5ffb..b28020e6 100644 --- a/src/local.c +++ b/src/local.c @@ -876,6 +876,7 @@ int main (int argc, char **argv) } } if (remote_port == NULL) remote_port = conf->remote_port; + if (local_addr == NULL) local_addr = conf->local_addr; if (local_port == NULL) local_port = conf->local_port; if (password == NULL) password = conf->password; if (method == NULL) method = conf->method; diff --git a/src/redir.c b/src/redir.c index abeda551..b674b5ad 100644 --- a/src/redir.c +++ b/src/redir.c @@ -729,6 +729,7 @@ int main (int argc, char **argv) } } if (remote_port == NULL) remote_port = conf->remote_port; + if (local_addr == NULL) local_addr = conf->local_addr; if (local_port == NULL) local_port = conf->local_port; if (password == NULL) password = conf->password; if (method == NULL) method = conf->method;