Skip to content

Commit

Permalink
ADD: version
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk committed Mar 10, 2020
1 parent 0df9649 commit 391e045
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/tcpkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
#include "tcpkit.h"
#include "server.h"


struct server *srv;

const char *VERSION = "1.1.0";

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

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

0 comments on commit 391e045

Please sign in to comment.