2009-06-08 sponge
* Fixed NPE and some other goofups in BOB. * BOB bump version
This commit is contained in:
@ -38,7 +38,6 @@ import net.i2p.client.I2PClient;
|
|||||||
import net.i2p.client.streaming.RetransmissionTimer;
|
import net.i2p.client.streaming.RetransmissionTimer;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SimpleScheduler;
|
import net.i2p.util.SimpleScheduler;
|
||||||
import net.i2p.util.SimpleStore;
|
|
||||||
import net.i2p.util.SimpleTimer2;
|
import net.i2p.util.SimpleTimer2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ public class DoCMDS implements Runnable {
|
|||||||
|
|
||||||
// FIX ME
|
// FIX ME
|
||||||
// I need a better way to do versioning, but this will do for now.
|
// I need a better way to do versioning, but this will do for now.
|
||||||
public static final String BMAJ = "00", BMIN = "00", BREV = "06", BEXT = "";
|
public static final String BMAJ = "00", BMIN = "00", BREV = "07", BEXT = "";
|
||||||
public static final String BOBversion = BMAJ + "." + BMIN + "." + BREV + BEXT;
|
public static final String BOBversion = BMAJ + "." + BMIN + "." + BREV + BEXT;
|
||||||
private Socket server;
|
private Socket server;
|
||||||
private Properties props;
|
private Properties props;
|
||||||
|
@ -52,12 +52,12 @@ public class I2PtoTCP implements Runnable {
|
|||||||
this.database = database;
|
this.database = database;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rlock() throws Exception {
|
private void rlock() {
|
||||||
database.getReadLock();
|
database.getReadLock();
|
||||||
info.getReadLock();
|
info.getReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runlock() throws Exception {
|
private void runlock() {
|
||||||
database.releaseReadLock();
|
database.releaseReadLock();
|
||||||
info.releaseReadLock();
|
info.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ import net.i2p.util.Log;
|
|||||||
*/
|
*/
|
||||||
public class MUXlisten implements Runnable {
|
public class MUXlisten implements Runnable {
|
||||||
|
|
||||||
private NamedDB database, info;
|
private NamedDB database, info;
|
||||||
private Log _log;
|
private Log _log;
|
||||||
private I2PSocketManager socketManager;
|
private I2PSocketManager socketManager;
|
||||||
private ByteArrayInputStream prikey;
|
private ByteArrayInputStream prikey;
|
||||||
|
@ -42,7 +42,6 @@ public class TCPlistener implements Runnable {
|
|||||||
|
|
||||||
private NamedDB info, database;
|
private NamedDB info, database;
|
||||||
private Log _log;
|
private Log _log;
|
||||||
private int tgwatch;
|
|
||||||
public I2PSocketManager socketManager;
|
public I2PSocketManager socketManager;
|
||||||
public I2PServerSocket serverSocket;
|
public I2PServerSocket serverSocket;
|
||||||
private ServerSocket listener;
|
private ServerSocket listener;
|
||||||
@ -60,7 +59,6 @@ public class TCPlistener implements Runnable {
|
|||||||
this._log = _log;
|
this._log = _log;
|
||||||
this.socketManager = S;
|
this.socketManager = S;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
tgwatch = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rlock() throws Exception {
|
private void rlock() throws Exception {
|
||||||
@ -84,28 +82,6 @@ public class TCPlistener implements Runnable {
|
|||||||
try {
|
try {
|
||||||
die:
|
die:
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
rlock();
|
|
||||||
} catch (Exception e) {
|
|
||||||
break die;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (info.exists("OUTPORT")) {
|
|
||||||
tgwatch = 2;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
try {
|
|
||||||
runlock();
|
|
||||||
} catch (Exception e2) {
|
|
||||||
break die;
|
|
||||||
}
|
|
||||||
break die;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
runlock();
|
|
||||||
} catch (Exception e) {
|
|
||||||
break die;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
Socket server = new Socket();
|
Socket server = new Socket();
|
||||||
listener.setSoTimeout(50); // We don't block, we cycle and check.
|
listener.setSoTimeout(50); // We don't block, we cycle and check.
|
||||||
@ -134,7 +110,7 @@ public class TCPlistener implements Runnable {
|
|||||||
if (g) {
|
if (g) {
|
||||||
conn++;
|
conn++;
|
||||||
// toss the connection to a new thread.
|
// toss the connection to a new thread.
|
||||||
TCPtoI2P conn_c = new TCPtoI2P(socketManager, server);
|
TCPtoI2P conn_c = new TCPtoI2P(socketManager, server, info, database);
|
||||||
Thread t = new Thread(conn_c, Thread.currentThread().getName() + " TCPtoI2P " + conn);
|
Thread t = new Thread(conn_c, Thread.currentThread().getName() + " TCPtoI2P " + conn);
|
||||||
t.start();
|
t.start();
|
||||||
g = false;
|
g = false;
|
||||||
|
@ -33,6 +33,7 @@ import java.net.Socket;
|
|||||||
import net.i2p.I2PException;
|
import net.i2p.I2PException;
|
||||||
import net.i2p.client.streaming.I2PSocket;
|
import net.i2p.client.streaming.I2PSocket;
|
||||||
import net.i2p.client.streaming.I2PSocketManager;
|
import net.i2p.client.streaming.I2PSocketManager;
|
||||||
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
import net.i2p.i2ptunnel.I2PTunnel;
|
import net.i2p.i2ptunnel.I2PTunnel;
|
||||||
|
|
||||||
@ -49,15 +50,29 @@ public class TCPtoI2P implements Runnable {
|
|||||||
private Socket sock;
|
private Socket sock;
|
||||||
private I2PSocketManager socketManager;
|
private I2PSocketManager socketManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param i2p
|
||||||
|
* @param socket
|
||||||
|
* param info
|
||||||
|
* param database
|
||||||
|
*/
|
||||||
|
TCPtoI2P(I2PSocketManager i2p, Socket socket , NamedDB info, NamedDB database) {
|
||||||
|
this.sock = socket;
|
||||||
|
this.info = info;
|
||||||
|
this.database = database;
|
||||||
|
this.socketManager = i2p;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a more forgiving readline,
|
* This is a more forgiving readline,
|
||||||
* it works on unbuffered streams
|
* it works on unbuffered streams
|
||||||
*
|
*
|
||||||
* @param in
|
* @param in
|
||||||
* @return line of text as a String
|
* @return line of text as a String
|
||||||
* @throws Exception
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static String lnRead(InputStream in) throws Exception {
|
private static String lnRead(InputStream in) throws IOException {
|
||||||
String S;
|
String S;
|
||||||
int b;
|
int b;
|
||||||
char c;
|
char c;
|
||||||
@ -80,20 +95,6 @@ public class TCPtoI2P implements Runnable {
|
|||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param i2p
|
|
||||||
* @param socket
|
|
||||||
* param info
|
|
||||||
* param database
|
|
||||||
*/
|
|
||||||
TCPtoI2P(I2PSocketManager i2p, Socket socket /*, NamedDB info, NamedDB database */) {
|
|
||||||
this.sock = socket;
|
|
||||||
// this.info = info;
|
|
||||||
// this.database = database;
|
|
||||||
this.socketManager = i2p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print an error message to out
|
* Print an error message to out
|
||||||
*
|
*
|
||||||
@ -103,19 +104,22 @@ public class TCPtoI2P implements Runnable {
|
|||||||
*/
|
*/
|
||||||
private void Emsg(String e, OutputStream out) throws IOException {
|
private void Emsg(String e, OutputStream out) throws IOException {
|
||||||
// Debugging System.out.println("ERROR TCPtoI2P: " + e);
|
// Debugging System.out.println("ERROR TCPtoI2P: " + e);
|
||||||
out.write("ERROR".concat(e).getBytes());
|
out.write("ERROR ".concat(e).getBytes());
|
||||||
out.write(13); // cr
|
out.write(13);
|
||||||
|
out.write(10);
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rlock() throws Exception {
|
// private void rlock() throws Exception {
|
||||||
|
private void rlock() {
|
||||||
database.getReadLock();
|
database.getReadLock();
|
||||||
info.getReadLock();
|
info.getReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runlock() throws Exception {
|
// private void runlock() throws Exception {
|
||||||
database.releaseReadLock();
|
private void runlock() {
|
||||||
info.releaseReadLock();
|
info.releaseReadLock();
|
||||||
|
database.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,56 +139,64 @@ public class TCPtoI2P implements Runnable {
|
|||||||
|
|
||||||
in = sock.getInputStream();
|
in = sock.getInputStream();
|
||||||
out = sock.getOutputStream();
|
out = sock.getOutputStream();
|
||||||
try {
|
line = lnRead(in);
|
||||||
line = lnRead(in);
|
input = line.toLowerCase();
|
||||||
input = line.toLowerCase();
|
Destination dest = null;
|
||||||
Destination dest = null;
|
if (input.endsWith(".i2p")) {
|
||||||
|
dest = I2PTunnel.destFromName(input);
|
||||||
if (input.endsWith(".i2p")) {
|
line = dest.toBase64();
|
||||||
dest = I2PTunnel.destFromName(input);
|
}
|
||||||
line = dest.toBase64();
|
dest = new Destination();
|
||||||
}
|
dest.fromBase64(line);
|
||||||
dest = new Destination();
|
|
||||||
dest.fromBase64(line);
|
try {
|
||||||
|
// get a client socket
|
||||||
try {
|
I2P = socketManager.connect(dest);
|
||||||
// get a client socket
|
I2P.setReadTimeout(0); // temp bugfix, this *SHOULD* be the default
|
||||||
I2P = socketManager.connect(dest);
|
// make readers/writers
|
||||||
I2P.setReadTimeout(0); // temp bugfix, this *SHOULD* be the default
|
Iin = I2P.getInputStream();
|
||||||
// make readers/writers
|
Iout = I2P.getOutputStream();
|
||||||
Iin = I2P.getInputStream();
|
// setup to cross the streams
|
||||||
Iout = I2P.getOutputStream();
|
TCPio conn_c = new TCPio(in, Iout /*, info, database */); // app -> I2P
|
||||||
// setup to cross the streams
|
TCPio conn_a = new TCPio(Iin, out /*, info, database */); // I2P -> app
|
||||||
TCPio conn_c = new TCPio(in, Iout /*, info, database */); // app -> I2P
|
t = new Thread(conn_c, Thread.currentThread().getName() + " TCPioA");
|
||||||
TCPio conn_a = new TCPio(Iin, out /*, info, database */); // I2P -> app
|
q = new Thread(conn_a, Thread.currentThread().getName() + " TCPioB");
|
||||||
t = new Thread(conn_c, Thread.currentThread().getName() + " TCPioA");
|
// Fire!
|
||||||
q = new Thread(conn_a, Thread.currentThread().getName() + " TCPioB");
|
t.start();
|
||||||
// Fire!
|
q.start();
|
||||||
t.start();
|
boolean spin = true;
|
||||||
q.start();
|
while (t.isAlive() && q.isAlive()) { // AND is used here to kill off the other thread
|
||||||
boolean spin = true;
|
Thread.sleep(10); //sleep for 10 ms
|
||||||
while (t.isAlive() && q.isAlive()) { // AND is used here to kill off the other thread
|
rlock();
|
||||||
Thread.sleep(10); //sleep for 10 ms
|
spin = info.get("RUNNING").equals(Boolean.TRUE);
|
||||||
rlock();
|
runlock();
|
||||||
spin = info.get("RUNNING").equals(Boolean.TRUE);
|
}
|
||||||
runlock();
|
} catch (I2PException e) {
|
||||||
}
|
Emsg(e.toString(), out);
|
||||||
} catch (I2PException e) {
|
} catch (ConnectException e) {
|
||||||
Emsg("ERROR " + e.toString(), out);
|
Emsg(e.toString(), out);
|
||||||
} catch (ConnectException e) {
|
} catch (NoRouteToHostException e) {
|
||||||
Emsg("ERROR " + e.toString(), out);
|
Emsg(e.toString(), out);
|
||||||
} catch (NoRouteToHostException e) {
|
}
|
||||||
Emsg("ERROR " + e.toString(), out);
|
|
||||||
} catch (InterruptedIOException e) {
|
} catch (InterruptedIOException e) {
|
||||||
// We're breaking away.
|
// We're breaking away.
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
|
// ditto
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
Emsg("ERROR " + e.toString(), out);
|
try {
|
||||||
|
Emsg(e.toString(), out);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// ditto
|
||||||
|
}
|
||||||
|
} catch (DataFormatException e) {
|
||||||
|
try {
|
||||||
|
Emsg(e.toString(), out);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// ditto
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
// bail on anything else
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
t.interrupt();
|
t.interrupt();
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2009-06-08 sponge
|
||||||
|
* Fixed NPE and some other goofups in BOB.
|
||||||
|
* BOB bump version
|
||||||
|
|
||||||
2009-06-07 zzz
|
2009-06-07 zzz
|
||||||
* Build file:
|
* Build file:
|
||||||
- Add updaterWithJettyFixesAndGeoIP, use it in pkg for one release
|
- Add updaterWithJettyFixesAndGeoIP, use it in pkg for one release
|
||||||
|
@ -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 = 15;
|
public final static long BUILD = 16;
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "-rc";
|
public final static String EXTRA = "-rc";
|
||||||
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
||||||
|
Reference in New Issue
Block a user