forked from KNEMC/KLALB
feat(srv6)!: replace openlines query with tiny/full node-info API
- 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
This commit is contained in:
@@ -76,7 +76,7 @@ public class KLALBController {
|
||||
new HashMapTimestampMonitor<UUID>(HighAccuracyClock.SYSTEM_CLOCK, "up", 100, TIME_WINDOW),
|
||||
new HashMapTimestampMonitor<UUID>(HighAccuracyClock.SYSTEM_CLOCK, "down", 100, TIME_WINDOW));
|
||||
|
||||
private List<MultiProtocolSocketAddress> selflineTable = new ArrayList<>();
|
||||
private List<MultiProtocolSocketAddress> externalEndpoints = new ArrayList<>();
|
||||
|
||||
private List<MultiProtocolSocketAddress> listensSocketAddress = new CopyOnWriteArrayList<>();
|
||||
|
||||
@@ -137,9 +137,9 @@ public class KLALBController {
|
||||
MultiProtocolSocketAddress bind = new MultiProtocolSocketAddress(tcpl.getProtocol(),
|
||||
inetAddress.getHostAddress(), tcpl.getPort());
|
||||
// System.out.println(bind);
|
||||
synchronized (selflineTable) {
|
||||
if (!selflineTable.contains(bind)) {
|
||||
selflineTable.add(bind);
|
||||
synchronized (externalEndpoints) {
|
||||
if (!externalEndpoints.contains(bind)) {
|
||||
externalEndpoints.add(bind);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class KLALBController {
|
||||
for (Iterator<IPMulticastDiscovery> iterator = ipmd.iterator(); iterator.hasNext(); ) {
|
||||
IPMulticastDiscovery ipMulticastDiscovery = (IPMulticastDiscovery) iterator.next();
|
||||
if (ipMulticastDiscovery.isClosed() || (!ipMulticastDiscovery.getInterface().isUp())
|
||||
|| (configItem != null && configItem.isDenyConnectionBroadcast())) {
|
||||
|| (configItem != null && configItem.isDenyExternalEndpointBroadcast())) {
|
||||
iterator.remove();
|
||||
try {
|
||||
ipMulticastDiscovery.close();
|
||||
@@ -222,7 +222,7 @@ public class KLALBController {
|
||||
}
|
||||
}
|
||||
|
||||
if (configItem != null && configItem.isDenyConnectionBroadcast()) {
|
||||
if (configItem != null && configItem.isDenyExternalEndpointBroadcast()) {
|
||||
|
||||
} else {
|
||||
List<NetworkInterface> interfaceList = networkInterfaceManager.getAllAvaliableNetworkInterface();
|
||||
@@ -299,7 +299,7 @@ public class KLALBController {
|
||||
private boolean checkIsSelf(MultiProtocolSocketAddress inetAddress) throws UnknownHostException {
|
||||
|
||||
return inetAddress.getInetAddress().isAnyLocalAddress() || inetAddress.getInetAddress().isLoopbackAddress()
|
||||
|| selflineTable.contains(inetAddress);
|
||||
|| externalEndpoints.contains(inetAddress);
|
||||
}
|
||||
|
||||
private boolean checkIsSelfLocator(InetAddress inetAddress) {
|
||||
@@ -339,9 +339,9 @@ public class KLALBController {
|
||||
try {
|
||||
InetSocketAddress iaddr = new InetSocketAddress(neighbor.getAddress().toInet6Address(),
|
||||
KLALBRoutingProtocol.DEFAULT_PORT);
|
||||
apiClient.requestOpenLines(iaddr, (v) -> {
|
||||
apiClient.requestNodeInfoFull(iaddr, (v) -> {
|
||||
ThreadTool.makeVDaemonThreadIfSupport("线路添加任务", () -> {
|
||||
for (MultiProtocolSocketAddress msa : v) {
|
||||
for (MultiProtocolSocketAddress msa : v.getOpenLines()) {
|
||||
// System.out.print(msa);
|
||||
addRemoteLines(msa);
|
||||
}
|
||||
@@ -401,8 +401,8 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
|
||||
public List<MultiProtocolSocketAddress> getSelflineTable() {
|
||||
return selflineTable;
|
||||
public List<MultiProtocolSocketAddress> getExternalEndpoints() {
|
||||
return externalEndpoints;
|
||||
}
|
||||
|
||||
|
||||
@@ -593,18 +593,18 @@ public class KLALBController {
|
||||
lineslock.writeLock().lock();
|
||||
try {
|
||||
krs.startIO();
|
||||
String selflineTable = generateSelfLineTable();
|
||||
if (selflineTable != null && !selflineTable.equals(""))
|
||||
krs.sendPacket(new ADDLINESPacket(selflineTable));
|
||||
String externalEndpointsText = generateExternalEndpointsString();
|
||||
if (externalEndpointsText != null && !externalEndpointsText.equals(""))
|
||||
krs.sendPacket(new ADDLINESPacket(externalEndpointsText));
|
||||
srv6Router.getLinkTabel().add(krs);
|
||||
} finally {
|
||||
lineslock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private String generateSelfLineTable() {
|
||||
private String generateExternalEndpointsString() {
|
||||
StringBuilder sbd = new StringBuilder();
|
||||
for (Iterator<MultiProtocolSocketAddress> iterator = selflineTable.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<MultiProtocolSocketAddress> iterator = externalEndpoints.iterator(); iterator.hasNext();) {
|
||||
MultiProtocolSocketAddress klalbRemoteLine = (MultiProtocolSocketAddress) iterator.next();
|
||||
sbd.append(klalbRemoteLine.toString());
|
||||
sbd.append('\n');
|
||||
@@ -801,10 +801,10 @@ public class KLALBController {
|
||||
getIpv6Router().setASN(vasn);
|
||||
}
|
||||
|
||||
List<MultiProtocolSocketAddress> linele = configItem.getOpenConnections();
|
||||
List<MultiProtocolSocketAddress> linele = configItem.getExternalEndpoints();
|
||||
if (linele != null) {
|
||||
getSelflineTable().addAll(linele);
|
||||
}
|
||||
getExternalEndpoints().addAll(linele);
|
||||
}
|
||||
List<MultiProtocolSocketAddress> linetoc = configItem.getAutoConnections();
|
||||
if (linetoc != null) {
|
||||
linetoc.forEach((aline) -> {
|
||||
|
||||
Reference in New Issue
Block a user