diff options
Diffstat (limited to 'src/fnettrace-sni/main.c')
-rw-r--r-- | src/fnettrace-sni/main.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/fnettrace-sni/main.c b/src/fnettrace-sni/main.c index d4fbf703a..d0a4f115a 100644 --- a/src/fnettrace-sni/main.c +++ b/src/fnettrace-sni/main.c | |||
@@ -32,16 +32,15 @@ static char last[512] = {'\0'}; | |||
32 | static void print_tls(uint32_t ip_dest, unsigned char *pkt, unsigned len) { | 32 | static void print_tls(uint32_t ip_dest, unsigned char *pkt, unsigned len) { |
33 | assert(pkt); | 33 | assert(pkt); |
34 | 34 | ||
35 | // expecting a handshake packet and client hello | ||
36 | if (pkt[0] != 0x16 || pkt[5] != 0x01) | ||
37 | return; | ||
38 | |||
35 | char ip[30]; | 39 | char ip[30]; |
36 | sprintf(ip, "%d.%d.%d.%d", PRINT_IP(ip_dest)); | 40 | sprintf(ip, "%d.%d.%d.%d", PRINT_IP(ip_dest)); |
37 | time_t seconds = time(NULL); | 41 | time_t seconds = time(NULL); |
38 | struct tm *t = localtime(&seconds); | 42 | struct tm *t = localtime(&seconds); |
39 | 43 | ||
40 | // expecting a handshake packet and client hello | ||
41 | if (pkt[0] != 0x16 || pkt[5] != 0x01) | ||
42 | goto errout; | ||
43 | |||
44 | |||
45 | // look for server name indication | 44 | // look for server name indication |
46 | unsigned char *ptr = pkt; | 45 | unsigned char *ptr = pkt; |
47 | unsigned int i = 0; | 46 | unsigned int i = 0; |
@@ -74,7 +73,7 @@ static void print_tls(uint32_t ip_dest, unsigned char *pkt, unsigned len) { | |||
74 | if (name) { | 73 | if (name) { |
75 | // filter output | 74 | // filter output |
76 | char tmp[sizeof(last)]; | 75 | char tmp[sizeof(last)]; |
77 | snprintf(tmp, sizeof(last), "%02d:%02d:%02d %-15s %s", t->tm_hour, t->tm_min, t->tm_sec, ip, name); | 76 | snprintf(tmp, sizeof(last), "%02d:%02d:%02d %-15s SNI %s", t->tm_hour, t->tm_min, t->tm_sec, ip, name); |
78 | if (strcmp(tmp, last)) { | 77 | if (strcmp(tmp, last)) { |
79 | printf("%s\n", tmp); | 78 | printf("%s\n", tmp); |
80 | fflush(0); | 79 | fflush(0); |
@@ -85,11 +84,6 @@ static void print_tls(uint32_t ip_dest, unsigned char *pkt, unsigned len) { | |||
85 | goto nosni; | 84 | goto nosni; |
86 | return; | 85 | return; |
87 | 86 | ||
88 | errout: | ||
89 | printf("%02d:%02d:%02d %-15s Error: invalid TLS packet\n", t->tm_hour, t->tm_min, t->tm_sec, ip); | ||
90 | fflush(0); | ||
91 | return; | ||
92 | |||
93 | nosni: | 87 | nosni: |
94 | printf("%02d:%02d:%02d %-15s no SNI\n", t->tm_hour, t->tm_min, t->tm_sec, ip); | 88 | printf("%02d:%02d:%02d %-15s no SNI\n", t->tm_hour, t->tm_min, t->tm_sec, ip); |
95 | return; | 89 | return; |