forked from KNEMC/KLALB
✨ feat: 新增设备信息与额外路由设置,支持设备名广播及TUN显式禁用
- 设置页新增设备名称(单行)、设备描述(多行)、额外路由(CIDR列表)设置项 - RouterInfo 广播携带 deviceName,并在拓扑图节点与节点概览中展示;deviceDescription 保持本地概览显示 - 拓扑图节点标签支持多行文本绘制 - 节点概览面板新增 IP 地址及设备详情展示 - 支持将 TUNName 设为 null/"null"/空字符串时完全跳过 Wintun 虚拟网卡创建 - .classpath 容器改为标准 JavaSE-25 执行环境以同时兼容 JDK 25 与 26 - 新增 AGENTS.md 与 VS Code 调试及运行配置 BREAKING CHANGE: RouterInfo 在序列化末尾追加了 deviceName 字段(writeUTF),新旧版本节点混连时路由协议解析异常,需同步升级
This commit is contained in:
@@ -51,6 +51,27 @@ public class KLALBUtils {
|
||||
v[3] = 0x01;
|
||||
return IPv6Address.valueOf(v);
|
||||
}
|
||||
|
||||
public static String parseCidr(String cidr) {
|
||||
int idx = cidr.indexOf('/');
|
||||
if (idx <= 0 || idx == cidr.length() - 1)
|
||||
throw new IllegalArgumentException("not a cidr: " + cidr);
|
||||
int prefix;
|
||||
try {
|
||||
prefix = Integer.parseInt(cidr.substring(idx + 1));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("bad prefix: " + cidr);
|
||||
}
|
||||
try {
|
||||
InetAddress addr = InetAddress.getByName(cidr.substring(0, idx));
|
||||
int max = (addr instanceof Inet6Address) ? 128 : 32;
|
||||
if (prefix < 0 || prefix > max)
|
||||
throw new IllegalArgumentException("prefix out of range: " + cidr);
|
||||
return addr.getHostAddress() + "/" + prefix;
|
||||
} catch (UnknownHostException e) {
|
||||
throw new IllegalArgumentException("bad address: " + cidr);
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
System.out.println(uuidToIP(new UUID(-1,-1)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user