forked from I2P_Developers/i2p.i2p
i2ptunnel: New form to enter private key file for alternate destination
- Use alt destination for registration if set - Another dup check for alt destination SusiDNS: New button for adding alternate destination - Fix nonces on details page with multiple destinations - Fix single dest deletion on details page with multiple destinations - Set book in all forms to ensure correct book Blockfile: Fix specified-destination deletion from the correct book
This commit is contained in:
@@ -314,6 +314,9 @@ public class AddressbookBean extends BaseBean
|
||||
}
|
||||
if (action.equals(_t("Delete Entry")))
|
||||
search = null;
|
||||
} else if (action.equals(_t("Add Alternate"))) {
|
||||
// button won't be in UI
|
||||
message = "Unsupported";
|
||||
}
|
||||
if( changed ) {
|
||||
try {
|
||||
|
@@ -231,7 +231,7 @@ public class NamingServiceBean extends AddressbookBean
|
||||
if (_context.getBooleanProperty(PROP_PW_ENABLE) ||
|
||||
(serial != null && serial.equals(lastSerial))) {
|
||||
boolean changed = false;
|
||||
if (action.equals(_t("Add")) || action.equals(_t("Replace"))) {
|
||||
if (action.equals(_t("Add")) || action.equals(_t("Replace")) || action.equals(_t("Add Alternate"))) {
|
||||
if(hostname != null && destination != null) {
|
||||
try {
|
||||
// throws IAE with translated message
|
||||
@@ -243,20 +243,38 @@ public class NamingServiceBean extends AddressbookBean
|
||||
Destination oldDest = getNamingService().lookup(host, nsOptions, outProperties);
|
||||
if (oldDest != null && destination.equals(oldDest.toBase64())) {
|
||||
message = _t("Host name {0} is already in address book, unchanged.", displayHost);
|
||||
} else if (oldDest != null && !action.equals(_t("Replace"))) {
|
||||
} else if (oldDest == null && action.equals(_t("Add Alternate"))) {
|
||||
message = _t("Host name {0} is not in the address book.", displayHost);
|
||||
} else if (oldDest != null && action.equals(_t("Add"))) {
|
||||
message = _t("Host name {0} is already in address book with a different destination. Click \"Replace\" to overwrite.", displayHost);
|
||||
} else {
|
||||
try {
|
||||
Destination dest = new Destination(destination);
|
||||
if (oldDest != null) {
|
||||
nsOptions.putAll(outProperties);
|
||||
nsOptions.setProperty("m", Long.toString(_context.clock().now()));
|
||||
String now = Long.toString(_context.clock().now());
|
||||
if (action.equals(_t("Add Alternate")))
|
||||
nsOptions.setProperty("a", now);
|
||||
else
|
||||
nsOptions.setProperty("m", now);
|
||||
}
|
||||
nsOptions.setProperty("s", _t("Manually added via SusiDNS"));
|
||||
boolean success = getNamingService().put(host, dest, nsOptions);
|
||||
boolean success;
|
||||
if (action.equals(_t("Add Alternate"))) {
|
||||
// check all for dups
|
||||
List<Destination> all = getNamingService().lookupAll(host);
|
||||
if (all == null || !all.contains(dest)) {
|
||||
success = getNamingService().addDestination(host, dest, nsOptions);
|
||||
} else {
|
||||
// will get generic message below
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
success = getNamingService().put(host, dest, nsOptions);
|
||||
}
|
||||
if (success) {
|
||||
changed = true;
|
||||
if (oldDest == null)
|
||||
if (oldDest == null || action.equals(_t("Add Alternate")))
|
||||
message = _t("Destination added for {0}.", displayHost);
|
||||
else
|
||||
message = _t("Destination changed for {0}.", displayHost);
|
||||
@@ -285,8 +303,21 @@ public class NamingServiceBean extends AddressbookBean
|
||||
} else if (action.equals(_t("Delete Selected")) || action.equals(_t("Delete Entry"))) {
|
||||
String name = null;
|
||||
int deleted = 0;
|
||||
Destination matchDest = null;
|
||||
if (action.equals(_t("Delete Entry"))) {
|
||||
// remove specified dest only in case there is more than one
|
||||
if (destination != null) {
|
||||
try {
|
||||
matchDest = new Destination(destination);
|
||||
} catch (DataFormatException dfe) {}
|
||||
}
|
||||
}
|
||||
for (String n : deletionMarks) {
|
||||
boolean success = getNamingService().remove(n, nsOptions);
|
||||
boolean success;
|
||||
if (matchDest != null)
|
||||
success = getNamingService().remove(n, matchDest, nsOptions);
|
||||
else
|
||||
success = getNamingService().remove(n, nsOptions);
|
||||
String uni = AddressBean.toUnicode(n);
|
||||
String displayHost = uni.equals(n) ? n : uni + " (" + n + ')';
|
||||
if (!success) {
|
||||
|
@@ -120,6 +120,7 @@ ${book.loadBookMessages}
|
||||
|
||||
<div id="search">
|
||||
<form method="POST" action="addressbook">
|
||||
<input type="hidden" name="book" value="${book.book}">
|
||||
<input type="hidden" name="begin" value="0">
|
||||
<input type="hidden" name="end" value="49">
|
||||
<table><tr>
|
||||
@@ -136,6 +137,7 @@ ${book.loadBookMessages}
|
||||
%>
|
||||
<c:if test="${book.notEmpty}">
|
||||
<form method="POST" action="addressbook">
|
||||
<input type="hidden" name="book" value="${book.book}">
|
||||
<input type="hidden" name="serial" value="<%=susiNonce%>">
|
||||
<input type="hidden" name="begin" value="0">
|
||||
<input type="hidden" name="end" value="49">
|
||||
@@ -163,7 +165,7 @@ ${book.loadBookMessages}
|
||||
</td><td class="names">
|
||||
<span class="addrhlpr"><a href="http://${addr.b32}/" target="_top" title="<%=intl._t("Base 32 address")%>">b32</a></span>
|
||||
</td><td class="names">
|
||||
<span class="addrhlpr"><a href="details?h=${addr.name}" title="<%=intl._t("More information on this entry")%>"><%=intl._t("details")%></a></span>
|
||||
<span class="addrhlpr"><a href="details?h=${addr.name}&book=${book.book}" title="<%=intl._t("More information on this entry")%>"><%=intl._t("details")%></a></span>
|
||||
</td>
|
||||
<td class="destinations"><textarea rows="1" style="height:3em;" wrap="off" cols="40" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td>
|
||||
</tr>
|
||||
@@ -208,6 +210,7 @@ ${book.loadBookMessages}
|
||||
</c:if>
|
||||
|
||||
<form method="POST" action="addressbook">
|
||||
<input type="hidden" name="book" value="${book.book}">
|
||||
<input type="hidden" name="serial" value="<%=susiNonce%>">
|
||||
<input type="hidden" name="begin" value="0">
|
||||
<input type="hidden" name="end" value="49">
|
||||
@@ -221,6 +224,9 @@ ${book.loadBookMessages}
|
||||
<p class="buttons">
|
||||
<input class="cancel" type="reset" value="<%=intl._t("Cancel")%>" >
|
||||
<input class="accept" type="submit" name="action" value="<%=intl._t("Replace")%>" >
|
||||
<% if (!book.getBook().equals("published")) { %>
|
||||
<input class="add" type="submit" name="action" value="<%=intl._t("Add Alternate")%>" >
|
||||
<% } %>
|
||||
<input class="add" type="submit" name="action" value="<%=intl._t("Add")%>" >
|
||||
</p>
|
||||
</div></form>
|
||||
|
@@ -81,6 +81,8 @@
|
||||
if (addrs == null) {
|
||||
%><p>Not found: <%=detail%></p><%
|
||||
} else {
|
||||
// use one nonce for all
|
||||
String nonce = book.getSerial();
|
||||
for (i2p.susi.dns.AddressBean addr : addrs) {
|
||||
String b32 = addr.getB32();
|
||||
%>
|
||||
@@ -139,10 +141,12 @@
|
||||
<div id="buttons">
|
||||
<form method="POST" action="addressbook">
|
||||
<p class="buttons">
|
||||
<input type="hidden" name="serial" value="${book.serial}">
|
||||
<input type="hidden" name="book" value="${book.book}">
|
||||
<input type="hidden" name="serial" value="<%=nonce%>">
|
||||
<input type="hidden" name="begin" value="0">
|
||||
<input type="hidden" name="end" value="49">
|
||||
<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")%>" >
|
||||
</p>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user