Files
KLALB/src/org/kne/cloud/network/klalb/KLALBControllerConfigItem.java
T
SerinaNya 61868fe93e feat(config): switch webPort to URI-style webListen address
- 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
2026-08-26 19:42:26 +08:00

421 lines
11 KiB
Java

package org.kne.cloud.network.klalb;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.kne.cloud.network.MultiProtocolSocketAddress;
public class KLALBControllerConfigItem extends KLALBConfigItem {
private String language;
private boolean nogui;
private String VirtualAddress=KLALBUtils.randomKLALBIPv6Address().toString();
private Long VirtualASN;
private List<InetAddress> DNS;
private MultiProtocolSocketAddress TCPListen=new MultiProtocolSocketAddress("0.0.0.0",4565);
private MultiProtocolSocketAddress UDPListen=new MultiProtocolSocketAddress("udp","0.0.0.0",4565);
private String VirtualSocketName;
private List<MultiProtocolSocketAddress> externalEndpoints = new ArrayList<>();
private List<MultiProtocolSocketAddress> autoConnections = new ArrayList<>();
private List<MultiProtocolSocketAddress> ntpServers = new ArrayList<>();
private List<String> ExtraRoutes = new ArrayList<>();
private boolean denyExternalEndpointQuery = false;
private boolean denyExternalEndpointBroadcast = false;
private String congestionAlgorithm="BBR";
private double burstLimit=1.50;
private double delayUpperBound=1.20;
private double delayLowerBound=1.15;
private long nagleDelayTime=1000000L;
private long linkNagleDelayTime=1000000L;
private int linkConnectionsCount=1;
private boolean enableTUN = true;
private String TUNName=CONST.KLALB_S_RV6;
private String performanceStrategy="multifill";
private String DeviceName;
private String DeviceDescription;
private boolean webUI = false;
private MultiProtocolSocketAddress webListen = new MultiProtocolSocketAddress("http", "0.0.0.0", 4665);
public boolean isEnableTUN() {
return enableTUN;
}
public void setEnableTUN(boolean enableTUN) {
this.enableTUN = enableTUN;
}
public boolean isWebUI() {
return webUI;
}
public void setWebUI(boolean webUI) {
this.webUI = webUI;
}
public MultiProtocolSocketAddress getWebListen() {
return webListen;
}
public void setWebListen(MultiProtocolSocketAddress webListen) {
this.webListen = webListen;
}
public String getPerformanceStrategy() {
return performanceStrategy;
}
public void setPerformanceStrategy(String performanceStrategy) {
this.performanceStrategy = performanceStrategy;
}
public String getDeviceName() {
return DeviceName;
}
public void setDeviceName(String deviceName) {
DeviceName = deviceName;
}
public String getDeviceDescription() {
return DeviceDescription;
}
public void setDeviceDescription(String deviceDescription) {
DeviceDescription = deviceDescription;
}
public void setNetworkInterfaceExcepts(List<String> networkInterfaceExcepts) {
NetworkInterfaceExcepts = networkInterfaceExcepts;
}
private List<String>NetworkInterfaceExcepts=new ArrayList<>();
public List<String> getNetworkInterfaceExcepts() {
return NetworkInterfaceExcepts;
}
public void setLanguage(String language) {
this.language = language;
}
public KLALBControllerConfigItem() {
super("KLALBController");
}
public String getLanguage() {
return language;
}
public String getVirtualSocketName() {
return VirtualSocketName;
}
public void setVirtualSocketName(String virtualSocketName) {
VirtualSocketName = virtualSocketName;
}
public boolean isNogui() {
return nogui;
}
public void setNogui(boolean nogui) {
this.nogui = nogui;
}
public String getVirtualAddress() {
return VirtualAddress;
}
public void setVirtualAddress(String virtualAddress) {
VirtualAddress = virtualAddress;
}
public Long getVirtualASN() {
return VirtualASN;
}
public void setVirtualASN(Long virtualASN) {
VirtualASN = virtualASN;
}
public List<InetAddress> getDNS() {
return DNS;
}
public void setDNS(List<InetAddress> dNS) {
DNS = dNS;
}
public MultiProtocolSocketAddress getTCPListen() {
return TCPListen;
}
public void setTCPListen(MultiProtocolSocketAddress tCPListen) {
TCPListen = tCPListen;
}
public MultiProtocolSocketAddress getUDPListen() {
return UDPListen;
}
public void setUDPListen(MultiProtocolSocketAddress uDPListen) {
UDPListen = uDPListen;
}
public List<MultiProtocolSocketAddress> getExternalEndpoints() {
return externalEndpoints;
}
public void setExternalEndpoints(List<MultiProtocolSocketAddress> externalEndpoints) {
this.externalEndpoints = externalEndpoints;
}
public List<MultiProtocolSocketAddress> getAutoConnections() {
return autoConnections;
}
public void setAutoConnections(List<MultiProtocolSocketAddress> autoConnections) {
this.autoConnections = autoConnections;
}
public List<MultiProtocolSocketAddress> getConnectLineTable() {
return autoConnections;
}
public void setConnectLineTable(List<MultiProtocolSocketAddress> connectLineTable) {
this.autoConnections = connectLineTable;
}
public List<MultiProtocolSocketAddress> getNtpServers() {
return ntpServers;
}
public void setNtpServers(List<MultiProtocolSocketAddress> ntpServers) {
this.ntpServers = ntpServers;
}
public List<MultiProtocolSocketAddress> getNtpServerTable() {
return ntpServers;
}
public void setNtpServerTable(List<MultiProtocolSocketAddress> ntpServerTable) {
this.ntpServers = ntpServerTable;
}
public List<String> getExtraRoutes() {
return ExtraRoutes;
}
public void setExtraRoutes(List<String> extraRoutes) {
ExtraRoutes = extraRoutes;
}
public String getCongestionAlgorithm() {
return congestionAlgorithm;
}
public void setCongestionAlgorithm(String congestionAlgorithm) {
this.congestionAlgorithm = congestionAlgorithm;
}
public double getBurstLimit() {
return burstLimit;
}
public void setBurstLimit(double burstLimit) {
this.burstLimit = burstLimit;
}
public double getDelayUpperBound() {
return delayUpperBound;
}
public void setDelayUpperBound(double delayUpperBound) {
this.delayUpperBound = delayUpperBound;
}
public double getDelayLowerBound() {
return delayLowerBound;
}
public void setDelayLowerBound(double delayLowerBound) {
this.delayLowerBound = delayLowerBound;
}
public boolean isDenyExternalEndpointQuery() {
return denyExternalEndpointQuery;
}
public void setDenyExternalEndpointQuery(boolean denyExternalEndpointQuery) {
this.denyExternalEndpointQuery = denyExternalEndpointQuery;
}
public boolean isDenyExternalEndpointBroadcast() {
return denyExternalEndpointBroadcast;
}
public void setDenyExternalEndpointBroadcast(boolean denyExternalEndpointBroadcast) {
this.denyExternalEndpointBroadcast = denyExternalEndpointBroadcast;
}
public long getNagleDelayTime() {
return nagleDelayTime;
}
public void setNagleDelayTime(long nagleDelayTime) {
this.nagleDelayTime = nagleDelayTime;
}
public int getLinkConnectionsCount() {
return linkConnectionsCount;
}
public void setLinkConnectionsCount(int linkConnectionsCount) {
this.linkConnectionsCount = linkConnectionsCount;
}
public long getLinkNagleDelayTime() {
return linkNagleDelayTime;
}
public void setLinkNagleDelayTime(long linkNagleDelayTime) {
this.linkNagleDelayTime = linkNagleDelayTime;
}
public String getTUNName() {
return TUNName;
}
public void setTUNName(String tUNName) {
TUNName = tUNName;
}
@Override
public String toString() {
return "KLALBControllerConfigItem{" +
"language='" + language + '\'' +
", nogui=" + nogui +
", VirtualAddress='" + VirtualAddress + '\'' +
", VirtualASN=" + VirtualASN +
", DNS=" + DNS +
", TCPListen=" + TCPListen +
", UDPListen=" + UDPListen +
", VirtualSocketName='" + VirtualSocketName + '\'' +
", externalEndpoints=" + externalEndpoints +
", autoConnections=" + autoConnections +
", ntpServers=" + ntpServers +
", ExtraRoutes=" + ExtraRoutes +
", denyExternalEndpointQuery=" + denyExternalEndpointQuery +
", denyExternalEndpointBroadcast=" + denyExternalEndpointBroadcast +
", congestionAlgorithm='" + congestionAlgorithm + '\'' +
", burstLimit=" + burstLimit +
", delayUpperBound=" + delayUpperBound +
", delayLowerBound=" + delayLowerBound +
", nagleDelayTime=" + nagleDelayTime +
", linkNagleDelayTime=" + linkNagleDelayTime +
", linkConnectionsCount=" + linkConnectionsCount +
", enableTUN=" + enableTUN +
", TUNName='" + TUNName + '\'' +
", performanceStrategy='" + performanceStrategy + '\'' +
", DeviceName='" + DeviceName + '\'' +
", DeviceDescription='" + DeviceDescription + '\'' +
", NetworkInterfaceExcepts=" + NetworkInterfaceExcepts +
", webUI=" + webUI +
", webListen=" + webListen +
'}';
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
KLALBControllerConfigItem that = (KLALBControllerConfigItem) o;
return nogui == that.nogui && enableTUN == that.enableTUN && webUI == that.webUI && denyExternalEndpointQuery == that.denyExternalEndpointQuery && denyExternalEndpointBroadcast == that.denyExternalEndpointBroadcast && Double.compare(burstLimit, that.burstLimit) == 0 && Double.compare(delayUpperBound, that.delayUpperBound) == 0 && Double.compare(delayLowerBound, that.delayLowerBound) == 0 && nagleDelayTime == that.nagleDelayTime && linkNagleDelayTime == that.linkNagleDelayTime && linkConnectionsCount == that.linkConnectionsCount && Objects.equals(webListen, that.webListen) && Objects.equals(language, that.language) && Objects.equals(VirtualAddress, that.VirtualAddress) && Objects.equals(VirtualASN, that.VirtualASN) && Objects.equals(DNS, that.DNS) && Objects.equals(TCPListen, that.TCPListen) && Objects.equals(UDPListen, that.UDPListen) && Objects.equals(VirtualSocketName, that.VirtualSocketName) && Objects.equals(externalEndpoints, that.externalEndpoints) && Objects.equals(autoConnections, that.autoConnections) && Objects.equals(ntpServers, that.ntpServers) && Objects.equals(ExtraRoutes, that.ExtraRoutes) && Objects.equals(congestionAlgorithm, that.congestionAlgorithm) && Objects.equals(TUNName, that.TUNName) && Objects.equals(performanceStrategy, that.performanceStrategy) && Objects.equals(DeviceName, that.DeviceName) && Objects.equals(DeviceDescription, that.DeviceDescription) && Objects.equals(NetworkInterfaceExcepts, that.NetworkInterfaceExcepts);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), language, nogui, VirtualAddress, VirtualASN, DNS, TCPListen, UDPListen, VirtualSocketName, externalEndpoints, autoConnections, ntpServers, ExtraRoutes, denyExternalEndpointQuery, denyExternalEndpointBroadcast, congestionAlgorithm, burstLimit, delayUpperBound, delayLowerBound, nagleDelayTime, linkNagleDelayTime, linkConnectionsCount, enableTUN, TUNName, performanceStrategy, DeviceName, DeviceDescription, NetworkInterfaceExcepts, webUI, webListen);
}
}