propagate from branch 'i2p.i2p' (head 60c5cb17c0406b6e6e547489f9ea8ef3c290e262)

to branch 'i2p.i2p.zzz.jrobin159' (head 330a4f9652fe5f67e6e9998f5c0a87c7ef163764)
This commit is contained in:
zzz
2011-03-21 14:29:03 +00:00
42 changed files with 355 additions and 124 deletions

View File

@ -70,6 +70,7 @@ public class CSSHelper extends HelperBase {
*/
public boolean allowIFrame(String ua) {
return ua == null || !(ua.startsWith("Lynx") || ua.startsWith("w3m") ||
ua.startsWith("ELinks") || ua.startsWith("Dillo"));
ua.startsWith("ELinks") || ua.startsWith("Links") ||
ua.startsWith("Dillo"));
}
}

View File

@ -171,8 +171,10 @@ class ProfileOrganizerRenderer {
buf.append(' ').append(fails).append('/').append(total).append(' ').append(_("Test Fails"));
}
buf.append("&nbsp;</td>");
buf.append("<td nowrap align=\"center\"><a target=\"_blank\" href=\"dumpprofile.jsp?peer=")
.append(peer.toBase64().substring(0,6)).append("\">").append(_("profile")).append("</a>");
//buf.append("<td nowrap align=\"center\"><a target=\"_blank\" href=\"dumpprofile.jsp?peer=")
// .append(peer.toBase64().substring(0,6)).append("\">").append(_("profile")).append("</a>");
buf.append("<td nowrap align=\"center\"><a href=\"viewprofile?peer=")
.append(peer.toBase64()).append("\">").append(_("profile")).append("</a>");
buf.append("&nbsp;<a href=\"configpeer?peer=").append(peer.toBase64()).append("\">+-</a></td>\n");
buf.append("</tr>");
// let's not build the whole page in memory (~500 bytes per peer)

View File

@ -1,37 +1,73 @@
package net.i2p.router.web;
import java.util.Iterator;
import java.io.IOException;
import java.util.Set;
import net.i2p.data.DataFormatException;
import net.i2p.data.Hash;
import net.i2p.router.RouterContext;
/**
* uuuugly. dump the peer profile data if given a peer.
* Dump the peer profile data if given a full B64 peer string or prefix.
*
*/
public class StatHelper extends HelperBase {
private String _peer;
/**
* Caller should strip HTML (XSS)
*/
public void setPeer(String peer) { _peer = peer; }
/**
* Look up based on a b64 prefix or full b64.
* Prefix is inefficient.
*/
public String getProfile() {
RouterContext ctx = (RouterContext)net.i2p.router.RouterContext.listContexts().get(0);
Set peers = ctx.profileOrganizer().selectAllPeers();
for (Iterator iter = peers.iterator(); iter.hasNext(); ) {
Hash peer = (Hash)iter.next();
if (_peer == null || _peer.length() <= 0)
return "No peer specified";
if (_peer.length() >= 44)
return outputProfile();
Set<Hash> peers = _context.profileOrganizer().selectAllPeers();
for (Hash peer : peers) {
if (peer.toBase64().startsWith(_peer)) {
try {
WriterOutputStream wos = new WriterOutputStream(_out);
ctx.profileOrganizer().exportProfile(peer, wos);
wos.flush();
_out.flush();
return "";
} catch (Exception e) {
e.printStackTrace();
}
return dumpProfile(peer);
}
}
return "Unknown";
return "Unknown peer " + _peer;
}
/**
* Look up based on the full b64 - efficient
* @since 0.8.5
*/
private String outputProfile() {
Hash peer = new Hash();
try {
peer.fromBase64(_peer);
return dumpProfile(peer);
} catch (DataFormatException dfe) {
return "Bad peer hash " + _peer;
}
}
/**
* dump the profile
* @since 0.8.5
*/
private String dumpProfile(Hash peer) {
try {
WriterOutputStream wos = new WriterOutputStream(_out);
boolean success = _context.profileOrganizer().exportProfile(peer, wos);
if (success) {
wos.flush();
_out.flush();
return "";
} else {
return "Unknown peer " + _peer;
}
} catch (IOException e) {
e.printStackTrace();
return "IO Error " + e;
}
}
}