mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 10:44:43 +08:00
New jconf parameters (#695)
* Add 'tunnel_address' support for json config parser And allow ss-tunnel to use the newly introduced parser. Signed-off-by: Adam Anonymous <anonymous_temp_user@yahoo.co.jp> * Add "mode" support for jconf Now jconf supports "mode" setting, allowed values are "tcp_only", "tcp_and_udp" and "udp_only". Signed-off-by: Adam Anonymous <anonymous_temp_mail@yahoo.co.jp> * Use jconf "mode" for server/local/tunnel/manager Signed-off-by: Adam Anonymous <anonymous_temp_mail@yahoo.co.jp> * Add per-project vimrc to gitignore As the coding style differs from kernel and other projects, so such project vimrc should be helpful. Signed-off-by: Adam Anonymous <anonymous_temp_mail@yahoo.co.jp>
This commit is contained in:
1 parent
38f33a653b
commit
af69798355
8 files changed
+43
-4
No files matched your search
@@ -27,6 +27,9 @@ shadowsocks-libev.pc
|
||||
debian/libshadowsocks-libev1.symbols
|
||||
libsodium/src/libsodium/include/sodium/version.h
|
||||
|
||||
# Ignore per-project vim config
|
||||
.vimrc
|
||||
|
||||
# Ignore garbage of OS X
|
||||
*.DS_Store
|
||||
|
||||
|
||||
@@ -49,10 +49,6 @@
|
||||
#define SOL_TCP IPPROTO_TCP
|
||||
#endif
|
||||
|
||||
#define TCP_ONLY 0
|
||||
#define TCP_AND_UDP 1
|
||||
#define UDP_ONLY 3
|
||||
|
||||
#if defined(MODULE_TUNNEL) || defined(MODULE_REDIR)
|
||||
#define MODULE_LOCAL
|
||||
#endif
|
||||
|
||||
+15
@@ -191,6 +191,21 @@ jconf_t *read_jconf(const char *file)
|
||||
conf.nofile = value->u.integer;
|
||||
} else if (strcmp(name, "nameserver") == 0) {
|
||||
conf.nameserver = to_string(value);
|
||||
} else if (strcmp(name, "tunnel_address") == 0) {
|
||||
conf.tunnel_address = to_string(value);
|
||||
} else if (strcmp(name, "mode") == 0) {
|
||||
char *mode_str = to_string(value);
|
||||
|
||||
if (strcmp(mode_str, "tcp_only") == 0)
|
||||
conf.mode = TCP_ONLY;
|
||||
else if (strcmp(mode_str, "tcp_and_udp") == 0)
|
||||
conf.mode = TCP_AND_UDP;
|
||||
else if (strcmp(mode_str, "udp_only") == 0)
|
||||
conf.mode = UDP_ONLY;
|
||||
else
|
||||
LOGI("ignore unknown mode: %s, use tcp_only as fallback",
|
||||
mode_str);
|
||||
free(mode_str);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
#define MAX_CONNECT_TIMEOUT 10
|
||||
#define MIN_UDP_TIMEOUT 10
|
||||
|
||||
#define TCP_ONLY 0
|
||||
#define TCP_AND_UDP 1
|
||||
#define UDP_ONLY 3
|
||||
|
||||
|
||||
typedef struct {
|
||||
char *host;
|
||||
char *port;
|
||||
@@ -54,6 +59,8 @@ typedef struct {
|
||||
int fast_open;
|
||||
int nofile;
|
||||
char *nameserver;
|
||||
char *tunnel_address;
|
||||
int mode;
|
||||
} jconf_t;
|
||||
|
||||
jconf_t *read_jconf(const char *file);
|
||||
|
||||
@@ -1137,6 +1137,12 @@ int main(int argc, char **argv)
|
||||
if (fast_open == 0) {
|
||||
fast_open = conf->fast_open;
|
||||
}
|
||||
if (mode == TCP_ONLY) {
|
||||
if (conf->mode == UDP_ONLY)
|
||||
LOGI("ignore unsupported mode: udp_only, use tcp_only as fallback");
|
||||
else
|
||||
mode = conf->mode;
|
||||
}
|
||||
#ifdef HAVE_SETRLIMIT
|
||||
if (nofile == 0) {
|
||||
nofile = conf->nofile;
|
||||
|
||||
@@ -703,6 +703,9 @@ int main(int argc, char **argv)
|
||||
if (auth == 0) {
|
||||
auth = conf->auth;
|
||||
}
|
||||
if (mode == TCP_ONLY) {
|
||||
mode = conf->mode;
|
||||
}
|
||||
}
|
||||
|
||||
if (server_num == 0) {
|
||||
|
||||
@@ -1485,6 +1485,9 @@ int main(int argc, char **argv)
|
||||
if (auth == 0) {
|
||||
auth = conf->auth;
|
||||
}
|
||||
if (mode == TCP_ONLY) {
|
||||
mode = conf->mode;
|
||||
}
|
||||
#ifdef TCP_FASTOPEN
|
||||
if (fast_open == 0) {
|
||||
fast_open = conf->fast_open;
|
||||
|
||||
@@ -843,6 +843,12 @@ int main(int argc, char **argv)
|
||||
if (auth == 0) {
|
||||
auth = conf->auth;
|
||||
}
|
||||
if (tunnel_addr_str == NULL) {
|
||||
tunnel_addr_str = conf->tunnel_address;
|
||||
}
|
||||
if (mode == TCP_ONLY) {
|
||||
mode = conf->mode;
|
||||
}
|
||||
#ifdef HAVE_SETRLIMIT
|
||||
if (nofile == 0) {
|
||||
nofile = conf->nofile;
|
||||
|
||||
Reference in new issue
Block a user