Browse Source

Fix #2285

pull/2304/head
Max Lv 5 years ago
parent
commit
404ec62b79
5 changed files with 19 additions and 21 deletions
  1. 3
      src/jconf.c
  2. 5
      src/local.c
  3. 3
      src/redir.c
  4. 26
      src/server.c
  5. 3
      src/tunnel.c

3
src/jconf.c

@ -211,8 +211,7 @@ read_jconf(const char *file)
conf.remote_num = j + 1;
}
} else if (value->type == json_string) {
conf.remote_addr[0].host = to_string(value);
conf.remote_addr[0].port = NULL;
parse_addr(to_string(value), conf.remote_addr);
conf.remote_num = 1;
}
} else if (strcmp(name, "port_password") == 0) {

5
src/local.c

@ -1531,8 +1531,7 @@ main(int argc, char **argv)
break;
case 's':
if (remote_num < MAX_REMOTE_NUM) {
remote_addr[remote_num].host = optarg;
remote_addr[remote_num++].port = NULL;
parse_addr(optarg, &remote_addr[remote_num++]);
}
break;
case 'p':
@ -1683,7 +1682,7 @@ main(int argc, char **argv)
if (ipv6first == 0) {
ipv6first = conf->ipv6_first;
}
if (acl == 0) {
if (acl == 0 && conf->acl != NULL) {
LOGI("initializing acl...");
acl = !init_acl(conf->acl);
}

3
src/redir.c

@ -911,8 +911,7 @@ main(int argc, char **argv)
break;
case 's':
if (remote_num < MAX_REMOTE_NUM) {
remote_addr[remote_num].host = optarg;
remote_addr[remote_num++].port = NULL;
parse_addr(optarg, &remote_addr[remote_num++]);
}
break;
case 'p':

26
src/server.c

@ -440,6 +440,7 @@ create_and_bind(const char *host, const char *port, int mptcp)
break;
} else {
ERROR("bind");
FATAL("failed to bind address");
}
close(listen_sock);
@ -1610,7 +1611,7 @@ main(int argc, char **argv)
char tmp_port[8];
int server_num = 0;
const char *server_host[MAX_REMOTE_NUM];
ss_addr_t server_addr[MAX_REMOTE_NUM];
char *nameservers = NULL;
@ -1676,7 +1677,7 @@ main(int argc, char **argv)
break;
case 's':
if (server_num < MAX_REMOTE_NUM) {
server_host[server_num++] = optarg;
parse_addr(optarg, &server_addr[server_num++]);
}
break;
case 'b':
@ -1759,7 +1760,7 @@ main(int argc, char **argv)
if (server_num == 0) {
server_num = conf->remote_num;
for (i = 0; i < server_num; i++)
server_host[i] = conf->remote_addr[i].host;
server_addr[i] = conf->remote_addr[i];
}
if (server_port == NULL) {
server_port = conf->remote_port;
@ -1817,14 +1818,14 @@ main(int argc, char **argv)
if (ipv6first == 0) {
ipv6first = conf->ipv6_first;
}
if (acl == 0) {
if (acl == 0 && conf->acl != NULL) {
LOGI("initializing acl...");
acl = !init_acl(conf->acl);
}
}
if (server_num == 0) {
server_host[server_num++] = "0.0.0.0";
server_addr[server_num++].host = "0.0.0.0";
}
if (server_num == 0 || server_port == NULL
@ -1982,10 +1983,10 @@ main(int argc, char **argv)
size_t buf_size = 256 * server_num;
char *server_str = ss_malloc(buf_size);
snprintf(server_str, buf_size, "%s", server_host[0]);
snprintf(server_str, buf_size, "%s", server_addr[0].host);
len = strlen(server_str);
for (int i = 1; i < server_num; i++) {
snprintf(server_str + len, buf_size - len, "|%s", server_host[i]);
snprintf(server_str + len, buf_size - len, "|%s", server_addr[i].host);
len = strlen(server_str);
}
@ -2008,16 +2009,17 @@ main(int argc, char **argv)
if (mode != UDP_ONLY) {
int num_listen_ctx = 0;
for (int i = 0; i < server_num; i++) {
const char *host = server_host[i];
const char *host = server_addr[i].host;
const char *port = server_addr[i].port ? server_addr[i].port : server_port;
if (plugin != NULL) {
host = "127.0.0.1";
}
if (host && ss_is_ipv6addr(host))
LOGI("tcp server listening at [%s]:%s", host, server_port);
LOGI("tcp server listening at [%s]:%s", host, port);
else
LOGI("tcp server listening at %s:%s", host ? host : "0.0.0.0", server_port);
LOGI("tcp server listening at %s:%s", host ? host : "0.0.0.0", port);
// Bind to port
int listenfd;
@ -2056,8 +2058,8 @@ main(int argc, char **argv)
if (mode != TCP_ONLY) {
int num_listen_ctx = 0;
for (int i = 0; i < server_num; i++) {
const char *host = server_host[i];
const char *port = server_port;
const char *host = server_addr[i].host;
const char *port = server_addr[i].port ? server_addr[i].port : server_port;
if (plugin != NULL) {
port = plugin_port;
}

3
src/tunnel.c

@ -947,8 +947,7 @@ main(int argc, char **argv)
break;
case 's':
if (remote_num < MAX_REMOTE_NUM) {
remote_addr[remote_num].host = optarg;
remote_addr[remote_num++].port = NULL;
parse_addr(optarg, &remote_addr[remote_num++]);
}
break;
case 'p':

Loading…
Cancel
Save