178 Commits

Author SHA1 Message Date
TianXuan Developer c49475d207 refactor: per-edge continuous lifecycle rendering
后端:
- traffic_timeline_view: 返回edges[{first_ts,last_ts}]替代windows
- datetime.strptime + .timestamp()保留微秒精度

前端:
- 完全移除窗口概念, edge._fs/_ls定义生命周期
- 时间桶索引(O(1)查找可见边)
- 生命周期<5s自动扩展±30s
- 5%软边缘淡入淡出
- 每帧仅检查当前时间桶±1的边(性能优化)
- 最大渲染500条(按count排序)

验证: 500条边, ~127K像素, 206活跃节点, 边持久可见

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 16:07:18 +08:00
TianXuan Developer 490f37d8fc feat: crossfade窗口过渡,末尾20%淡出旧边淡入新边
getWindowMix: 返回crossfade(0→1), window末尾20%线性过渡
renderTrafficCrossfade: 两窗口边集按(1-cf)/cf透明度混合
- 同边去重(取max alpha)避免闪烁
- 粒子透明度跟随窗口混合
- 节点活跃=两窗口并集

验证: cf=0→20条(单窗口), cf=0.45→40条(双窗口混合)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 15:35:47 +08:00
TianXuan Developer e2349f951d fix: canvas用position:fixed+getBoundingClientRect精准定位map
根因: canvas inside #saMap时Leaflet内部div覆盖遮挡
修复: canvas→document.body, position:fixed,
每帧getBoundingClientRect()计算left/top对准map

验证: map(256,396) canvas(256,396) 完美重合,
动画: win 0→1, t 0.59→0.89→0.19

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 15:13:49 +08:00
TianXuan Developer 51c0d5ad53 fix: canvas移到map容器外(同级节点)避免overflow:hidden裁剪
canvas作为mapContainer的sibling插入到map之后,
z-index:99999确保在所有Leaflet图层之上

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 14:50:16 +08:00
TianXuan Developer 45034813ad fix: 每帧仅显示当前窗口边,不再混合两窗口
放弃交叉淡入淡出(两条边透明度叠加难以区分),
改为仅显示当前窗口的边(t<0.5→w0, t>=0.5→w1),
不同窗口不同边集一目了然。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 14:48:54 +08:00
TianXuan Developer bca6929838 fix: w阈值0.03实际过滤+前后窗口平滑入口/出口
- w<=0永不触发→改为w<0.03实际过滤
- 添加wins[i+2]平滑进入(t-0.85阈值)
- 添加wins[i-1]平滑退出(0.15-t阈值)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 14:44:36 +08:00
TianXuan Developer 7872e729cb fix: 交叉淡入淡出可见—权重范围扩大到8%-100%
- alpha: 0.08+0.92*weight (之前0.4+0.6导致不活跃边仍40%可见)
- weight<0.05直接跳过(不可见)
- 不再Math.max累积权重(每帧重新计算)

效果: t=0时w0边~100%可见+w1边~8%几乎不可见, 真正的淡入淡出

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 14:43:33 +08:00
TianXuan Developer 32586d3ed4 fix: 移除Canvas像素缓存—每帧实时latLngToContainerPoint
根因: _trafficEdgeCache缓存旧像素位置,地图拖动/缩放后不更新
修复:
- 完全移除像素缓存,每帧重新计算latLngToContainerPoint
- Canvas为#saMap子元素,绝对定位,跟随容器
- 移除moveend缓存清除逻辑(不再需要)

