NetDb: Add MTU, SSU caps, IPv6 prefix, and cost lookups

This commit is contained in:
zzz
2016-11-27 15:46:07 +00:00
parent 2318a2b319
commit 850f1504f7
3 changed files with 90 additions and 7 deletions

View File

@@ -90,7 +90,8 @@ class NetDbRenderer {
*/
public void renderRouterInfoHTML(Writer out, String routerPrefix, String version,
String country, String family, String caps,
String ip, String sybil, int port, SigType type) throws IOException {
String ip, String sybil, int port, SigType type,
String mtu, String ipv6, String ssucaps, int cost) throws IOException {
StringBuilder buf = new StringBuilder(4*1024);
List<Hash> sybils = sybil != null ? new ArrayList<Hash>(128) : null;
if (".".equals(routerPrefix)) {
@@ -156,6 +157,49 @@ class NetDbRenderer {
break;
}
}
} else if (mtu != null) {
for (RouterAddress ra : ri.getAddresses()) {
if (mtu.equals(ra.getOption("mtu"))) {
renderRouterInfo(buf, ri, false, true);
if (sybil != null)
sybils.add(key);
notFound = false;
break;
}
}
} else if (ipv6 != null) {
for (RouterAddress ra : ri.getAddresses()) {
String host = ra.getHost();
if (host != null && host.startsWith(ipv6)) {
renderRouterInfo(buf, ri, false, true);
if (sybil != null)
sybils.add(key);
notFound = false;
break;
}
}
} else if (ssucaps != null) {
for (RouterAddress ra : ri.getAddresses()) {
if (!"SSU".equals(ra.getTransportStyle()))
continue;
if (ssucaps.equals(ra.getOption("caps"))) {
renderRouterInfo(buf, ri, false, true);
if (sybil != null)
sybils.add(key);
notFound = false;
break;
}
}
} else if (cost != 0) {
for (RouterAddress ra : ri.getAddresses()) {
if (cost == ra.getCost()) {
renderRouterInfo(buf, ri, false, true);
if (sybil != null)
sybils.add(key);
notFound = false;
break;
}
}
}
}
if (notFound) {