From 978cd2c484bd68157da05366bb0dbbd07886ac29 Mon Sep 17 00:00:00 2001 From: sponge Date: Sat, 5 Dec 2009 13:26:40 +0000 Subject: [PATCH] * BOB: fix a critical bug causing ghosts on probes and remove unused code. --- apps/BOB/src/net/i2p/BOB/DoCMDS.java | 2 +- apps/BOB/src/net/i2p/BOB/I2Plistener.java | 58 +++++++------------ apps/BOB/src/net/i2p/BOB/MUXlisten.java | 4 +- apps/BOB/src/net/i2p/BOB/TCPlistener.java | 49 ++++++---------- history.txt | 4 ++ .../src/net/i2p/router/RouterVersion.java | 2 +- 6 files changed, 47 insertions(+), 72 deletions(-) diff --git a/apps/BOB/src/net/i2p/BOB/DoCMDS.java b/apps/BOB/src/net/i2p/BOB/DoCMDS.java index 14c83c4ba..dcb0a195d 100644 --- a/apps/BOB/src/net/i2p/BOB/DoCMDS.java +++ b/apps/BOB/src/net/i2p/BOB/DoCMDS.java @@ -50,7 +50,7 @@ public class DoCMDS implements Runnable { // FIX ME // I need a better way to do versioning, but this will do for now. - public static final String BMAJ = "00", BMIN = "00", BREV = "09", BEXT = ""; + public static final String BMAJ = "00", BMIN = "00", BREV = "0A", BEXT = ""; public static final String BOBversion = BMAJ + "." + BMIN + "." + BREV + BEXT; private Socket server; private Properties props; diff --git a/apps/BOB/src/net/i2p/BOB/I2Plistener.java b/apps/BOB/src/net/i2p/BOB/I2Plistener.java index e55e54b9d..fc6dde603 100644 --- a/apps/BOB/src/net/i2p/BOB/I2Plistener.java +++ b/apps/BOB/src/net/i2p/BOB/I2Plistener.java @@ -60,20 +60,9 @@ public class I2Plistener implements Runnable { this._log = _log; this.socketManager = S; this.serverSocket = SS; -// tgwatch = 1; this.lives = lives; } - private void rlock() throws Exception { - database.getReadLock(); - info.getReadLock(); - } - - private void runlock() throws Exception { - database.releaseReadLock(); - info.releaseReadLock(); - } - /** * Simply listen on I2P port, and thread connections * @@ -83,34 +72,31 @@ public class I2Plistener implements Runnable { I2PSocket sessSocket = null; int conn = 0; try { - die: - { - try { - serverSocket.setSoTimeout(50); - - while (lives.get()) { - try { - sessSocket = serverSocket.accept(); - g = true; - } catch (ConnectException ce) { - g = false; - } catch (SocketTimeoutException ste) { - g = false; - } - if (g) { - g = false; - conn++; - // toss the connection to a new thread. - I2PtoTCP conn_c = new I2PtoTCP(sessSocket, info, database, lives); - Thread t = new Thread(conn_c, Thread.currentThread().getName() + " I2PtoTCP " + conn); - t.start(); - } + try { + serverSocket.setSoTimeout(50); + while (lives.get()) { + try { + sessSocket = serverSocket.accept(); + g = true; + } catch (ConnectException ce) { + g = false; + } catch (SocketTimeoutException ste) { + g = false; } - } catch (I2PException e) { - // bad shit - System.out.println("Exception " + e); + if (g) { + g = false; + conn++; + // toss the connection to a new thread. + I2PtoTCP conn_c = new I2PtoTCP(sessSocket, info, database, lives); + Thread t = new Thread(conn_c, Thread.currentThread().getName() + " I2PtoTCP " + conn); + t.start(); + } + } + } catch (I2PException e) { + // bad shit + System.out.println("Exception " + e); } } finally { try { diff --git a/apps/BOB/src/net/i2p/BOB/MUXlisten.java b/apps/BOB/src/net/i2p/BOB/MUXlisten.java index c91a8743c..671fffa95 100644 --- a/apps/BOB/src/net/i2p/BOB/MUXlisten.java +++ b/apps/BOB/src/net/i2p/BOB/MUXlisten.java @@ -104,10 +104,10 @@ public class MUXlisten implements Runnable { this.database.releaseReadLock(); this.info.releaseReadLock(); - socketManager = I2PSocketManagerFactory.createManager(prikey, Q); if (this.come_in) { this.listener = new ServerSocket(port, backlog, host); } + socketManager = I2PSocketManagerFactory.createManager(prikey, Q); // I2PException, IOException, RuntimeException // To bad we can't just catch and enumerate.... // } catch (I2PException e) { @@ -141,8 +141,6 @@ public class MUXlisten implements Runnable { this.info.add("STARTING", new Boolean(false)); this.info.releaseWriteLock(); this.database.releaseWriteLock(); - // throw new Exception(e); - // Debugging, I guess. e.printStackTrace(); throw new RuntimeException(e); } diff --git a/apps/BOB/src/net/i2p/BOB/TCPlistener.java b/apps/BOB/src/net/i2p/BOB/TCPlistener.java index b5addc27b..714ee1e7f 100644 --- a/apps/BOB/src/net/i2p/BOB/TCPlistener.java +++ b/apps/BOB/src/net/i2p/BOB/TCPlistener.java @@ -64,16 +64,6 @@ public class TCPlistener implements Runnable { this.lives = lives; } - private void rlock() throws Exception { - database.getReadLock(); - info.getReadLock(); - } - - private void runlock() throws Exception { - database.releaseReadLock(); - info.releaseReadLock(); - } - /** * Simply listen on TCP port, and thread connections * @@ -81,30 +71,27 @@ public class TCPlistener implements Runnable { public void run() { boolean g = false; int conn = 0; + Socket server = null; try { - die: - { - try { - Socket server = new Socket(); - listener.setSoTimeout(50); // We don't block, we cycle and check. - while (lives.get()) { - try { - server = listener.accept(); - g = true; - } catch (SocketTimeoutException ste) { - g = false; - } - if (g) { - conn++; - // toss the connection to a new thread. - TCPtoI2P conn_c = new TCPtoI2P(socketManager, server, info, database, lives); - Thread t = new Thread(conn_c, Thread.currentThread().getName() + " TCPtoI2P " + conn); - t.start(); - g = false; - } + try { + listener.setSoTimeout(50); // We don't block, we cycle and check. + while (lives.get()) { + try { + server = listener.accept(); + g = true; + } catch (SocketTimeoutException ste) { + g = false; + } + if (g) { + conn++; + // toss the connection to a new thread. + TCPtoI2P conn_c = new TCPtoI2P(socketManager, server, info, database, lives); + Thread t = new Thread(conn_c, Thread.currentThread().getName() + " TCPtoI2P " + conn); + t.start(); + g = false; } - } catch (IOException ioe) { } + } catch (IOException ioe) { } } finally { try { diff --git a/history.txt b/history.txt index ce9463465..01e2e6617 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,7 @@ +2009-12-05 sponge + * BOB: fix a critical bug causing ghosts on probes + and remove unused code. + 2009-12-04 zzz * Console: Close up some possible XSS (thanks Pragmatk) * i2psnark: Config cleanup, more HTML transitional fixes diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index b2865c3c1..f55bf0ab2 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 25; + public final static long BUILD = 26; /** for example "-test" */ public final static String EXTRA = ""; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;