propagate from branch 'i2p.i2p.zzz.test2' (head ec8e362ce8b93280b518c599a3cc075b89085d2b)

to branch 'i2p.i2p' (head c9b1eef91f61f4482ad11c4f2b2d01be67a17ad2)
This commit is contained in:
zzz
2013-12-10 02:26:32 +00:00
54 changed files with 362 additions and 281 deletions

View File

@@ -194,6 +194,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
Boolean.parseBoolean(tunnel.getClientOptions().getProperty(I2PTunnelIRCClient.PROP_DCC));
if (!dccEnabled)
tunnel.getClientOptions().setProperty("i2cp.dontPublishLeaseSet", "true");
if (tunnel.getClientOptions().getProperty("i2p.streaming.answerPings") == null)
tunnel.getClientOptions().setProperty("i2p.streaming.answerPings", "false");
boolean openNow = !Boolean.parseBoolean(tunnel.getClientOptions().getProperty("i2cp.delayOpen"));
if (openNow) {

View File

@@ -39,7 +39,7 @@ abstract class IRCFilter {
final String[] allowedCommands =
{
// "NOTICE", // can contain CTCP
//"PING",
"PING",
//"PONG",
"MODE",
"JOIN",
@@ -76,8 +76,6 @@ abstract class IRCFilter {
} catch(NumberFormatException nfe){}
if ("PING".equals(command))
return "PING 127.0.0.1"; // no way to know what the ircd to i2ptunnel server con is, so localhost works
if ("PONG".equals(command)) {
// Turn the received ":irc.freshcoffee.i2p PONG irc.freshcoffee.i2p :127.0.0.1"
// into ":127.0.0.1 PONG 127.0.0.1 " so that the caller can append the client's extra parameter
@@ -175,7 +173,7 @@ abstract class IRCFilter {
// "PART", // replace with filtered PART to hide client part messages
"PASS",
// "PING",
// "PONG", // replaced with a filtered PING/PONG since some clients send the server IP (thanks aardvax!)
"PONG",
// "QUIT", // replace with a filtered QUIT to hide client quit messages
"RULES",
"SETNAME",
@@ -291,8 +289,6 @@ abstract class IRCFilter {
return rv;
}
if ("PONG".equals(command))
return "PONG 127.0.0.1"; // no way to know what the ircd to i2ptunnel server con is, so localhost works
// Allow all allowedCommands
if (_allowedOutbound.contains(command))

View File

@@ -1,8 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.streamr;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -17,6 +12,7 @@ import net.i2p.i2ptunnel.udp.*;
* @author zzz modded for I2PTunnel
*/
public class MultiSource implements Source, Sink {
public MultiSource() {
this.sinks = new CopyOnWriteArrayList<Destination>();
}
@@ -45,20 +41,6 @@ public class MultiSource implements Source, Sink {
this.sinks.remove(sink);
}
private Sink sink;
private List<Destination> sinks;
private final List<Destination> sinks;
}

View File

@@ -7,9 +7,11 @@ import net.i2p.i2ptunnel.udp.*;
* @author welterde/zzz
*/
public class Pinger implements Source, Runnable {
public Pinger() {
this.thread = new Thread(this);
}
public void setSink(Sink sink) {
this.sink = sink;
}
@@ -53,7 +55,7 @@ public class Pinger implements Source, Runnable {
}
protected Sink sink;
protected Thread thread;
protected final Thread thread;
private final Object waitlock = new Object();
protected boolean running;
protected volatile boolean running;
}

View File

@@ -1,8 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.streamr;
import java.net.InetAddress;
@@ -52,16 +47,7 @@ public class StreamrConsumer extends I2PTunnelUDPClientBase {
this.sink.stop();
return super.close(forced);
}
private UDPSink sink;
private Pinger pinger;
private final UDPSink sink;
private final Pinger pinger;
}

View File

@@ -1,14 +1,7 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.streamr;
// system
import java.io.File;
// i2p
import net.i2p.i2ptunnel.I2PTunnel;
import net.i2p.i2ptunnel.Logging;
import net.i2p.i2ptunnel.udp.*;
@@ -57,17 +50,8 @@ public class StreamrProducer extends I2PTunnelUDPServerBase {
this.multi.stop();
return super.close(forced);
}
private MultiSource multi;
private UDPSource server;
private Sink subscriber;
private final MultiSource multi;
private final UDPSource server;
private final Sink subscriber;
}

View File

@@ -1,11 +1,5 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.streamr;
// system
import java.util.Set;
import net.i2p.data.Destination;
@@ -51,15 +45,6 @@ public class Subscriber implements Sink {
}
}
private Set<Destination> subscriptions;
private MultiSource multi;
private final Set<Destination> subscriptions;
private final MultiSource multi;
}

View File

@@ -1,11 +1,5 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.udp;
// i2p
import net.i2p.client.I2PSession;
import net.i2p.client.I2PSessionException;
import net.i2p.data.Destination;
@@ -19,17 +13,23 @@ import net.i2p.client.datagram.I2PDatagramMaker;
* @author welterde
*/
public class I2PSink implements Sink {
public I2PSink(I2PSession sess, Destination dest) {
this(sess, dest, false);
}
public I2PSink(I2PSession sess, Destination dest, boolean raw) {
this.sess = sess;
this.dest = dest;
this.raw = raw;
// create maker
if (!raw)
if (raw) {
this.maker = null;
} else {
this.maker = new I2PDatagramMaker();
this.maker.setI2PDatagramMaker(this.sess);
}
}
/** @param src ignored */
@@ -46,7 +46,8 @@ public class I2PSink implements Sink {
// send message
try {
this.sess.sendMessage(this.dest, payload, I2PSession.PROTO_DATAGRAM,
this.sess.sendMessage(this.dest, payload,
(this.raw ? I2PSession.PROTO_DATAGRAM_RAW : I2PSession.PROTO_DATAGRAM),
I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
} catch(I2PSessionException exc) {
// TODO: handle better
@@ -54,8 +55,8 @@ public class I2PSink implements Sink {
}
}
protected boolean raw;
protected I2PSession sess;
protected Destination dest;
protected final I2PDatagramMaker maker= new I2PDatagramMaker(); // FIXME should be final and use a factory. FIXME
protected final boolean raw;
protected final I2PSession sess;
protected final Destination dest;
protected final I2PDatagramMaker maker;
}

View File

@@ -1,11 +1,5 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.udp;
// i2p
import net.i2p.client.I2PSession;
import net.i2p.client.I2PSessionException;
import net.i2p.data.Destination;
@@ -19,16 +13,22 @@ import net.i2p.client.datagram.I2PDatagramMaker;
* @author zzz modded from I2PSink by welterde
*/
public class I2PSinkAnywhere implements Sink {
public I2PSinkAnywhere(I2PSession sess) {
this(sess, false);
}
public I2PSinkAnywhere(I2PSession sess, boolean raw) {
this.sess = sess;
this.raw = raw;
// create maker
if (!raw)
if (raw) {
this.maker = null;
} else {
this.maker = new I2PDatagramMaker();
this.maker.setI2PDatagramMaker(this.sess);
}
}
/** @param to - where it's going */
@@ -44,7 +44,8 @@ public class I2PSinkAnywhere implements Sink {
// send message
try {
this.sess.sendMessage(to, payload, I2PSession.PROTO_DATAGRAM,
this.sess.sendMessage(to, payload,
(this.raw ? I2PSession.PROTO_DATAGRAM_RAW : I2PSession.PROTO_DATAGRAM),
I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
} catch(I2PSessionException exc) {
// TODO: handle better
@@ -52,8 +53,7 @@ public class I2PSinkAnywhere implements Sink {
}
}
protected boolean raw;
protected I2PSession sess;
protected Destination dest;
protected final I2PDatagramMaker maker = new I2PDatagramMaker();
protected final boolean raw;
protected final I2PSession sess;
protected final I2PDatagramMaker maker;
}

View File

@@ -1,15 +1,8 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.udp;
// system
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
// i2p
import net.i2p.client.I2PSession;
import net.i2p.client.I2PSessionListener;
import net.i2p.client.datagram.I2PDatagramDissector;
@@ -19,15 +12,17 @@ import net.i2p.client.datagram.I2PDatagramDissector;
* @author welterde
*/
public class I2PSource implements Source, Runnable {
public I2PSource(I2PSession sess) {
this(sess, true, false);
}
public I2PSource(I2PSession sess, boolean verify) {
this(sess, verify, false);
}
public I2PSource(I2PSession sess, boolean verify, boolean raw) {
this.sess = sess;
this.sink = null;
this.verify = verify;
this.raw = raw;
@@ -80,11 +75,6 @@ public class I2PSource implements Source, Runnable {
}
}
protected class Listener implements I2PSessionListener {
public void messageAvailable(I2PSession sess, int id, long size) {
@@ -109,15 +99,10 @@ public class I2PSource implements Source, Runnable {
}
protected I2PSession sess;
protected BlockingQueue<Integer> queue;
protected final I2PSession sess;
protected final BlockingQueue<Integer> queue;
protected Sink sink;
protected Thread thread;
protected boolean verify;
protected boolean raw;
protected final Thread thread;
protected final boolean verify;
protected final boolean raw;
}

View File

@@ -1,11 +1,5 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.udp;
// i2p
import net.i2p.data.Destination;
/**

View File

@@ -1,8 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.udp;
/**

View File

@@ -1,8 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.udp;
/**

View File

@@ -1,16 +1,9 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.udp;
// system
import java.net.DatagramSocket;
import java.net.DatagramPacket;
import java.net.InetAddress;
// i2p
import net.i2p.data.Destination;
/**
@@ -18,6 +11,7 @@ import net.i2p.data.Destination;
* @author welterde
*/
public class UDPSink implements Sink {
public UDPSink(InetAddress host, int port) {
// create socket
try {
@@ -61,17 +55,8 @@ public class UDPSink implements Sink {
this.sock.close();
}
protected DatagramSocket sock;
protected InetAddress remoteHost;
protected int remotePort;
protected final DatagramSocket sock;
protected final InetAddress remoteHost;
protected final int remotePort;
}

View File

@@ -1,11 +1,5 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.i2p.i2ptunnel.udp;
// system
import java.net.DatagramSocket;
import java.net.DatagramPacket;
@@ -15,9 +9,8 @@ import java.net.DatagramPacket;
*/
public class UDPSource implements Source, Runnable {
public static final int MAX_SIZE = 15360;
public UDPSource(int port) {
this.sink = null;
// create udp-socket
try {
this.sock = new DatagramSocket(port);
@@ -31,7 +24,6 @@ public class UDPSource implements Source, Runnable {
/** use socket from UDPSink */
public UDPSource(DatagramSocket sock) {
this.sink = null;
this.sock = sock;
this.thread = new Thread(this);
}
@@ -73,19 +65,7 @@ public class UDPSource implements Source, Runnable {
this.sock.close();
}
protected DatagramSocket sock;
protected final DatagramSocket sock;
protected Sink sink;
protected Thread thread;
protected final Thread thread;
}

View File

@@ -51,14 +51,15 @@ import net.i2p.util.EventDispatcher;
private static final AtomicLong __clientId = new AtomicLong();
protected long _clientId;
protected Destination dest = null;
protected Destination dest;
private final Object startLock = new Object();
private I2PSession _session;
private Source _i2pSource;
private Sink _i2pSink;
private Destination _otherDest;
private final I2PSession _session;
private final Source _i2pSource;
private final Sink _i2pSink;
private final Destination _otherDest;
/**
* @throws IllegalArgumentException if the I2CP configuration is b0rked so
* badly that we cant create a socketManager
@@ -105,6 +106,7 @@ import net.i2p.util.EventDispatcher;
}
_i2pSink = new I2PSink(_session, _otherDest, false);
} else {
_otherDest = null;
_i2pSink = new I2PSinkAnywhere(_session, false);
}
}