* Firewall fix for NTCP, where firewalls will forget a NAT relationship

on a stream... AKA setting keepalive. This should fix the stuck NTCP
      issue that has been bothing zzz for years.
    * Set keepalive on BOB connections too, since this will assist closing
      the connections in the event of a crash on a client.
This commit is contained in:
sponge
2010-01-19 08:54:40 +00:00
parent 00fa3806d8
commit 5c595ef289
7 changed files with 18 additions and 2 deletions

View File

@ -2,6 +2,7 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> <project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/> <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1"> <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
<file>file:/usblv/NetBeansProjects/i2p.i2p/apps/BOB/src/net/i2p/BOB/BOB.java</file> <file>file:/usblv/NetBeansProjects/i2p.i2p/apps/BOB/src/net/i2p/BOB/I2PtoTCP.java</file>
<file>file:/usblv/NetBeansProjects/i2p.i2p/apps/BOB/src/net/i2p/BOB/MUXlisten.java</file>
</open-files> </open-files>
</project-private> </project-private>

View File

@ -256,11 +256,13 @@ public class BOB {
listener = new ServerSocket(Integer.parseInt(props.getProperty(PROP_BOB_PORT)), 10, InetAddress.getByName(props.getProperty(PROP_BOB_HOST))); listener = new ServerSocket(Integer.parseInt(props.getProperty(PROP_BOB_PORT)), 10, InetAddress.getByName(props.getProperty(PROP_BOB_HOST)));
Socket server = null; Socket server = null;
listener.setSoTimeout(500); // .5 sec listener.setSoTimeout(500); // .5 sec
while (spin.get()) { while (spin.get()) {
//DoCMDS connection; //DoCMDS connection;
try { try {
server = listener.accept(); server = listener.accept();
server.setKeepAlive(true);
g = true; g = true;
} catch (ConnectException ce) { } catch (ConnectException ce) {
g = false; g = false;

View File

@ -102,6 +102,7 @@ public class I2PtoTCP implements Runnable {
break die; break die;
} }
sock = new Socket(host, port); sock = new Socket(host, port);
sock.setKeepAlive(true);
// make readers/writers // make readers/writers
in = sock.getInputStream(); in = sock.getInputStream();
out = sock.getOutputStream(); out = sock.getOutputStream();

View File

@ -78,6 +78,7 @@ public class TCPlistener implements Runnable {
while (lives.get()) { while (lives.get()) {
try { try {
server = listener.accept(); server = listener.accept();
server.setKeepAlive(true);
g = true; g = true;
} catch (SocketTimeoutException ste) { } catch (SocketTimeoutException ste) {
g = false; g = false;

View File

@ -1,3 +1,10 @@
2010-01-19 sponge
* Firewall fix for NTCP, where firewalls will forget a NAT relationship
on a stream... AKA setting keepalive. This should fix the stuck NTCP
issue that has been bothing zzz for years.
* Set keepalive on BOB connections too, since this will assist closing
the connections in the event of a crash on a client.
2010-01-18 zzz 2010-01-18 zzz
* configclients.jsp: Fix add-new-client feature * configclients.jsp: Fix add-new-client feature
* Console: Add a tunnel share ratio estimate * Console: Add a tunnel share ratio estimate

View File

@ -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 = 4; public final static long BUILD = 5;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = "-rc"; public final static String EXTRA = "-rc";

View File

@ -418,6 +418,8 @@ public class EventPumper implements Runnable {
try { chan.close(); } catch (IOException ioe) { } try { chan.close(); } catch (IOException ioe) { }
return; return;
} }
// BUGFIX for firewalls. --Sponge
chan.socket().setKeepAlive(true);
SelectionKey ckey = chan.register(_selector, SelectionKey.OP_READ); SelectionKey ckey = chan.register(_selector, SelectionKey.OP_READ);
NTCPConnection con = new NTCPConnection(_context, _transport, chan, ckey); NTCPConnection con = new NTCPConnection(_context, _transport, chan, ckey);
@ -436,6 +438,8 @@ public class EventPumper implements Runnable {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("processing connect for " + key + " / " + con + ": connected? " + connected); _log.debug("processing connect for " + key + " / " + con + ": connected? " + connected);
if (connected) { if (connected) {
// BUGFIX for firewalls. --Sponge
chan.socket().setKeepAlive(true);
con.setKey(key); con.setKey(key);
con.outboundConnected(); con.outboundConnected();
_context.statManager().addRateData("ntcp.connectSuccessful", 1, 0); _context.statManager().addRateData("ntcp.connectSuccessful", 1, 0);