diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java index c831c59d24..f55ebcc94d 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHandler.java @@ -49,9 +49,12 @@ public class ConfigUpdateHandler extends FormHandler { if ("Check for update now".equals(_action)) { NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext()); fetcher.fetchNews(); - if (fetcher.updateAvailable()) - addFormNotice("Update available, click link on left"); - else + if (fetcher.updateAvailable()) { + if ( (_updatePolicy == null) || (!_updatePolicy.equals("notify")) ) + addFormNotice("Update available, attempting to download now"); + else + addFormNotice("Update available, click link on left to download"); + } else addFormNotice("No update available"); } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java index ca42999f54..f35705d143 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java @@ -102,10 +102,15 @@ public class ConfigUpdateHelper { else buf.append(""); - if ("install".equals(policy)) - buf.append(""); + if ("download".equals(policy)) + buf.append(""); else - buf.append(""); + buf.append(""); + + if ("install".equals(policy)) + buf.append(""); + else + buf.append(""); buf.append("\n"); return buf.toString(); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/NewsFetcher.java b/apps/routerconsole/java/src/net/i2p/router/web/NewsFetcher.java index 3267eb0261..92430654e5 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/NewsFetcher.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/NewsFetcher.java @@ -9,6 +9,7 @@ import java.util.StringTokenizer; import net.i2p.I2PAppContext; import net.i2p.crypto.TrustedUpdate; import net.i2p.data.DataHelper; +import net.i2p.router.Router; import net.i2p.router.RouterContext; import net.i2p.router.RouterVersion; import net.i2p.util.EepGet; @@ -68,7 +69,10 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener { private boolean shouldInstall() { String policy = _context.getProperty(ConfigUpdateHandler.PROP_UPDATE_POLICY); - return ("install".equals(policy)); + if ("notify".equals(policy)) + return false; + File zip = new File(Router.UPDATE_FILE); + return !zip.exists(); } private boolean shouldFetchNews() { diff --git a/apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java index eebf1625cc..29d2c5c8b3 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java @@ -159,18 +159,23 @@ public class UpdateHandler { public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) { _status = "Update downloaded"; TrustedUpdate up = new TrustedUpdate(_context); - boolean ok = up.migrateVerified(RouterVersion.VERSION, SIGNED_UPDATE_FILE, "i2pupdate.zip"); + String err = up.migrateVerified(RouterVersion.VERSION, SIGNED_UPDATE_FILE, Router.UPDATE_FILE); File f = new File(SIGNED_UPDATE_FILE); f.delete(); - if (ok) { - _log.log(Log.CRIT, "Update was VERIFIED, restarting to install it"); - _status = "Update verified
Restarting"; - restart(); + if (err == null) { + String policy = _context.getProperty(ConfigUpdateHandler.PROP_UPDATE_POLICY); + if ("install".equals(policy)) { + _log.log(Log.CRIT, "Update was VERIFIED, restarting to install it"); + _status = "Update verified
Restarting"; + restart(); + } else { + _log.log(Log.CRIT, "Update was VERIFIED, will be installed at next restart"); + _status = "Update downloaded
Click Restart to Install"; + } } else { - // One other possibility, the version in the file is not sufficient - // Perhaps need an int return code - but version problem unlikely? - _log.log(Log.CRIT, "Update was INVALID - signing key is not trusted or file is corrupt from " + url); - _status = "Update signing key invalid or file is corrupt from " + url + ""; + err = err + " from " + url; + _log.log(Log.CRIT, err); + _status = "" + err + ""; System.setProperty(PROP_UPDATE_IN_PROGRESS, "false"); } } diff --git a/core/java/src/net/i2p/crypto/TrustedUpdate.java b/core/java/src/net/i2p/crypto/TrustedUpdate.java index 8b4b53b400..dfd055382d 100644 --- a/core/java/src/net/i2p/crypto/TrustedUpdate.java +++ b/core/java/src/net/i2p/crypto/TrustedUpdate.java @@ -405,15 +405,15 @@ D8usM7Dxp5yrDrCYZ5AIijc= * @param signedFile A signed update file. * @param outputFile The file to write the verified data to. * - * @return true if the signature and version were valid and the - * data was moved, false otherwise. + * @return null if the signature and version were valid and the + * data was moved, and an error String otherwise. */ - public boolean migrateVerified(String currentVersion, String signedFile, String outputFile) { + public String migrateVerified(String currentVersion, String signedFile, String outputFile) { if (!isUpdatedVersion(currentVersion, signedFile)) - return false; + return "Downloaded version is not greater than current version"; if (!verify(signedFile)) - return false; + return "Unknown signing key or corrupt file"; FileInputStream fileInputStream = null; FileOutputStream fileOutputStream = null; @@ -432,7 +432,7 @@ D8usM7Dxp5yrDrCYZ5AIijc= while ( (bytesRead = fileInputStream.read(buffer)) != -1) fileOutputStream.write(buffer, 0, bytesRead); } catch (IOException ioe) { - return false; + return "I/O Exception during file extraction"; } finally { if (fileInputStream != null) try { @@ -447,7 +447,7 @@ D8usM7Dxp5yrDrCYZ5AIijc= } } - return true; + return null; } /** diff --git a/history.txt b/history.txt index 4d524e4ce5..2a70a5ecfc 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,16 @@ +2008-05-10 zzz + * NetDb: Don't write the my.info file to disk, it isn't used for anything + * Stats: + - Simplify oldstats.jsp if no events in a stat + - Fix the hosed inNetPool.droppedDeliveryStatusDelay stat + (caused by an SSU hack) + * Update Handler: + - Add option to download and verify only + - Add distinct error message if version check fails + +2008-05-09 welterde + * Add an update URL to the list + 2008-05-07 zzz * Reachability: - Restrict peers requiring introducers from inbound tunnels, diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 1dacd705fd..5abbeaf37c 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -998,7 +998,7 @@ public class Router { } } - private static final String UPDATE_FILE = "i2pupdate.zip"; + public static final String UPDATE_FILE = "i2pupdate.zip"; private static void installUpdates() { File updateFile = new File(UPDATE_FILE); diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index b689b230f9..bf1a1d0c44 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -17,7 +17,7 @@ import net.i2p.CoreVersion; public class RouterVersion { public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $"; public final static String VERSION = "0.6.1.33"; - public final static long BUILD = 3; + public final static long BUILD = 4; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID);