mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-24 02:55:40 +08:00
Simplify socket options printing
+ add supported options to 3proxy help message
This commit is contained in:
parent
e2906f1219
commit
39be30ba5d
@ -500,6 +500,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
|||||||
#else
|
#else
|
||||||
fprintf(stderr, "\n if conffile is missing, configuration is expected from stdin\n");
|
fprintf(stderr, "\n if conffile is missing, configuration is expected from stdin\n");
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr, "available socket options:\n\t%s\n", printopts("\n\t"));
|
||||||
fprintf(stderr, "\n%s %s\n%s\n", conf.stringtable[2], conf.stringtable[3], copyright);
|
fprintf(stderr, "\n%s %s\n%s\n", conf.stringtable[2], conf.stringtable[3], copyright);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -348,6 +348,7 @@ extern struct socketoptions {
|
|||||||
char * optname;
|
char * optname;
|
||||||
} sockopts[];
|
} sockopts[];
|
||||||
void setopts(SOCKET s, int opts);
|
void setopts(SOCKET s, int opts);
|
||||||
|
char * printopts(char *sep);
|
||||||
|
|
||||||
#ifdef _WINCE
|
#ifdef _WINCE
|
||||||
char * CEToUnicode (const char *str);
|
char * CEToUnicode (const char *str);
|
||||||
|
@ -104,6 +104,15 @@ struct socketoptions sockopts[] = {
|
|||||||
{0, NULL}
|
{0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char optsbuf[1024];
|
||||||
|
|
||||||
|
char * printopts(char *sep){
|
||||||
|
int i=0, pos=0;
|
||||||
|
for(; sockopts[i].optname; i++)pos += sprintf(optsbuf+pos,"%s%s",i?sep:"",sockopts[i].optname);
|
||||||
|
return optsbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int getopts(const char *s){
|
int getopts(const char *s){
|
||||||
int i=0, ret=0;
|
int i=0, ret=0;
|
||||||
for(; sockopts[i].optname; i++)if(strstr(s,sockopts[i].optname)) ret |= (1<<i);
|
for(; sockopts[i].optname; i++)if(strstr(s,sockopts[i].optname)) ret |= (1<<i);
|
||||||
@ -196,47 +205,6 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
" -b(BUFSIZE) size of network buffer (default 4096 for TCP, 16384 for UDP)\n"
|
" -b(BUFSIZE) size of network buffer (default 4096 for TCP, 16384 for UDP)\n"
|
||||||
" -S(STACKSIZE) value to add to default client thread stack size\n"
|
" -S(STACKSIZE) value to add to default client thread stack size\n"
|
||||||
" -t be silent (do not log service start/stop)\n"
|
" -t be silent (do not log service start/stop)\n"
|
||||||
" -ocOPTIONS, -osOPTIONS, -olOPTIONS - options for client (oc), server (os) or listening (ol) socket,"
|
|
||||||
" where possible options are: "
|
|
||||||
#ifdef TCP_NODELAY
|
|
||||||
"TCP_NODELAY "
|
|
||||||
#endif
|
|
||||||
#ifdef TCP_CORK
|
|
||||||
"TCP_CORK "
|
|
||||||
#endif
|
|
||||||
#ifdef TCP_DEFER_ACCEPT
|
|
||||||
"TCP_DEFER_ACCEPT "
|
|
||||||
#endif
|
|
||||||
#ifdef TCP_QUICKACK
|
|
||||||
"TCP_QUICKACK "
|
|
||||||
#endif
|
|
||||||
#ifdef TCP_TIMESTAMPS
|
|
||||||
"TCP_TIMESTAMPS "
|
|
||||||
#endif
|
|
||||||
#ifdef USE_TCP_FASTOPEN
|
|
||||||
"USE_TCP_FASTOPEN "
|
|
||||||
#endif
|
|
||||||
#ifdef SO_REUSEADDR
|
|
||||||
"SO_REUSEADDR "
|
|
||||||
#endif
|
|
||||||
#ifdef SO_REUSEPORT
|
|
||||||
"SO_REUSEPORT "
|
|
||||||
#endif
|
|
||||||
#ifdef SO_PORT_SCALABILITY
|
|
||||||
"SO_PORT_SCALABILITY "
|
|
||||||
#endif
|
|
||||||
#ifdef SO_REUSE_UNICASTPORT
|
|
||||||
"SO_REUSE_UNICASTPORT "
|
|
||||||
#endif
|
|
||||||
#ifdef SO_KEEPALIVE
|
|
||||||
"SO_KEEPALIVE "
|
|
||||||
#endif
|
|
||||||
#ifdef SO_DONTROUTE
|
|
||||||
"SO_DONTROUTE "
|
|
||||||
#endif
|
|
||||||
#ifdef IP_TRANSPARENT
|
|
||||||
"IP_TRANSPARENT"
|
|
||||||
#endif
|
|
||||||
"\n"
|
"\n"
|
||||||
" -iIP ip address or internal interface (clients are expected to connect)\n"
|
" -iIP ip address or internal interface (clients are expected to connect)\n"
|
||||||
" -eIP ip address or external interface (outgoing connection will have this)\n"
|
" -eIP ip address or external interface (outgoing connection will have this)\n"
|
||||||
@ -245,7 +213,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
" -4 Use IPv4 for outgoing connections\n"
|
" -4 Use IPv4 for outgoing connections\n"
|
||||||
" -6 Use IPv6 for outgoing connections\n"
|
" -6 Use IPv6 for outgoing connections\n"
|
||||||
" -46 Prefer IPv4 for outgoing connections, use both IPv4 and IPv6\n"
|
" -46 Prefer IPv4 for outgoing connections, use both IPv4 and IPv6\n"
|
||||||
" -64 Prefer IPv6 for outgoing connections, use both IPv4 and IPv6\n";
|
" -64 Prefer IPv6 for outgoing connections, use both IPv4 and IPv6\n"
|
||||||
|
" -ocOPTIONS, -osOPTIONS, -olOPTIONS - options for client (oc), server (os) or listening (ol) socket,"
|
||||||
|
" where possible options are: ";
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
@ -462,16 +432,15 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
fprintf(stderr, "%s of %s\n"
|
fprintf(stderr, "%s of %s\n"
|
||||||
"Usage: %s options\n"
|
"Usage: %s options\n"
|
||||||
"Available options are:\n"
|
"Available options are:\n"
|
||||||
"%s"
|
"%s\n"
|
||||||
|
"\t%s\n"
|
||||||
" -pPORT - service port to accept connections\n"
|
" -pPORT - service port to accept connections\n"
|
||||||
" -RIP:PORT - connect back IP:PORT to listen and accept connections\n"
|
|
||||||
" -rIP:PORT - connect back IP:PORT to establish connect back connection\n"
|
|
||||||
"%s"
|
"%s"
|
||||||
"\tExample: %s -i127.0.0.1\n\n"
|
"\tExample: %s -i127.0.0.1\n\n"
|
||||||
"%s",
|
"%s",
|
||||||
argv[0],
|
argv[0],
|
||||||
conf.stringtable?conf.stringtable[3]: VERSION " (" BUILDDATE ")",
|
conf.stringtable?conf.stringtable[3]: VERSION " (" BUILDDATE ")",
|
||||||
argv[0], loghelp, childdef.helpmessage, argv[0],
|
argv[0], loghelp, printopts("\n\t"), childdef.helpmessage, argv[0],
|
||||||
#ifdef STDMAIN
|
#ifdef STDMAIN
|
||||||
copyright
|
copyright
|
||||||
#else
|
#else
|
||||||
@ -497,15 +466,14 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
" [-e<external_ip>] <port_to_bind>"
|
" [-e<external_ip>] <port_to_bind>"
|
||||||
" <target_hostname> <target_port>\n"
|
" <target_hostname> <target_port>\n"
|
||||||
"Available options are:\n"
|
"Available options are:\n"
|
||||||
" -RIP:PORT - connect back IP:PORT to listen and accept connections\n"
|
"%s\n"
|
||||||
" -rIP:PORT - connect back IP:PORT to establish connect back connection\n"
|
"\t%s\n"
|
||||||
"%s"
|
|
||||||
"%s"
|
"%s"
|
||||||
"\tExample: %s -d -i127.0.0.1 6666 serv.somehost.ru 6666\n\n"
|
"\tExample: %s -d -i127.0.0.1 6666 serv.somehost.ru 6666\n\n"
|
||||||
"%s",
|
"%s",
|
||||||
argv[0],
|
argv[0],
|
||||||
conf.stringtable?conf.stringtable[3]: VERSION " (" BUILDDATE ")",
|
conf.stringtable?conf.stringtable[3]: VERSION " (" BUILDDATE ")",
|
||||||
argv[0], loghelp, childdef.helpmessage, argv[0],
|
argv[0], loghelp, printopts("\n\t"), childdef.helpmessage, argv[0],
|
||||||
#ifdef STDMAIN
|
#ifdef STDMAIN
|
||||||
copyright
|
copyright
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user