diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2020-08-18 17:14:05 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2020-08-18 17:14:05 +0200 |
commit | 1db474507b8957dc07a0486757cb0a7bc4edbad8 (patch) | |
tree | 647bbbaf88236d8a4f523ea9c7ff4d1cf11eb728 /nDPIsrvd.c | |
parent | e6c2bc6373d9848cdef61919b1297a1c93e99dc4 (diff) |
nDPIsrvd: add command line option for distributor listen host/port
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'nDPIsrvd.c')
-rw-r--r-- | nDPIsrvd.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/nDPIsrvd.c b/nDPIsrvd.c index f5a038b5a..3eecbdda7 100644 --- a/nDPIsrvd.c +++ b/nDPIsrvd.c @@ -35,8 +35,7 @@ struct remote_desc enum ev_type type; int fd; struct io_buffer buf; - union - { + union { struct { int json_sockfd; @@ -201,7 +200,7 @@ static int parse_options(int argc, char ** argv) { int opt; - while ((opt = getopt(argc, argv, "hlc:dp:")) != -1) + while ((opt = getopt(argc, argv, "hlc:dp:s:")) != -1) { switch (opt) { @@ -219,8 +218,28 @@ static int parse_options(int argc, char ** argv) strncpy(pidfile, optarg, sizeof(pidfile) - 1); pidfile[sizeof(pidfile) - 1] = '\0'; break; + case 's': + { + char * delim = strchr(optarg, ':'); + if (delim != NULL) + { + char * endptr = NULL; + errno = 0; + serv_listen_port = strtoul(delim + 1, &endptr, 10); + if (endptr == delim + 1 || errno != 0) + { + fprintf(stderr, "%s: invalid port number \"%s\"\n", argv[0], delim + 1); + return 1; + } + } + size_t len = (delim != NULL ? (size_t)(delim - optarg) : strlen(optarg)); + strncpy(serv_listen_addr, optarg, (len < sizeof(serv_listen_addr) ? len : sizeof(serv_listen_addr))); + break; + } default: - fprintf(stderr, "Usage: %s [-l] [-c path-to-unix-sock] [-d] [-p pidfile]\n", argv[0]); + fprintf(stderr, + "Usage: %s [-l] [-c path-to-unix-sock] [-d] [-p pidfile] -s [distributor-host:port]\n", + argv[0]); return 1; } } |