forked from KNEMC/KLALB
Compare commits
1
Commits
52f44335e4
...
patch-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c5a81da25
|
@@ -92,6 +92,8 @@ transmitnagledelaytime=Transmit nagle delay time
|
|||||||
linknagledelaytime=Link nagle delay time
|
linknagledelaytime=Link nagle delay time
|
||||||
linkconnectionscount=Link connections count
|
linkconnectionscount=Link connections count
|
||||||
tunname=Virtual network device name
|
tunname=Virtual network device name
|
||||||
|
enabletun=Enable TUN device
|
||||||
|
tundisabledwarning=⚠️ TUNTAP is disabled: Virtual network device not mounted
|
||||||
dashboard=Dashboard
|
dashboard=Dashboard
|
||||||
backplanedelay=Backplane delay
|
backplanedelay=Backplane delay
|
||||||
backplanepps=Backplane PPS
|
backplanepps=Backplane PPS
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ transmitnagledelaytime=传输粘包等待时间
|
|||||||
linknagledelaytime=链路粘包等待时间
|
linknagledelaytime=链路粘包等待时间
|
||||||
linkconnectionscount=链路连接数
|
linkconnectionscount=链路连接数
|
||||||
tunname=虚拟网卡名称
|
tunname=虚拟网卡名称
|
||||||
|
enabletun=启用虚拟网卡 (TUN)
|
||||||
|
tundisabledwarning=⚠️ TUNTAP 未启用:虚拟网卡未挂载
|
||||||
dashboard=仪表盘
|
dashboard=仪表盘
|
||||||
backplanedelay=背板处理延迟
|
backplanedelay=背板处理延迟
|
||||||
backplanepps=背板包转发率
|
backplanepps=背板包转发率
|
||||||
|
|||||||
@@ -661,12 +661,13 @@ public class KLALBController {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("挂载虚拟网卡失败,可能是无管理员权限?请尝试使用管理员权限运行软件");
|
System.err.println("挂载虚拟网卡失败,可能是无管理员权限?请尝试使用管理员权限运行软件");
|
||||||
|
System.err.println("WARNING: Failed to mount TUN adapter (requires administrator privileges)");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
}else {
|
}else {
|
||||||
System.out.println(" Tun Adapter Disabled");
|
System.out.println(" WARNING: TUNTAP is disabled: Virtual network device not mounted");
|
||||||
|
|
||||||
}
|
}
|
||||||
udpr=new UDPProtocolRegister(this);
|
udpr=new UDPProtocolRegister(this);
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ public class KLALBStateGUI3 extends XFrame {
|
|||||||
private JCheckBox denyQuery;
|
private JCheckBox denyQuery;
|
||||||
private ClosableTabbedPane tabbedPane; // 可关闭的标签页面板
|
private ClosableTabbedPane tabbedPane; // 可关闭的标签页面板
|
||||||
private JCheckBox nogui;
|
private JCheckBox nogui;
|
||||||
|
private JCheckBox enableTun;
|
||||||
|
private TextSettingItem tunNameItem;
|
||||||
|
private SettingItem tunWarningItem;
|
||||||
|
|
||||||
// ==================== 配置和回调 ====================
|
// ==================== 配置和回调 ====================
|
||||||
private KLALBConfig config; // 配置文件
|
private KLALBConfig config; // 配置文件
|
||||||
@@ -820,10 +823,29 @@ public class KLALBStateGUI3 extends XFrame {
|
|||||||
asnFieldSet = asn.getTextField();
|
asnFieldSet = asn.getTextField();
|
||||||
settings.getView().add(asn);
|
settings.getView().add(asn);
|
||||||
|
|
||||||
TextSettingItem tunName = new TextSettingItem(UIEnv.getRsb().getString("tunname"),
|
// 启用虚拟网卡 (TUN)
|
||||||
|
CheckBoxSettingItem enableTunc = new CheckBoxSettingItem(UIEnv.getRsb().getString("enabletun"),
|
||||||
CONST.itemwidth, CONST.settingheight);
|
CONST.itemwidth, CONST.settingheight);
|
||||||
tunDeviceName = tunName.getTextField();
|
enableTun = enableTunc.getCheckBox();
|
||||||
settings.getView().add(tunName);
|
settings.getView().add(enableTunc);
|
||||||
|
|
||||||
|
tunNameItem = new TextSettingItem(UIEnv.getRsb().getString("tunname"),
|
||||||
|
CONST.itemwidth, CONST.settingheight);
|
||||||
|
tunDeviceName = tunNameItem.getTextField();
|
||||||
|
settings.getView().add(tunNameItem);
|
||||||
|
|
||||||
|
tunWarningItem = new SettingItem(UIEnv.getRsb().getString("tundisabledwarning"),
|
||||||
|
UIEnv.getFont().deriveFont(13.0f), CONST.itemwidth, CONST.settingheight);
|
||||||
|
tunWarningItem.getLabel().setForeground(new Color(220, 80, 0));
|
||||||
|
settings.getView().add(tunWarningItem);
|
||||||
|
|
||||||
|
enableTun.addActionListener(e -> {
|
||||||
|
boolean en = enableTun.isSelected();
|
||||||
|
if (en && (tunDeviceName.getText().trim().isEmpty() || tunDeviceName.getText().trim().equalsIgnoreCase("null"))) {
|
||||||
|
tunDeviceName.setText(CONST.KLALB_S_RV6);
|
||||||
|
}
|
||||||
|
updateTunVisibility(en);
|
||||||
|
});
|
||||||
|
|
||||||
// 链接设置标题
|
// 链接设置标题
|
||||||
SettingItem six = new SettingItem(UIEnv.getRsb().getString("linksettings"),
|
SettingItem six = new SettingItem(UIEnv.getRsb().getString("linksettings"),
|
||||||
@@ -1026,6 +1048,19 @@ public class KLALBStateGUI3 extends XFrame {
|
|||||||
delayLbound.getSlider().addChangeListener(cll);
|
delayLbound.getSlider().addChangeListener(cll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateTunVisibility(boolean enabled) {
|
||||||
|
if (tunNameItem != null) {
|
||||||
|
tunNameItem.setVisible(enabled);
|
||||||
|
}
|
||||||
|
if (tunWarningItem != null) {
|
||||||
|
tunWarningItem.setVisible(!enabled);
|
||||||
|
}
|
||||||
|
if (yspc != null && yspc.getView() != null) {
|
||||||
|
yspc.getView().revalidate();
|
||||||
|
yspc.getView().repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 配置保存方法 ====================
|
// ==================== 配置保存方法 ====================
|
||||||
/**
|
/**
|
||||||
* 保存配置到文件
|
* 保存配置到文件
|
||||||
@@ -1134,12 +1169,17 @@ public class KLALBStateGUI3 extends XFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String tunNameText=tunDeviceName.getText().trim();
|
// 保存TUN虚拟网卡设置
|
||||||
if(tunNameText.equals("") || tunNameText.equalsIgnoreCase("null")) {
|
if (!enableTun.isSelected()) {
|
||||||
kck.setTUNName(null);
|
kck.setTUNName(null);
|
||||||
}else {
|
} else {
|
||||||
|
String tunNameText = tunDeviceName.getText().trim();
|
||||||
|
if (tunNameText.equals("") || tunNameText.equalsIgnoreCase("null")) {
|
||||||
|
kck.setTUNName(CONST.KLALB_S_RV6);
|
||||||
|
} else {
|
||||||
kck.setTUNName(tunNameText);
|
kck.setTUNName(tunNameText);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 保存TCP监听设置
|
// 保存TCP监听设置
|
||||||
String tcptext = tcpListeningSet.getText();
|
String tcptext = tcpListeningSet.getText();
|
||||||
@@ -1539,7 +1579,10 @@ public class KLALBStateGUI3 extends XFrame {
|
|||||||
asnFieldSet.setText(vasn != null ? vasn.toString() : "");
|
asnFieldSet.setText(vasn != null ? vasn.toString() : "");
|
||||||
|
|
||||||
String tunname=kck.getTUNName();
|
String tunname=kck.getTUNName();
|
||||||
tunDeviceName.setText(tunname!=null?tunname:"");
|
boolean isTunActive = (tunname != null && !tunname.trim().isEmpty() && !tunname.trim().equalsIgnoreCase("null"));
|
||||||
|
enableTun.setSelected(isTunActive);
|
||||||
|
tunDeviceName.setText(isTunActive ? tunname.trim() : "");
|
||||||
|
updateTunVisibility(isTunActive);
|
||||||
|
|
||||||
// 加载TCP监听
|
// 加载TCP监听
|
||||||
MultiProtocolSocketAddress mpat = kck.getTCPListen();
|
MultiProtocolSocketAddress mpat = kck.getTCPListen();
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class UIEnv {
|
|||||||
// TODO 自动生成的 catch 块
|
// TODO 自动生成的 catch 块
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
font=new Font("微软雅黑",Font.PLAIN , 12);
|
font = pickDefaultFont(12);
|
||||||
/*try {
|
/*try {
|
||||||
font = Font.createFont(Font.PLAIN, UIEnv.class.getResourceAsStream("/assets/SourceHanSansCN-Light.otf")).deriveFont(13f);
|
font = Font.createFont(Font.PLAIN, UIEnv.class.getResourceAsStream("/assets/SourceHanSansCN-Light.otf")).deriveFont(13f);
|
||||||
} catch (FontFormatException e1) {
|
} catch (FontFormatException e1) {
|
||||||
@@ -117,6 +117,31 @@ public class UIEnv {
|
|||||||
start.setFont(font.deriveFont(Font.BOLD, fontsize));
|
start.setFont(font.deriveFont(Font.BOLD, fontsize));
|
||||||
start.setBackground(defaultcolor);
|
start.setBackground(defaultcolor);
|
||||||
}
|
}
|
||||||
|
private static Font pickDefaultFont(int size) {
|
||||||
|
String[] preferredFonts = new String[] {
|
||||||
|
"Microsoft YaHei UI", "Microsoft YaHei", "微软雅黑",
|
||||||
|
"PingFang SC", ".AppleSystemUIFont", "Helvetica Neue",
|
||||||
|
"Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei",
|
||||||
|
"Segoe UI", "Arial"
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
String[] available = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
|
||||||
|
java.util.Set<String> set = new java.util.HashSet<>(java.util.Arrays.asList(available));
|
||||||
|
for (String name : preferredFonts) {
|
||||||
|
if (set.contains(name)) {
|
||||||
|
return new Font(name, Font.PLAIN, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
// fallback in case of headless or security restrictions
|
||||||
|
}
|
||||||
|
Font sysFont = UIManager.getFont("Label.font");
|
||||||
|
if (sysFont != null) {
|
||||||
|
return sysFont.deriveFont(Font.PLAIN, (float) size);
|
||||||
|
}
|
||||||
|
return new Font(Font.DIALOG, Font.PLAIN, size);
|
||||||
|
}
|
||||||
|
|
||||||
public static Font getFont(){
|
public static Font getFont(){
|
||||||
if(icon==null)
|
if(icon==null)
|
||||||
inituie();
|
inituie();
|
||||||
|
|||||||
Reference in New Issue
Block a user