forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head 36bd43007b45f4b59b1dc14a2cb02b06c9e7fa84)
to branch 'i2p.i2p.zzz.dhtsnark' (head 2960be09b366cb629d254d72f0654ff9ecc0133b)
This commit is contained in:
@ -107,6 +107,17 @@ public class I2PSnarkServlet extends Default {
|
|||||||
return _resourceBase.addPath(pathInContext);
|
return _resourceBase.addPath(pathInContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the browser to cache the icons
|
||||||
|
* @since 0.8.3
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void handleGet(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource, boolean endsWithSlash) throws ServletException, IOException {
|
||||||
|
if (resource.getName().startsWith("jar:file:"))
|
||||||
|
response.setHeader("Cache-Control", "max-age=86400"); // cache for a day
|
||||||
|
super.handleGet(request, response, pathInContext, resource, endsWithSlash);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some parts modified from:
|
* Some parts modified from:
|
||||||
* <pre>
|
* <pre>
|
||||||
|
@ -9,7 +9,7 @@ msgstr ""
|
|||||||
"Project-Id-Version: I2P i2psnark\n"
|
"Project-Id-Version: I2P i2psnark\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2010-12-19 03:16+0000\n"
|
"POT-Creation-Date: 2010-12-19 03:16+0000\n"
|
||||||
"PO-Revision-Date: 2010-12-28 00:36+0100\n"
|
"PO-Revision-Date: 2010-12-31 01:09+0100\n"
|
||||||
"Last-Translator: mixxy <m1xxy@mail.i2p>\n"
|
"Last-Translator: mixxy <m1xxy@mail.i2p>\n"
|
||||||
"Language-Team: foo <foo@bar>\n"
|
"Language-Team: foo <foo@bar>\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@ -453,7 +453,7 @@ msgstr "completo"
|
|||||||
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:787
|
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:787
|
||||||
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:792
|
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:792
|
||||||
msgid "OK"
|
msgid "OK"
|
||||||
msgstr "Bien"
|
msgstr "bien"
|
||||||
|
|
||||||
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:796
|
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:796
|
||||||
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:801
|
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:801
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@ msgstr ""
|
|||||||
"Project-Id-Version: I2P i2psnark\n"
|
"Project-Id-Version: I2P i2psnark\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2010-12-19 03:16+0000\n"
|
"POT-Creation-Date: 2010-12-19 03:16+0000\n"
|
||||||
"PO-Revision-Date: 2010-12-29 16:29+0100\n"
|
"PO-Revision-Date: 2010-12-31 01:09+0100\n"
|
||||||
"Last-Translator: mixxy <m1xxy@mail.i2p>\n"
|
"Last-Translator: mixxy <m1xxy@mail.i2p>\n"
|
||||||
"Language-Team: foo <foo@bar>\n"
|
"Language-Team: foo <foo@bar>\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@ -453,7 +453,7 @@ msgstr "completo"
|
|||||||
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:787
|
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:787
|
||||||
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:792
|
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:792
|
||||||
msgid "OK"
|
msgid "OK"
|
||||||
msgstr "Bem"
|
msgstr "bem"
|
||||||
|
|
||||||
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:796
|
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:796
|
||||||
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:801
|
#: ../java/src/org/klomp/snark/web/I2PSnarkServlet.java:801
|
||||||
|
@ -22,6 +22,7 @@ import net.i2p.util.ShellCommand;
|
|||||||
|
|
||||||
import org.mortbay.http.DigestAuthenticator;
|
import org.mortbay.http.DigestAuthenticator;
|
||||||
import org.mortbay.http.HashUserRealm;
|
import org.mortbay.http.HashUserRealm;
|
||||||
|
import org.mortbay.http.NCSARequestLog;
|
||||||
import org.mortbay.http.SecurityConstraint;
|
import org.mortbay.http.SecurityConstraint;
|
||||||
import org.mortbay.http.SslListener;
|
import org.mortbay.http.SslListener;
|
||||||
import org.mortbay.http.handler.SecurityHandler;
|
import org.mortbay.http.handler.SecurityHandler;
|
||||||
@ -141,6 +142,18 @@ public class RouterConsoleRunner {
|
|||||||
// so Jetty can find WebAppConfiguration
|
// so Jetty can find WebAppConfiguration
|
||||||
System.setProperty("jetty.class.path", I2PAppContext.getGlobalContext().getBaseDir() + "/lib/routerconsole.jar");
|
System.setProperty("jetty.class.path", I2PAppContext.getGlobalContext().getBaseDir() + "/lib/routerconsole.jar");
|
||||||
_server = new Server();
|
_server = new Server();
|
||||||
|
|
||||||
|
String log = I2PAppContext.getGlobalContext().getProperty("routerconsole.log");
|
||||||
|
if (log != null) {
|
||||||
|
File logFile = new File(log);
|
||||||
|
if (!logFile.isAbsolute())
|
||||||
|
logFile = new File(I2PAppContext.getGlobalContext().getLogDir(), "logs/" + log);
|
||||||
|
try {
|
||||||
|
_server.setRequestLog(new NCSARequestLog(logFile.getAbsolutePath()));
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
System.err.println("ERROR: Unable to create Jetty log: " + ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
boolean rewrite = false;
|
boolean rewrite = false;
|
||||||
Properties props = webAppProperties();
|
Properties props = webAppProperties();
|
||||||
if (props.isEmpty()) {
|
if (props.isEmpty()) {
|
||||||
|
@ -174,7 +174,7 @@ details on other applications available, as well as their licenses, please see t
|
|||||||
client applications can be found on our <a href="http://www.i2p2.i2p/download">download page</a>.
|
client applications can be found on our <a href="http://www.i2p2.i2p/download">download page</a>.
|
||||||
.</p>
|
.</p>
|
||||||
|
|
||||||
<h2>Release history</h2>
|
<h2>Change Log</h2>
|
||||||
<jsp:useBean class="net.i2p.router.web.ContentHelper" id="contenthelper" scope="request" />
|
<jsp:useBean class="net.i2p.router.web.ContentHelper" id="contenthelper" scope="request" />
|
||||||
<% java.io.File fpath = new java.io.File(net.i2p.I2PAppContext.getGlobalContext().getBaseDir(), "history.txt"); %>
|
<% java.io.File fpath = new java.io.File(net.i2p.I2PAppContext.getGlobalContext().getBaseDir(), "history.txt"); %>
|
||||||
<jsp:setProperty name="contenthelper" property="page" value="<%=fpath.getAbsolutePath()%>" />
|
<jsp:setProperty name="contenthelper" property="page" value="<%=fpath.getAbsolutePath()%>" />
|
||||||
@ -182,6 +182,5 @@ client applications can be found on our <a href="http://www.i2p2.i2p/download">d
|
|||||||
<jsp:setProperty name="contenthelper" property="startAtBeginning" value="true" />
|
<jsp:setProperty name="contenthelper" property="startAtBeginning" value="true" />
|
||||||
<jsp:getProperty name="contenthelper" property="textContent" />
|
<jsp:getProperty name="contenthelper" property="textContent" />
|
||||||
|
|
||||||
<p>A more complete list of changes can be found
|
<p><a href="/history.txt">View the full change log</a>
|
||||||
in the history.txt file in your i2p directory.
|
|
||||||
</p><hr></div></body></html>
|
</p><hr></div></body></html>
|
||||||
|
@ -8,5 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath();
|
String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath();
|
||||||
net.i2p.util.FileUtil.readFile("history.txt", base, response.getOutputStream());
|
try {
|
||||||
|
net.i2p.util.FileUtil.readFile("history.txt", base, response.getOutputStream());
|
||||||
|
} catch (java.io.IOException ioe) {
|
||||||
|
response.sendError(403, ioe.toString());
|
||||||
|
}
|
||||||
%>
|
%>
|
@ -44,5 +44,9 @@ if (themePath != null)
|
|||||||
else
|
else
|
||||||
base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
|
base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
|
||||||
java.io.File.separatorChar + "docs";
|
java.io.File.separatorChar + "docs";
|
||||||
net.i2p.util.FileUtil.readFile(uri, base, response.getOutputStream());
|
try {
|
||||||
|
net.i2p.util.FileUtil.readFile(uri, base, response.getOutputStream());
|
||||||
|
} catch (java.io.IOException ioe) {
|
||||||
|
response.sendError(403, ioe.toString());
|
||||||
|
}
|
||||||
%>
|
%>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -274,7 +274,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession {
|
|||||||
_demultiplexer.messageAvailable(I2PSessionMuxedImpl.this,
|
_demultiplexer.messageAvailable(I2PSessionMuxedImpl.this,
|
||||||
msg.id, msg.size, msg.proto, msg.fromPort, msg.toPort);
|
msg.id, msg.size, msg.proto, msg.fromPort, msg.toPort);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.error("Error notifying app of message availability");
|
_log.error("Error notifying app of message availability", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ public final class I2PDatagramDissector {
|
|||||||
|
|
||||||
private Hash rxHash = null;
|
private Hash rxHash = null;
|
||||||
|
|
||||||
private Signature rxSign = new Signature();
|
private Signature rxSign;
|
||||||
|
|
||||||
private Destination rxDest = new Destination();
|
private Destination rxDest;
|
||||||
|
|
||||||
private byte[] rxPayload = new byte[DGRAM_BUFSIZE];
|
private byte[] rxPayload = new byte[DGRAM_BUFSIZE];
|
||||||
|
|
||||||
@ -68,6 +68,9 @@ public final class I2PDatagramDissector {
|
|||||||
this.valid = false;
|
this.valid = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
rxDest = new Destination();
|
||||||
|
rxSign = new Signature();
|
||||||
|
|
||||||
// read destination
|
// read destination
|
||||||
rxDest.readBytes(dgStream);
|
rxDest.readBytes(dgStream);
|
||||||
|
|
||||||
@ -153,6 +156,8 @@ public final class I2PDatagramDissector {
|
|||||||
* @return The Destination of the I2P repliable datagram sender
|
* @return The Destination of the I2P repliable datagram sender
|
||||||
*/
|
*/
|
||||||
public Destination extractSender() {
|
public Destination extractSender() {
|
||||||
|
if (this.rxDest == null)
|
||||||
|
return null;
|
||||||
Destination retDest = new Destination();
|
Destination retDest = new Destination();
|
||||||
try {
|
try {
|
||||||
retDest.fromByteArray(this.rxDest.toByteArray());
|
retDest.fromByteArray(this.rxDest.toByteArray());
|
||||||
@ -184,6 +189,10 @@ public final class I2PDatagramDissector {
|
|||||||
if(this.valid)
|
if(this.valid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (rxSign == null || rxSign.getData() == null ||
|
||||||
|
rxDest == null || rxDest.getSigningPublicKey() == null)
|
||||||
|
throw new I2PInvalidDatagramException("Datagram not yet read");
|
||||||
|
|
||||||
// now validate
|
// now validate
|
||||||
if (!this.dsaEng.verifySignature(rxSign, rxHash.getData(), rxDest.getSigningPublicKey()))
|
if (!this.dsaEng.verifySignature(rxSign, rxHash.getData(), rxDest.getSigningPublicKey()))
|
||||||
throw new I2PInvalidDatagramException("Incorrect I2P repliable datagram signature");
|
throw new I2PInvalidDatagramException("Incorrect I2P repliable datagram signature");
|
||||||
|
@ -54,7 +54,7 @@ class LookupDest {
|
|||||||
|
|
||||||
/** @param h 32 byte hash */
|
/** @param h 32 byte hash */
|
||||||
static Destination lookupHash(I2PAppContext ctx, byte[] h) {
|
static Destination lookupHash(I2PAppContext ctx, byte[] h) {
|
||||||
Hash key = new Hash(h);
|
Hash key = Hash.create(h);
|
||||||
Destination rv = null;
|
Destination rv = null;
|
||||||
try {
|
try {
|
||||||
I2PClient client = new I2PSimpleClient();
|
I2PClient client = new I2PSimpleClient();
|
||||||
|
@ -43,6 +43,24 @@ public class Certificate extends DataStructureImpl {
|
|||||||
/** Contains multiple certs */
|
/** Contains multiple certs */
|
||||||
public final static int CERTIFICATE_TYPE_MULTIPLE = 4;
|
public final static int CERTIFICATE_TYPE_MULTIPLE = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pull from cache or return new
|
||||||
|
* @throws AIOOBE if not enough bytes
|
||||||
|
* @since 0.8.3
|
||||||
|
*/
|
||||||
|
public static Certificate create(byte[] data, int off) {
|
||||||
|
int type = data[off] & 0xff;
|
||||||
|
int length = (int) DataHelper.fromLong(data, off + 1, 2);
|
||||||
|
if (type == 0 && length == 0)
|
||||||
|
return NULL_CERT;
|
||||||
|
// from here down roughly the same as readBytes() below
|
||||||
|
if (length == 0)
|
||||||
|
return new Certificate(type, null);
|
||||||
|
byte[] payload = new byte[length];
|
||||||
|
System.arraycopy(data, off = 3, payload, 0, length);
|
||||||
|
return new Certificate(type, payload);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If null cert, return immutable static instance, else create new
|
* If null cert, return immutable static instance, else create new
|
||||||
* @since 0.8.3
|
* @since 0.8.3
|
||||||
|
@ -49,20 +49,14 @@ public class Destination extends KeysAndCert {
|
|||||||
throw new DataFormatException("Not enough data (len=" + source.length + " off=" + offset + ")");
|
throw new DataFormatException("Not enough data (len=" + source.length + " off=" + offset + ")");
|
||||||
int cur = offset;
|
int cur = offset;
|
||||||
|
|
||||||
_publicKey = new PublicKey();
|
_publicKey = PublicKey.create(source, cur);
|
||||||
byte buf[] = new byte[PublicKey.KEYSIZE_BYTES];
|
|
||||||
System.arraycopy(source, cur, buf, 0, PublicKey.KEYSIZE_BYTES);
|
|
||||||
_publicKey.setData(buf);
|
|
||||||
cur += PublicKey.KEYSIZE_BYTES;
|
cur += PublicKey.KEYSIZE_BYTES;
|
||||||
|
|
||||||
_signingKey = new SigningPublicKey();
|
_signingKey = SigningPublicKey.create(source, cur);
|
||||||
buf = new byte[SigningPublicKey.KEYSIZE_BYTES];
|
|
||||||
System.arraycopy(source, cur, buf, 0, SigningPublicKey.KEYSIZE_BYTES);
|
|
||||||
_signingKey.setData(buf);
|
|
||||||
cur += SigningPublicKey.KEYSIZE_BYTES;
|
cur += SigningPublicKey.KEYSIZE_BYTES;
|
||||||
|
|
||||||
_certificate = new Certificate();
|
_certificate = Certificate.create(source, cur);
|
||||||
cur += _certificate.readBytes(source, cur);
|
cur += _certificate.size();
|
||||||
|
|
||||||
return cur - offset;
|
return cur - offset;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,15 @@ public class PublicKey extends SimpleDataStructure {
|
|||||||
|
|
||||||
private static final SDSCache<PublicKey> _cache = new SDSCache(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
|
private static final SDSCache<PublicKey> _cache = new SDSCache(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pull from cache or return new
|
||||||
|
* @throws AIOOBE if not enough bytes
|
||||||
|
* @since 0.8.3
|
||||||
|
*/
|
||||||
|
public static PublicKey create(byte[] data, int off) {
|
||||||
|
return _cache.get(data, off);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pull from cache or return new
|
* Pull from cache or return new
|
||||||
* @since 0.8.3
|
* @since 0.8.3
|
||||||
|
@ -26,6 +26,15 @@ public class SigningPublicKey extends SimpleDataStructure {
|
|||||||
|
|
||||||
private static final SDSCache<SigningPublicKey> _cache = new SDSCache(SigningPublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
|
private static final SDSCache<SigningPublicKey> _cache = new SDSCache(SigningPublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pull from cache or return new
|
||||||
|
* @throws AIOOBE if not enough bytes
|
||||||
|
* @since 0.8.3
|
||||||
|
*/
|
||||||
|
public static SigningPublicKey create(byte[] data, int off) {
|
||||||
|
return _cache.get(data, off);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pull from cache or return new
|
* Pull from cache or return new
|
||||||
* @since 0.8.3
|
* @since 0.8.3
|
||||||
|
@ -60,9 +60,7 @@ public class DestReplyMessage extends I2CPMessageImpl {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (size == Hash.HASH_LENGTH) {
|
if (size == Hash.HASH_LENGTH) {
|
||||||
Hash h = new Hash();
|
_hash = Hash.create(in);
|
||||||
h.readBytes(in);
|
|
||||||
_hash = h;
|
|
||||||
} else {
|
} else {
|
||||||
Destination d = new Destination();
|
Destination d = new Destination();
|
||||||
d.readBytes(in);
|
d.readBytes(in);
|
||||||
|
@ -50,7 +50,8 @@ public abstract class Addresses {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a sorted array of all addresses
|
* @return a sorted array of all addresses
|
||||||
* @param whether to exclude IPV6 and local
|
* @param includeLocal whether to include local
|
||||||
|
* @param includeIPv6 whether to include IPV6
|
||||||
* @return an array of all addresses
|
* @return an array of all addresses
|
||||||
* @since 0.8.3
|
* @since 0.8.3
|
||||||
*/
|
*/
|
||||||
|
14
history.txt
14
history.txt
@ -1,3 +1,17 @@
|
|||||||
|
2010-12-31 zzz
|
||||||
|
* Console:
|
||||||
|
- Make themes and history.txt return 403 on error,
|
||||||
|
not 500, to avoid the new error page
|
||||||
|
- Add logging, enable with routerconsole.log=filename
|
||||||
|
- Link to full history.txt on help page
|
||||||
|
* Data Structures: Caching cleanups
|
||||||
|
* Datagram Dissector: Fix RuntimeException caused by reuse,
|
||||||
|
preventing iMule from connecting on UDP
|
||||||
|
(thanks devzero)
|
||||||
|
* i2psnark:
|
||||||
|
- Send cache directive for in-war icons
|
||||||
|
* OCMOSJ: Refactor cache keys for efficiency
|
||||||
|
|
||||||
2010-12-30 zzz
|
2010-12-30 zzz
|
||||||
* Data Structures:
|
* Data Structures:
|
||||||
- New SDSCache for SimpleDataStructures
|
- New SDSCache for SimpleDataStructures
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
<h2>Willst Du Deine eigene Eepseite?</h2>
|
<h2>Willst Du Deine eigene Eepseite?</h2>
|
||||||
|
|
||||||
<p>Das I2P-Paket beinhaltet Software, die es Dir ermöglicht, Deine eigene Eepseite zu betreiben
|
<p>Das I2P-Paket beinhaltet Software, die es Dir ermöglicht, Deine eigene Eepseite zu betreiben
|
||||||
: Eine
|
: Eine
|
||||||
<a href="http://jetty.mortbay.org/">Jetty</a>-Instanz horcht auf
|
<a href="http://jetty.mortbay.org/">Jetty</a>-Instanz horcht auf
|
||||||
<a href="http://127.0.0.1:7658/">http://127.0.0.1:7658/</a>. Platziere einfach
|
<a href="http://127.0.0.1:7658/">http://127.0.0.1:7658/</a>. Platziere einfach
|
||||||
|
@ -59,7 +59,7 @@ body {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 11pt;
|
font-size: 11pt;
|
||||||
color: #fb0;
|
color: #fb0;
|
||||||
background: #eeb url('images/snarknav_lowlight.png') repeat-x scroll center center;
|
background: #eeb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.snarkRefresh:last-child {
|
.snarkRefresh:last-child {
|
||||||
|
@ -305,7 +305,7 @@ public class Blocklist {
|
|||||||
if (end1 - start1 == 44 && buf.substring(start1).indexOf(".") < 0) {
|
if (end1 - start1 == 44 && buf.substring(start1).indexOf(".") < 0) {
|
||||||
byte b[] = Base64.decode(buf.substring(start1));
|
byte b[] = Base64.decode(buf.substring(start1));
|
||||||
if (b != null)
|
if (b != null)
|
||||||
return new Entry(comment, new Hash(b), null, null);
|
return new Entry(comment, Hash.create(b), null, null);
|
||||||
}
|
}
|
||||||
index = buf.indexOf("-", start1);
|
index = buf.indexOf("-", start1);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
@ -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 = 5;
|
public final static long BUILD = 6;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
@ -39,8 +39,10 @@ public class ClientManagerFacadeImpl extends ClientManagerFacade implements Inte
|
|||||||
private final static Log _log = new Log(ClientManagerFacadeImpl.class);
|
private final static Log _log = new Log(ClientManagerFacadeImpl.class);
|
||||||
private ClientManager _manager;
|
private ClientManager _manager;
|
||||||
private RouterContext _context;
|
private RouterContext _context;
|
||||||
|
/** note that this is different than the property the client side uses, i2cp.tcp.port */
|
||||||
public final static String PROP_CLIENT_PORT = "i2cp.port";
|
public final static String PROP_CLIENT_PORT = "i2cp.port";
|
||||||
public final static int DEFAULT_PORT = 7654;
|
public final static int DEFAULT_PORT = 7654;
|
||||||
|
/** note that this is different than the property the client side uses, i2cp.tcp.host */
|
||||||
public final static String PROP_CLIENT_HOST = "i2cp.hostname";
|
public final static String PROP_CLIENT_HOST = "i2cp.hostname";
|
||||||
public final static String DEFAULT_HOST = "127.0.0.1";
|
public final static String DEFAULT_HOST = "127.0.0.1";
|
||||||
|
|
||||||
|
@ -216,7 +216,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
|||||||
*
|
*
|
||||||
* Key the cache on the source+dest pair.
|
* Key the cache on the source+dest pair.
|
||||||
*/
|
*/
|
||||||
private final static HashMap<String, LeaseSet> _leaseSetCache = new HashMap();
|
private final static HashMap<HashPair, LeaseSet> _leaseSetCache = new HashMap();
|
||||||
|
|
||||||
private LeaseSet getReplyLeaseSet(boolean force) {
|
private LeaseSet getReplyLeaseSet(boolean force) {
|
||||||
LeaseSet newLS = getContext().netDb().lookupLeaseSetLocally(_from.calculateHash());
|
LeaseSet newLS = getContext().netDb().lookupLeaseSetLocally(_from.calculateHash());
|
||||||
if (newLS == null)
|
if (newLS == null)
|
||||||
@ -316,7 +317,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
|||||||
* lease).
|
* lease).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private final static HashMap<String, Lease> _leaseCache = new HashMap();
|
private final static HashMap<HashPair, Lease> _leaseCache = new HashMap();
|
||||||
|
|
||||||
private boolean getNextLease() {
|
private boolean getNextLease() {
|
||||||
_leaseSet = getContext().netDb().lookupLeaseSetLocally(_to.calculateHash());
|
_leaseSet = getContext().netDb().lookupLeaseSetLocally(_to.calculateHash());
|
||||||
if (_leaseSet == null) {
|
if (_leaseSet == null) {
|
||||||
@ -456,7 +458,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
|||||||
* before upper layers like streaming lib fail, even for low-bandwidth
|
* before upper layers like streaming lib fail, even for low-bandwidth
|
||||||
* connections like IRC.
|
* connections like IRC.
|
||||||
*/
|
*/
|
||||||
private final static HashMap<String, Long> _lastReplyRequestCache = new HashMap();
|
private final static HashMap<HashPair, Long> _lastReplyRequestCache = new HashMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the message to the specified tunnel by creating a new garlic message containing
|
* Send the message to the specified tunnel by creating a new garlic message containing
|
||||||
@ -628,23 +630,46 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String used to cache things with based on source + dest
|
* Key used to cache things with based on source + dest
|
||||||
* Put the dest first to make string matching faster
|
|
||||||
*/
|
*/
|
||||||
private String _hashPair;
|
private HashPair _hashPair;
|
||||||
private String hashPair() {
|
private HashPair hashPair() {
|
||||||
if (_hashPair == null)
|
if (_hashPair == null)
|
||||||
_hashPair = _to.calculateHash().toBase64() + _from.calculateHash().toBase64();
|
_hashPair = new HashPair(_from.calculateHash(), _to.calculateHash());
|
||||||
return _hashPair;
|
return _hashPair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key used to cache things with based on source + dest
|
||||||
|
* @since 0.8.3
|
||||||
|
*/
|
||||||
|
private static class HashPair {
|
||||||
|
private final Hash sh, dh;
|
||||||
|
|
||||||
|
public HashPair(Hash s, Hash d) {
|
||||||
|
sh = s;
|
||||||
|
dh = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return sh.hashCode() + dh.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o == null || !(o instanceof HashPair))
|
||||||
|
return false;
|
||||||
|
HashPair hp = (HashPair) o;
|
||||||
|
return sh.equals(hp.sh) && dh.equals(hp.dh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a little sneaky, but get the _from back out of the "opaque" hash key
|
* This is a little sneaky, but get the _from back out of the "opaque" hash key
|
||||||
* (needed for cleanTunnelCache)
|
* (needed for cleanTunnelCache)
|
||||||
* 44 = 32 * 4 / 3
|
|
||||||
*/
|
*/
|
||||||
private static Hash sourceFromHashPair(String s) {
|
private static Hash sourceFromHashPair(HashPair s) {
|
||||||
return new Hash(Base64.decode(s.substring(44, 88)));
|
return s.sh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -655,7 +680,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
|||||||
* But it's a start.
|
* But it's a start.
|
||||||
*/
|
*/
|
||||||
private void clearCaches() {
|
private void clearCaches() {
|
||||||
String key = hashPair();
|
HashPair key = hashPair();
|
||||||
if (_inTunnel != null) { // if we wanted an ack, we sent our lease too
|
if (_inTunnel != null) { // if we wanted an ack, we sent our lease too
|
||||||
synchronized(_leaseSetCache) {
|
synchronized(_leaseSetCache) {
|
||||||
_leaseSetCache.remove(key);
|
_leaseSetCache.remove(key);
|
||||||
@ -681,42 +706,38 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean out old leaseSets from a set.
|
* Clean out old leaseSets
|
||||||
* Caller must synchronize on tc.
|
* Caller must synchronize on tc.
|
||||||
*/
|
*/
|
||||||
private static void cleanLeaseSetCache(RouterContext ctx, HashMap tc) {
|
private static void cleanLeaseSetCache(RouterContext ctx, Map<HashPair, LeaseSet> tc) {
|
||||||
long now = ctx.clock().now();
|
long now = ctx.clock().now();
|
||||||
for (Iterator iter = tc.entrySet().iterator(); iter.hasNext(); ) {
|
for (Iterator<LeaseSet> iter = tc.values().iterator(); iter.hasNext(); ) {
|
||||||
Map.Entry entry = (Map.Entry)iter.next();
|
LeaseSet l = iter.next();
|
||||||
String k = (String) entry.getKey();
|
|
||||||
LeaseSet l = (LeaseSet) entry.getValue();
|
|
||||||
if (l.getEarliestLeaseDate() < now)
|
if (l.getEarliestLeaseDate() < now)
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean out old leases from a set.
|
* Clean out old leases
|
||||||
* Caller must synchronize on tc.
|
* Caller must synchronize on tc.
|
||||||
*/
|
*/
|
||||||
private static void cleanLeaseCache(HashMap tc) {
|
private static void cleanLeaseCache(Map<HashPair, Lease> tc) {
|
||||||
for (Iterator iter = tc.entrySet().iterator(); iter.hasNext(); ) {
|
for (Iterator<Lease> iter = tc.values().iterator(); iter.hasNext(); ) {
|
||||||
Map.Entry entry = (Map.Entry)iter.next();
|
Lease l = iter.next();
|
||||||
String k = (String) entry.getKey();
|
|
||||||
Lease l = (Lease) entry.getValue();
|
|
||||||
if (l.isExpired(Router.CLOCK_FUDGE_FACTOR))
|
if (l.isExpired(Router.CLOCK_FUDGE_FACTOR))
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean out old tunnels from a set.
|
* Clean out old tunnels
|
||||||
* Caller must synchronize on tc.
|
* Caller must synchronize on tc.
|
||||||
*/
|
*/
|
||||||
private static void cleanTunnelCache(RouterContext ctx, HashMap tc) {
|
private static void cleanTunnelCache(RouterContext ctx, Map<HashPair, TunnelInfo> tc) {
|
||||||
for (Iterator iter = tc.entrySet().iterator(); iter.hasNext(); ) {
|
for (Iterator iter = tc.entrySet().iterator(); iter.hasNext(); ) {
|
||||||
Map.Entry entry = (Map.Entry)iter.next();
|
Map.Entry entry = (Map.Entry)iter.next();
|
||||||
String k = (String) entry.getKey();
|
HashPair k = (HashPair) entry.getKey();
|
||||||
TunnelInfo tunnel = (TunnelInfo) entry.getValue();
|
TunnelInfo tunnel = (TunnelInfo) entry.getValue();
|
||||||
if (!ctx.tunnelManager().isValidTunnel(sourceFromHashPair(k), tunnel))
|
if (!ctx.tunnelManager().isValidTunnel(sourceFromHashPair(k), tunnel))
|
||||||
iter.remove();
|
iter.remove();
|
||||||
@ -727,7 +748,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
|||||||
* Clean out old reply times
|
* Clean out old reply times
|
||||||
* Caller must synchronize on tc.
|
* Caller must synchronize on tc.
|
||||||
*/
|
*/
|
||||||
private static void cleanReplyCache(RouterContext ctx, HashMap tc) {
|
private static void cleanReplyCache(RouterContext ctx, Map<HashPair, Long> tc) {
|
||||||
long now = ctx.clock().now();
|
long now = ctx.clock().now();
|
||||||
for (Iterator iter = tc.values().iterator(); iter.hasNext(); ) {
|
for (Iterator iter = tc.values().iterator(); iter.hasNext(); ) {
|
||||||
Long l = (Long) iter.next();
|
Long l = (Long) iter.next();
|
||||||
@ -766,8 +787,10 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
|||||||
* Key the caches on the source+dest pair.
|
* Key the caches on the source+dest pair.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final HashMap<String, TunnelInfo> _tunnelCache = new HashMap();
|
private static final HashMap<HashPair, TunnelInfo> _tunnelCache = new HashMap();
|
||||||
private static HashMap<String, TunnelInfo> _backloggedTunnelCache = new HashMap();
|
|
||||||
|
private static HashMap<HashPair, TunnelInfo> _backloggedTunnelCache = new HashMap();
|
||||||
|
|
||||||
private TunnelInfo selectOutboundTunnel(Destination to) {
|
private TunnelInfo selectOutboundTunnel(Destination to) {
|
||||||
TunnelInfo tunnel;
|
TunnelInfo tunnel;
|
||||||
long now = getContext().clock().now();
|
long now = getContext().clock().now();
|
||||||
|
@ -28,7 +28,7 @@ import net.i2p.util.Log;
|
|||||||
*/
|
*/
|
||||||
class LocalHash extends Hash {
|
class LocalHash extends Hash {
|
||||||
private final static Log _log = new Log(LocalHash.class);
|
private final static Log _log = new Log(LocalHash.class);
|
||||||
private /* FIXME final FIXME */ Map _xorCache;
|
private /* FIXME final FIXME */ Map<Hash, byte[]> _xorCache;
|
||||||
|
|
||||||
private static final int MAX_CACHED_XOR = 1024;
|
private static final int MAX_CACHED_XOR = 1024;
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ class LocalHash extends Hash {
|
|||||||
public byte[] cachedXor(Hash key) throws IllegalStateException {
|
public byte[] cachedXor(Hash key) throws IllegalStateException {
|
||||||
if (_xorCache == null)
|
if (_xorCache == null)
|
||||||
throw new IllegalStateException("To use the cache, you must first prepare it");
|
throw new IllegalStateException("To use the cache, you must first prepare it");
|
||||||
byte[] distance = (byte[])_xorCache.get(key);
|
byte[] distance = _xorCache.get(key);
|
||||||
|
|
||||||
if (distance == null) {
|
if (distance == null) {
|
||||||
// not cached, lets cache it
|
// not cached, lets cache it
|
||||||
@ -83,7 +83,7 @@ class LocalHash extends Hash {
|
|||||||
_xorCache.remove(iter.next());
|
_xorCache.remove(iter.next());
|
||||||
}
|
}
|
||||||
distance = DataHelper.xor(key.getData(), getData());
|
distance = DataHelper.xor(key.getData(), getData());
|
||||||
_xorCache.put(key, (Object) distance);
|
_xorCache.put(key, distance);
|
||||||
cached = _xorCache.size();
|
cached = _xorCache.size();
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.DEBUG)) {
|
if (_log.shouldLog(Log.DEBUG)) {
|
||||||
|
@ -18,6 +18,7 @@ import java.util.Map;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import net.i2p.data.Base64;
|
||||||
import net.i2p.data.DataFormatException;
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataStructure;
|
import net.i2p.data.DataStructure;
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
@ -481,8 +482,12 @@ class PersistentDataStore extends TransientDataStore {
|
|||||||
try {
|
try {
|
||||||
String key = filename.substring(prefix.length());
|
String key = filename.substring(prefix.length());
|
||||||
key = key.substring(0, key.length() - suffix.length());
|
key = key.substring(0, key.length() - suffix.length());
|
||||||
Hash h = new Hash();
|
//Hash h = new Hash();
|
||||||
h.fromBase64(key);
|
//h.fromBase64(key);
|
||||||
|
byte[] b = Base64.decode(key);
|
||||||
|
if (b == null)
|
||||||
|
return null;
|
||||||
|
Hash h = Hash.create(b);
|
||||||
return h;
|
return h;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// static
|
// static
|
||||||
|
@ -937,11 +937,9 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
RouterAddress addr = _externalAddress;
|
RouterAddress addr = _externalAddress;
|
||||||
UDPAddress ua = new UDPAddress(addr);
|
UDPAddress ua = new UDPAddress(addr);
|
||||||
int valid = 0;
|
int valid = 0;
|
||||||
Hash peerHash = new Hash();
|
|
||||||
for (int i = 0; i < ua.getIntroducerCount(); i++) {
|
for (int i = 0; i < ua.getIntroducerCount(); i++) {
|
||||||
// warning: this is only valid as long as we use the ident hash as their key.
|
// warning: this is only valid as long as we use the ident hash as their key.
|
||||||
peerHash.setData(ua.getIntroducerKey(i));
|
PeerState peer = getPeerState(Hash.create(ua.getIntroducerKey(i)));
|
||||||
PeerState peer = getPeerState(peerHash);
|
|
||||||
if (peer != null)
|
if (peer != null)
|
||||||
valid++;
|
valid++;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user