效果: 地图平移/缩放时流量边自动跟随,不再是'贴片'

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 10:56:23 +08:00
TianXuan Developer 6c7fbb28b1 fix: moveend即时重绘+缓存清除,canvas跟随地图平移
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 10:52:54 +08:00
TianXuan Developer 8fbf5be897 feat: 粒子源-目标颜色区分+流速按流量比例
- 边轨迹: linearGradient src青绿→dst红色
- 粒子: src青绿(#2ec4b6)→dst红色(#e63946)渐变
- 粒子速度: speedMul=0.5+1.5*ratio, 高流量边粒子更快
- 粒子数量: 3+6*ratio, 高流量边更多粒子
- 发光增强: shadowBlur=5, opacity=0.6+0.4*weight

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 10:36:40 +08:00
TianXuan Developer 0c75d986c2 fix: 地图拖动/缩放时流量边实时跟随
- moveend事件清空边坐标缓存+立即重绘
- 不每帧重复绑定handler

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 10:35:04 +08:00
TianXuan Developer b2b3fca9f2 fix: 恢复Canvas贝塞尔曲线+粒子,保留窗口分裂和交叉淡入淡出
合成两个方案的优点:
- Canvas贝塞尔曲线+蓝红渐变粒子(Date.now连续流动)
- 窗口分裂(单独窗口15→每组~20边)
- 交叉淡入淡出(透明度0.4-1.0)
- 边坐标缓存(地图moveend失效)
- 节点活跃/非活跃高亮/变暗

验证: win 0→1, t 0.58→0.79, pixels 54-61K, 节点16→17

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 10:14:16 +08:00
TianXuan Developer 8ef76f90d0 fix: 使用L.svg渲染器避免preferCanvas冲突
Leaflet map使用preferCanvas:true时,所有polyline经canvas渲染,
dashOffset动画可能不生效。为流量层显式指定L.svg()渲染器。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 10:05:36 +08:00
TianXuan Developer b04ca5cca9 fix: 改用Leaflet原生虚线+动画dashOffset, 100%可见
彻底放弃canvas粒子方案,改用Leaflet L.polyline + dashArray:
- 每条活跃边=1条虚线(dash=15,gap=25)
- dashOffset持续动画(0.3px/帧),产生流动效果
- 交叉淡入淡出: 透明度0.4-1.0 + 宽度1.5-5.5px
- removeLayer旧边,addTo新边,平滑过渡
- 零z-index问题,Leaflet原生渲染

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 10:04:33 +08:00
TianXuan Developer bbecd4a4f1 fix: 更小窗口组(15-20边)+颜色偏移(hue)让过渡更明显
- 窗口拆分更细: ~20条/组,最大15个窗口
- 颜色随窗口组偏移hue(15°/组),视觉变化明显
- 去重: 同一边不会在多个窗口重复出现
- 透明度范围扩大(0.4-1.0)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 10:00:53 +08:00
TianXuan Developer 5170c262e1 fix: 稀疏数据自动分裂为多窗口,交叉淡入淡出可见
根因: 数据仅1个真实窗口,所有边同时活跃,无变化
修复: loadTrafficData检测windows≤2时,将边按count排序
后分割为~40条/组,每组一个虚拟窗口(间隔10s)
效果: 300条边→8个窗口,每窗口不同边集,交叉淡入淡出可见

验证: 窗口0(40边)↔窗口1(40边),i=0→i=1,t平滑变化
Playwright: 0 JS错误

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:57:42 +08:00
TianXuan Developer 66b35eb207 refactor: smooth crossfade transition for traffic timeline, fix animation freeze, reduce memory
完全重写动态流通动画:
- Crossfade: 相邻窗口边通过透明度渐变(1-t↔t)平滑过渡
- getWindowMix: 计算当前窗口索引+混合因子t
- 边去重: 同一边在两窗口间连续存在不闪烁
- 时间确保持续推进,循环播放
- 边坐标缓存(地图移动时失效),减少latLngToContainerPoint调用
- 粒子基于Date.now()连续运动,不受窗口切换影响
- 节点活跃状态按两窗口并集+权重
- 移除旧的phase band/edgeMap/particle pool/_spawnTimers

验证: 上传→聚类→地图→流量面板→时间推进→实体流量图表,0 JS错误

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:53:17 +08:00
TianXuan Developer 55b1d0a7a2 fix: canvas回map内+position:relative避免错位
_ensureFlowLayer: canvas作为#saMap子元素,
position:absolute;top:0;left:0, resize事件同步尺寸
不再需要在map外部计算偏移

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:24:45 +08:00
TianXuan Developer 8bd1ff7ccf fix: 修复重复声明_trafficCanvasCtx导致上传失效
let _trafficCanvasCtx在旧代码(2576行)和新flow层(2759行)各声明一次,
导致'Identifier has already been declared'错误,
handleFiles等后续函数均未定义,上传完全失效

删除旧声明,保留flow层中的声明

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:19:17 +08:00
TianXuan Developer 7a597a3f9f fix: Canvas粒子流动——插入到map容器外部确保在最上层渲染
关键修复: canvas直接插入到map容器parent,绝对定位覆盖地图,
不再受Leaflet内部图层堆叠影响。
粒子沿贝塞尔曲线流动,颜色从蓝渐变到红(3-8个/边)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:15:20 +08:00
TianXuan Developer 91fb072f9f feat: 流量动画改用Leaflet原生dashArray虚线流动
Canvas粒子方案在Leaflet层面存在图层遮挡问题。
改为Leaflet原生L.polyline + dashArray + dashOffset动画:
- 每条活跃边绘制虚线 polyline (dash/gap按流量比例)
- requestAnimationFrame 持续偏移 dashOffset
- 产生'蚂蚁行军'流动效果, 100%可见
- 不透明度0.85, 线宽2-7px, HSL颜色渐变

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:14:28 +08:00
TianXuan Developer 569c7411b8 fix: canvas插入到Leaflet tilePane之后,确保在最上层渲染
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:12:14 +08:00
TianXuan Developer 5da0f2bf90 chore: remove test screenshots 2026-07-25 09:11:27 +08:00
TianXuan Developer 56007c2122 fix: 增强边缘线可见度——移除200条限制,提高不透明度(0.5-1.0),加粗(2-7px)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:11:02 +08:00
TianXuan Developer 613f7d2d50 fix: 增强粒子视觉效果——发光粒子+加粗边缘+更高不透明度
- 粒子尺寸3-7px, 红色发光(shadowBlur=6)
- 边缘线加粗到1.5-5.5px, 不透明度0.3-0.8
- 粒子生成率提高(4/边/生命周期)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:09:28 +08:00
TianXuan Developer bcf447db37 fix: 修复动画始终重复第一帧——边按phase分批轮流活跃
根因: 数据min_ts==max_ts(所有时间戳同一秒),时间无法推进
修复:
- 数据加载时给每条边分配phase(0→1),按相位分布
- 活跃带(bandWidth=0.3)随progress扫过相位空间
- 单窗口数据自动扩展为60s虚拟跨度
- trafficSeek/Step统一使用_data._minTs/_maxTs

效果: 400+粒子持续流动,活跃边随进度轮换,
      ~30%边同时活跃,时间平滑推进

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-25 09:08:21 +08:00
TianXuan Developer 74455a03b9 feat: 流量动画重构为连续粒子系统
替换逐帧窗口切换为连续时间轴粒子动画:
- 时间连续推进(requestAnimationFrame + speed倍率)
- 粒子从源节点沿贝塞尔曲线流向目标,自动生成/过期
- 条边淡淡轨迹 + 运动光点,大小/透明度反映流量
- 时间滑块平滑映射到完整时间范围
- 活跃窗口自适应扩展(data稀疏时保持边可见)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 23:28:28 +08:00
TianXuan Developer f17ba2255a fix: 流量动画Canvas贝塞尔曲线渲染修复
根因: Canvas不在map容器内,缺少position:relative;z-index不够高
修复:
- _ensureTrafficCanvas动态创建canvas为#saMap子元素
- 添加position:relative到#saMap容器
- z-index提升到99999确保在Leaflet画布之上
- requestAnimationFrame替代setTimeout实现平滑粒子动画
- 面板关闭/trafficStop时清理canvas和恢复节点样式
- 粒子位置用Date.now()计算实现连续运动

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 23:01:17 +08:00
TianXuan Developer b02258330b fix: 修复上传按钮消失 + 移动流量面板HTML至script外
根因: 上一提交将traffic panel HTML放在</script>之前,
导致HTML被解析为JS代码,引发'Unexpected token <'错误,
handleFiles等函数未定义,上传功能完全失效

修复: 将traffic panel HTML移至</script>之后,{% endblock %}之前

验证: 14/14 Playwright测试通过 (上传/筛选/聚类/地图/边/节点/流量面板/社区焦点)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 22:46:11 +08:00
TianXuan Developer 82e3cd26ee feat: add global and per-entity dynamic traffic flow animation
- backend: traffic_timeline_view + entity_traffic_timeline_view
  time-window aggregation (10s/30s/1min/5min/10min)
  Beijing time (UTC+8), per-edge count/bytes, node activity
- frontend: global traffic panel with play/pause/speed controls
  canvas overlay for curved edge flow particles + node dimming
  entity traffic view with 24h distribution + in/out chart.js
- routes: /simple/traffic-timeline/ + /simple/traffic-timeline/entity/

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 22:35:46 +08:00
TianXuan Developer eb5758b77b fix: 社区点击自动跳转步骤4 + 边显示 + 区分节点样式
修复:
- loadClusterDetail: 无map时自动goStep(4)并等待初始化
- focusClusterOnMap: 边已正确添加到_clusterFocusLayer
- renderMapData: 集群聚焦时保留_clusterFocusLayer
- 节点样式按度数区分: 高流量(>20对端)大圆深色, 孤立节点小圆浅色
- 节点提示显示对端数和服务器标签
- clearClusterFocus简化,去除无用_clusterNodeLayer

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 20:59:55 +08:00
TianXuan Developer cd68d7c9af fix: gen_multi2 使用真实公网IP,GeoIP可解析
根因: 服务器IP(203.0.113.x等RFC5737)和代理IP(10.0.x.x私有)无法被GeoIP解析
→ 500条边仅2条两端有坐标 → 图上不显示

修复:
- 服务器IP: 替换为 Akamai/Cloudflare/Google/AWS/Microsoft 公网IP
- 代理IP: 替换为 1.1.1.1/8.8.8.8 等已知DNS公网IP
- 移除硬编码SERVER_GEO,依赖MMDB自动解析

结果: 710/718节点有坐标, 496/500边两端可渲染 → 300条边显示

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 20:38:59 +08:00
TianXuan Developer 0a3c0a6eb3 fix: 修复gen_multi2过滤后无边的问题
根因: gen_test_data 第135行 cert_cn 生成有bug
  f'*.{random.choice(SERVICES).split(".")[-2:]}'
  → 产生 "*.['example', 'com']" 垃圾cnam
  → 过滤匹配不到任何有效IP
  → 所有节点度=1,无边

修复: 检测并清除垃圾cnam/snam模式,仅保留有效值

测试结果(筛选cnam=api.example.com):
  节点718, 边500, 最大度201, 平均度18.5
  服务器入度: 152-201

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 20:30:15 +08:00
TianXuan Developer d6687e8aa0 fix: gen_multi2 完全继承 gen_test_data 格式 + 拓扑约束
- 复用 generate_row() 保证所有列格式/覆盖率/空值率一致
- 重映射: snam/cnam 有值时 → :ipd 指向1-3个固定服务器IP
- 同步更新 GeoIP 字段匹配服务器位置
- 200文件 × 10000行 = 200万行
- 代理出度60K+, 服务器入度50K-202K

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 20:17:23 +08:00
TianXuan Developer 005a6b82bb fix: 重写gen_multi2, 继承gen_test_data精确格式
- 复用 generate_row() 保证列格式/覆盖率/空值率完全一致
- 覆盖IP和服务字段为拓扑感知值
- cnam→1-3固定服务器IP, snam同理
- 代理出度870-1005, 服务器入度1615-2100
- 200文件×~100行, 列顺序/删减同gen_multi

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 20:08:49 +08:00
TianXuan Developer b33845e9a2 chore: gitignore data/gen_multi2/ 2026-07-24 19:57:10 +08:00
TianXuan Developer a4cd8cdf1d feat: 真实网络拓扑测试数据生成器
gen_multi2.py:
- 服务器节点: 13个, 入度350-1700 (CDN/API/Mail/Auth等)
- 代理节点: 5个, 出度700+
- 客户端节点: 144个, 出度100-130
- cnam/snam 映射到特定服务器IP (1-3个)
- 12个地理区域, 匹配GeoIP坐标
- 输出: data/gen_multi2/ (200文件, 18148行)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 19:56:33 +08:00
TianXuan Developer 829729943c feat: 社区交互增强 + 卫星地图 + 节点/边数据丰富 + 项目清理
核心改进:
- 节点数据丰富: TLS版本/加密套件/SNI/端口/流量统计/连接成功率
- 边数据丰富: 包数/持续时间/TLS/端口/SNI/分类标签
- 新增 edge_time_series 端点: 边流量时序图(北京时间)
- 新增 cluster_nodes_edges 端点: 社区聚焦(zoom+高亮+专属边)
- 社区点击: 自动缩放/高亮节点/显示社区边(可点击)
- 边交互修复: 事件从layerGroup移至hitPoly,三处边渲染全修复
- 地图升级: ESRI卫星影像 + 255国矢量边界叠加
- 离线回退: 卫星→CartoDB→暗色矢量地图,完整可用
- 节点面板: 删除无意义社区标签,移至Host+组织同行
- sanitizeName: 清理5个非ASCII国家名避免乱码
- .gitignore: 补充geoip_chunks/和嵌套CSV规则

项目清理:
- 删除 logs/ (20个调试文件,~2.5MB)
- 删除 test_*.py (4个临时测试脚本)
- 删除 _check_bool/_pipeline_test/_restart_server/start_server (硬编码路径)
- 删除 node_modules/package.json/package-lock.json (18MB,不用Node)
- 删除 tests/ 旧日志和调试脚本
- 删除 .pytest_cache/ .server_pid.txt RUNTIME_CHANGED.txt
- AGENTS.md → CLAUDE.md

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 13:06:14 +08:00
PM-pinou a56a06c940 chore: gitignore large binary files (GeoIP chunks, mmdb, test CSVs) 2026-07-24 11:21:34 +08:00
TianXuan Developer 8ba99292b7 fix: MMDB中文路径解决方案 + 聚类优先使用最新GeoIP数据
- geoip.py: maxminddb C库不支持Windows中文路径,复制MMDB到ASCII临时目录
- views.py: _cluster_network 优先用 geoip_lookup()(MMDB) 而非上传时缓存(text)
- 效果: IP地理坐标从 ~55城市粗定位 → 全球百万级精确城市定位

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-23 23:59:27 +08:00
TianXuan Developer 2e93bcad2e chore: gitignore 忽略生成的 .mmdb 和 .mmdb.gz 文件 2026-07-23 23:51:49 +08:00
TianXuan Developer 4b8963a834 feat: GeoIP City分块 partaf 2026-07-23 23:49:04 +08:00
TianXuan Developer bb16219739 feat: GeoIP City分块 partae 2026-07-23 23:47:50 +08:00
TianXuan Developer 4c8cb6d187 feat: GeoIP City分块 partad 2026-07-23 23:47:24 +08:00
TianXuan Developer 4936bd72ae feat: GeoIP City分块 partac 2026-07-23 23:46:52 +08:00
TianXuan Developer f2120175af feat: GeoIP City分块 partab 2026-07-23 23:46:29 +08:00
TianXuan Developer 45429ef6f3 feat: GeoIP分块 — ASN(5MB) + City首尾块(9MB+6MB) 2026-07-23 23:45:28 +08:00
TianXuan Developer e0a7400bd7 feat: 高精度离线GeoIP — MMDB支持 + 中文路径修复 + 分块自解压
- geoip.py: 修复中文路径 str()→Path 编码问题 (maxminddb Latin-1 bug)
- geoip.py: 启动自动重组geoip_chunks分块 + gunzip解压
- scripts/setup_geoip.py: 手动重组/解压脚本
- .gitignore: 忽略解压后的 .mmdb 文件

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-23 23:42:38 +08:00
TianXuan Developer 0f84497c82 fix: 边线点击优化 — 双层线结构 + hover 高亮
- 每条边由底层粗透明线(12px)和上层可见线组成
- 粗透明线捕获点击,命中区域扩大10倍以上
- 线宽 2-6px(按通信频次),不透明度 0.45-0.80
- hover 时高亮:加粗+亮红+不透明
- tooltip 提示点击查看详情
- highlightNodeEdges 同步使用双层线

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-23 23:20:26 +08:00
TianXuan Developer 2f7173637a fix: 静态资源路径改用 Django {% static %} 模板变量,确保离线部署兼容 2026-07-23 23:17:59 +08:00