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 | def render_about(
*,
app_name: str,
app_version: str,
app_author: str,
snapshot: Any | None = None,
is_docker: bool,
) -> list[Any]:
"""Render About view content.
Read snapshot["app_info"] only and avoid network calls.
"""
app_info: dict[str, Any] = {}
if isinstance(snapshot, dict):
info = snapshot.get("app_info")
if isinstance(info, dict):
app_info = info
server_port = app_info.get("server_port")
poll_ms = app_info.get("poll_interval_ms")
coord_precision = app_info.get("coord_precision")
near_km = app_info.get("zoom_near_km")
geoinfo_enabled = bool(app_info.get("geoinfo_enabled", False))
geo_data_dir_val = app_info.get("geo_data_dir")
geo_data_dir = geo_data_dir_val if isinstance(geo_data_dir_val, str) else ""
myloc_mode_val = app_info.get("myloc_mode")
myloc_mode = myloc_mode_val if isinstance(myloc_mode_val, str) else "OFF"
my_location = app_info.get("my_location")
public_ip_cached = app_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 = app_info.get("auto_geo_cached")
auto_geo = auto_geo_cached if isinstance(auto_geo_cached, dict) else {}
os_text = app_info.get("os") if isinstance(app_info.get("os"), str) else "-"
py_text = app_info.get("python") if isinstance(app_info.get("python"), str) else "-"
net_backend_val = app_info.get("net_backend")
net_backend = net_backend_val if isinstance(net_backend_val, str) else "-"
net_backend_version_val = app_info.get("net_backend_version")
net_backend_version = (
net_backend_version_val if isinstance(net_backend_version_val, str) else "-"
)
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"),
("GeoIP data folder", geo_data_dir if geo_data_dir else "-"),
]
location_rows = _build_location_rows(
myloc_mode=myloc_mode,
my_location=my_location,
public_ip_cached=public_ip_cached,
auto_geo=auto_geo,
)
runtime_rows: list[tuple[str, str]] = [
("OS", os_text),
("Python", py_text),
("Network backend", net_backend),
("Backend version", net_backend_version),
]
return [
html.H1(f"About {app_name}"),
html.P(
"TapMap inspects local socket data, enriches IP addresses "
"with geolocation, and visualizes their locations on an interactive map."
),
html.P(
"It reads active socket data using a platform-specific backend, "
"local MaxMind GeoLite2 databases for geolocation, "
"and Dash with Plotly for visualization."
),
html.P("All processing is local. TapMap does not inspect traffic contents."),
kv_table(tapmap_rows),
html.H2("Geolocation"),
html.P(
"Geolocation is based on local MaxMind GeoLite2 .mmdb databases. "
"The databases are not included."
),
kv_table(geo_rows),
html.Div(
className="mx-path-row",
children=[
html.Pre(geo_data_dir, className="mx-path-box") if geo_data_dir else None,
*(
[]
if is_docker
else [
html.Button(
"Open data folder",
id="btn_open_data",
n_clicks=0,
className="mx-btn mx-btn--primary mx-btn--nowrap",
type="button",
)
]
),
html.Button(
"Recheck GeoIP databases",
id="btn_check_databases",
n_clicks=0,
className="mx-btn mx-btn--primary mx-btn--nowrap",
type="button",
),
],
),
*(
[
html.P(
"Running in Docker. Place the GeoLite2 .mmdb files in the "
"host folder mounted to this path.",
className="mx-note",
)
]
if is_docker
else []
),
html.H2("Location"),
kv_table(location_rows),
html.H2("Runtime"),
kv_table(runtime_rows),
html.H2("Project"),
html.P("TapMap is free and open source."),
html.Ul(
[
html.Li(
html.A(
"Project page on GitHub",
href="https://github.com/olalie/tapmap",
target="_blank",
rel="noopener noreferrer",
)
),
html.Li(
html.A(
"MaxMind GeoLite2 project",
href="https://dev.maxmind.com/geoip/geolite2-free-geolocation-data",
target="_blank",
rel="noopener noreferrer",
)
),
html.Li(
html.A(
"Buy Me a Coffee",
href="https://www.buymeacoffee.com/olalie",
target="_blank",
rel="noopener noreferrer",
)
),
]
),
]
|