- SusiDNS cleanups

- Logging cleanups
This commit is contained in:
zzz
2011-03-29 02:16:42 +00:00
parent 8ae398d786
commit fbfffa9987
5 changed files with 26 additions and 17 deletions

View File

@@ -22,6 +22,7 @@
package net.i2p.addressbook; package net.i2p.addressbook;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@@ -168,8 +169,11 @@ public class Daemon {
if (publishedNS == null) if (publishedNS == null)
publishedNS = new SingleFileNamingService(I2PAppContext.getGlobalContext(), published.getAbsolutePath()); publishedNS = new SingleFileNamingService(I2PAppContext.getGlobalContext(), published.getAbsolutePath());
success = publishedNS.putIfAbsent(key, dest); success = publishedNS.putIfAbsent(key, dest);
if (!success) if (!success) {
log.append("Save to published addressbook " + published.getAbsolutePath() + " failed for new key " + key); try {
log.append("Save to published address book " + published.getCanonicalPath() + " failed for new key " + key);
} catch (IOException ioe) {}
}
} }
if (isTextFile) if (isTextFile)
// keep track for later dup check // keep track for later dup check

View File

@@ -14,7 +14,7 @@ p {
} }
span.addrhlpr { span.addrhlpr {
font-size:7pt; font-size:8pt;
} }
h3 { h3 {
@@ -41,8 +41,7 @@ th {
color:black; color:black;
line-height:12pt; line-height:12pt;
margin-left:5mm; padding:5px 10px;
margin-right:5mm;
font-size:10pt; font-size:10pt;
} }
@@ -50,8 +49,7 @@ td {
color:black; color:black;
line-height:12pt; line-height:12pt;
margin-left:5mm; padding:5px 10px;
margin-right:5mm;
font-size:10pt; font-size:10pt;
vertical-align:center; vertical-align:center;
} }

View File

@@ -141,7 +141,7 @@ ${book.loadBookMessages}
</c:if> </c:if>
<th><%=intl._("Name")%></th> <th><%=intl._("Name")%></th>
<th><%=intl._("Links")%></th> <th colspan="2"><%=intl._("Links")%></th>
<th><%=intl._("Destination")%></th> <th><%=intl._("Destination")%></th>
</tr> </tr>
<!-- limit iterator, or "Form too large" may result on submit, and is a huge web page if we don't --> <!-- 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> </c:if>
<td class="names"><a href="http://${addr.name}/">${addr.displayName}</a> <td class="names"><a href="http://${addr.name}/">${addr.displayName}</a>
</td><td class="names"> </td><td class="names">
<span class="addrhlpr">(<a href="http://${addr.b32}/">b32</a>)</span> <span class="addrhlpr"><a href="http://${addr.b32}/" title="<%=intl._("Base 32 address")%>">b32</a></span>
<span class="addrhlpr">(<a href="details.jsp?h=${addr.name}"><%=intl._("details")%></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>
<td class="destinations"><textarea rows="1" style="height: 3em;" cols="40" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></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> </tr>
@@ -180,10 +181,13 @@ ${book.loadBookMessages}
<div id="add"> <div id="add">
<h3><%=intl._("Add new destination")%>:</h3> <h3><%=intl._("Add new destination")%>:</h3>
<p class="add"> <table><tr><td>
<b><%=intl._("Hostname")%>:</b> <input type="text" name="hostname" value="${book.hostname}" size="20"> <b><%=intl._("Host Name")%></b></td><td><input type="text" name="hostname" value="${book.hostname}" size="54">
<b><%=intl._("Destination")%>:</b> <textarea name="destination" rows="1" style="height: 3em;" cols="40" wrap="off" >${book.destination}</textarea><br/> </td></tr><tr><td>
</p><p> <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._("Replace")%>" >
<input type="submit" name="action" value="<%=intl._("Add")%>" > <input type="submit" name="action" value="<%=intl._("Add")%>" >
</p> </p>

View File

@@ -163,7 +163,6 @@ public class BlockfileNamingService extends DummyNamingService {
info.setProperty(PROP_LISTS, list); info.setProperty(PROP_LISTS, list);
hdr.put(PROP_INFO, info); hdr.put(PROP_INFO, info);
// TODO all in one skiplist or separate?
int total = 0; int total = 0;
for (String hostsfile : getFilenames(list)) { for (String hostsfile : getFilenames(list)) {
File file = new File(_context.getRouterDir(), hostsfile); File file = new File(_context.getRouterDir(), hostsfile);
@@ -171,6 +170,7 @@ public class BlockfileNamingService extends DummyNamingService {
continue; continue;
int count = 0; int count = 0;
BufferedReader in = null; BufferedReader in = null;
String sourceMsg = "Imported from " + hostsfile + " file";
try { try {
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"), 16*1024); in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"), 16*1024);
String line = null; String line = null;
@@ -189,8 +189,11 @@ public class BlockfileNamingService extends DummyNamingService {
String b64 = line.substring(split+1); //.trim() ?????????????? String b64 = line.substring(split+1); //.trim() ??????????????
Destination d = lookupBase64(b64); Destination d = lookupBase64(b64);
if (d != null) { if (d != null) {
addEntry(rv, hostsfile, key, d, hostsfile); addEntry(rv, hostsfile, key, d, sourceMsg);
count++; count++;
} else {
_log.logAlways(Log.WARN, "Unable to import entry for " + key +
" from file " + file + " - bad Base 64: " + b64);
} }
} }
} catch (IOException ioe) { } catch (IOException ioe) {

View File

@@ -83,7 +83,7 @@ public abstract class NamingService {
result.fromBase64(hostname); result.fromBase64(hostname);
return result; return result;
} catch (DataFormatException dfe) { } 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; return null;
} }
} }