I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit cd4d5a39 authored by zzz's avatar zzz
Browse files

Console: Add netdb lookup by family

parent 7a1a1d5b
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ public class NetDbHelper extends HelperBase {
private String _routerPrefix;
private String _version;
private String _country;
private String _family;
private int _full;
private boolean _lease;
private boolean _debug;
......@@ -49,6 +50,12 @@ public class NetDbHelper extends HelperBase {
_country = DataHelper.stripHTML(c); // XSS
}
/** @since 0.9.28 */
public void setFamily(String c) {
if (c != null)
_family = DataHelper.stripHTML(c); // XSS
}
public void setFull(String f) {
try {
_full = Integer.parseInt(f);
......@@ -75,8 +82,8 @@ public class NetDbHelper extends HelperBase {
NetDbRenderer renderer = new NetDbRenderer(_context);
try {
renderNavBar();
if (_routerPrefix != null || _version != null || _country != null)
renderer.renderRouterInfoHTML(_out, _routerPrefix, _version, _country);
if (_routerPrefix != null || _version != null || _country != null || _family != null)
renderer.renderRouterInfoHTML(_out, _routerPrefix, _version, _country, _family);
else if (_lease)
renderer.renderLeaseSetHTML(_out, _debug);
else if (_full == 3)
......
......@@ -85,8 +85,10 @@ class NetDbRenderer {
* @param routerPrefix may be null. "." for our router only
* @param version may be null
* @param country may be null
* @param family may be null
*/
public void renderRouterInfoHTML(Writer out, String routerPrefix, String version, String country) throws IOException {
public void renderRouterInfoHTML(Writer out, String routerPrefix, String version,
String country, String family) throws IOException {
StringBuilder buf = new StringBuilder(4*1024);
if (".".equals(routerPrefix)) {
renderRouterInfo(buf, _context.router().getRouterInfo(), true, true);
......@@ -97,7 +99,8 @@ class NetDbRenderer {
Hash key = ri.getIdentity().getHash();
if ((routerPrefix != null && key.toBase64().startsWith(routerPrefix)) ||
(version != null && version.equals(ri.getVersion())) ||
(country != null && country.equals(_context.commSystem().getCountry(key)))) {
(country != null && country.equals(_context.commSystem().getCountry(key))) ||
(family != null && family.equals(ri.getOption("family")))) {
renderRouterInfo(buf, ri, false, true);
notFound = false;
}
......@@ -110,6 +113,8 @@ class NetDbRenderer {
buf.append(version);
else if (country != null)
buf.append(country);
else if (family != null)
buf.append(_t("Family")).append(' ').append(family);
buf.append(' ').append(_t("not found in network database"));
}
}
......
......@@ -588,8 +588,9 @@ class SybilRenderer {
boolean found = false;
for (String s : foo) {
int count = oc.count(s);
buf.append("<p><b>").append(count).append(" floodfills in declared family \"").append(DataHelper.escapeHTML(s) + '"')
.append("</b></p>");
String ss = DataHelper.escapeHTML(s);
buf.append("<p><b>").append(count).append(" floodfills in declared family \"<a href=\"/netdb?fam=")
.append(ss).append("\">").append(ss).append("</a>\"</b></p>");
for (RouterInfo info : ris) {
String fam = info.getOption("family");
if (fam == null)
......
......@@ -25,5 +25,6 @@
<jsp:setProperty name="netdbHelper" property="lease" value="<%=request.getParameter(\"l\")%>" />
<jsp:setProperty name="netdbHelper" property="version" value="<%=request.getParameter(\"v\")%>" />
<jsp:setProperty name="netdbHelper" property="country" value="<%=request.getParameter(\"c\")%>" />
<jsp:setProperty name="netdbHelper" property="family" value="<%=request.getParameter(\"fam\")%>" />
<jsp:getProperty name="netdbHelper" property="netDbSummary" />
</div></div></body></html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment