merge of '3e6cfe9a01136316f39f1bd294a515e6bc91ff8e'

and 'b4b595d294ace07f7fde583957d8e00e96af347c'
This commit is contained in:
kytv
2014-11-28 20:39:57 +00:00
22 changed files with 250 additions and 58 deletions

View File

@@ -1339,10 +1339,10 @@ public class IndexBean {
// as of 0.9.17, add a random key if not previously present
byte[] rk = new byte[32];
_context.random().nextBytes(rk);
config.setProperty(OPT + p, Base64.encode(rk));
config.setProperty(p, Base64.encode(rk));
p = OPT + "outbound.randomKey";
_context.random().nextBytes(rk);
config.setProperty(OPT + p, Base64.encode(rk));
config.setProperty(p, Base64.encode(rk));
}
}

View File

@@ -41,7 +41,7 @@ public class NewsMetadata {
@Override
public int compareTo(Update other) {
return Integer.compare(getTypeOrder(), other.getTypeOrder());
return getTypeOrder() - other.getTypeOrder();
}
protected int getTypeOrder() {

View File

@@ -348,8 +348,11 @@ public class SummaryBarRenderer {
.append(_helper.getReachability())
.append("</a></h4>\n");
if (!SigType.ECDSA_SHA256_P256.isAvailable()) {
buf.append("<hr>\n<h4><a href=\"/logs\" target=\"_top\" title=\"")
.append(_("See more information on the logs page"))
buf.append("<hr>\n<h4><a href=\"http://trac.i2p2.i2p/wiki/Crypto/ECDSA");
if ("ru".equals(Messages.getLanguage(_context)))
buf.append("-ru");
buf.append("\" target=\"_top\" title=\"")
.append(_("See more information on the wiki"))
.append("\">")
.append(_("Warning: ECDSA is not available. Update your Java or OS"))
.append("</a></h4>\n");

View File

@@ -82,7 +82,7 @@ class SAMStreamSession {
* Create a new SAM STREAM session.
*
* @param dest Base64-encoded destination and private keys (same format as PrivateKeyFile)
* @param dir Session direction ("RECEIVE", "CREATE" or "BOTH")
* @param dir Session direction ("RECEIVE", "CREATE" or "BOTH") or "__v3__" if extended by SAMv3StreamSession
* @param props Properties to setup the I2P session
* @param recv Object that will receive incoming data
* @throws IOException
@@ -98,7 +98,7 @@ class SAMStreamSession {
* Create a new SAM STREAM session.
*
* @param destStream Input stream containing the destination and private keys (same format as PrivateKeyFile)
* @param dir Session direction ("RECEIVE", "CREATE" or "BOTH")
* @param dir Session direction ("RECEIVE", "CREATE" or "BOTH") or "__v3__" if extended by SAMv3StreamSession
* @param props Properties to setup the I2P session
* @param recv Object that will receive incoming data
* @throws IOException
@@ -111,15 +111,24 @@ class SAMStreamSession {
_log = I2PAppContext.getGlobalContext().logManager().getLog(getClass());
boolean canReceive;
boolean startAcceptor;
if (dir.equals("BOTH")) {
canCreate = true;
canReceive = true;
startAcceptor = true;
} else if (dir.equals("__v3__")) {
// we are super to SAMv3StreamSession, don't start thread, he handles it
canCreate = true;
canReceive = true;
startAcceptor = false;
} else if (dir.equals("CREATE")) {
canCreate = true;
canReceive = false;
startAcceptor = false;
} else if (dir.equals("RECEIVE")) {
canCreate = false;
canReceive = true;
startAcceptor = true;
} else {
_log.error("BUG! Wrong direction passed to SAMStreamSession: "
+ dir);
@@ -162,7 +171,7 @@ class SAMStreamSession {
forceFlush = Boolean.parseBoolean(allprops.getProperty(PROP_FORCE_FLUSH, DEFAULT_FORCE_FLUSH));
if (canReceive) {
if (startAcceptor) {
server = new SAMStreamSessionServer();
Thread t = new I2PAppThread(server, "SAMStreamSessionServer");

View File

@@ -61,7 +61,7 @@ class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handler.Sessi
public SAMv3StreamSession(String login)
throws IOException, DataFormatException, SAMException
{
super(getDB().get(login).getDest(), "BOTH",
super(getDB().get(login).getDest(), "__v3__",
getDB().get(login).getProps(),
getDB().get(login).getHandler());
this.nick = login ;

View File

@@ -11,7 +11,7 @@
# Note: Include the trailing slash! Don't surround the URL in quotes!
javasedocs.url=http://docs.oracle.com/javase/6/docs/api/
javaeedocs.url=http://docs.oracle.com/javaee/6/api/
jettydocs.url=http://download.eclipse.org/jetty/stable-7/apidocs/
jettydocs.url=http://download.eclipse.org/jetty/stable-8/apidocs/
jrobindocs.url=http://docs.i2p-projekt.de/jrobin/javadoc/
wrapperdocs.url=http://wrapper.tanukisoftware.com/jdoc/
# these are only for unit test javadocs

View File

@@ -169,9 +169,11 @@ public class PrivateKeyFile {
usage();
return;
}
System.out.println(pkf);
pkf.write();
verifySignature(pkf.getDestination());
if (mode != 0) {
System.out.println(pkf);
pkf.write();
verifySignature(pkf.getDestination());
}
} catch (Exception e) {
e.printStackTrace();
System.exit(1);

View File

@@ -9,6 +9,8 @@ package net.i2p.data;
*
*/
import java.util.Arrays;
import net.i2p.crypto.SigType;
/**
@@ -102,4 +104,23 @@ public class Signature extends SimpleDataStructure {
buf.append(']');
return buf.toString();
}
/**
* @since 0.9.17
*/
@Override
public int hashCode() {
return DataHelper.hashCode(_type) ^ super.hashCode();
}
/**
* @since 0.9.17
*/
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || !(obj instanceof Signature)) return false;
Signature s = (Signature) obj;
return _type == s._type && Arrays.equals(_data, s._data);
}
}

View File

@@ -9,6 +9,8 @@ package net.i2p.data;
*
*/
import java.util.Arrays;
import net.i2p.crypto.KeyGenerator;
import net.i2p.crypto.SigType;
@@ -104,4 +106,23 @@ public class SigningPrivateKey extends SimpleDataStructure {
buf.append(']');
return buf.toString();
}
/**
* @since 0.9.17
*/
@Override
public int hashCode() {
return DataHelper.hashCode(_type) ^ super.hashCode();
}
/**
* @since 0.9.17
*/
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || !(obj instanceof SigningPrivateKey)) return false;
SigningPrivateKey s = (SigningPrivateKey) obj;
return _type == s._type && Arrays.equals(_data, s._data);
}
}

View File

@@ -12,6 +12,7 @@ package net.i2p.data;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import net.i2p.crypto.SigType;
@@ -113,7 +114,8 @@ public class SigningPublicKey extends SimpleDataStructure {
}
/**
* Up-convert this from an untyped (type 0) SPK to a typed SPK based on the Key Cert given
* Up-convert this from an untyped (type 0) SPK to a typed SPK based on the Key Cert given.
* The type of the returned key will be null if the kcert sigtype is null.
*
* @throws IllegalArgumentException if this is already typed to a different type
* @since 0.9.12
@@ -126,6 +128,9 @@ public class SigningPublicKey extends SimpleDataStructure {
return this;
if (_type != SigType.DSA_SHA1)
throw new IllegalArgumentException("Cannot convert " + _type + " to " + newType);
// unknown type, keep the 128 bytes of data
if (newType == null)
return new SigningPublicKey(null, _data);
int newLen = newType.getPubkeyLen();
if (newLen == SigType.DSA_SHA1.getPubkeyLen())
return new SigningPublicKey(newType, _data);
@@ -145,7 +150,7 @@ public class SigningPublicKey extends SimpleDataStructure {
* Get the portion of this (type 0) SPK that is really padding based on the Key Cert type given,
* if any
*
* @return leading padding length > 0 or null
* @return leading padding length > 0 or null if no padding or type is unknown
* @throws IllegalArgumentException if this is already typed to a different type
* @since 0.9.12
*/
@@ -153,7 +158,7 @@ public class SigningPublicKey extends SimpleDataStructure {
if (_data == null)
throw new IllegalStateException();
SigType newType = kcert.getSigType();
if (_type == newType)
if (_type == newType || newType == null)
return null;
if (_type != SigType.DSA_SHA1)
throw new IllegalStateException("Cannot convert " + _type + " to " + newType);
@@ -200,4 +205,23 @@ public class SigningPublicKey extends SimpleDataStructure {
public static void clearCache() {
_cache.clear();
}
/**
* @since 0.9.17
*/
@Override
public int hashCode() {
return DataHelper.hashCode(_type) ^ super.hashCode();
}
/**
* @since 0.9.17
*/
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || !(obj instanceof SigningPublicKey)) return false;
SigningPublicKey s = (SigningPublicKey) obj;
return _type == s._type && Arrays.equals(_data, s._data);
}
}

View File

@@ -1,7 +1,30 @@
2014-11-28 kytv
* Updated PO files from Transifex
* Updates to geoip.txt and geoipv6.dat.gz based on Maxmind GeoLite Country
database from 2014-11-05.
2014-11-26 zzz
* BuildRequestor: Reduce delay when client build can't find
a paired tunnel (ticket #1412)
* Data:
- Fix NPE on unknown sig type in destination
- Fix hashcode and equals for typed data
* Tunnels: Disallow changing allowZeroHop setting for exploratory
2014-11-24 zzz
* i2ptunnel: Fix automatic setting of random key
* PrivateKeyFile: Don't rewrite file in main() if no options
2014-11-23 zzz
* Reseed hosts update
2014-11-22 zzz
* PeerSelector: If non-DSA, don't use incompatible peers
for exploratory tunnels or closest-hop in client tunnels
* SAM: Fix v3 bug accepting incoming connections
2014-11-17 zzz
* NetDB: Exclude A1/A2 "countries" from auto-floodfill
2014-11-15 zzz
* I2NP:
- Set lookup type flags even if no reply tunnel specified
- Reduce object churn when writing some messages
2014-11-13 zzz
* I2PTunnel:

View File

@@ -1,21 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDhTCCAm2gAwIBAgIJAPVgXcMcr3zqMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV
BAYTAkVVMQ8wDQYDVQQIDAZFdXJvcGUxDDAKBgNVBAoMA0kyUDETMBEGA1UECwwK
T3V0cHJveGllczEWMBQGA1UEAwwNaTJwLmZlYXJlZC5ldTAeFw0xMjEwMjkxNzMw
MDZaFw0yMTAxMTUxNzMwMDZaMFkxCzAJBgNVBAYTAkVVMQ8wDQYDVQQIDAZFdXJv
cGUxDDAKBgNVBAoMA0kyUDETMBEGA1UECwwKT3V0cHJveGllczEWMBQGA1UEAwwN
aTJwLmZlYXJlZC5ldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOUh
y2+6Q4RO+b5WPXX/cZ/9fiI7aWGe/C7z0083HOEqnkgGCYgxFWUCed6/eZbYoZ7/
PV1BAuEereNwTp+Ov7fQB2H73O9sSAEejW6O4C2PZiZWaPxpZiTJNENbLOZxJnIN
+fSqmA5pqvGkYAJ2heZH4v4tayun7Vib58GWuizhzJ4EvhOrOrLq/YHrxMn++r4e
kNNbq4QzWpfxNa7ocDY9OJh5qFzuc+6wKj1m1syK6euDqs5d6X+y0aDTMgRxey2b
tkmNx9wC0flLg1oMcv9o1zN+dENy7Inkd/SqbSjLUqDTJzdq6xURVsgLoV63pb6r
B4gbGIlriYWK/mOPTTkCAwEAAaNQME4wHQYDVR0OBBYEFOI94JZ3Rb2RVmr8QjOp
u3KfVSrNMB8GA1UdIwQYMBaAFOI94JZ3Rb2RVmr8QjOpu3KfVSrNMAwGA1UdEwQF
MAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAD7bI05zg9nf9qanq4ZNw/rvEzYQRBmy
MqzZjcwBMGvbcEbS+zYAdAkfxmN3l/AT4I4z138Om0ud4ZJUQTVlRsJkMlmLD4Rt
Jbi2rl7mrY7Qupgu5hvgH+ZaEWr7LTq+tFjPycRS+zijw9NToKeAsgEex9zYIOYD
BxDUn/trvyA41ItvegWh803IsZUBb45Via+bopid9aFFkejRrck9hhcQ6fVh2yju
nuVwHrxNvGc0NmmJ7zI+nPESFS+TAYbWXikDhc5Vtyiuoz47WZU1cgXYYMejK4WA
+3GLvei7qKm4GOJSg7BngF5Iyj/n7ML1rBqTlN3KA1YOgpGCwJlKzto=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,25 @@
-----BEGIN CERTIFICATE-----
MIIESzCCAzOgAwIBAgIJAKII1waVnWddMA0GCSqGSIb3DQEBCwUAMIG7MQswCQYD
VQQGEwJERTEaMBgGA1UECAwRaWViOW9vcG8ubW9vby5jb20xGjAYBgNVBAcMEWll
Yjlvb3BvLm1vb28uY29tMRowGAYDVQQKDBFpZWI5b29wby5tb29vLmNvbTEaMBgG
A1UECwwRaWViOW9vcG8ubW9vby5jb20xGjAYBgNVBAMMEWllYjlvb3BvLm1vb28u
Y29tMSAwHgYJKoZIhvcNAQkBFhFpZWI5b29wby5tb29vLmNvbTAeFw0xNDExMjIx
MzQzNThaFw0yMDA1MTQxMzQzNThaMIG7MQswCQYDVQQGEwJERTEaMBgGA1UECAwR
aWViOW9vcG8ubW9vby5jb20xGjAYBgNVBAcMEWllYjlvb3BvLm1vb28uY29tMRow
GAYDVQQKDBFpZWI5b29wby5tb29vLmNvbTEaMBgGA1UECwwRaWViOW9vcG8ubW9v
by5jb20xGjAYBgNVBAMMEWllYjlvb3BvLm1vb28uY29tMSAwHgYJKoZIhvcNAQkB
FhFpZWI5b29wby5tb29vLmNvbTCCASIwD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zd22vduX5riY0Rag6B
dPtW0M9bJrC1AIjexzDcStupj9v/ceGYZQYC4zb2tZ7Ek/6q+vei8TxWZjku7Dl4
YRPXXufyB24uQ1hJVy2fSyIJ63tIRJoEFLBNaKDOB53i10xLWBcsJpXKY57AOQMn
flqW4HG8uGJ/o1WjhiOB9eI7T9toy08zNzt+kSI/blFIoek=
-----END CERTIFICATE-----

View File

@@ -4,6 +4,7 @@ certificates/r31453.ovh.net
certificates/75.145.125.59.crt
certificates/forum.i2p2.de.crt
certificates/cowpuncher.drollette.com.crt
certificates/ssl/i2p.feared.eu.crt
certificates/ssl/reseed.pkol.de.crt
# old translated proxy error pages
docs/ahelper-conflict-header_ar.ht

View File

@@ -18,10 +18,10 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 7;
public final static long BUILD = 10;
/** for example "-test" */
public final static String EXTRA = "";
public final static String EXTRA = "-rc";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
public static void main(String args[]) {
System.out.println("I2P Router version: " + FULL_VERSION);

View File

@@ -244,9 +244,10 @@ public class TunnelPoolSettings {
String name = (String) e.getKey();
String value = (String) e.getValue();
if (name.startsWith(prefix)) {
if (name.equalsIgnoreCase(prefix + PROP_ALLOW_ZERO_HOP))
_allowZeroHop = getBoolean(value, DEFAULT_ALLOW_ZERO_HOP);
else if (name.equalsIgnoreCase(prefix + PROP_BACKUP_QUANTITY))
if (name.equalsIgnoreCase(prefix + PROP_ALLOW_ZERO_HOP)) {
if (!_isExploratory)
_allowZeroHop = getBoolean(value, DEFAULT_ALLOW_ZERO_HOP);
} else if (name.equalsIgnoreCase(prefix + PROP_BACKUP_QUANTITY))
_backupQuantity = getInt(value, DEFAULT_BACKUP_QUANTITY);
//else if (name.equalsIgnoreCase(prefix + PROP_DURATION))
// _duration = getInt(value, DEFAULT_DURATION);

View File

@@ -70,9 +70,7 @@ public class Reseeder {
* URLs are constructed, and because SSLEepGet doesn't follow redirects.
*/
public static final String DEFAULT_SEED_URL =
//http://netdb.i2p2.de/" + "," +
"http://reseed.i2p-projekt.de/" + "," +
//"http://euve5653.vserver.de/netDb/" + "," +
"http://cowpuncher.drollette.com/netdb/" + "," +
"http://i2p.mooo.com/netDb/" + "," +
"http://193.150.121.66/netDb/" + "," +
@@ -83,14 +81,10 @@ public class Reseeder {
"http://jp.reseed.i2p2.no/" + "," +
"http://i2p-netdb.innovatio.no/" + "," +
"http://ieb9oopo.mooo.com/";
// Temp disabled since h2ik have been AWOL since 06-03-2013
//"http://i2p.feared.eu/";
/** @since 0.8.2 */
public static final String DEFAULT_SSL_SEED_URL =
//"https://netdb.i2p2.de/" + "," +
"https://reseed.i2p-projekt.de/" + "," +
//"https://euve5653.vserver.de/netDb/" + "," +
"https://cowpuncher.drollette.com/netdb/" + "," +
"https://i2p.mooo.com/netDb/" + "," +
"https://193.150.121.66/netDb/" + "," +
@@ -101,9 +95,8 @@ public class Reseeder {
"https://jp.reseed.i2p2.no:444/" + "," +
"https://i2p-netdb.innovatio.no/" + "," +
"https://ssl.webpack.de/ivae2he9.sg4.e-plaza.de/" + "," + // Only HTTPS and SU3 (v2) support
"https://link.mx24.eu/" + "," + // Only HTTPS and SU3 (v3) support
"https://ieb9oopo.mooo.com/";
// Temp disabled since h2ik have been AWOL since 06-03-2013
//"https://i2p.feared.eu/";
private static final String SU3_FILENAME = "i2pseeds.su3";

View File

@@ -166,7 +166,10 @@ abstract class BuildRequestor {
exec.buildComplete(cfg, pool);
// Not even an exploratory tunnel? We are in big trouble.
// Let's not spin through here too fast.
try { Thread.sleep(250); } catch (InterruptedException ie) {}
// But don't let a client tunnel waiting for exploratories slow things down too much,
// as there may be other tunnel pools who can build
int ms = pool.getSettings().isExploratory() ? 250 : 25;
try { Thread.sleep(ms); } catch (InterruptedException ie) {}
return false;
}

View File

@@ -36,6 +36,10 @@ class ClientPeerSelector extends TunnelPeerSelector {
Set<Hash> exclude = getExclude(settings.isInbound(), false);
Set<Hash> matches = new HashSet<Hash>(length);
if (length == 1) {
// closest-hop restrictions
Set<Hash> moreExclude = getClosestHopExclude(settings.isInbound());
if (moreExclude != null)
exclude.addAll(moreExclude);
ctx.profileOrganizer().selectFastPeers(length, exclude, matches, 0);
matches.remove(ctx.routerHash());
rv = new ArrayList<Hash>(matches);
@@ -46,10 +50,22 @@ class ClientPeerSelector extends TunnelPeerSelector {
rv = new ArrayList<Hash>(length + 1);
// OBEP or IB last hop
// group 0 or 1 if two hops, otherwise group 0
Set<Hash> firstHopExclude;
if (!settings.isInbound()) {
// exclude existing OBEPs to get some diversity
// exclude existing OBEPs to get some diversity ?
// closest-hop restrictions
Set<Hash> moreExclude = getClosestHopExclude(false);
if (moreExclude != null) {
moreExclude.addAll(exclude);
firstHopExclude = moreExclude;
} else {
firstHopExclude = exclude;
}
} else {
firstHopExclude = exclude;
}
ctx.profileOrganizer().selectFastPeers(1, exclude, matches, settings.getRandomKey(), length == 2 ? 2 : 4);
ctx.profileOrganizer().selectFastPeers(1, firstHopExclude, matches, settings.getRandomKey(), length == 2 ? 2 : 4);
matches.remove(ctx.routerHash());
exclude.addAll(matches);
rv.addAll(matches);
@@ -73,7 +89,12 @@ class ClientPeerSelector extends TunnelPeerSelector {
// IBGW or OB first hop
// group 2 or 3 if two hops, otherwise group 1
if (settings.isInbound()) {
// exclude existing IBGWs to get some diversity
// exclude existing IBGWs to get some diversity ?
// closest-hop restrictions
Set<Hash> moreExclude = getClosestHopExclude(true);
if (moreExclude != null)
exclude.addAll(moreExclude);
}
ctx.profileOrganizer().selectFastPeers(1, exclude, matches, settings.getRandomKey(), length == 2 ? 3 : 5);
matches.remove(ctx.routerHash());

View File

@@ -42,6 +42,13 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
Set<Hash> exclude = getExclude(settings.isInbound(), true);
exclude.add(ctx.routerHash());
// closest-hop restrictions
// Since we're applying orderPeers() later, we don't know
// which will be the closest hop, so just appply to all peers for now.
Set<Hash> moreExclude = getClosestHopExclude(settings.isInbound());
if (moreExclude != null)
exclude.addAll(moreExclude);
// Don't use ff peers for exploratory tunnels to lessen exposure to netDb searches and stores
// Hmm if they don't get explored they don't get a speed/capacity rating
// so they don't get used for client tunnels either.

View File

@@ -14,6 +14,7 @@ import java.util.StringTokenizer;
import net.i2p.I2PAppContext;
import net.i2p.crypto.SHA256Generator;
import net.i2p.crypto.SigType;
import net.i2p.data.DataFormatException;
import net.i2p.data.Hash;
import net.i2p.data.router.RouterInfo;
@@ -327,6 +328,40 @@ public abstract class TunnelPeerSelector {
return peers;
}
/**
* Pick peers that we want to avoid for the first OB hop or last IB hop.
* This is only filled in if our router sig type is not DSA.
*
* @param isInbound unused
* @return null if none
* @since 0.9.17
*/
protected Set<Hash> getClosestHopExclude(boolean isInbound) {
RouterInfo ri = ctx.router().getRouterInfo();
if (ri == null)
return null;
SigType type = ri.getIdentity().getSigType();
if (type == SigType.DSA_SHA1)
return null;
Set<Hash> rv = new HashSet<Hash>(1024);
FloodfillNetworkDatabaseFacade fac = (FloodfillNetworkDatabaseFacade)ctx.netDb();
List<RouterInfo> known = fac.getKnownRouterData();
if (known != null) {
for (int i = 0; i < known.size(); i++) {
RouterInfo peer = known.get(i);
String v = peer.getOption("router.version");
if (v == null)
continue;
// RI sigtypes added in 0.9.16
// SSU inbound connection bug fixed in 0.9.17, but it won't bid, so NTCP only,
// no need to check
if (VersionComparator.comp(v, "0.9.16") < 0)
rv.add(peer.getIdentity().calculateHash());
}
}
return rv;
}
/** warning, this is also called by ProfileOrganizer.isSelectable() */
public static boolean shouldExclude(RouterContext ctx, RouterInfo peer) {
Log log = ctx.logManager().getLog(TunnelPeerSelector.class);