From d0eebb05c3bf073dee83e57ebfe1c4c995d0ed86 Mon Sep 17 00:00:00 2001 From: zzz Date: Fri, 31 Jul 2026 10:23:36 -0400 Subject: [PATCH] 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 --- .../java/src/net/i2p/addressbook/Daemon.java | 5 +- .../src/i2p/susi/dns/AddressbookBean.java | 8 ++-- .../src/i2p/susi/dns/NamingServiceBean.java | 44 +++++++++++++++++ apps/susidns/src/jsp/addressbook.jsp | 16 ++++++- apps/susidns/src/jsp/details.jsp | 47 +++++++++++++++++-- apps/susidns/src/themes/dark/susidns.css | 5 +- apps/susidns/src/themes/light/susidns.css | 4 ++ 7 files changed, 116 insertions(+), 13 deletions(-) diff --git a/apps/addressbook/java/src/net/i2p/addressbook/Daemon.java b/apps/addressbook/java/src/net/i2p/addressbook/Daemon.java index 46e2ed112..7471353fd 100644 --- a/apps/addressbook/java/src/net/i2p/addressbook/Daemon.java +++ b/apps/addressbook/java/src/net/i2p/addressbook/Daemon.java @@ -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 diff --git a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java index 2916c938d..428aa5798 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java @@ -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 deletionMarks; + protected final List deletionMarks; protected static final Comparator sorter; private static final int DISPLAY_SIZE = 50; @@ -93,7 +95,7 @@ public class AddressbookBean extends BaseBean public AddressbookBean() { super(); - deletionMarks = new LinkedList(); + deletionMarks = new ArrayList(); 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 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 13f7c9574..e42ee2e57 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java @@ -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 propsList = new ArrayList(4); + List 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()) + "
"; + } else { + message += _t("Replaced Destination for {0} in naming service {1}", displayHost, getNamingService().getName()) + "
"; + changed = true; + name = displayHost; + } + } } if( changed ) { message += "
" + _t("Address book saved."); diff --git a/apps/susidns/src/jsp/addressbook.jsp b/apps/susidns/src/jsp/addressbook.jsp index 4ead28afd..8ef522fb9 100644 --- a/apps/susidns/src/jsp/addressbook.jsp +++ b/apps/susidns/src/jsp/addressbook.jsp @@ -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 */ %> <%=intl._t("Hostname")%> <%=intl._t("Link (b32)")%> -<%=intl._t("Helper")%> + +<% + if (!isConflicts) { + %><%=intl._t("Helper")%><% + } +%> + <% if (isConflicts) { @@ -296,7 +302,13 @@ ${addr.displayName} %> ">b32 -">link + +<% + if (!isConflicts) { + %>">link<% + } +%> + "><%=intl._t("details")%>
${addr.destination}
diff --git a/apps/susidns/src/jsp/details.jsp b/apps/susidns/src/jsp/details.jsp index af865a166..5920d33ab 100644 --- a/apps/susidns/src/jsp/details.jsp +++ b/apps/susidns/src/jsp/details.jsp @@ -143,14 +143,22 @@ <%=intl._t("Base 32 Address")%> <%=b32%> +<%-- <%=intl._t("Base 64 Hash")%> <%=addr.getB64()%> +--%> +<% + if (!isConflicts) { +%> <%=intl._t("Address Helper")%> <%=intl._t("link")%> +<% + } +%> <%-- <%=intl._t("Public Key")%> @@ -172,12 +180,34 @@ <% if (showNotes || isConflicts) { %> <%=intl._t("Source")%> -<%=addr.getSource()%> - + +<% + String src = addr.getSource(); + if (isConflicts) { + %><% + src = src.replace("<%=src%><% + %><% + } else { + %><%=src%><% + } +%> + <%=intl._t("Added Date")%> -<%=addr.getAdded()%> - + +<% + if (isConflicts) { + %><% + } +%> +<%=addr.getAdded()%> +<% + if (isConflicts) { + %><% + } +%> + <% String lastmod = addr.getModded(); if (lastmod.length() > 0) { @@ -205,7 +235,7 @@ <% if (showNotes) { %> <% } // showNotes - if (!isConflicts) { + if (!isConflicts || i <= conflictCount) { %>
@@ -217,6 +247,13 @@ " > +<% + if (isConflicts) { +%> +" title="<%=intl._t("Replace the router address book entry with this one")%>" > +<% + } // isConflicts +%>

<%-- buttons --%> diff --git a/apps/susidns/src/themes/dark/susidns.css b/apps/susidns/src/themes/dark/susidns.css index 38c281409..55e3fba05 100644 --- a/apps/susidns/src/themes/dark/susidns.css +++ b/apps/susidns/src/themes/dark/susidns.css @@ -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 { diff --git a/apps/susidns/src/themes/light/susidns.css b/apps/susidns/src/themes/light/susidns.css index 3774b81b4..c14549fed 100644 --- a/apps/susidns/src/themes/light/susidns.css +++ b/apps/susidns/src/themes/light/susidns.css @@ -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 */