Skip to content

src.tapmap.ui.about_view

src.tapmap.ui.about_view

About view rendering for the TapMap UI.

Build the About modal content from application metadata and cached runtime information.

kv_table(rows)

Build a two column key/value table with tooltips.

Source code in src/tapmap/ui/tables.py
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
def kv_table(rows: Iterable[tuple[str, str]]) -> html.Table:
    """Build a two column key/value table with tooltips."""
    body: list[Any] = []
    for key, value in rows:
        v = "" if value is None else str(value)
        body.append(
            html.Tr(
                [
                    html.Td(key),
                    html.Td(html.Span(v, title=v if v else None)),
                ]
            )
        )

    colgroup = html.Colgroup(
        [
            html.Col(style={"width": "180px"}),
            html.Col(),
        ]
    )

    return html.Table(
        className="mx-table mx-info-table",
        children=[colgroup, html.Tbody(body)],
    )

render_about(*, app_name, app_version, app_author, snapshot=None, is_docker)

Render About view content.

Read snapshot["app_info"] only and avoid network calls.

Source code in src/tapmap/ui/about_view.py
 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
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_host_val = app_info.get("server_host")
    server_host = server_host_val if isinstance(server_host_val, str) else "-"
    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_provider = str(app_info.get("geo_provider") or "-")
    geo_database_date = str(app_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 = 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"),
        ("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,
    )

    runtime_rows: list[tuple[str, str]] = [
        ("OS", os_text),
        ("Python", py_text),
        ("Network backend", net_backend),
        ("Backend version", net_backend_version),
        ("Server host", server_host),
        ("Docker", "Yes" if is_docker else "No"),
    ]

    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"
        ),
        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("Runtime"),
        kv_table(runtime_rows),
        html.H2("Project"),
        html.P(
            "TapMap is free, open source, and available on GitHub and Docker Hub."
        ),
        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(
                        "Buy Me a Coffee",
                        href="https://www.buymeacoffee.com/olalie",
                        target="_blank",
                        rel="noopener noreferrer",
                    )
                ),
            ]
        ),
    ]

_build_location_rows(*, myloc_mode, my_location, public_ip_cached, auto_geo)

Build Location section rows for MY_LOCATION mode.

Source code in src/tapmap/ui/about_view.py
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
def _build_location_rows(
    *,
    myloc_mode: str,
    my_location: Any,
    public_ip_cached: str | None,
    auto_geo: dict[str, Any],
) -> list[tuple[str, str]]:
    """Build Location section rows for MY_LOCATION mode."""
    if myloc_mode == "OFF":
        return [("MY_LOCATION", "none (local marker hidden)")]

    if myloc_mode == "FIXED":
        if isinstance(my_location, (list, tuple)) and len(my_location) == 2:
            lon, lat = my_location[0], my_location[1]
            return [("MY_LOCATION", _fmt_coord(lon, lat))]
        return [("MY_LOCATION", "fixed (invalid value)")]

    if myloc_mode == "ENV":
        if isinstance(my_location, (list, tuple)) and len(my_location) == 2:
            lon, lat = my_location[0], my_location[1]
            return [
                ("MY_LOCATION", "env override"),
                ("Coordinate", _fmt_coord(lon, lat)),
            ]
        return [("MY_LOCATION", "env override")]

    rows: list[tuple[str, str]] = [("MY_LOCATION", "auto")]
    rows.append(("Public IP", public_ip_cached or "-"))

    if myloc_mode == "AUTO":
        place = _fmt_place(auto_geo.get("city"), auto_geo.get("country"))
        coord = _fmt_coord(auto_geo.get("lon"), auto_geo.get("lat"))
        rows.append(("AUTO place", place))
        rows.append(("AUTO coordinate", coord))
        return rows

    rows.append(("AUTO geo", "not available"))
    return rows

_fmt_coord(lon, lat)

Format lon/lat coordinates for UI display.

Source code in src/tapmap/ui/about_view.py
236
237
238
239
240
def _fmt_coord(lon: Any, lat: Any) -> str:
    """Format lon/lat coordinates for UI display."""
    if isinstance(lon, (int, float)) and isinstance(lat, (int, float)):
        return f"{float(lon)}, {float(lat)}"
    return "-"

_fmt_place(city, country)

Format city/country place for UI display.

Source code in src/tapmap/ui/about_view.py
243
244
245
246
247
248
249
250
251
def _fmt_place(city: Any, country: Any) -> str:
    """Format city/country place for UI display."""
    c = city.strip() if isinstance(city, str) else ""
    k = country.strip() if isinstance(country, str) else ""
    if c and k:
        return f"{c}, {k}"
    if k:
        return k
    return "-"