forked from I2P_Developers/i2p.i2p
More i2ptunnel error propagation fixes - key file - thx echelon
This commit is contained in:
@@ -390,10 +390,10 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
if (!privKeyFile.isAbsolute())
|
||||
privKeyFile = new File(_context.getConfigDir(), args[2]);
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
l.log(getPrefix() + "Private key file does not exist or is not readable: " + args[2]);
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[2]);
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
throw new IllegalArgumentException(getPrefix() + "Cannot open private key file " + args[2]);
|
||||
}
|
||||
I2PTunnelServer serv = new I2PTunnelServer(serverHost, portNum, privKeyFile, args[2], l, (EventDispatcher) this, this);
|
||||
serv.setReadTimeout(readTimeout);
|
||||
@@ -441,10 +441,10 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
if (!privKeyFile.isAbsolute())
|
||||
privKeyFile = new File(_context.getConfigDir(), args[2]);
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
l.log(getPrefix() + "Private key file does not exist or is not readable: " + args[2]);
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[2]);
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
throw new IllegalArgumentException(getPrefix() + "Cannot open private key file " + args[2]);
|
||||
}
|
||||
I2PTunnelServer serv = new I2PTunnelIRCServer(serverHost, portNum, privKeyFile, args[2], l, (EventDispatcher) this, this);
|
||||
serv.setReadTimeout(readTimeout);
|
||||
@@ -502,10 +502,10 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
if (!privKeyFile.isAbsolute())
|
||||
privKeyFile = new File(_context.getConfigDir(), args[3]);
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
l.log(getPrefix() + "Private key file does not exist or is not readable: " + args[3]);
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[3]);
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
throw new IllegalArgumentException(getPrefix() + "Cannot open private key file " + args[3]);
|
||||
}
|
||||
I2PTunnelHTTPServer serv = new I2PTunnelHTTPServer(serverHost, portNum, privKeyFile, args[3], spoofedHost, l, (EventDispatcher) this, this);
|
||||
serv.setReadTimeout(readTimeout);
|
||||
@@ -577,10 +577,10 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
if (!privKeyFile.isAbsolute())
|
||||
privKeyFile = new File(_context.getConfigDir(), args[4]);
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
l.log(getPrefix() + "Private key file does not exist or is not readable: " + args[4]);
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[4]);
|
||||
notifyEvent("serverTaskId", Integer.valueOf(-1));
|
||||
return;
|
||||
throw new IllegalArgumentException(getPrefix() + "Cannot open private key file " + args[4]);
|
||||
}
|
||||
|
||||
I2PTunnelHTTPBidirServer serv = new I2PTunnelHTTPBidirServer(serverHost, portNum, port2Num, privKeyFile, args[3], spoofedHost, l, (EventDispatcher) this, this);
|
||||
|
||||
@@ -46,6 +46,7 @@ public class TunnelController implements Logging {
|
||||
public TunnelController(Properties config, String prefix) {
|
||||
this(config, prefix, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param createKey for servers, whether we want to create a brand new destination
|
||||
@@ -58,17 +59,21 @@ public class TunnelController implements Logging {
|
||||
setConfig(config, prefix);
|
||||
_messages = new ArrayList(4);
|
||||
_running = false;
|
||||
boolean keyOK = true;
|
||||
if (createKey && (getType().endsWith("server") || getPersistentClientKey()))
|
||||
createPrivateKey();
|
||||
_starting = getStartOnLoad();
|
||||
keyOK = createPrivateKey();
|
||||
_starting = keyOK && getStartOnLoad();
|
||||
}
|
||||
|
||||
private void createPrivateKey() {
|
||||
/**
|
||||
* @return success
|
||||
*/
|
||||
private boolean createPrivateKey() {
|
||||
I2PClient client = I2PClientFactory.createClient();
|
||||
String filename = getPrivKeyFile();
|
||||
if ( (filename == null) || (filename.trim().length() <= 0) ) {
|
||||
log("No filename specified for the private key");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
File keyFile = new File(getPrivKeyFile());
|
||||
@@ -76,7 +81,7 @@ public class TunnelController implements Logging {
|
||||
keyFile = new File(I2PAppContext.getGlobalContext().getConfigDir(), getPrivKeyFile());
|
||||
if (keyFile.exists()) {
|
||||
//log("Not overwriting existing private keys in " + keyFile.getAbsolutePath());
|
||||
return;
|
||||
return true;
|
||||
} else {
|
||||
File parent = keyFile.getParentFile();
|
||||
if ( (parent != null) && (!parent.exists()) )
|
||||
@@ -94,13 +99,16 @@ public class TunnelController implements Logging {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Error creating new destination", ie);
|
||||
log("Error creating new destination: " + ie.getMessage());
|
||||
return false;
|
||||
} catch (IOException ioe) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Error creating writing the destination to " + keyFile.getAbsolutePath(), ioe);
|
||||
log("Error writing the keys to " + keyFile.getAbsolutePath());
|
||||
return false;
|
||||
} finally {
|
||||
if (fos != null) try { fos.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void startTunnelBackground() {
|
||||
@@ -126,6 +134,10 @@ public class TunnelController implements Logging {
|
||||
}
|
||||
_starting = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException via methods in I2PTunnel
|
||||
*/
|
||||
private void doStartTunnel() {
|
||||
if (_running) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
2010-07-08 zzz
|
||||
* I2PTunnel: More error propagation fixes
|
||||
|
||||
2010-07-07 duck
|
||||
* RouterConsole: Add Help & FAQ link, minor label improvements.
|
||||
|
||||
|
||||
@@ -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 = 8;
|
||||
public final static long BUILD = 9;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
||||
Reference in New Issue
Block a user