(results)
| 984 | |
| 985 | |
| 986 | def print_summary(results): |
| 987 | print() |
| 988 | print(ccolor(CYAN + BOLD, " -- DISCOVERED DEVICES --")) |
| 989 | print() |
| 990 | |
| 991 | if not results: |
| 992 | warn("No devices were discovered.") |
| 993 | print(ccolor(DIM, " This can happen if the network blocks discovery or the subnet is wrong.")) |
| 994 | return |
| 995 | |
| 996 | for index, item in enumerate(results, 1): |
| 997 | label, icon, color = type_label(item.get("type_confidence", 0)) |
| 998 | device_type = item.get("device_type", "unknown") |
| 999 | print(ccolor(color, f" ┌─ #{index} ─────────────────────────")) |
| 1000 | print(ccolor(color, " │") + " " + ccolor(GREEN, "LIVE") + " " + ccolor(WHITE, item["ip"])) |
| 1001 | print(ccolor(color, " │") + f" Live confidence : {presence_bar(item.get('presence_confidence', 0))}") |
| 1002 | print(ccolor(color, " │") + f" Type : {ccolor(BOLD, device_type)} {ccolor(color, label)} ({item.get('type_confidence', 0)}%)") |
| 1003 | if item.get("device_name"): |
| 1004 | print(ccolor(color, " │") + f" Name : {ccolor(WHITE, item['device_name'])}") |
| 1005 | if item.get("mac"): |
| 1006 | mac_line = item["mac"] |
| 1007 | if item.get("vendor"): |
| 1008 | mac_line += f" ({item['vendor']})" |
| 1009 | print(ccolor(color, " │") + f" MAC : {ccolor(WHITE, mac_line)}") |
| 1010 | print(ccolor(color, " │") + f" Sources : {ccolor(WHITE, ', '.join(sorted(item.get('discovery_sources', []))))}") |
| 1011 | if item.get("open_ports"): |
| 1012 | print(ccolor(color, " │") + f" Open ports : {ccolor(WHITE, format_ports(item['open_ports']))}") |
| 1013 | extra = item.get("extra_info", {}) |
| 1014 | if extra.get("hostname"): |
| 1015 | print(ccolor(color, " │") + f" DNS : {ccolor(WHITE, extra['hostname'])}") |
| 1016 | if extra.get("mdns_name"): |
| 1017 | print(ccolor(color, " │") + f" mDNS : {ccolor(WHITE, extra['mdns_name'])}") |
| 1018 | if extra.get("snmp", {}).get("description"): |
| 1019 | print(ccolor(color, " │") + f" SNMP : {ccolor(WHITE, extra['snmp']['description'][:80])}") |
| 1020 | print(ccolor(color, " │") + " Why:") |
| 1021 | for reason in item.get("type_reasons", []): |
| 1022 | print(ccolor(color, " │") + " " + ccolor(GREEN, "✓") + " " + reason) |
| 1023 | if not item.get("type_reasons"): |
| 1024 | print(ccolor(color, " │") + " " + ccolor(YELLOW, "•") + " Host is live, but the type is still unknown") |
| 1025 | print(ccolor(color, " └──────────────────────────────────")) |
| 1026 | print() |
| 1027 | |
| 1028 | type_totals = defaultdict(int) |
| 1029 | for item in results: |
| 1030 | type_totals[item.get("device_type", "unknown")] += 1 |
| 1031 | |
| 1032 | divider() |
| 1033 | summary_parts = [] |
| 1034 | for kind, count in sorted(type_totals.items()): |
| 1035 | summary_parts.append(f"{kind}:{count}") |
| 1036 | print(" " + ccolor(WHITE, " | ".join(summary_parts))) |
| 1037 | divider() |
| 1038 | |
| 1039 | |
| 1040 | # ───────────────────────────────────────────── |
no test coverage detected