16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248 | def render_about(
*,
app_name: str,
app_version: str,
app_author: str,
snapshot: Any | None = None,
notifications_enabled: bool = False,
) -> list[Any]:
"""Render About view content from runtime info and the live notifications toggle state."""
runtime_info: dict[str, Any] = {}
if isinstance(snapshot, dict):
info = snapshot.get("runtime_info")
if isinstance(info, dict):
runtime_info = info
server_host_val = runtime_info.get("server_host")
server_host = server_host_val if isinstance(server_host_val, str) else "-"
server_port = runtime_info.get("server_port")
poll_ms = runtime_info.get("poll_interval_ms")
coord_precision = runtime_info.get("coord_precision")
near_km = runtime_info.get("zoom_near_km")
launch_browser = bool(runtime_info.get("launch_browser", True))
cache_retention_min = runtime_info.get("cache_retention_min")
if not isinstance(cache_retention_min, int):
cache_retention_min = 0
geoinfo_enabled = bool(runtime_info.get("geoinfo_enabled", False))
geo_provider = str(runtime_info.get("geo_provider") or "-")
geo_database_date = str(runtime_info.get("geo_database_date") or "-")
provider_label = {
"maxmind": "MaxMind GeoLite2",
"dbip": "DB-IP Lite",
"none": "None",
}.get(geo_provider, geo_provider)
myloc_mode_val = runtime_info.get("myloc_mode")
myloc_mode = myloc_mode_val if isinstance(myloc_mode_val, str) else "OFF"
my_location = runtime_info.get("my_location")
public_ip_cached = runtime_info.get("public_ip_cached")
public_ip_cached = (
public_ip_cached if isinstance(public_ip_cached, str) and public_ip_cached else None
)
auto_geo_cached = runtime_info.get("auto_geo_cached")
auto_geo = auto_geo_cached if isinstance(auto_geo_cached, dict) else {}
os_text = runtime_info.get("os") if isinstance(runtime_info.get("os"), str) else "-"
py_text = runtime_info.get("python") if isinstance(runtime_info.get("python"), str) else "-"
net_backend_val = runtime_info.get("net_backend")
net_backend = net_backend_val if isinstance(net_backend_val, str) else "-"
net_backend_version_val = runtime_info.get("net_backend_version")
net_backend_version = (
net_backend_version_val if isinstance(net_backend_version_val, str) else "-"
)
is_docker = bool(runtime_info.get("is_docker", False))
notification_learning_days = runtime_info.get("notification_learning_days")
desktop_notifications_available = bool(
runtime_info.get("desktop_notifications_available", False)
)
mqtt_configured = bool(runtime_info.get("mqtt_configured", False))
mqtt_host = runtime_info.get("mqtt_host")
mqtt_port = runtime_info.get("mqtt_port")
mqtt_topic = runtime_info.get("mqtt_topic")
mqtt_tls = runtime_info.get("mqtt_tls")
dash_version = str(runtime_info.get("dash_version") or "-")
tapmap_rows: list[tuple[str, str]] = [
("Name", app_name),
("Version", app_version),
("Author", app_author),
("Server port", str(server_port) if isinstance(server_port, int) else "-"),
("Poll interval", f"{poll_ms} ms" if isinstance(poll_ms, int) else "-"),
("Coord precision", str(coord_precision) if coord_precision is not None else "-"),
("Near distance", f"{near_km} km" if isinstance(near_km, (int, float)) else "-"),
]
geo_rows: list[tuple[str, str]] = [
("Geolocation", "Enabled" if geoinfo_enabled else "Disabled"),
("Databases", provider_label),
("Database date", geo_database_date if geo_database_date else "-"),
]
location_rows = _build_location_rows(
myloc_mode=myloc_mode,
my_location=my_location,
public_ip_cached=public_ip_cached,
auto_geo=auto_geo,
)
if not desktop_notifications_available:
desktop_notifications_display = "Not available"
elif notifications_enabled:
desktop_notifications_display = "On"
else:
desktop_notifications_display = "Off"
notification_rows: list[tuple[str, str]] = [
(
"Learning period",
f"{notification_learning_days} days"
if isinstance(notification_learning_days, int)
else "-",
),
("Desktop notifications", desktop_notifications_display),
("MQTT configured", "Yes" if mqtt_configured else "No"),
]
if mqtt_configured:
notification_rows.append(
(
"Broker",
f"{mqtt_host}:{mqtt_port}" if mqtt_host and mqtt_port is not None else "-",
)
)
notification_rows.append(("Topic", mqtt_topic if mqtt_topic else "-"))
notification_rows.append(("TLS", "On" if mqtt_tls else "Off"))
runtime_rows: list[tuple[str, str]] = [
("OS", os_text),
("Python", py_text),
("Network backend", net_backend),
("Backend version", net_backend_version),
("Frontend", "Dash"),
("Frontend version", dash_version),
("Server host", server_host),
("Docker", "Yes" if is_docker else "No"),
("Browser launch", "Enabled" if launch_browser else "Disabled"),
(
"Cache retention",
"Until Clear cache"
if cache_retention_min == 0
else f"{cache_retention_min} min",
),
]
return [
html.H1(f"About {app_name}"),
html.P(
"TapMap inspects local socket activity, enriches IP addresses with "
"geolocation, visualizes connections on an interactive map, and "
"builds insights from the most recent 30 days of activity."
),
html.P(
"Historical insights include recurring activity patterns, provider "
"distribution, country activity and generated activity logs."
),
html.P(
"It reads active socket data using a platform-specific backend, "
"local GeoIP databases for geolocation, "
"and Dash with Plotly for visualization."
),
html.P("Runs locally. No telemetry. TapMap does not inspect traffic contents."),
kv_table(tapmap_rows),
html.H2("Command line"),
html.Pre(
"tapmap Start application\n"
"tapmap --help Show options\n"
"tapmap --version Show version\n"
"tapmap --no-browser Do not open the browser automatically\n"
"tapmap --configure-mqtt Configure MQTT notifications"
),
html.H2("Geolocation"),
html.P(
"Geolocation uses locally installed MaxMind GeoLite2 or DB-IP Lite .mmdb databases."
),
kv_table(geo_rows),
html.P(
[
"IP Geolocation by ",
html.A(
"DB-IP",
href="https://db-ip.com",
target="_blank",
rel="noopener noreferrer",
),
]
) if geo_provider == "dbip" else None,
html.P(
[
"This product includes GeoLite Data created by MaxMind, available from ",
html.A(
"https://www.maxmind.com",
href="https://www.maxmind.com",
target="_blank",
rel="noopener noreferrer",
),
".",
]
) if geo_provider == "maxmind" else None,
html.H2("Location"),
kv_table(location_rows),
html.H2("Notifications"),
kv_table(notification_rows),
html.H2("Runtime"),
kv_table(runtime_rows),
html.H2("Project"),
html.P("TapMap is free and open source, "
"developed by Ola Lie at TIP Teknologi i Praksis AS."),
html.Ul(
[
html.Li(
html.A(
"GitHub repository",
href="https://github.com/olalie/tapmap",
target="_blank",
rel="noopener noreferrer",
)
),
html.Li(
html.A(
"Docker Hub image",
href="https://hub.docker.com/r/olalie/tapmap",
target="_blank",
rel="noopener noreferrer",
)
),
html.Li(
html.A(
"Professional services",
href="https://tip.no",
target="_blank",
rel="noopener noreferrer",
)
),
]
),
]
|