forked from I2P_Developers/i2p.i2p
NetDb: Add advanced lookup form
Fix /16 and /8 lookup Fix tab highlighted for all lookups Add sybil points for banlist
This commit is contained in:
@ -21,7 +21,8 @@ public class NetDbHelper extends HelperBase {
|
||||
_x("All Routers with Full Stats"), // 4
|
||||
"LeaseSet Debug", // 5
|
||||
_x("LeaseSets"), // 6
|
||||
"Sybil" }; // 7
|
||||
"Sybil", // 7
|
||||
"Advanced Lookup" }; // 8
|
||||
|
||||
private static final String links[] =
|
||||
{"", // 0
|
||||
@ -31,40 +32,41 @@ public class NetDbHelper extends HelperBase {
|
||||
"?f=1", // 4
|
||||
"?l=2", // 5
|
||||
"?l=1", // 6
|
||||
"?f=3" }; // 7
|
||||
"?f=3", // 7
|
||||
"?f=4" }; // 8
|
||||
|
||||
public void setRouter(String r) {
|
||||
if (r != null)
|
||||
if (r != null && r.length() > 0)
|
||||
_routerPrefix = DataHelper.stripHTML(r); // XSS
|
||||
}
|
||||
|
||||
/** @since 0.9.21 */
|
||||
public void setVersion(String v) {
|
||||
if (v != null)
|
||||
if (v != null && v.length() > 0)
|
||||
_version = DataHelper.stripHTML(v); // XSS
|
||||
}
|
||||
|
||||
/** @since 0.9.21 */
|
||||
public void setCountry(String c) {
|
||||
if (c != null)
|
||||
if (c != null && c.length() > 0)
|
||||
_country = DataHelper.stripHTML(c); // XSS
|
||||
}
|
||||
|
||||
/** @since 0.9.28 */
|
||||
public void setFamily(String c) {
|
||||
if (c != null)
|
||||
if (c != null && c.length() > 0)
|
||||
_family = DataHelper.stripHTML(c); // XSS
|
||||
}
|
||||
|
||||
/** @since 0.9.28 */
|
||||
public void setCaps(String c) {
|
||||
if (c != null)
|
||||
if (c != null && c.length() > 0)
|
||||
_caps = DataHelper.stripHTML(c); // XSS
|
||||
}
|
||||
|
||||
/** @since 0.9.28 */
|
||||
public void setIp(String c) {
|
||||
if (c != null)
|
||||
if (c != null && c.length() > 0)
|
||||
_ip = DataHelper.stripHTML(c); // XSS
|
||||
}
|
||||
|
||||
@ -74,6 +76,14 @@ public class NetDbHelper extends HelperBase {
|
||||
_sybil = DataHelper.stripHTML(c); // XSS
|
||||
}
|
||||
|
||||
/** For form, same as above but with a length check
|
||||
* @since 0.9.28
|
||||
*/
|
||||
public void setSybil2(String c) {
|
||||
if (c != null && c.length() > 0)
|
||||
_sybil = DataHelper.stripHTML(c); // XSS
|
||||
}
|
||||
|
||||
public void setFull(String f) {
|
||||
try {
|
||||
_full = Integer.parseInt(f);
|
||||
@ -108,6 +118,8 @@ public class NetDbHelper extends HelperBase {
|
||||
renderer.renderLeaseSetHTML(_out, _debug);
|
||||
else if (_full == 3)
|
||||
(new SybilRenderer(_context)).getNetDbSummary(_out);
|
||||
else if (_full == 4)
|
||||
renderLookupForm();
|
||||
else
|
||||
renderer.renderStatusHTML(_out, _full);
|
||||
} catch (IOException ioe) {
|
||||
@ -126,7 +138,8 @@ public class NetDbHelper extends HelperBase {
|
||||
return 6;
|
||||
if (".".equals(_routerPrefix))
|
||||
return 1;
|
||||
if (_routerPrefix != null)
|
||||
if (_routerPrefix != null || _version != null || _country != null ||
|
||||
_family != null || _caps != null || _ip != null || _sybil != null)
|
||||
return 2;
|
||||
if (_full == 2)
|
||||
return 3;
|
||||
@ -134,6 +147,8 @@ public class NetDbHelper extends HelperBase {
|
||||
return 4;
|
||||
if (_full == 3)
|
||||
return 7;
|
||||
if (_full == 4)
|
||||
return 8;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -152,7 +167,7 @@ public class NetDbHelper extends HelperBase {
|
||||
for (int i = 0; i < titles.length; i++) {
|
||||
if (i == 2 && tab != 2)
|
||||
continue; // can't nav to lookup
|
||||
if ((i == 5 || i == 7) && !_context.getBooleanProperty(PROP_ADVANCED))
|
||||
if ((i == 5 || i == 7 || i == 8) && !_context.getBooleanProperty(PROP_ADVANCED))
|
||||
continue;
|
||||
if (i == tab) {
|
||||
// we are there
|
||||
@ -175,4 +190,22 @@ public class NetDbHelper extends HelperBase {
|
||||
buf.append("</div>");
|
||||
_out.write(buf.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.28
|
||||
*/
|
||||
private void renderLookupForm() throws IOException {
|
||||
_out.write("<form action=\"/netdb\" method=\"GET\"><p><b>Pick One</b></p>\n" +
|
||||
"Caps <input type=\"text\" name=\"caps\">e.g. f or XOfR<br>\n" +
|
||||
"Country code <input type=\"text\" name=\"c\">e.g. ru<br>\n" +
|
||||
"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" +
|
||||
"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" +
|
||||
"or Sybil close to this router <input type=\"checkbox\" class=\"optbox\" value=\"1\" name=\"sybil\"><br>" +
|
||||
"<p><input type=\"submit\" class=\"search\" value=\"Lookup\"></p>" +
|
||||
"</form>\n");
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class NetDbRenderer {
|
||||
ipMode = 3;
|
||||
}
|
||||
for (int i = 0; i < ipMode; i++) {
|
||||
int last = ip.lastIndexOf('.');
|
||||
int last = ip.substring(0, ip.length() - 1).lastIndexOf('.');
|
||||
if (last > 0)
|
||||
ip = ip.substring(0, last + 1);
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ class SybilRenderer {
|
||||
private static final double POINTS_BAD_VERSION = 50.0;
|
||||
private static final double POINTS_UNREACHABLE = 4.0;
|
||||
private static final double POINTS_NEW = 4.0;
|
||||
private static final double POINTS_BANLIST = 25.0;
|
||||
|
||||
public SybilRenderer(RouterContext ctx) {
|
||||
_context = ctx;
|
||||
@ -638,6 +639,8 @@ class SybilRenderer {
|
||||
RateAverages ra = RateAverages.getTemp();
|
||||
for (RouterInfo info : ris) {
|
||||
Hash h = info.getHash();
|
||||
if (_context.banlist().isBanlisted(h))
|
||||
addPoints(points, h, POINTS_BANLIST, "Banlisted");
|
||||
PeerProfile prof = _context.profileOrganizer().getProfileNonblocking(h);
|
||||
if (prof != null) {
|
||||
long heard = prof.getFirstHeardAbout();
|
||||
|
@ -29,5 +29,6 @@
|
||||
<jsp:setProperty name="netdbHelper" property="caps" value="<%=request.getParameter(\"caps\")%>" />
|
||||
<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:getProperty name="netdbHelper" property="netDbSummary" />
|
||||
</div></div></body></html>
|
||||
|
Reference in New Issue
Block a user