SusiDNS: Conflicts address book part 2

- Add resolution buttons
- Hide addresshelper column and rows
- Highlight source and added date
- Remove b64 hash line on details page
- Change deletionMarks LinkedList to ArrayList
- Disable on Android
- CSS tweaks
This commit is contained in:
zzz
2026-07-31 10:23:36 -04:00
parent 67b2f73275
commit d0eebb05c3
7 changed files with 116 additions and 13 deletions
@@ -65,6 +65,7 @@ class Daemon {
*/
private static final String RCVD_PROP_PREFIX = "=";
private static final boolean MUST_VALIDATE = false;
private static final boolean ANDROID = SystemVersion.isAndroid();
/**
* Update the router and published address books using remote data from the
@@ -652,7 +653,7 @@ class Daemon {
+ addressbook.getLocation());
invalid++;
}
} else if (action == null && isKnown) {
} else if (!ANDROID && action == null && isKnown) {
if (!oldDest.toBase64().equals(he.getDest())) {
// there could be multiple dests in the router address book, so double check
Properties props = new OrderedProperties();
@@ -805,7 +806,7 @@ class Daemon {
etagsFile, lastModifiedFile, lastFetchedFile,
delay, defaultSubs, settings.get("proxy_host"),
Integer.parseInt(settings.get("proxy_port")));
Log log = SystemVersion.isAndroid() ? null : new Log(logFile);
Log log = ANDROID ? null : new Log(logFile);
// If false, add hosts via naming service; if true, write hosts.txt file directly
// Default false
@@ -31,8 +31,10 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@@ -48,7 +50,7 @@ public class AddressbookBean extends BaseBean
protected int beginIndex, endIndex;
private Properties addressbook;
private int trClass;
protected final LinkedList<String> deletionMarks;
protected final List<String> deletionMarks;
protected static final Comparator<AddressBean> sorter;
private static final int DISPLAY_SIZE = 50;
@@ -93,7 +95,7 @@ public class AddressbookBean extends BaseBean
public AddressbookBean()
{
super();
deletionMarks = new LinkedList<String>();
deletionMarks = new ArrayList<String>();
beginIndex = 0;
endIndex = DISPLAY_SIZE - 1;
}
@@ -457,7 +459,7 @@ public class AddressbookBean extends BaseBean
deletionMarks.clear();
}
public void setMarkedForDeletion( String name ) {
deletionMarks.addLast( DataHelper.stripHTML(name) ); // XSS
deletionMarks.add(DataHelper.stripHTML(name)); // XSS
}
public void setHostname(String hostname) {
this.hostname = DataHelper.stripHTML(hostname).trim(); // XSS
@@ -437,6 +437,50 @@ public class NamingServiceBean extends AddressbookBean
DeletedHosts dh = new DeletedHosts(addressbookDir());
dh.add(deletionMarks);
}
} else if (action.equals(_t("Replace Router Entry"))) {
Destination matchDest = null;
// remove specified dest only in case there is more than one
if (destination != null) {
try {
matchDest = new Destination(destination);
} catch (DataFormatException dfe) {}
}
boolean success = false;
if (matchDest != null && deletionMarks.size() == 1) {
String name = null;
String n = deletionMarks.get(0);
// get stored options
List<Properties> propsList = new ArrayList<Properties>(4);
List<Destination> dests = getNamingService().lookupAll(n, nsOptions, propsList);
if (dests != null) {
int i = dests.indexOf(matchDest);
if (i >= 0) {
Properties sprops = propsList.get(i);
// remove old host.txt entry
nsOptions.setProperty("list", "hosts.txt");
getNamingService().remove(n, matchDest, nsOptions);
// add new host.txt entry with stored options
nsOptions.putAll(sprops);
nsOptions.setProperty("list", "hosts.txt");
success = getNamingService().put(n, matchDest, nsOptions);
if (success) {
// remove conflicts entry
nsOptions.clear();
nsOptions.setProperty("list", "conflicts");
success = getNamingService().remove(n, matchDest, nsOptions);
}
}
}
String uni = AddressBean.toUnicode(n);
String displayHost = uni.equals(n) ? n : uni + " (" + n + ')';
if (!success) {
message += _t("Failed to replace Destination for {0} in naming service {1}", displayHost, getNamingService().getName()) + "<br>";
} else {
message += _t("Replaced Destination for {0} in naming service {1}", displayHost, getNamingService().getName()) + "<br>";
changed = true;
name = displayHost;
}
}
}
if( changed ) {
message += "<br>" + _t("Address book saved.");
+14 -2
View File
@@ -254,7 +254,13 @@ ${book.loadBookMessages}
<% if (book.getEntries().length > 0) { /* Don't show if no results. Can't figure out how to do this with c:if */ %>
<th><%=intl._t("Hostname")%></th>
<th><%=intl._t("Link (b32)")%></th>
<th><%=intl._t("Helper")%></th>
<th>
<%
if (!isConflicts) {
%><%=intl._t("Helper")%><%
}
%>
</th>
<th>
<%
if (isConflicts) {
@@ -296,7 +302,13 @@ ${addr.displayName}
%>
</td>
<td class="names"><span class="addrhlpr"><a href="http://${addr.b32}/" target="_blank" title="<%=intl._t("Base 32 address")%>">b32</a></span></td>
<td class="helper"><a href="http://${addr.name}/?i2paddresshelper=${addr.destination}" target="_blank" title="<%=intl._t("Helper link to share host address with option to add to address book")%>">link</a></td>
<td class="helper">
<%
if (!isConflicts) {
%><a href="http://${addr.name}/?i2paddresshelper=${addr.destination}" target="_blank" title="<%=intl._t("Helper link to share host address with option to add to address book")%>">link</a><%
}
%>
</td>
<td class="names"><span class="addrhlpr"><a href="details?h=${addr.name}&amp;book=${book.book}" title="<%=intl._t("More information on this entry")%>"><%=intl._t("details")%></a></span></td>
<td class="destinations"><div class="destaddress resetScrollLeft" name="dest_${addr.name}" width="200px" tabindex="0">${addr.destination}</div></td>
+42 -5
View File
@@ -143,14 +143,22 @@
<td><%=intl._t("Base 32 Address")%></td>
<td><a href="http://<%=b32%>/" target="_top"><%=b32%></a></td>
</tr>
<%--
<tr class="list${book.trClass}">
<td><%=intl._t("Base 64 Hash")%></td>
<td><%=addr.getB64()%></td>
</tr>
--%>
<%
if (!isConflicts) {
%>
<tr class="list${book.trClass}">
<td><%=intl._t("Address Helper")%></td>
<td><a href="http://<%=addr.getName()%>/?i2paddresshelper=<%=addr.getDestination()%>" target="_top"><%=intl._t("link")%></a></td>
</tr>
<%
}
%>
<%--
<tr class="list${book.trClass}">
<td><%=intl._t("Public Key")%></td>
@@ -172,12 +180,34 @@
<% if (showNotes || isConflicts) { %>
<tr class="list${book.trClass}">
<td><%=intl._t("Source")%></td>
<td><%=addr.getSource()%></td>
</tr>
<td>
<%
String src = addr.getSource();
if (isConflicts) {
%><b><%
src = src.replace("<a ", "<a class=\"conflict\" ");
%><%=src%><%
%></b><%
} else {
%><%=src%><%
}
%>
</td></tr>
<tr class="list${book.trClass}">
<td><%=intl._t("Added Date")%></td>
<td><%=addr.getAdded()%></td>
</tr>
<td>
<%
if (isConflicts) {
%><b><span class="conflict"><%
}
%>
<%=addr.getAdded()%>
<%
if (isConflicts) {
%></span></b><%
}
%>
</td></tr>
<%
String lastmod = addr.getModded();
if (lastmod.length() > 0) {
@@ -205,7 +235,7 @@
<% if (showNotes) { %>
</form>
<% } // showNotes
if (!isConflicts) {
if (!isConflicts || i <= conflictCount) {
%>
<div id="buttons">
<form method="POST" action="addressbook">
@@ -217,6 +247,13 @@
<input type="hidden" name="checked" value="<%=detail%>">
<input type="hidden" name="destination" value="<%=addr.getDestination()%>">
<input class="delete" type="submit" name="action" value="<%=intl._t("Delete Entry")%>" >
<%
if (isConflicts) {
%>
<input class="export" type="submit" name="action" value="<%=intl._t("Replace Router Entry")%>" title="<%=intl._t("Replace the router address book entry with this one")%>" >
<%
} // isConflicts
%>
</p>
</form>
</div><%-- buttons --%>
+4 -1
View File
@@ -452,7 +452,6 @@ div#book p, p.messages {
h4 {
font-size: 9pt;
margin-top: -15px;
word-spacing: 0.1em;
border: 1px solid #292929;
padding: 8px 10px 8px 35px;
@@ -1043,6 +1042,10 @@ p.book {
white-space: normal !important;
}
.conflict {
color: #d80000 !important;
}
/* end host details */
.names img {
@@ -981,6 +981,10 @@ img[src="/imagegen/id?s=256&c="], img[src="/imagegen/id?s=20&c="] {
opacity: 0; /* hide broken identicons but ensure hostlist remains intact */
}
.conflict {
color: #d80000 !important;
}
/* end host details */
/* host list identicons */