diff --git a/man/shadowsocks-libev.8 b/man/shadowsocks-libev.8 index aa0ae18f..5a6a47a4 100644 --- a/man/shadowsocks-libev.8 +++ b/man/shadowsocks-libev.8 @@ -164,6 +164,9 @@ Only available in manager mode. .TP .B \-v Enable verbose mode. +.TP +.B \-h, --help +Print help message. .SH EXAMPLE \*(Re requires netfilter's NAT function. Here is an example: diff --git a/man/ss-local.1 b/man/ss-local.1 index 3c7007c6..9a35d7c3 100644 --- a/man/ss-local.1 +++ b/man/ss-local.1 @@ -31,11 +31,11 @@ ss-local \- shadowsocks client as socks5 proxy, libev port .SH SYNOPSIS \*(Lo - [\fB\-Auhv\fR] + [\fB\-Auv\fR] [\fB\-h\fR|\fB\--help\fR] [\fB\-s\fR \fIserver_host\fR] [\fB\-p\fR \fIserver_port\fR] [\fB\-l\fR \fIlocal_port\fR] [\fB\-k\fR \fIpassword\fR] [\fB\-m\fR \fIencrypt_method\fR] [\fB\-f\fR \fIpid_file\fR] [\fB\-t\fR \fItimeout\fR] [\fB\-c\fR \fIconfig_file\fR] [\fB\-b\fR \fIinterface\fR] [\fB\-a\fR \fIuser_name\fR] - [\fB\-n\fR \fInofile\fR] [\fB\-\-fast\-open\fR] [\fB\-\-acl\fR \fIacl_config\fR] + [\fB\-n\fR \fInofile\fR] [\fB\-\-fast\-open\fR] [\fB\-\-acl\fR \fIacl_config\fR] .SH DESCRIPTION \*(Me is a lightweight and secure socks5 proxy. It is a port of the original @@ -110,6 +110,9 @@ Enable ACL (Access Control List) and specify config file. .TP .B \-v Enable verbose mode. +.TP +.B \-h, --help +Print help message. .SH EXAMPLE \*(Lo(1) can be started from command line and run in foreground. Here is an diff --git a/man/ss-manager.1 b/man/ss-manager.1 index 00902398..cab021a8 100644 --- a/man/ss-manager.1 +++ b/man/ss-manager.1 @@ -32,7 +32,7 @@ statistics .SH SYNOPSIS \*(Ma - [\fB\-AhuUv\fR] + [\fB\-AuUv\fR] [\fB\-h\fR|\fB\--help\fR] [\fB\-s\fR \fIserver_host\fR] [\fB\-p\fR \fIserver_port\fR] [\fB\-l\fR \fIlocal_port\fR] [\fB\-k\fR \fIpassword\fR] [\fB\-m\fR \fIencrypt_method\fR] [\fB\-f\fR \fIpid_file\fR] [\fB\-t\fR \fItimeout\fR] [\fB\-c\fR \fIconfig_file\fR] [\fB\-i\fR \fIinterface\fR] @@ -119,6 +119,9 @@ Only available in manager mode. .TP .B \-v Enable verbose mode. +.TP +.B \-h, --help +Print help message. .SH PROTOCOL \*(Ma(1) provides several APIs through UDP protocol: diff --git a/man/ss-redir.1 b/man/ss-redir.1 index 244798ac..5b85e0bd 100644 --- a/man/ss-redir.1 +++ b/man/ss-redir.1 @@ -31,7 +31,7 @@ ss-redir \- shadowsocks client as transparent proxy, libev port .SH SYNOPSIS \*(Re - [\fB\-AhuUv\fR] + [\fB\-AuUv\fR] [\fB\-h\fR|\fB\--help\fR] [\fB\-s\fR \fIserver_host\fR] [\fB\-p\fR \fIserver_port\fR] [\fB\-l\fR \fIlocal_port\fR] [\fB\-k\fR \fIpassword\fR] [\fB\-m\fR \fIencrypt_method\fR] [\fB\-f\fR \fIpid_file\fR] [\fB\-t\fR \fItimeout\fR] [\fB\-c\fR \fIconfig_file\fR] [\fB\-b\fR \fIlocal_address\fR] @@ -105,6 +105,9 @@ Enable onetime authentication. .TP .B \-v Enable verbose mode. +.TP +.B \-h, --help +Print help message. .SH EXAMPLE \*(Re requires netfilter's NAT function. Here is an example: diff --git a/man/ss-server.1 b/man/ss-server.1 index 9b699cbd..6b952640 100644 --- a/man/ss-server.1 +++ b/man/ss-server.1 @@ -31,7 +31,7 @@ ss-server \- shadowsocks server, libev port .SH SYNOPSIS \*(Se - [\fB-AhuUv\fR] + [\fB-AuUv\fR] [\fB\-h\fR|\fB\--help\fR] [\fB\-s\fR \fIserver_host\fR] [\fB\-p\fR \fIserver_port\fR] [\fB\-l\fR \fIlocal_port\fR] [\fB\-k\fR \fIpassword\fR] [\fB\-m\fR \fIencrypt_method\fR] [\fB\-f\fR \fIpid_file\fR] [\fB\-t\fR \fItimeout\fR] [\fB\-c\fR \fIconfig_file\fR] [\fB\-i\fR \fIinterface\fR] @@ -122,6 +122,9 @@ Only available in server and manager mode. .TP .B \-v Enable verbose mode. +.TP +.B \-h, --help +Print help message. .SH EXAMPLE It is recommended to use a config file when starting \*(Se(1). diff --git a/man/ss-tunnel.1 b/man/ss-tunnel.1 index 89f0d579..72e4997b 100644 --- a/man/ss-tunnel.1 +++ b/man/ss-tunnel.1 @@ -31,7 +31,7 @@ ss-tunnel \- shadowsocks tools for local port forwarding, libev port .SH SYNOPSIS \*(Tu - [\fB-AhuUv\fR] + [\fB-AuUv\fR] [\fB\-h\fR|\fB\--help\fR] [\fB\-s\fR \fIserver_host\fR] [\fB\-p\fR \fIserver_port\fR] [\fB\-l\fR \fIlocal_port\fR] [\fB\-k\fR \fIpassword\fR] [\fB\-m\fR \fIencrypt_method\fR] [\fB\-f\fR \fIpid_file\fR] [\fB\-t\fR \fItimeout\fR] [\fB\-c\fR \fIconfig_file\fR] [\fB\-i\fR \fIinterface\fR] @@ -111,6 +111,9 @@ Only used and available in tunnel mode. .TP .B \-v Enable verbose mode. +.TP +.B \-h, --help +Print help message. .SH SEE ALSO .BR \*(Lo (1), diff --git a/src/local.c b/src/local.c index 12b1a67e..8eb97430 100644 --- a/src/local.c +++ b/src/local.c @@ -985,8 +985,9 @@ int main(int argc, char **argv) int option_index = 0; static struct option long_options[] = { - { "fast-open", no_argument, 0, 0 }, - { "acl", required_argument, 0, 0 }, + { "fast-open", no_argument , 0, 0 }, + { "acl" , required_argument, 0, 0 }, + { "help" , no_argument , 0, 0 }, { 0, 0, 0, 0 } }; @@ -995,10 +996,10 @@ int main(int argc, char **argv) USE_TTY(); #ifdef ANDROID - while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:P:uvVA", + while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:P:huvVA", long_options, &option_index)) != -1) { #else - while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:uvA", + while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:huvA", long_options, &option_index)) != -1) { #endif switch (c) { @@ -1008,6 +1009,9 @@ int main(int argc, char **argv) } else if (option_index == 1) { LOGI("initialize acl..."); acl = !init_acl(optarg, BLACK_LIST); + } else if (option_index == 2) { + usage(); + exit(EXIT_SUCCESS); } break; case 's': @@ -1058,6 +1062,9 @@ int main(int argc, char **argv) case 'v': verbose = 1; break; + case 'h': + usage(); + exit(EXIT_SUCCESS); case 'A': auth = 1; break; @@ -1069,6 +1076,10 @@ int main(int argc, char **argv) prefix = optarg; break; #endif + case '?': + // The option character is not recognized. + opterr = 1; + break; } } diff --git a/src/manager.c b/src/manager.c index c2dc7b47..f43d3e82 100644 --- a/src/manager.c +++ b/src/manager.c @@ -572,10 +572,11 @@ int main(int argc, char **argv) int option_index = 0; static struct option long_options[] = { - { "fast-open", no_argument, 0, 0 }, - { "acl", required_argument, 0, 0 }, + { "fast-open" , no_argument , 0, 0 }, + { "acl" , required_argument, 0, 0 }, { "manager-address", required_argument, 0, 0 }, - { "executable", required_argument, 0, 0 }, + { "executable" , required_argument, 0, 0 }, + { "help" , no_argument , 0, 0 }, { 0, 0, 0, 0 } }; @@ -583,7 +584,7 @@ int main(int argc, char **argv) USE_TTY(); - while ((c = getopt_long(argc, argv, "f:s:l:k:t:m:c:i:d:a:uUvA", + while ((c = getopt_long(argc, argv, "f:s:l:k:t:m:c:i:d:a:huUvA", long_options, &option_index)) != -1) switch (c) { case 0: @@ -595,6 +596,9 @@ int main(int argc, char **argv) manager_address = optarg; } else if (option_index == 3) { executable = optarg; + } else if (option_index == 4) { + usage(); + exit(EXIT_SUCCESS); } break; case 's': @@ -638,9 +642,16 @@ int main(int argc, char **argv) case 'v': verbose = 1; break; + case 'h': + usage(); + exit(EXIT_SUCCESS); case 'A': auth = 1; break; + case '?': + // The option character is not recognized. + opterr = 1; + break; } if (opterr) { diff --git a/src/redir.c b/src/redir.c index 187e55a2..3f6f88f7 100644 --- a/src/redir.c +++ b/src/redir.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -671,10 +672,23 @@ int main(int argc, char **argv) ss_addr_t remote_addr[MAX_REMOTE_NUM]; char *remote_port = NULL; + int option_index = 0; + static struct option long_options[] = { + { "help", no_argument, 0, 0 }, + { 0, 0, 0, 0 } + }; + opterr = 0; - while ((c = getopt(argc, argv, "f:s:p:l:k:t:m:c:b:a:n:uUvA")) != -1) + while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:c:b:a:n:huUvA", + long_options, &option_index)) != -1) { switch (c) { + case 0: + if (option_index == 0) { + usage(); + exit(EXIT_SUCCESS); + } + break; case 's': if (remote_num < MAX_REMOTE_NUM) { remote_addr[remote_num].host = optarg; @@ -723,10 +737,18 @@ int main(int argc, char **argv) case 'v': verbose = 1; break; + case 'h': + usage(); + exit(EXIT_SUCCESS); case 'A': auth = 1; break; + case '?': + // The option character is not recognized. + opterr = 1; + break; } + } if (opterr) { usage(); diff --git a/src/server.c b/src/server.c index 1d96d00a..ec94ac65 100644 --- a/src/server.c +++ b/src/server.c @@ -1316,9 +1316,10 @@ int main(int argc, char **argv) int option_index = 0; static struct option long_options[] = { - { "fast-open", no_argument, 0, 0 }, - { "acl", required_argument, 0, 0 }, + { "fast-open" , no_argument , 0, 0 }, + { "acl" , required_argument, 0, 0 }, { "manager-address", required_argument, 0, 0 }, + { "help" , no_argument , 0, 0 }, { 0, 0, 0, 0 } }; @@ -1326,8 +1327,8 @@ int main(int argc, char **argv) USE_TTY(); - while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:c:i:d:a:n:uUvAw", - long_options, &option_index)) != -1) + while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:c:i:d:a:n:huUvAw", + long_options, &option_index)) != -1) { switch (c) { case 0: if (option_index == 0) { @@ -1338,6 +1339,9 @@ int main(int argc, char **argv) acl_path = optarg; } else if (option_index == 2) { manager_address = optarg; + } else if (option_index == 3) { + usage(); + exit(EXIT_SUCCESS); } break; case 's': @@ -1389,13 +1393,21 @@ int main(int argc, char **argv) case 'v': verbose = 1; break; + case 'h': + usage(); + exit(EXIT_SUCCESS); case 'A': auth = 1; break; case 'w': white_list = 1; break; + case '?': + // The option character is not recognized. + opterr = 1; + break; } + } if (opterr) { usage(); diff --git a/src/tunnel.c b/src/tunnel.c index ab25d142..e1fbc09f 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifndef __MINGW32__ #include @@ -696,16 +697,30 @@ int main(int argc, char **argv) ss_addr_t tunnel_addr = { .host = NULL, .port = NULL }; char *tunnel_addr_str = NULL; + int option_index = 0; + static struct option long_options[] = { + { "help", no_argument, 0, 0 }, + { 0, 0, 0, 0 } + }; + opterr = 0; USE_TTY(); #ifdef ANDROID - while ((c = getopt(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:P:uUvVA")) != -1) { + while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:P:huUvVA", + long_options, &option_index)) != -1) { #else - while ((c = getopt(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:uUvA")) != -1) { + while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:huUvA", + long_options, &option_index)) != -1) { #endif switch (c) { + case 0: + if (option_index == 0) { + usage(); + exit(EXIT_SUCCESS); + } + break; case 's': if (remote_num < MAX_REMOTE_NUM) { remote_addr[remote_num].host = optarg; @@ -760,6 +775,9 @@ int main(int argc, char **argv) case 'v': verbose = 1; break; + case 'h': + usage(); + exit(EXIT_SUCCESS); case 'A': auth = 1; break; @@ -771,6 +789,10 @@ int main(int argc, char **argv) prefix = optarg; break; #endif + case '?': + // The option character is not recognized. + opterr = 1; + break; } } diff --git a/src/utils.c b/src/utils.c index cff3c6c7..245f12d9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -205,7 +205,7 @@ void usage() #endif printf("\n"); printf( - " -s Host name or ip address of your remote server.\n"); + " -s Host name or IP address of your remote server.\n"); printf( " -p Port number of your remote server.\n"); printf( @@ -219,9 +219,13 @@ void usage() printf( " bf-cfb, camellia-128-cfb, camellia-192-cfb,\n"); printf( - " camellia-256-cfb, cast5-cfb, des-cfb, idea-cfb,\n"); + " camellia-256-cfb, cast5-cfb, des-cfb,\n"); printf( - " rc2-cfb, seed-cfb, salsa20 and chacha20.\n"); + " idea-cfb, rc2-cfb, seed-cfb, salsa20 and\n"); + printf( + " chacha20.\n"); + printf( + " The default cipher is tables.\n"); printf("\n"); printf( " [-a ] Run as another user.\n"); @@ -289,7 +293,9 @@ void usage() #endif printf("\n"); printf( - " [-v] Verbose mode\n"); + " [-v] Verbose mode.\n"); + printf( + " [-h, --help] Print this message.\n"); printf("\n"); }