forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head 60c5cb17c0406b6e6e547489f9ea8ef3c290e262)
to branch 'i2p.i2p.zzz.jrobin159' (head 330a4f9652fe5f67e6e9998f5c0a87c7ef163764)
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
<manifest>
|
||||
<attribute name="Build-Date" value="${build.timestamp}" />
|
||||
<attribute name="Base-Revision" value="${workspace.version}" />
|
||||
<attribute name="Workspace-Changes" value="${workspace.changes}" />
|
||||
<attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
|
||||
</manifest>
|
||||
</war>
|
||||
</target>
|
||||
|
||||
@@ -426,6 +426,10 @@ public class PeerCoordinator implements PeerListener
|
||||
_log.info("New connection to peer: " + peer + " for " + name);
|
||||
}
|
||||
|
||||
// We may have gotten the metainfo after the peer was created.
|
||||
if (metainfo != null)
|
||||
peer.setMetaInfo(metainfo);
|
||||
|
||||
// Add it to the beginning of the list.
|
||||
// And try to optimistically make it a uploader.
|
||||
// Can't add to beginning since we converted from a List to a Queue
|
||||
|
||||
@@ -496,10 +496,14 @@ class PeerState implements DataLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch from magnet mode to normal mode
|
||||
* Switch from magnet mode to normal mode.
|
||||
* If we already have the metainfo, this does nothing.
|
||||
* @param meta non-null
|
||||
* @since 0.8.4
|
||||
*/
|
||||
public void setMetaInfo(MetaInfo meta) {
|
||||
if (metainfo != null)
|
||||
return;
|
||||
BitField oldBF = bitfield;
|
||||
if (oldBF != null) {
|
||||
if (oldBF.size() != meta.getPieces())
|
||||
@@ -511,7 +515,7 @@ class PeerState implements DataLoader
|
||||
//bitfield = new BitField(meta.getPieces());
|
||||
}
|
||||
metainfo = meta;
|
||||
if (bitfield.count() > 0)
|
||||
if (bitfield != null && bitfield.count() > 0)
|
||||
setInteresting(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -351,7 +351,8 @@ public class I2PSnarkServlet extends Default {
|
||||
// Using a unique name fixes Opera, except for the buttons with js confirms, see below
|
||||
String ua = req.getHeader("User-Agent");
|
||||
boolean isDegraded = ua != null && (ua.startsWith("Lynx") || ua.startsWith("w3m") ||
|
||||
ua.startsWith("ELinks") || ua.startsWith("Dillo"));
|
||||
ua.startsWith("ELinks") || ua.startsWith("Links") ||
|
||||
ua.startsWith("Dillo"));
|
||||
|
||||
boolean noThinsp = isDegraded || (ua != null && ua.startsWith("Opera"));
|
||||
if (_manager.util().connected()) {
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean" %><%
|
||||
<%
|
||||
// NOTE: Do the header carefully so there is no whitespace before the <?xml... line
|
||||
|
||||
%><%@page pageEncoding="UTF-8"
|
||||
%><%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean"
|
||||
%><%
|
||||
String tun = request.getParameter("tunnel");
|
||||
if (tun != null) {
|
||||
try {
|
||||
int curTunnel = Integer.parseInt(tun);
|
||||
if (EditBean.staticIsClient(curTunnel)) {
|
||||
%><jsp:include page="editClient.jsp" /><%
|
||||
%><jsp:include page="editClient.jsp" /><%
|
||||
} else {
|
||||
%><jsp:include page="editServer.jsp" /><%
|
||||
%><jsp:include page="editServer.jsp" /><%
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
%>Invalid tunnel parameter<%
|
||||
@@ -16,9 +20,9 @@ String tun = request.getParameter("tunnel");
|
||||
String type = request.getParameter("type");
|
||||
int curTunnel = -1;
|
||||
if (EditBean.isClient(type)) {
|
||||
%><jsp:include page="editClient.jsp" /><%
|
||||
%><jsp:include page="editClient.jsp" /><%
|
||||
} else {
|
||||
%><jsp:include page="editServer.jsp" /><%
|
||||
%><jsp:include page="editServer.jsp" /><%
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
</label>
|
||||
<textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off" spellcheck="false"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
|
||||
<% if (!"".equals(editBean.getDestinationBase64(curTunnel))) { %>
|
||||
<a href="/susidns/addressbook.jsp?book=private&hostname=<%=editBean.getTunnelName(curTunnel)%>&destination=<%=editBean.getDestinationBase64(curTunnel)%>#add"><%=intl._("Add to local addressbook")%></a>
|
||||
<a href="/susidns/addressbook.jsp?book=private&hostname=<%=editBean.getTunnelName(curTunnel)%>&destination=<%=editBean.getDestinationBase64(curTunnel)%>#add"><%=intl._("Add to local addressbook")%></a>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
@@ -340,7 +340,7 @@
|
||||
<label for="force" accesskey="c">
|
||||
<%=intl._("Generate New Key")%>:
|
||||
</label>
|
||||
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Generate" title="Generate New Key Now"><%=intl._("Generate")%></button>
|
||||
<button accesskey="S" class="control" type="submit" name="action" value="Generate" title="Generate New Key Now"><%=intl._("Generate")%></button>
|
||||
<span class="comment"><%=intl._("(Tunnel must be stopped first)")%></span>
|
||||
</div>
|
||||
|
||||
@@ -374,7 +374,7 @@
|
||||
|
||||
<div class="rowItem">
|
||||
<div id="optionsField" class="rowItem">
|
||||
<label><%=intl._("Inbound connection limits (0=unlimited)")%><br><%=intl._("Per client")%>:</label>
|
||||
<label><%=intl._("Inbound connection limits (0=unlimited)")%><br /><%=intl._("Per client")%>:</label>
|
||||
</div>
|
||||
<div id="portField" class="rowItem">
|
||||
<label><%=intl._("Per minute")%>:</label>
|
||||
@@ -453,7 +453,6 @@
|
||||
<div id="portField" class="rowItem">
|
||||
<label><%=intl._("None")%></label>
|
||||
<input value="0" type="radio" id="startOnLoad" name="cert" title="No Certificate"<%=(editBean.getCert(curTunnel)==0 ? " checked=\"checked\"" : "")%> class="tickbox" />
|
||||
<span class="comment"></span>
|
||||
</div>
|
||||
<div id="portField" class="rowItem">
|
||||
<label><%=intl._("Hashcash (effort)")%></label>
|
||||
@@ -465,13 +464,12 @@
|
||||
<label for="force" accesskey="c">
|
||||
<%=intl._("Hashcash Calc Time")%>:
|
||||
</label>
|
||||
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Estimate" title="Estimate Calculation Time"><%=intl._("Estimate")%></button>
|
||||
<button accesskey="S" class="control" type="submit" name="action" value="Estimate" title="Estimate Calculation Time"><%=intl._("Estimate")%></button>
|
||||
</div>
|
||||
<div id="hostField" class="rowItem">
|
||||
<div id="portField" class="rowItem">
|
||||
<label><%=intl._("Hidden")%></label>
|
||||
<input value="2" type="radio" id="startOnLoad" name="cert" title="Hidden Certificate"<%=(editBean.getCert(curTunnel)==2 ? " checked=\"checked\"" : "")%> class="tickbox" />
|
||||
<span class="comment"></span>
|
||||
</div>
|
||||
<div id="portField" class="rowItem">
|
||||
<label for="signer" accesskey="c">
|
||||
@@ -479,14 +477,13 @@
|
||||
</label>
|
||||
<input value="3" type="radio" id="startOnLoad" name="cert" title="Signed Certificate"<%=(editBean.getCert(curTunnel)==3 ? " checked=\"checked\"" : "")%> class="tickbox" />
|
||||
<input type="text" id="port" name="signer" size="50" title="Cert Signer" value="<%=editBean.getSigner(curTunnel)%>" class="freetext" />
|
||||
<span class="comment"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="portField" class="rowItem">
|
||||
<label for="force" accesskey="c">
|
||||
<%=intl._("Modify Certificate")%>:
|
||||
</label>
|
||||
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Modify" title="Force New Cert Now"><%=intl._("Modify")%></button>
|
||||
<button accesskey="S" class="control" type="submit" name="action" value="Modify" title="Force New Cert Now"><%=intl._("Modify")%></button>
|
||||
<span class="comment"><%=intl._("(Tunnel must be stopped first)")%></span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<%
|
||||
// NOTE: Do the header carefully so there is no whitespace before the <?xml... line
|
||||
|
||||
// http://www.crazysquirrel.com/computing/general/form-encoding.jspx
|
||||
if (request.getCharacterEncoding() == null)
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
%>
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.IndexBean"%><?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
%><%@page pageEncoding="UTF-8"
|
||||
%><%@page contentType="text/html" import="net.i2p.i2ptunnel.web.IndexBean"
|
||||
%><?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<jsp:useBean class="net.i2p.i2ptunnel.web.IndexBean" id="indexBean" scope="request" />
|
||||
<jsp:setProperty name="indexBean" property="*" />
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,8 +171,10 @@ class ProfileOrganizerRenderer {
|
||||
buf.append(' ').append(fails).append('/').append(total).append(' ').append(_("Test Fails"));
|
||||
}
|
||||
buf.append(" </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(" <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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
if (request.getCharacterEncoding() == null)
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Cache-Control","no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
// Now that we use POST for most forms, these prevent the back button from working after a form submit
|
||||
// Just let the browser do its thing
|
||||
//response.setHeader("Pragma", "no-cache");
|
||||
//response.setHeader("Cache-Control","no-cache");
|
||||
//response.setDateHeader("Expires", 0);
|
||||
|
||||
// the above will b0rk if the servlet engine has already flushed
|
||||
// the response prior to including this file, so it should be
|
||||
// near the top
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<%@page contentType="text/plain"
|
||||
%><jsp:useBean id="helper" class="net.i2p.router.web.StatHelper"
|
||||
/><jsp:setProperty name="helper" property="peer" value="<%=request.getParameter("peer")%>"
|
||||
/><jsp:setProperty name="helper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>"
|
||||
/><jsp:setProperty name="helper" property="peer" value="<%=net.i2p.data.DataHelper.stripHTML(request.getParameter("peer"))%>"
|
||||
/><% helper.storeWriter(out);
|
||||
%><jsp:getProperty name="helper" property="profile" />
|
||||
|
||||
30
apps/routerconsole/jsp/viewprofile.jsp
Normal file
30
apps/routerconsole/jsp/viewprofile.jsp
Normal file
@@ -0,0 +1,30 @@
|
||||
<%@page contentType="text/html"%>
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html><head>
|
||||
<%@include file="css.jsi" %>
|
||||
<%=intl.title("Peer Profile")%>
|
||||
</head><body>
|
||||
<%@include file="summary.jsi" %>
|
||||
<h1><%=intl._("Peer Profile")%></h1>
|
||||
<div class="main" id="main"><div class="wideload">
|
||||
<%
|
||||
String peerB64 = request.getParameter("peer");
|
||||
if (peerB64 == null || peerB64.length() <= 0) {
|
||||
out.print("No peer specified");
|
||||
} else {
|
||||
peerB64 = net.i2p.data.DataHelper.stripHTML(peerB64); // XSS
|
||||
%>
|
||||
<jsp:useBean id="stathelper" class="net.i2p.router.web.StatHelper" />
|
||||
<jsp:setProperty name="stathelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
|
||||
<jsp:setProperty name="stathelper" property="peer" value="<%=peerB64%>" />
|
||||
<% stathelper.storeWriter(out); %>
|
||||
<h2><%=intl._("Profile for peer {0}", peerB64)%></h2>
|
||||
<pre>
|
||||
<jsp:getProperty name="stathelper" property="profile" />
|
||||
</pre>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</div></div></body></html>
|
||||
Reference in New Issue
Block a user