forked from I2P_Developers/i2p.i2p
Console: Lookup RI by IP with netmask
This commit is contained in:
@ -95,6 +95,21 @@ class NetDbRenderer {
|
||||
} else {
|
||||
boolean notFound = true;
|
||||
Set<RouterInfo> routers = _context.netDb().getRouters();
|
||||
int ipMode = 0;
|
||||
if (ip != null) {
|
||||
if (ip.endsWith("/24")) {
|
||||
ipMode = 1;
|
||||
} else if (ip.endsWith("/16")) {
|
||||
ipMode = 2;
|
||||
} else if (ip.endsWith("/8")) {
|
||||
ipMode = 3;
|
||||
}
|
||||
for (int i = 0; i < ipMode; i++) {
|
||||
int last = ip.lastIndexOf('.');
|
||||
if (last > 0)
|
||||
ip = ip.substring(0, last + 1);
|
||||
}
|
||||
}
|
||||
for (RouterInfo ri : routers) {
|
||||
Hash key = ri.getIdentity().getHash();
|
||||
if ((routerPrefix != null && key.toBase64().startsWith(routerPrefix)) ||
|
||||
@ -106,10 +121,19 @@ class NetDbRenderer {
|
||||
notFound = false;
|
||||
} else if (ip != null) {
|
||||
for (RouterAddress ra : ri.getAddresses()) {
|
||||
if (ip.equals(ra.getHost())) {
|
||||
renderRouterInfo(buf, ri, false, true);
|
||||
notFound = false;
|
||||
break;
|
||||
if (ipMode == 0) {
|
||||
if (ip.equals(ra.getHost())) {
|
||||
renderRouterInfo(buf, ri, false, true);
|
||||
notFound = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
String host = ra.getHost();
|
||||
if (host != null && host.startsWith(ip)) {
|
||||
renderRouterInfo(buf, ri, false, true);
|
||||
notFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -501,8 +501,10 @@ class SybilRenderer {
|
||||
int i0 = i >> 16;
|
||||
int i1 = (i >> 8) & 0xff;
|
||||
int i2 = i & 0xff;
|
||||
buf.append("<p><b>").append(count).append(" floodfills in ").append(i0).append('.')
|
||||
.append(i1).append('.').append(i2).append(".0/24:</b></p>");
|
||||
String sip = i0 + "." + i1 + '.' + i2 + ".0/24";
|
||||
buf.append("<p><b>").append(count).append(" floodfills with IP <a href=\"/netdb?ip=")
|
||||
.append(sip).append("\">").append(sip)
|
||||
.append("</a>:</b></p>");
|
||||
for (RouterInfo info : ris) {
|
||||
byte[] ip = getIP(info);
|
||||
if (ip == null)
|
||||
@ -549,8 +551,10 @@ class SybilRenderer {
|
||||
int i = ii.intValue();
|
||||
int i0 = i >> 8;
|
||||
int i1 = i & 0xff;
|
||||
buf.append("<p><b>").append(count).append(" floodfills in ").append(i0).append('.')
|
||||
.append(i1).append(".0.0/16</b></p>");
|
||||
String sip = i0 + "." + i1 + ".0/16";
|
||||
buf.append("<p><b>").append(count).append(" floodfills with IP <a href=\"/netdb?ip=")
|
||||
.append(sip).append("\">").append(sip)
|
||||
.append("</a></b></p>");
|
||||
for (RouterInfo info : ris) {
|
||||
byte[] ip = getIP(info);
|
||||
if (ip == null)
|
||||
|
Reference in New Issue
Block a user