Added client debug output option

This commit is contained in:
frekky 2015-08-29 20:10:53 +08:00
parent c83a52c771
commit 9f6033c4b8
2 changed files with 16 additions and 3 deletions

View File

@ -18,6 +18,8 @@
#ifndef __CLIENT_H__
#define __CLIENT_H__
extern int debug;
void client_init();
void client_stop();
@ -33,7 +35,7 @@ char *client_get_qtype();
void client_set_downenc(char *encoding);
void client_set_selecttimeout(int select_timeout);
void client_set_lazymode(int lazy_mode);
void client_set_hostname_maxlen(int i);
void client_set_hostname_maxlen(size_t i);
int client_handshake(int dns_fd, int raw_mode, int autodetect_frag_size, int fragsize);
int client_tunnel(int tun_fd, int dns_fd);

View File

@ -69,7 +69,7 @@ static void
usage() {
extern char *__progname;
fprintf(stderr, "Usage: %s [-v] [-h] [-f] [-r] [-u user] [-t chrootdir] [-d device] "
fprintf(stderr, "Usage: %s [-v] [-h] [-f] [-D] [-r] [-u user] [-t chrootdir] [-d device] "
"[-P password] [-m maxfragsize] [-M maxlen] [-T type] [-O enc] [-L 0|1] [-I sec] "
"[-z context] [-F pidfile] topdomain [nameserver ...]\n", __progname);
exit(2);
@ -97,6 +97,7 @@ help() {
fprintf(stderr, " -v to print version info and exit\n");
fprintf(stderr, " -h to print this help and exit\n");
fprintf(stderr, " -f to keep running in foreground\n");
fprintf(stderr, " -D enable debug mode (add more D's to increase debug level)\n");
fprintf(stderr, " -u name to drop privileges and run as user 'name'\n");
fprintf(stderr, " -t dir to chroot to directory dir\n");
fprintf(stderr, " -d device to set tunnel device name\n");
@ -169,6 +170,7 @@ main(int argc, char **argv)
context = NULL;
device = NULL;
pidfile = NULL;
debug = 0;
autodetect_frag_size = 1;
max_downstream_frag_size = 3072;
@ -194,7 +196,7 @@ main(int argc, char **argv)
__progname++;
#endif
while ((choice = getopt(argc, argv, "46vfhru:t:d:R:P:m:M:F:T:O:L:I:")) != -1) {
while ((choice = getopt(argc, argv, "46vfDhru:t:d:R:P:m:M:F:T:O:L:I:")) != -1) {
switch(choice) {
case '4':
nameserv_family = AF_INET;
@ -209,6 +211,9 @@ main(int argc, char **argv)
case 'f':
foreground = 1;
break;
case 'D':
debug++;
break;
case 'h':
help();
/* NOTREACHED */
@ -286,6 +291,12 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
if (debug) {
fprintf(stderr, "Debug level %d enabled, will stay in foreground.\n", debug);
fprintf(stderr, "Add more -D switches to set higher debug level.\n");
foreground = 1;
}
nameserv_hosts_len = argc - 1;
if (nameserv_hosts_len <= 0)
nameserv_hosts_len = 1;