aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2023-07-25 08:00:57 -0400
committerLibravatar netblue30 <netblue30@protonmail.com>2023-07-25 08:00:57 -0400
commit97d6993f35c0cc1434c8dccc4bad49c37b84a655 (patch)
tree0b89f5e714fdee694fed70a4921beab0f9db186c
parentMerge branch 'master' of ssh://github.com/netblue30/firejail (diff)
downloadfirejail-97d6993f35c0cc1434c8dccc4bad49c37b84a655.tar.gz
firejail-97d6993f35c0cc1434c8dccc4bad49c37b84a655.tar.zst
firejail-97d6993f35c0cc1434c8dccc4bad49c37b84a655.zip
cleanup
-rw-r--r--src/fnettrace/main.c100
-rw-r--r--src/fnettrace/static-ip-map.txt4
2 files changed, 51 insertions, 53 deletions
diff --git a/src/fnettrace/main.c b/src/fnettrace/main.c
index 54ef54314..22da429af 100644
--- a/src/fnettrace/main.c
+++ b/src/fnettrace/main.c
@@ -294,23 +294,23 @@ typedef struct port_type_t {
294 char *service; 294 char *service;
295} PortType; 295} PortType;
296static PortType ports[] = { 296static PortType ports[] = {
297 {20, "(FTP)"}, 297 {20, "FTP"},
298 {21, "(FTP)"}, 298 {21, "FTP"},
299 {22, "(SSH)"}, 299 {22, "SSH"},
300 {23, "(telnet)"}, 300 {23, "telnet"},
301 {25, "(SMTP)"}, 301 {25, "SMTP"},
302 {43, "(WHOIS)"}, 302 {43, "WHOIS"},
303 {67, "(DHCP)"}, 303 {67, "DHCP"},
304 {68, "(DHCP)"}, 304 {68, "DHCP"},
305 {69, "(TFTP)"}, 305 {69, "TFTP"},
306 {80, "(HTTP)"}, 306 {80, "HTTP"},
307 {109, "(POP2)"}, 307 {109, "POP2"},
308 {110, "(POP3)"}, 308 {110, "POP3"},
309 {113, "(IRC)"}, 309 {113, "IRC"},
310 {123, "(NTP)"}, 310 {123, "NTP"},
311 {161, "(SNMP)"}, 311 {161, "SNMP"},
312 {162, "(SNMP)"}, 312 {162, "SNMP"},
313 {194, "(IRC)"}, 313 {194, "IRC"},
314 {0, NULL}, 314 {0, NULL},
315}; 315};
316 316
@@ -318,27 +318,27 @@ static PortType ports[] = {
318static inline const char *common_port(uint16_t port) { 318static inline const char *common_port(uint16_t port) {
319 if (port >= 6660 && port <= 10162) { 319 if (port >= 6660 && port <= 10162) {
320 if (port >= 6660 && port <= 6669) 320 if (port >= 6660 && port <= 6669)
321 return "(IRC)"; 321 return "IRC";
322 else if (port == 6679) 322 else if (port == 6679)
323 return "(IRC)"; 323 return "IRC";
324 else if (port == 6771) 324 else if (port == 6771)
325 return "(BitTorrent)"; 325 return "BitTorrent";
326 else if (port >= 6881 && port <= 6999) 326 else if (port >= 6881 && port <= 6999)
327 return "(BitTorrent)"; 327 return "BitTorrent";
328 else if (port == 9001) 328 else if (port == 9001)
329 return "(Tor)"; 329 return "Tor";
330 else if (port == 9030) 330 else if (port == 9030)
331 return "(Tor)"; 331 return "Tor";
332 else if (port == 9050) 332 else if (port == 9050)
333 return "(Tor)"; 333 return "Tor";
334 else if (port == 9051) 334 else if (port == 9051)
335 return "(Tor)"; 335 return "Tor";
336 else if (port == 9150) 336 else if (port == 9150)
337 return "(Tor)"; 337 return "Tor";
338 else if (port == 10161) 338 else if (port == 10161)
339 return "(secure SNMP)"; 339 return "secure SNMP";
340 else if (port == 10162) 340 else if (port == 10162)
341 return "(secure SNMP)"; 341 return "secure SNMP";
342 return NULL; 342 return NULL;
343 } 343 }
344 344
@@ -388,7 +388,7 @@ static void hnode_print(unsigned bw) {
388 else 388 else
389 sprintf(stats, "%u KB/s ", bw / (1024 * DISPLAY_INTERVAL)); 389 sprintf(stats, "%u KB/s ", bw / (1024 * DISPLAY_INTERVAL));
390// int len = snprintf(line, LINE_MAX, "%32s geoip %d, IP database %d\n", stats, geoip_calls, radix_nodes); 390// int len = snprintf(line, LINE_MAX, "%32s geoip %d, IP database %d\n", stats, geoip_calls, radix_nodes);
391 int len = snprintf(line, LINE_MAX, "%32s address:port (protocol) network (packets)\n", stats); 391 int len = snprintf(line, LINE_MAX, "%32s address:port (protocol) network\n", stats);
392 adjust_line(line, len, cols); 392 adjust_line(line, len, cols);
393 printf("%s", line); 393 printf("%s", line);
394 394
@@ -422,59 +422,57 @@ static void hnode_print(unsigned bw) {
422 422
423 const char *protocol = NULL; 423 const char *protocol = NULL;
424 if (ptr->port_src == 443 && ptr->protocol == 0x06) { // TCP 424 if (ptr->port_src == 443 && ptr->protocol == 0x06) { // TCP
425 protocol = "(TLS)"; 425 protocol = "TLS";
426 stats_tls += ptr->pkts; 426 stats_tls += ptr->pkts;
427 if (strstr(ptr->rnode->name, "DNS")) {
428 protocol = "DoH";
429 stats_dns_doh += ptr->pkts;
430 }
431
427 } 432 }
428 else if (ptr->port_src == 443 && ptr->protocol == 0x11) { // UDP 433 else if (ptr->port_src == 443 && ptr->protocol == 0x11) { // UDP
429 protocol = "(QUIC)"; 434 protocol = "QUIC";
430 stats_quic += ptr->pkts; 435 stats_quic += ptr->pkts;
436 if (strstr(ptr->rnode->name, "DNS")) {
437 protocol = "DoQ";
438 stats_dns_doq += ptr->pkts;
439 }
431 } 440 }
432 else if (ptr->port_src == 53) { 441 else if (ptr->port_src == 53) {
442 protocol = "DNS";
433 stats_dns += ptr->pkts; 443 stats_dns += ptr->pkts;
434 if (ptr->protocol == 0x06)
435 protocol = "(TCP/DNS)";
436 else if (ptr->protocol == 0x11)
437 protocol = "(UDP/DNS)";
438 else
439 protocol = NULL;
440 } 444 }
441 else if (ptr->port_src == 853) { 445 else if (ptr->port_src == 853) {
442 if (ptr->protocol == 0x06) { 446 if (ptr->protocol == 0x06) {
443 protocol = "(DoT)"; 447 protocol = "DoT";
444 stats_dns_dot += ptr->pkts; 448 stats_dns_dot += ptr->pkts;
445 } 449 }
446 else if (ptr->protocol == 0x11) { 450 else if (ptr->protocol == 0x11) {
447 protocol = "(DoQ)"; 451 protocol = "DoQ";
448 stats_dns_doq += ptr->pkts; 452 stats_dns_doq += ptr->pkts;
449 } 453 }
450 else 454 else
451 protocol = NULL; 455 protocol = NULL;
452 } 456 }
453 else if ((protocol = common_port(ptr->port_src)) != NULL) { 457 else if ((protocol = common_port(ptr->port_src)) != NULL) {
454 if (strcmp(protocol, "(HTTP)") == 0) 458 if (strcmp(protocol, "HTTP") == 0)
455 stats_http += ptr->pkts; 459 stats_http += ptr->pkts;
456 else if (strcmp(protocol, "(Tor)") == 0) 460 else if (strcmp(protocol, "Tor") == 0)
457 stats_tor += ptr->pkts; 461 stats_tor += ptr->pkts;
458 } 462 }
459 else if (ptr->protocol == 0x11) 463 else if (ptr->protocol == 0x11)
460 protocol = "(UDP)"; 464 protocol = "UDP";
461 else if (ptr->protocol == 0x06) 465 else if (ptr->protocol == 0x06)
462 protocol = "(TCP)"; 466 protocol = "TCP";
463 467
464 if (protocol == NULL) 468 if (protocol == NULL)
465 protocol = ""; 469 protocol = "";
466 if (ptr->port_src == 0) 470 if (ptr->port_src == 0)
467 len = snprintf(line, LINE_MAX, "%10s %s %d.%d.%d.%d (ICMP) %s\n", 471 len = snprintf(line, LINE_MAX, "%10s %s %d.%d.%d.%d (ICMP) %s\n",
468 bytes, bwline, PRINT_IP(ptr->ip_src), ptr->rnode->name); 472 bytes, bwline, PRINT_IP(ptr->ip_src), ptr->rnode->name);
469 else if (ptr->rnode->pkts > 1000000)
470 len = snprintf(line, LINE_MAX, "%10s %s %d.%d.%d.%d:%u%s %s (%.01fM)\n",
471 bytes, bwline, PRINT_IP(ptr->ip_src), ptr->port_src, protocol, ptr->rnode->name, ((double) ptr->rnode->pkts) / 1000000);
472 else if (ptr->rnode->pkts > 1000)
473 len = snprintf(line, LINE_MAX, "%10s %s %d.%d.%d.%d:%u%s %s (%.01fK)\n",
474 bytes, bwline, PRINT_IP(ptr->ip_src), ptr->port_src, protocol, ptr->rnode->name, ((double) ptr->rnode->pkts) / 1000);
475 else 473 else
476 len = snprintf(line, LINE_MAX, "%10s %s %d.%d.%d.%d:%u%s %s (%u)\n", 474 len = snprintf(line, LINE_MAX, "%10s %s %d.%d.%d.%d:%u (%s) %s\n",
477 bytes, bwline, PRINT_IP(ptr->ip_src), ptr->port_src, protocol, ptr->rnode->name, ptr->rnode->pkts); 475 bytes, bwline, PRINT_IP(ptr->ip_src), ptr->port_src, protocol, ptr->rnode->name);
478 adjust_line(line, len, cols); 476 adjust_line(line, len, cols);
479 printf("%s", line); 477 printf("%s", line);
480 478
diff --git a/src/fnettrace/static-ip-map.txt b/src/fnettrace/static-ip-map.txt
index 10b3a0ffb..20c404064 100644
--- a/src/fnettrace/static-ip-map.txt
+++ b/src/fnettrace/static-ip-map.txt
@@ -98,7 +98,6 @@
9845.11.45.0/24 DNS-SB 9845.11.45.0/24 DNS-SB
9964.6.64.6/32 Neustar DNS 9964.6.64.6/32 Neustar DNS
10064.6.65.6/32 Neustar DNS 10064.6.65.6/32 Neustar DNS
10169.197.138.24/29 BitChute
10274.82.42.42/32 Hurricane Electric DNS 10174.82.42.42/32 Hurricane Electric DNS
10376.76.2.0/24 ControlD DNS 10276.76.2.0/24 ControlD DNS
10476.76.10.0/24 ControlD DNS 10376.76.10.0/24 ControlD DNS
@@ -113,7 +112,7 @@
11394.140.14.0/23 Adguard DNS 11294.140.14.0/23 Adguard DNS
114149.112.112.0/24 Quad9 DNS 113149.112.112.0/24 Quad9 DNS
115149.112.120.0/21 CIRA DNS Canada 114149.112.120.0/21 CIRA DNS Canada
116146.255.56.96/29 Applied Privacy 115146.255.56.96/29 Applied Privacy DNS
117176.103.128.0/19 Adguard DNS 116176.103.128.0/19 Adguard DNS
118185.222.222.0/24 DNS-SB 117185.222.222.0/24 DNS-SB
119185.228.168.0/24 Cleanbrowsing DNS 118185.228.168.0/24 Cleanbrowsing DNS
@@ -184,6 +183,7 @@
18491.189.94.0/24 Ubuntu One 18391.189.94.0/24 Ubuntu One
18595.161.64.0/20 Telegram 18495.161.64.0/20 Telegram
18699.181.64.0/18 Twitch 18599.181.64.0/18 Twitch
18669.197.138.24/29 BitChute
187103.10.124.0/23 Steam 187103.10.124.0/23 Steam
188103.28.54.0/24 Steam 188103.28.54.0/24 Steam
189103.53.48.0/23 Twitch 189103.53.48.0/23 Twitch