forked from I2P_Developers/i2p.i2p
SusiDNS: Add notes form (ticket #1433)
This commit is contained in:
@ -33,6 +33,7 @@ import net.i2p.crypto.SigType;
|
|||||||
import net.i2p.data.Base32;
|
import net.i2p.data.Base32;
|
||||||
import net.i2p.data.Base64;
|
import net.i2p.data.Base64;
|
||||||
import net.i2p.data.Certificate;
|
import net.i2p.data.Certificate;
|
||||||
|
import net.i2p.data.DataHelper;
|
||||||
|
|
||||||
public class AddressBean
|
public class AddressBean
|
||||||
{
|
{
|
||||||
@ -209,7 +210,7 @@ public class AddressBean
|
|||||||
|
|
||||||
/** @since 0.8.7 */
|
/** @since 0.8.7 */
|
||||||
public String getNotes() {
|
public String getNotes() {
|
||||||
return getProp("notes");
|
return DataHelper.escapeHTML(getProp("notes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +48,7 @@ public class NamingServiceBean extends AddressbookBean
|
|||||||
{
|
{
|
||||||
private static final String DEFAULT_NS = "BlockfileNamingService";
|
private static final String DEFAULT_NS = "BlockfileNamingService";
|
||||||
private String detail;
|
private String detail;
|
||||||
|
private String notes;
|
||||||
|
|
||||||
private boolean isDirect() {
|
private boolean isDirect() {
|
||||||
return getBook().equals("published");
|
return getBook().equals("published");
|
||||||
@ -359,10 +360,64 @@ public class NamingServiceBean extends AddressbookBean
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.35
|
||||||
|
*/
|
||||||
|
public void saveNotes() {
|
||||||
|
if (action == null || !action.equals(_t("Save Notes")) ||
|
||||||
|
destination == null || detail == null || isDirect() ||
|
||||||
|
notes == null ||
|
||||||
|
serial == null || !serial.equals(lastSerial))
|
||||||
|
return;
|
||||||
|
Properties nsOptions = new Properties();
|
||||||
|
List<Properties> propsList = new ArrayList<Properties>(4);
|
||||||
|
nsOptions.setProperty("list", getFileName());
|
||||||
|
List<Destination> dests = getNamingService().lookupAll(detail, nsOptions, propsList);
|
||||||
|
if (dests == null)
|
||||||
|
return;
|
||||||
|
for (int i = 0; i < dests.size(); i++) {
|
||||||
|
if (!dests.get(i).toBase64().equals(destination))
|
||||||
|
continue;
|
||||||
|
Properties props = propsList.get(i);
|
||||||
|
byte[] nbytes = DataHelper.getUTF8(notes);
|
||||||
|
if (nbytes.length > 255) {
|
||||||
|
// violently truncate, possibly splitting a char
|
||||||
|
byte[] newbytes = new byte[255];
|
||||||
|
System.arraycopy(nbytes, 0, newbytes, 0, 255);
|
||||||
|
notes = DataHelper.getUTF8(newbytes);
|
||||||
|
// drop replacement char or split pair
|
||||||
|
int last = notes.length() - 1;
|
||||||
|
char lastc = notes.charAt(last);
|
||||||
|
if (lastc == (char) 0xfffd || Character.isHighSurrogate(lastc))
|
||||||
|
notes = notes.substring(0, last);
|
||||||
|
}
|
||||||
|
props.setProperty("notes", notes);
|
||||||
|
props.setProperty("list", getFileName());
|
||||||
|
String now = Long.toString(_context.clock().now());
|
||||||
|
props.setProperty("m", now);
|
||||||
|
if (dests.size() > 1) {
|
||||||
|
// we don't have any API to update properties on a single dest
|
||||||
|
// so remove and re-add
|
||||||
|
getNamingService().remove(detail, dests.get(i), nsOptions);
|
||||||
|
getNamingService().addDestination(detail, dests.get(i), props);
|
||||||
|
} else {
|
||||||
|
getNamingService().put(detail, dests.get(i), props);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setH(String h) {
|
public void setH(String h) {
|
||||||
this.detail = DataHelper.stripHTML(h);
|
this.detail = DataHelper.stripHTML(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.35
|
||||||
|
*/
|
||||||
|
public void setNofilter_notes(String n) {
|
||||||
|
notes = n;
|
||||||
|
}
|
||||||
|
|
||||||
public AddressBean getLookup() {
|
public AddressBean getLookup() {
|
||||||
if (this.detail == null)
|
if (this.detail == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -73,6 +73,8 @@
|
|||||||
if (detail == null) {
|
if (detail == null) {
|
||||||
%><p>No host specified</p><%
|
%><p>No host specified</p><%
|
||||||
} else {
|
} else {
|
||||||
|
// process save notes form
|
||||||
|
book.saveNotes();
|
||||||
detail = net.i2p.data.DataHelper.stripHTML(detail);
|
detail = net.i2p.data.DataHelper.stripHTML(detail);
|
||||||
java.util.List<i2p.susi.dns.AddressBean> addrs = book.getLookupAll();
|
java.util.List<i2p.susi.dns.AddressBean> addrs = book.getLookupAll();
|
||||||
if (addrs == null) {
|
if (addrs == null) {
|
||||||
@ -85,6 +87,11 @@
|
|||||||
String b32 = addr.getB32();
|
String b32 = addr.getB32();
|
||||||
%>
|
%>
|
||||||
<jsp:setProperty name="book" property="trClass" value="0" />
|
<jsp:setProperty name="book" property="trClass" value="0" />
|
||||||
|
<form method="POST" action="details">
|
||||||
|
<input type="hidden" name="book" value="${book.book}">
|
||||||
|
<input type="hidden" name="serial" value="<%=nonce%>">
|
||||||
|
<input type="hidden" name="h" value="<%=detail%>">
|
||||||
|
<input type="hidden" name="destination" value="<%=addr.getDestination()%>">
|
||||||
<table class="book" id="host_details" cellspacing="0" cellpadding="5">
|
<table class="book" id="host_details" cellspacing="0" cellpadding="5">
|
||||||
<tr class="list${book.trClass}">
|
<tr class="list${book.trClass}">
|
||||||
<td><%=intl._t("Hostname")%></td>
|
<td><%=intl._t("Hostname")%></td>
|
||||||
@ -141,14 +148,16 @@
|
|||||||
<td><%=addr.getModded()%></td>
|
<td><%=addr.getModded()%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="list${book.trClass}">
|
<tr class="list${book.trClass}">
|
||||||
<td><%=intl._t("Notes")%></td>
|
|
||||||
<td><%=addr.getNotes()%></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="list${book.trClass}">
|
|
||||||
<td><%=intl._t("Destination")%></td>
|
<td><%=intl._t("Destination")%></td>
|
||||||
<td class="destinations"><div class="destaddress" tabindex="0"><%=addr.getDestination()%></div></td>
|
<td class="destinations"><div class="destaddress" tabindex="0"><%=addr.getDestination()%></div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="list${book.trClass}">
|
||||||
|
<td><%=intl._t("Notes")%><br>
|
||||||
|
<input class="accept" type="submit" name="action" value="<%=intl._t("Save Notes")%>"></td>
|
||||||
|
<td><textarea name="nofilter_notes" rows="3" style="height:6em" wrap="off" cols="70"><%=addr.getNotes()%></textarea></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
</form>
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<form method="POST" action="addressbook">
|
<form method="POST" action="addressbook">
|
||||||
<p class="buttons">
|
<p class="buttons">
|
||||||
|
17
history.txt
17
history.txt
@ -1,4 +1,21 @@
|
|||||||
|
2018-05-31 zzz
|
||||||
|
* Console:
|
||||||
|
- Fix CSS preventing ordered lists (ticket #2075)
|
||||||
|
- Change Java 10 warning to Java 11,
|
||||||
|
* SusiDNS: Add notes form (ticket #1433)
|
||||||
|
|
||||||
|
2018-05-30 zzz
|
||||||
|
* Debian build fixes, remove things from source package
|
||||||
|
* NTCP: Cleanup, prep for NTCP2, increase max RI size
|
||||||
|
* SusiMail:
|
||||||
|
- Button and CSS fixes
|
||||||
|
- Don't require confirmation to delete from Trash,
|
||||||
|
- Clear reallydelete flag when clicking cancel or change folder
|
||||||
|
- Fix dup ConnectWaiter run, lack of failure message
|
||||||
|
- Fix persistent loading/fetching/refresh messages
|
||||||
|
|
||||||
2018-05-28 zzz
|
2018-05-28 zzz
|
||||||
|
* Console: Tagged string fixes (ticket #2017)
|
||||||
* SusiMail: (ticket #2087)
|
* SusiMail: (ticket #2087)
|
||||||
- Send deletions after connect so emails don't come back after a move
|
- Send deletions after connect so emails don't come back after a move
|
||||||
- Fix fetches in check mail
|
- Fix fetches in check mail
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 15;
|
public final static long BUILD = 16;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user