aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar zfl9 <zfl9.com@gmail.com> 2019-08-30 21:46:48 +0800
committerGravatar zfl9 <zfl9.com@gmail.com> 2019-08-30 21:46:48 +0800
commit19cce523f7b5ff3f919a266146f55fafc901fb4a (patch)
tree4b71f7657ff5e52b3e7d538568a627e0738113c4
parentupdate dns2tcp.c (diff)
downloaddns2tcp-19cce523f7b5ff3f919a266146f55fafc901fb4a.tar.gz
dns2tcp-19cce523f7b5ff3f919a266146f55fafc901fb4a.tar.bz2
dns2tcp-19cce523f7b5ff3f919a266146f55fafc901fb4a.zip
update dns2tcp.c
-rw-r--r--dns2tcp.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/dns2tcp.c b/dns2tcp.c
index 7267f69..50a5f14 100644
--- a/dns2tcp.c
+++ b/dns2tcp.c
@@ -3,6 +3,8 @@
#include <uv.h>
#undef _GNU_SOURCE
+static bool g_verbose = false;
+
static void print_command_help(void) {
printf("usage: dns2tcp <-L LISTEN_ADDR> <-R REMOTE_ADDR> [-vVh]\n"
" -L <ip#port> udp listen address, it is required\n"
@@ -14,6 +16,29 @@ static void print_command_help(void) {
);
}
+static void parse_command_args(int argc, char *argv[]) {
+ opterr = 0;
+ int shortopt = -1;
+ char *bindaddr_optarg = NULL;
+ char *servaddr_optarg = NULL;
+ const char *optstr = ":L:R:vVh";
+ while ((shortopt = getopt(argc, argv, optstr)) != -1) {
+ switch (shortopt) {
+ case 'L':
+ bindaddr_optarg = optarg;
+ break;
+ case 'R':
+ servaddr_optarg = optarg;
+ case 'v':
+ g_verbose = true;
+ }
+ }
+ return;
+PRINT_HELP_AND_EXIT:
+ print_command_help();
+ exit(1);
+}
+
int main() {
print_command_help();
return 0;