{% extends "base.html" %} {% block title %}GeoIP 地图 - Squid Manager{% endblock %} {% block head %} {% endblock %} {% block content %}

📡 数据来源

本页地理位置查询使用 {{ data_source }}。 {% if use_online %} 默认走 ip-api.com 免费公共 API (45 req/min,无需 key)。 如果你需要更稳定/更高速的查询,可以下载 MaxMind GeoLite2-City.mmdb 文件并通过 AppConfig(geoip_mmdb) 配置离线路径。 {% else %} 已配置离线数据库 {{ db_path }},优先使用本地查询,不再发送外网请求。 {% endif %}

私有 IP (10.x / 192.168.x / 172.16-31.x / 127.x) 不会发出查询请求,直接在表里标记为「私有 IP」, 不会出现在地图上。本页默认仅展示 Top 20 客户端;需要更广范围的数据请用 /api/geoip/clients (Top 50) 与 /api/geoip/hosts (目标主机) 接口。

客户端总数
{{ total_clients }}
Top {{ total_clients }} 客户端
已解析位置
{{ resolved_clients }}
{{ '%.0f' % (resolved_clients / total_clients * 100) if total_clients else 0 }}% 命中率
国家数
{{ countries }}
按 ISO 国家码统计
城市数
{{ cities }}
(国家, 城市) 去重

🗺️ Top 客户端位置

{% if geo_rows %}

地图标签基于 OpenStreetMap 瓦片;点位大小近似与该客户端的请求数成正比。 私有地址不会出现在地图上,可参考下方表格。

{% else %}
🗺️

没有可显示的客户端位置

{% if total_clients == 0 %}

当前解析日志中没有客户端 IP。请确认 access.log 路径与权限。

{% else %}

Top {{ total_clients }} 个客户端均为私有地址,或 ip-api.com 暂时不可达。 详见下方的状态表。

{% endif %}
{% endif %}

📋 客户端明细

{% if rows %} {% for r in rows %} {% endfor %}
# 客户端 IP 国家 城市 ISP/ASN 请求数 流量 状态
{{ loop.index }} {{ r.ip }} {% if r.country_name %} {{ r.country_name }} {% if r.country %}{{ r.country }}{% endif %} {% else %} - {% endif %} {{ r.city or '-' }} {% if r.region %}{{ r.region }}{% endif %} {{ r.isp or '-' }} {% if r.asn %}
{{ r.asn }}{% endif %}
{{ '{:,}'.format(r.count) }} {{ format_bytes(r.bytes) }} {% if not r.error %} 已解析 {% elif r.error == 'private IP' %} 私有 IP {% else %} ⚠ 查询失败 {% endif %}
{% else %}

暂无客户端数据。

{% endif %}

🔌 JSON 接口

同样数据以 JSON 形式提供,便于脚本与外部仪表盘接入:

路径说明返回
GET /api/geoip/clients Top 50 客户端 IP + GeoIP {ok, source:"clients", backend, rows:[…]}
GET /api/geoip/hosts Top 50 目标主机 (先解析为 IP 再查询) {ok, source:"hosts", backend, rows, placed, skipped}
GET /geoip 本页 (Top 20) HTML
{% endblock %} {% block scripts %} {% if geo_rows %} {% else %} {% endif %} {% endblock %}