fix for finding stats for tcp interfaces

This commit is contained in:
liamcottle 2024-05-29 22:58:34 +12:00
parent 884f993d62
commit 6ee2a4397f

View file

@ -1442,17 +1442,42 @@
// do nothing if failed to load interfaces
}
},
findInterfaceStats(interfaceName) {
getInterfaceDescription(interfaceName) {
// the interface-stats api returns interface names like the following;
//
// "AutoInterface[Default Interface]"
// "RNodeInterface[RNode LoRa Interface Fast]"
// "TCPInterface[RNS Testnet Amsterdam/amsterdam.connect.reticulum.network:4965]"
//
// however, the interfaces api just returns;
// "Default Interface"
// "RNode LoRa Interface Fast"
// "RNS Testnet Amsterdam"
//
// so we need to map the basic interface name to the former, so we can lookup stats for the interface
const iface = this.interfaces[interfaceName];
if(iface){
const interfaceNameWithType = `${iface.type}[${interfaceName}]`;
return this.interfaceStats[interfaceNameWithType];
switch(iface.type){
case "TCPClientInterface": {
// yes, this is meant to be passed as TCPInterface, even though the interface type includes client...
// example: "TCPInterface[RNS Testnet Amsterdam/amsterdam.connect.reticulum.network:4965]";
return `TCPInterface[${interfaceName}/${iface.target_host}:${iface.target_port}]`;
}
default: {
// example: "RNodeInterface[RNode LoRa Interface Fast]",
return `${iface.type}[${interfaceName}]`;
}
}
}
return null;
},
findInterfaceStats(interfaceName) {
const interfaceDescription = this.getInterfaceDescription(interfaceName);
return this.interfaceStats[interfaceDescription];
},
async loadNodePage(destinationHash, pagePath, addToHistory = true, loadFromCache = true) {
// get new sequence for this page load