From d97908b43038128beac15e7885461916113d09e9 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 23 Apr 2016 16:52:15 +0000 Subject: [PATCH] SusiDNS: Add support for multiple dests per hostname --- .../src/i2p/susi/dns/NamingServiceBean.java | 30 +++++++++++++++++++ apps/susidns/src/jsp/details.jsp | 17 +++++++---- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java b/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java index 0fd3262019..6351764466 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java @@ -24,6 +24,8 @@ package i2p.susi.dns; import java.io.IOException; import java.io.Writer; import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Locale; @@ -356,6 +358,34 @@ public class NamingServiceBean extends AddressbookBean return rv; } + /** + * @since 0.9.26 + */ + public List<AddressBean> getLookupAll() { + if (this.detail == null) + return null; + if (isDirect()) { + // won't work for the published addressbook + AddressBean ab = getLookup(); + if (ab != null) + return Collections.singletonList(ab); + return null; + } + Properties nsOptions = new Properties(); + List<Properties> propsList = new ArrayList<Properties>(4); + nsOptions.setProperty("list", getFileName()); + List<Destination> dests = getNamingService().lookupAll(this.detail, nsOptions, propsList); + if (dests == null) + return null; + List<AddressBean> rv = new ArrayList<AddressBean>(dests.size()); + for (int i = 0; i < dests.size(); i++) { + AddressBean ab = new AddressBean(this.detail, dests.get(i).toBase64()); + ab.setProperties(propsList.get(i)); + rv.add(ab); + } + return rv; + } + /** * @since 0.9.20 */ diff --git a/apps/susidns/src/jsp/details.jsp b/apps/susidns/src/jsp/details.jsp index bf5a3fa436..2fddad5b65 100644 --- a/apps/susidns/src/jsp/details.jsp +++ b/apps/susidns/src/jsp/details.jsp @@ -76,11 +76,12 @@ %><p>No host specified</p><% } else { detail = net.i2p.data.DataHelper.stripHTML(detail); - i2p.susi.dns.AddressBean addr = book.getLookup(); - if (addr == null) { + java.util.List<i2p.susi.dns.AddressBean> addrs = book.getLookupAll(); + if (addrs == null) { %><p>Not found: <%=detail%></p><% } else { - String b32 = addr.getB32(); + for (i2p.susi.dns.AddressBean addr : addrs) { + String b32 = addr.getB32(); %> <jsp:setProperty name="book" property="trClass" value="0" /> <table class="book" cellspacing="0" cellpadding="5"> @@ -146,13 +147,17 @@ <img src="/imagegen/id?s=320&c=<%=addr.getB64().replace("=", "%3d")%>" width="320" height="320"> </td><td> <img src="/imagegen/qr?s=320&t=<%=addr.getName()%>&c=http%3a%2f%2f<%=addr.getName()%>%2f%3fi2paddresshelper%3d<%=addr.getDestination()%>"> -</td></tr></table></div> +</td></tr></table> +<hr> <% - } // addr == null + } // foreach addr +%> +</div> +<% + } // addrs == null } // detail == null %> <div id="footer"> -<hr> <p class="footer">susidns v${version.version} © <a href="${version.url}" target="_top">susi</a> 2005</p> </div> </div> -- GitLab