impl Web UI (dashboard) #2

Merged
KNEMC merged 11 commits from SerinaNya/KLALB:patch-2 into master 2026-08-26 19:57:29 +08:00
Contributor
  • 前端代码通过 git submodule 的形式引入
  • 新增 KLALBWebServer 支持 REST API、200ms SSE 实时事件流与 SPA 静态托管
  • 引入 enableTUN 开关配置,解耦 TUNName 与禁用状态判定
  • 重构 LineTable/ConnectLineTableopenConnections/autoConnections
  • 重命名查询与广播安全开关字段为 denyConnectionQuery/Broadcast,保持双向向后兼容
  • 支持通过 Web API 热更新控制器配置并自动持久化写回 klalb-config.json
  • 调整默认 Web API 端口为 4665,更新 dashboard 模块引用
  • KLALBWebServer.java — fix gson-2.1 members 序列化 bug
- 前端代码通过 git submodule 的形式引入 - 新增 `KLALBWebServer `支持 REST API、200ms SSE 实时事件流与 SPA 静态托管 - 引入 `enableTUN` 开关配置,解耦 `TUNName `与禁用状态判定 - 重构 `LineTable`/`ConnectLineTable` 为 `openConnections`/`autoConnections` - 重命名查询与广播安全开关字段为 denyConnectionQuery/Broadcast,保持双向向后兼容 - 支持通过 Web API 热更新控制器配置并自动持久化写回 `klalb-config.json` - 调整默认 Web API 端口为 `4665`,更新 dashboard 模块引用 - `KLALBWebServer.java` — fix gson-2.1 `members` 序列化 bug
SerinaNya added 6 commits 2026-08-23 17:46:57 +08:00
- 设置页新增设备名称(单行)、设备描述(多行)、额外路由(CIDR列表)设置项
- RouterInfo 广播携带 deviceName,并在拓扑图节点与节点概览中展示;deviceDescription 保持本地概览显示
- 拓扑图节点标签支持多行文本绘制
- 节点概览面板新增 IP 地址及设备详情展示
- 支持将 TUNName 设为 null/"null"/空字符串时完全跳过 Wintun 虚拟网卡创建
- .classpath 容器改为标准 JavaSE-25 执行环境以同时兼容 JDK 25 与 26
- 新增 AGENTS.md 与 VS Code 调试及运行配置

BREAKING CHANGE: RouterInfo 在序列化末尾追加了 deviceName 字段(writeUTF),新旧版本节点混连时路由协议解析异常,需同步升级
SerinaNya added 1 commit 2026-08-24 00:01:27 +08:00
- Add embedded KLALBWebServer with REST API, SSE streaming (200ms) and SPA hosting
- Introduce enableTUN configuration flag with fallback and non-admin execution support
- Refactor LineTable and ConnectLineTable to openConnections and autoConnections
- Rename denyLineTableQuery/Broadcast to denyConnectionQuery/Broadcast with backwards compatibility
- Support runtime config hot-reloading and automatic persistence to klalb-config.json
- Update default Web API port to 4665 and update dashboard submodule reference
Author
Contributor

Caution

BREAKING CHANGES
klalb-config.json 键名有更新,升级时需适配

> [!CAUTION] > **BREAKING CHANGES** > `klalb-config.json` 键名有更新,升级时需适配
SerinaNya requested review from KNEMC 2026-08-24 00:04:19 +08:00
SerinaNya added 1 commit 2026-08-24 00:13:36 +08:00
SerinaNya changed title from WIP: Web UI (dashboard) to WIP: impl Web UI (dashboard) 2026-08-24 00:14:46 +08:00
SerinaNya added 1 commit 2026-08-24 23:59:17 +08:00
- sendJsonResponse now serializes JsonElement via toString(), since gson-2.1's
  JSON_ELEMENT factory misses JsonObject/JsonArray subclasses and falls back to
  reflection (leaking the internal "members" field into every REST response)
- Document javac full-path requirement, pre-existing compile warnings,
  frontend page data flow, and gson quirks in AGENTS.md
SerinaNya added 1 commit 2026-08-26 00:23:24 +08:00
- routing-protocol JSON API: nodeinfotinyreq/resp returns device name
  only and is never gated; nodeinfofullreq/resp returns external
  endpoints + device name + description, where denyExternalEndpointQuery
  hides only the endpoint list (name/description always answer);
  legacy openlines* wire types removed - upgrade the whole mesh together
- rename misnamed openConnections -> externalEndpoints and
  denyConnection{Query,Broadcast} -> denyExternalEndpoint{Query,Broadcast};
  legacy config keys normalized on load because gson-2.1 lacks
  @SerializedName(alternate=...)
- remove TCP-based KLALBRemoteManagement, superseded by the HTTP API
- dashboard settings follow the renamed keys; update AGENTS.md
Author
Contributor

About e0296e0ccd


1. 节点信息查询协议(srv6)

  • 移除旧的 openlinesreq/resp 报文类型,替换为两类查询接口:
    • 精简查询 nodeinfotinyreq/resp:仅返回设备名称,开销最小,不受任何隐私开关限制(设备名本就随路由广播公开)。
    • 完整查询 nodeinfofullreq/resp:返回外部端点列表 + 设备名称 + 设备描述,用于查看节点详情。
  • KLALBRoutingProtocolAPIClient 新增 requestNodeInfoTiny / requestNodeInfoFull,统一回调 KLALBNodeInformation 值对象;响应处理对空数据做了空安全处理。
  • 隐私语义收紧:denyExternalEndpointQuery=true仅隐藏端点列表data=null),设备名称与描述仍正常应答,不再整体静默。
  • GUI 规则:打开节点信息面板即发起完整查询;概览文本改用对端实时返回的名称/描述刷新(旧版本节点回退到广播名称)。

Caution

线上报文类型已更换,旧版本节点对新查询静默无响应,混合版本组网时自动线路发现会失效,请全网一起升级。

2. 配置键更名(纠正历史错误命名)

旧键名 新键名
openConnections / LineTable externalEndpoints
denyConnectionQuery denyExternalEndpointQuery
denyConnectionBroadcast denyExternalEndpointBroadcast
  • 这些地址实际是本节点对外发布的端点而非"连接",旧命名为开发者笔误;autoConnections 本次保持不变。
  • 向后兼容:gson-2.1 不支持 @SerializedName(alternate=...),因此在 KLALBConfigItem.getDefaultJsonDeserializer() 中手动归一化旧键名,旧配置文件可无损加载;Web API handleConfig 同样接受新旧键,新保存一律写标准键名。
  • 根目录 klalb-config.json 示例已更新为新键名。

3. 移除 TCP 远程管理协议

  • 删除 KLALBRemoteManagement(默认监听 127.9.9.9:49573 的 JSON-over-TCP 协议),其能力已全部由内置 Web 服务器 HTTP API 覆盖:
    • GETLINES → /api/links
    • ADDLINE → /api/links/action
    • GETSELFLINES / ADDSELFLINE → /api/config
  • 同步清理 KLALBProxySystem 中相关启用/禁用方法及主程序中的注释残块。

4. Dashboard(子模块)

  • 设置页读取优先 externalEndpoints,回退旧键;保存时同时携带新标准键与全部历史别名,新旧后端均可工作。
  • 禁用查询/广播开关按新键名镜像三份,保证本地表单状态一致。
About https://git.code.cq.cn/KNEMC/KLALB/commit/e0296e0ccdcc0fc39b6ba8129cb95bdc5d418606 --- ### 1. 节点信息查询协议(srv6) - 移除旧的 `openlinesreq/resp` 报文类型,替换为两类查询接口: - **精简查询** `nodeinfotinyreq/resp`:仅返回设备名称,开销最小,不受任何隐私开关限制(设备名本就随路由广播公开)。 - **完整查询** `nodeinfofullreq/resp`:返回外部端点列表 + 设备名称 + 设备描述,用于查看节点详情。 - `KLALBRoutingProtocolAPIClient` 新增 `requestNodeInfoTiny` / `requestNodeInfoFull`,统一回调 `KLALBNodeInformation` 值对象;响应处理对空数据做了空安全处理。 - 隐私语义收紧:`denyExternalEndpointQuery=true` 时**仅隐藏端点列表**(`data=null`),设备名称与描述仍正常应答,不再整体静默。 - GUI 规则:打开节点信息面板即发起完整查询;概览文本改用对端实时返回的名称/描述刷新(旧版本节点回退到广播名称)。 > [!CAUTION] > 线上报文类型已更换,旧版本节点对新查询静默无响应,混合版本组网时自动线路发现会失效,请全网一起升级。 ### 2. 配置键更名(纠正历史错误命名) | 旧键名 | 新键名 | | --- | --- | | `openConnections` / `LineTable` | `externalEndpoints` | | `denyConnectionQuery` | `denyExternalEndpointQuery` | | `denyConnectionBroadcast` | `denyExternalEndpointBroadcast` | - 这些地址实际是本节点对外发布的端点而非"连接",旧命名为开发者笔误;`autoConnections` 本次保持不变。 - **向后兼容**:gson-2.1 不支持 `@SerializedName(alternate=...)`,因此在 `KLALBConfigItem.getDefaultJsonDeserializer()` 中手动归一化旧键名,旧配置文件可无损加载;Web API `handleConfig` 同样接受新旧键,新保存一律写标准键名。 - 根目录 `klalb-config.json` 示例已更新为新键名。 ### 3. 移除 TCP 远程管理协议 - 删除 `KLALBRemoteManagement`(默认监听 `127.9.9.9:49573` 的 JSON-over-TCP 协议),其能力已全部由内置 Web 服务器 HTTP API 覆盖: - GETLINES → `/api/links` - ADDLINE → `/api/links/action` - GETSELFLINES / ADDSELFLINE → `/api/config` - 同步清理 `KLALBProxySystem` 中相关启用/禁用方法及主程序中的注释残块。 ### 4. Dashboard(子模块) - 设置页读取优先 `externalEndpoints`,回退旧键;保存时同时携带新标准键与全部历史别名,新旧后端均可工作。 - 禁用查询/广播开关按新键名镜像三份,保证本地表单状态一致。
SerinaNya added 1 commit 2026-08-26 00:36:29 +08:00
- new "Web API settings" section after security settings in the Swing
  options panel: checkbox bound to webUI plus a port text field bound
  to webPort (empty -> default 4665; non-numeric or out of 0-65535
  shows an invalid-port warning and aborts the save)
- load handler fills both controls from the current config item
- add i18n keys to klalb_zh_CN / klalb_en_US bundles
- include previously missing webUI/webPort fields in
  KLALBControllerConfigItem equals/hashCode
SerinaNya added 1 commit 2026-08-26 19:42:34 +08:00
- replace integer webPort with MultiProtocolSocketAddress webListen
  (default: http://0.0.0.0:4665) in controller config
- rename Swing UI item to "Web API 监听地址" and validate as full URI
- update WebServer binding to honor configured host and port
- normalize legacy webPort integers to http://0.0.0.0:<port> on load
  and keep JSON API backward compatibility
- update i18n keys in zh_CN and en_US resource bundles
- update root klalb-config.json and AGENTS.md documentation
SerinaNya marked the pull request as ready for review 2026-08-26 19:56:04 +08:00
KNEMC approved these changes 2026-08-26 19:56:34 +08:00
KNEMC left a comment
Owner

OK

OK
KNEMC merged commit 61868fe93e into master 2026-08-26 19:57:29 +08:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KNEMC/KLALB#2