Lookup by port and sig type

This commit is contained in:
zzz
2016-11-26 17:43:18 +00:00
parent 5a87c232ea
commit 8d494ad162
3 changed files with 39 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package net.i2p.router.web;
import java.io.IOException;
import net.i2p.crypto.SigType;
import net.i2p.data.DataHelper;
public class NetDbHelper extends HelperBase {
@ -8,10 +9,11 @@ public class NetDbHelper extends HelperBase {
private String _version;
private String _country;
private String _family, _caps, _ip, _sybil;
private int _full;
private int _full, _port;
private boolean _lease;
private boolean _debug;
private boolean _graphical;
private SigType _type;
private static final String titles[] =
{_x("Summary"), // 0
@ -84,6 +86,19 @@ public class NetDbHelper extends HelperBase {
_sybil = DataHelper.stripHTML(c); // XSS
}
/** @since 0.9.28 */
public void setPort(String f) {
try {
_port = Integer.parseInt(f);
} catch (NumberFormatException nfe) {}
}
/** @since 0.9.28 */
public void setType(String f) {
if (f != null && f.length() > 0)
_type = SigType.parseSigType(f);
}
public void setFull(String f) {
try {
_full = Integer.parseInt(f);
@ -111,9 +126,10 @@ public class NetDbHelper extends HelperBase {
try {
renderNavBar();
if (_routerPrefix != null || _version != null || _country != null ||
_family != null || _caps != null || _ip != null || _sybil != null)
_family != null || _caps != null || _ip != null || _sybil != null ||
_port != 0 || _type != null)
renderer.renderRouterInfoHTML(_out, _routerPrefix, _version, _country,
_family, _caps, _ip, _sybil);
_family, _caps, _ip, _sybil, _port, _type);
else if (_lease)
renderer.renderLeaseSetHTML(_out, _debug);
else if (_full == 3)
@ -139,7 +155,8 @@ public class NetDbHelper extends HelperBase {
if (".".equals(_routerPrefix))
return 1;
if (_routerPrefix != null || _version != null || _country != null ||
_family != null || _caps != null || _ip != null || _sybil != null)
_family != null || _caps != null || _ip != null || _sybil != null ||
_port != 0 || _type != null)
return 2;
if (_full == 2)
return 3;
@ -201,6 +218,8 @@ public class NetDbHelper extends HelperBase {
"Family <input type=\"text\" name=\"fam\"><br>\n" +
"Hash prefix <input type=\"text\" name=\"r\"><br>\n" +
"IP <input type=\"text\" name=\"ip\">IPv4 or IPv6, /24,/16,/8 suffixes optional for IPv4<br>\n" +
"Port <input type=\"text\" name=\"port\"><br>\n" +
"Sig Type <input type=\"text\" name=\"type\"><br>\n" +
"Version <input type=\"text\" name=\"v\"><br>\n" +
"<p><b>Add Sybil analysis (must pick one above):</b></p>\n" +
"Sybil close to <input type=\"text\" name=\"sybil2\">Router hash, dest hash, b32, or from address book<br>\n" +

View File

@ -24,6 +24,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.i2p.crypto.SigType;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.Hash;
@ -89,7 +90,7 @@ class NetDbRenderer {
*/
public void renderRouterInfoHTML(Writer out, String routerPrefix, String version,
String country, String family, String caps,
String ip, String sybil) throws IOException {
String ip, String sybil, int port, SigType type) throws IOException {
StringBuilder buf = new StringBuilder(4*1024);
List<Hash> sybils = sybil != null ? new ArrayList<Hash>(128) : null;
if (".".equals(routerPrefix)) {
@ -118,7 +119,8 @@ class NetDbRenderer {
(version != null && version.equals(ri.getVersion())) ||
(country != null && country.equals(_context.commSystem().getCountry(key))) ||
(family != null && family.equals(ri.getOption("family"))) ||
(caps != null && ri.getCapabilities().contains(caps))) {
(caps != null && ri.getCapabilities().contains(caps)) ||
(type != null && type == ri.getIdentity().getSigType())) {
renderRouterInfo(buf, ri, false, true);
if (sybil != null)
sybils.add(key);
@ -144,6 +146,16 @@ class NetDbRenderer {
}
}
}
} else if (port != 0) {
for (RouterAddress ra : ri.getAddresses()) {
if (port == ra.getPort()) {
renderRouterInfo(buf, ri, false, true);
if (sybil != null)
sybils.add(key);
notFound = false;
break;
}
}
}
}
if (notFound) {

View File

@ -30,5 +30,7 @@
<jsp:setProperty name="netdbHelper" property="ip" value="<%=request.getParameter(\"ip\")%>" />
<jsp:setProperty name="netdbHelper" property="sybil" value="<%=request.getParameter(\"sybil\")%>" />
<jsp:setProperty name="netdbHelper" property="sybil2" value="<%=request.getParameter(\"sybil2\")%>" />
<jsp:setProperty name="netdbHelper" property="port" value="<%=request.getParameter(\"port\")%>" />
<jsp:setProperty name="netdbHelper" property="type" value="<%=request.getParameter(\"type\")%>" />
<jsp:getProperty name="netdbHelper" property="netDbSummary" />
</div></div></body></html>