I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit d078ed39 authored by zzz's avatar zzz
Browse files

move init, add config

parent 7c36c0c8
No related branches found
No related tags found
No related merge requests found
......@@ -93,6 +93,7 @@ public class I2PSocketManagerFull implements I2PSocketManager {
_log.info("Socket manager created. \ndefault options: " + _defaultOptions
+ "\noriginal properties: " + opts);
}
debugInit(context);
}
public I2PSocketOptions buildOptions() { return buildOptions(null); }
......@@ -269,4 +270,25 @@ public class I2PSocketManagerFull implements I2PSocketManager {
public void removeDisconnectListener(I2PSocketManager.DisconnectListener lsnr) {
_connectionManager.getMessageHandler().removeDisconnectListener(lsnr);
}
private static final Object _pcapInitLock = new Object();
private static boolean _pcapInitialized;
static PcapWriter pcapWriter;
static final String PROP_PCAP = "i2p.streaming.pcap";
private static final String PCAP_FILE = "streaming.pcap";
private static void debugInit(I2PAppContext ctx) {
if (!Boolean.valueOf(ctx.getProperty(PROP_PCAP)).booleanValue())
return;
synchronized(_pcapInitLock) {
if (!_pcapInitialized) {
try {
pcapWriter = new PcapWriter(ctx, PCAP_FILE);
} catch (java.io.IOException ioe) {
System.err.println("pcap init ioe: " + ioe);
}
_pcapInitialized = true;
}
}
}
}
......@@ -29,9 +29,6 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat
private volatile int _nackCount;
private volatile boolean _retransmitted;
private SimpleTimer2.TimedEvent _resendEvent;
private static final Object initLock = new Object();
private static boolean _initialized;
private static PcapWriter _pcapWriter;
public PacketLocal(I2PAppContext ctx, Destination to) {
this(ctx, to, null);
......@@ -46,12 +43,6 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat
_cancelledOn = -1;
_nackCount = 0;
_retransmitted = false;
synchronized(initLock) {
if (!_initialized) {
initPcap();
_initialized = true;
}
}
}
public Destination getTo() { return _to; }
......@@ -255,24 +246,16 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat
public boolean writeFailed() { return _cancelledOn > 0; }
public boolean writeSuccessful() { return _ackOn > 0 && _cancelledOn <= 0; }
static final String PCAP = "foo.pcap";
private void initPcap() {
try {
_pcapWriter = new PcapWriter(_context, PCAP);
} catch (IOException ioe) {
System.err.println("pcap init ioe: " + ioe);
}
}
/** Generate a pcap/tcpdump-compatible format,
* so we can use standard debugging tools.
*/
public void logTCPDump(boolean isInbound) {
if (!_log.shouldLog(Log.INFO)) return;
_log.info(toString());
if (_pcapWriter != null) {
if (_log.shouldLog(Log.INFO))
_log.info(toString());
if (I2PSocketManagerFull.pcapWriter != null &&
Boolean.valueOf(_context.getProperty(I2PSocketManagerFull.PROP_PCAP)).booleanValue()) {
try {
_pcapWriter.write(this, isInbound);
I2PSocketManagerFull.pcapWriter.write(this, isInbound);
} catch (IOException ioe) {
_log.warn("pcap write ioe: " + ioe);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment