Files
squid-manager/templates/logs_live.html
T
Hermes Agent 4a1d949e41 feat: 完整 Squid Web Manager 平台 - P0-P3 全功能
完整 Web 管理平台,涵盖:

P0 生产加固:
- 会话超时(空闲+绝对) + CSRF 防护 + 登录失败限流
- HTTPS/TLS 证书管理(自签生成/上传/删除/过期提醒)
- SSL Bump (HTTPS 透明代理) 可视化配置
- 配置文件 diff 预览 + 二次确认才写入
- 服务控制二次确认 + 操作期间按钮锁定

P1 运维能力:
- 日志轮转管理(logrotate) + 日志状态监控
- 告警规则(5xx/命中率/磁盘/客户端流量)
- 多 Squid 实例管理 + 一键切换
- squidclient mgr 实时性能指标
- 流量异常检测(突增/大文件/高频小包/新客户端)

P2 日志分析增强:
- 日志持久化到 SQLite + 历史时间范围查询
- 导出 CSV/JSON(日志/KPI/异常/审计)
- GeoIP 地图(Leaflet + ip-api.com 离线可选 GeoLite2)
- 每客户端 24h 趋势图
- 自定义 Squid logformat 解析器

P3 体验锦上添花:
- 暗/亮主题切换(cookie 持久化)
- WebSSH 终端(xterm.js + paramiko)
- 完整审计日志 + 用户管理

技术栈: Flask 3.0 + SQLAlchemy 2.0 + SQLite + Chart.js + Leaflet
总代码量: ~16500 行 (15 Python 模块 + 34 模板 + CSS)
路由数: 73
2026-07-15 10:19:21 +08:00

61 lines
2.2 KiB
HTML

{% extends "base.html" %}
{% block title %}实时日志 - Squid Manager{% endblock %}
{% block head %}
<meta http-equiv="refresh" content="{{ cfg.auto_refresh_seconds }}">
{% endblock %}
{% block content %}
<div class="page-header">
<h1>⚡ 实时日志 (Live Tail)</h1>
<div class="page-actions">
<span class="meta-text">显示最近 {{ n }} 条 · 每 {{ cfg.auto_refresh_seconds }} 秒自动刷新</span>
<a href="{{ url_for('config_paths') }}" class="btn btn-small btn-secondary">⚙️ 调整</a>
<button onclick="location.reload()" class="btn btn-small btn-primary">🔄 立即刷新</button>
</div>
</div>
<div class="card">
{% if entries %}
<div class="table-scroll">
<table class="data-table log-table">
<thead>
<tr>
<th>时间</th>
<th>客户端</th>
<th>结果码</th>
<th>HTTP</th>
<th>方法</th>
<th>大小</th>
<th>耗时</th>
<th>URL</th>
<th>层级</th>
</tr>
</thead>
<tbody>
{% for e in entries %}
<tr>
<td class="time-cell">{{ e.timestamp.strftime('%H:%M:%S') if e.timestamp else e.time }}</td>
<td>{{ e.client }}</td>
<td>
<span class="badge badge-{% if e.category == 'Hit' %}green{% elif e.category == 'Miss' %}blue{% elif e.category == 'Tunnel' %}cyan{% elif e.category == 'Denied' %}red{% elif e.category == 'Aborted' %}orange{% elif e.category == 'Error' %}red{% else %}gray{% endif %}">{{ e.result_code }}</span>
</td>
<td><span class="badge badge-gray">{{ e.http_code or '-' }}</span></td>
<td>{{ e.method }}</td>
<td>{{ format_bytes(e.size) }}</td>
<td>{{ format_duration(e.elapsed_ms) }}</td>
<td class="url-cell" title="{{ e.url }}">{{ e.url }}</td>
<td><code>{{ e.hier_code }}</code></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="card-empty">
<div class="empty-icon">📭</div>
<p>暂无日志数据。请确认访问日志路径正确:
<code>{{ cfg.access_log_path }}</code></p>
</div>
{% endif %}
</div>
{% endblock %}