- SusiDNS cleanups
- Logging cleanups
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
package net.i2p.addressbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
@ -168,8 +169,11 @@ public class Daemon {
|
||||
if (publishedNS == null)
|
||||
publishedNS = new SingleFileNamingService(I2PAppContext.getGlobalContext(), published.getAbsolutePath());
|
||||
success = publishedNS.putIfAbsent(key, dest);
|
||||
if (!success)
|
||||
log.append("Save to published addressbook " + published.getAbsolutePath() + " failed for new key " + key);
|
||||
if (!success) {
|
||||
try {
|
||||
log.append("Save to published address book " + published.getCanonicalPath() + " failed for new key " + key);
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
if (isTextFile)
|
||||
// keep track for later dup check
|
||||
|
@ -14,7 +14,7 @@ p {
|
||||
}
|
||||
|
||||
span.addrhlpr {
|
||||
font-size:7pt;
|
||||
font-size:8pt;
|
||||
}
|
||||
|
||||
h3 {
|
||||
@ -41,8 +41,7 @@ th {
|
||||
|
||||
color:black;
|
||||
line-height:12pt;
|
||||
margin-left:5mm;
|
||||
margin-right:5mm;
|
||||
padding:5px 10px;
|
||||
font-size:10pt;
|
||||
}
|
||||
|
||||
@ -50,8 +49,7 @@ td {
|
||||
|
||||
color:black;
|
||||
line-height:12pt;
|
||||
margin-left:5mm;
|
||||
margin-right:5mm;
|
||||
padding:5px 10px;
|
||||
font-size:10pt;
|
||||
vertical-align:center;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ ${book.loadBookMessages}
|
||||
</c:if>
|
||||
|
||||
<th><%=intl._("Name")%></th>
|
||||
<th><%=intl._("Links")%></th>
|
||||
<th colspan="2"><%=intl._("Links")%></th>
|
||||
<th><%=intl._("Destination")%></th>
|
||||
</tr>
|
||||
<!-- limit iterator, or "Form too large" may result on submit, and is a huge web page if we don't -->
|
||||
@ -152,8 +152,9 @@ ${book.loadBookMessages}
|
||||
</c:if>
|
||||
<td class="names"><a href="http://${addr.name}/">${addr.displayName}</a>
|
||||
</td><td class="names">
|
||||
<span class="addrhlpr">(<a href="http://${addr.b32}/">b32</a>)</span>
|
||||
<span class="addrhlpr">(<a href="details.jsp?h=${addr.name}"><%=intl._("details")%></a>)</span>
|
||||
<span class="addrhlpr"><a href="http://${addr.b32}/" title="<%=intl._("Base 32 address")%>">b32</a></span>
|
||||
</td><td class="names">
|
||||
<span class="addrhlpr"><a href="details.jsp?h=${addr.name}" title="<%=intl._("More information on this entry")%>"><%=intl._("details")%></a></span>
|
||||
</td>
|
||||
<td class="destinations"><textarea rows="1" style="height: 3em;" cols="40" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td>
|
||||
</tr>
|
||||
@ -180,10 +181,13 @@ ${book.loadBookMessages}
|
||||
|
||||
<div id="add">
|
||||
<h3><%=intl._("Add new destination")%>:</h3>
|
||||
<p class="add">
|
||||
<b><%=intl._("Hostname")%>:</b> <input type="text" name="hostname" value="${book.hostname}" size="20">
|
||||
<b><%=intl._("Destination")%>:</b> <textarea name="destination" rows="1" style="height: 3em;" cols="40" wrap="off" >${book.destination}</textarea><br/>
|
||||
</p><p>
|
||||
<table><tr><td>
|
||||
<b><%=intl._("Host Name")%></b></td><td><input type="text" name="hostname" value="${book.hostname}" size="54">
|
||||
</td></tr><tr><td>
|
||||
<b><%=intl._("Destination")%></b></td><td><textarea name="destination" rows="1" style="height: 3em;" cols="70" wrap="off" spellcheck="false">${book.destination}</textarea>
|
||||
</td></tr></table>
|
||||
<p>
|
||||
<input type="reset" value="<%=intl._("Cancel")%>" >
|
||||
<input type="submit" name="action" value="<%=intl._("Replace")%>" >
|
||||
<input type="submit" name="action" value="<%=intl._("Add")%>" >
|
||||
</p>
|
||||
|
@ -163,7 +163,6 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
info.setProperty(PROP_LISTS, list);
|
||||
hdr.put(PROP_INFO, info);
|
||||
|
||||
// TODO all in one skiplist or separate?
|
||||
int total = 0;
|
||||
for (String hostsfile : getFilenames(list)) {
|
||||
File file = new File(_context.getRouterDir(), hostsfile);
|
||||
@ -171,6 +170,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
continue;
|
||||
int count = 0;
|
||||
BufferedReader in = null;
|
||||
String sourceMsg = "Imported from " + hostsfile + " file";
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"), 16*1024);
|
||||
String line = null;
|
||||
@ -189,8 +189,11 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
String b64 = line.substring(split+1); //.trim() ??????????????
|
||||
Destination d = lookupBase64(b64);
|
||||
if (d != null) {
|
||||
addEntry(rv, hostsfile, key, d, hostsfile);
|
||||
addEntry(rv, hostsfile, key, d, sourceMsg);
|
||||
count++;
|
||||
} else {
|
||||
_log.logAlways(Log.WARN, "Unable to import entry for " + key +
|
||||
" from file " + file + " - bad Base 64: " + b64);
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
|
@ -83,7 +83,7 @@ public abstract class NamingService {
|
||||
result.fromBase64(hostname);
|
||||
return result;
|
||||
} catch (DataFormatException dfe) {
|
||||
if (_log.shouldLog(Log.WARN)) _log.warn("Error translating [" + hostname + "]", dfe);
|
||||
if (_log.shouldLog(Log.WARN)) _log.warn("Bad B64 dest [" + hostname + "]", dfe);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user