From d7e2f39d25d34581deb12c6663bf1c0bacd9ebd4 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 10 Apr 2010 15:28:31 +0000 Subject: [PATCH] * Startup: - Don't die horribly if there is a router.info file but no router.keys file http://forum.i2p/viewtopic.php?t=4424 - Log tweaks --- .../i2p/router/startup/CreateRouterInfoJob.java | 4 ++-- .../net/i2p/router/startup/LoadRouterInfoJob.java | 15 ++++++++++----- .../i2p/router/startup/RebuildRouterInfoJob.java | 8 ++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java b/router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java index 5fbce84cd6..459cd0fb3a 100644 --- a/router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java +++ b/router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java @@ -98,9 +98,9 @@ public class CreateRouterInfoJob extends JobImpl { _log.info("Router info created and stored at " + ifile.getAbsolutePath() + " with private keys stored at " + kfile.getAbsolutePath() + " [" + info + "]"); } catch (DataFormatException dfe) { - _log.error("Error building the new router information", dfe); + _log.log(Log.CRIT, "Error building the new router information", dfe); } catch (IOException ioe) { - _log.error("Error writing out the new router information", ioe); + _log.log(Log.CRIT, "Error writing out the new router information", ioe); } finally { if (fos1 != null) try { fos1.close(); } catch (IOException ioe) {} if (fos2 != null) try { fos2.close(); } catch (IOException ioe) {} diff --git a/router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java b/router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java index f3428c4474..94b4f1d2ed 100644 --- a/router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java +++ b/router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java @@ -68,11 +68,18 @@ public class LoadRouterInfoJob extends JobImpl { FileInputStream fis1 = null; FileInputStream fis2 = null; try { - if (_infoExists) { + // if we have a routerinfo but no keys, things go bad in a hurry: + // CRIT ...rkdb.PublishLocalRouterInfoJob: Internal error - signing private key not known? rescheduling publish for 30s + // CRIT net.i2p.router.Router : Internal error - signing private key not known? wtf + // CRIT ...sport.udp.EstablishmentManager: Error in the establisher java.lang.NullPointerException + // at net.i2p.router.transport.udp.PacketBuilder.buildSessionConfirmedPacket(PacketBuilder.java:574) + // so pretend the RI isn't there if there is no keyfile + if (_infoExists && _keysExist) { fis1 = new FileInputStream(rif); info = new RouterInfo(); info.readBytes(fis1); _log.debug("Reading in routerInfo from " + rif.getAbsolutePath() + " and it has " + info.getAddresses().size() + " addresses"); + _us = info; } if (_keysExist) { @@ -91,17 +98,15 @@ public class LoadRouterInfoJob extends JobImpl { getContext().keyManager().setPublicKey(pubkey); //info.getIdentity().getPublicKey()); getContext().keyManager().setSigningPublicKey(signingPubKey); // info.getIdentity().getSigningPublicKey()); } - - _us = info; } catch (IOException ioe) { - _log.error("Error reading the router info from " + rif.getAbsolutePath() + " and the keys from " + rkf.getAbsolutePath(), ioe); + _log.log(Log.CRIT, "Error reading the router info from " + rif.getAbsolutePath() + " and the keys from " + rkf.getAbsolutePath(), ioe); _us = null; rif.delete(); rkf.delete(); _infoExists = false; _keysExist = false; } catch (DataFormatException dfe) { - _log.error("Corrupt router info or keys at " + rif.getAbsolutePath() + " / " + rkf.getAbsolutePath(), dfe); + _log.log(Log.CRIT, "Corrupt router info or keys at " + rif.getAbsolutePath() + " / " + rkf.getAbsolutePath(), dfe); _us = null; rif.delete(); rkf.delete(); diff --git a/router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java b/router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java index fda82de8e5..e3daf60ea4 100644 --- a/router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java +++ b/router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java @@ -107,7 +107,7 @@ public class RebuildRouterInfoJob extends JobImpl { ident.setSigningPublicKey(signingPubKey); info.setIdentity(ident); } catch (Exception e) { - _log.error("Error reading in the key data from " + keyFile.getAbsolutePath(), e); + _log.log(Log.CRIT, "Error reading in the key data from " + keyFile.getAbsolutePath(), e); if (fis != null) try { fis.close(); } catch (IOException ioe) {} fis = null; keyFile.delete(); @@ -129,7 +129,7 @@ public class RebuildRouterInfoJob extends JobImpl { info.sign(getContext().keyManager().getSigningPrivateKey()); } catch (DataFormatException dfe) { - _log.error("Error rebuilding the new router info", dfe); + _log.log(Log.CRIT, "Error rebuilding the new router info", dfe); return; } @@ -138,9 +138,9 @@ public class RebuildRouterInfoJob extends JobImpl { fos = new FileOutputStream(infoFile); info.writeBytes(fos); } catch (DataFormatException dfe) { - _log.error("Error rebuilding the router information", dfe); + _log.log(Log.CRIT, "Error rebuilding the router information", dfe); } catch (IOException ioe) { - _log.error("Error writing out the rebuilt router information", ioe); + _log.log(Log.CRIT, "Error writing out the rebuilt router information", ioe); } finally { if (fos != null) try { fos.close(); } catch (IOException ioe) {} } -- GitLab