forked from I2P_Developers/i2p.i2p
SusiDNS: Add support for multiple dests per hostname
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user