Skip to content

Commit 391e045

Browse files
committed
ADD: version
1 parent 0df9649 commit 391e045

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/tcpkit.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
#include "tcpkit.h"
2424
#include "server.h"
2525

26+
2627
struct server *srv;
2728

29+
const char *VERSION = "1.1.0";
30+
2831
void signal_handler(int sig) {
2932
if (sig == SIGINT || sig == SIGTERM) {
3033
server_terminate(srv);
@@ -34,6 +37,7 @@ void signal_handler(int sig) {
3437
void usage() {
3538
const char *usage_literal = ""
3639
"the tcpkit was designed to make network packets programable with LUA by @git-hulk\n"
40+
" version: %s\n"
3741
" -h, Print the tcpkit version strings, print a usage message, and exit\n"
3842
" -i interface, Listen on network card interface\n"
3943
" -A Print each packet (minus its link level header) in ASCII. Handy for capturing web pages.\n"
@@ -50,7 +54,7 @@ void usage() {
5054
" `tcpkit -i eth0 tcp port 6379 -p redis` was used to monitor the redis reqeust latency\n\n"
5155
" `tcpkit -i eth0 tcp port 6379 -p redis -w 6379.pcap` would also dump the packets to `6379.pcap`\n\n"
5256
" `tcpkit -i eth0 tcp port 6379 -p redis -t 10` would only print the request latency slower than 10ms\n";
53-
color_printf(GREEN, "%s\n", usage_literal);
57+
color_printf(GREEN, usage_literal, VERSION);
5458
exit(0);
5559
}
5660

@@ -178,6 +182,10 @@ int main(int argc, char **argv) {
178182
free_options(opts);
179183
usage();
180184
}
185+
if (opts->print_version) {
186+
printf("tcpkit %s\n", VERSION);
187+
exit(0);
188+
}
181189
if (getuid() != 0 && !opts->offline_file) {
182190
free_options(opts);
183191
log_message(FATAL, "You don't have permission to capture on the network card interface");

0 commit comments

Comments
 (0)