I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 619b5c0e authored by zzz's avatar zzz
Browse files

* Update Handler:

      - Add option to download and verify only
      - Add distinct error message if version check fails
parent 4c2c5ca2
No related branches found
No related tags found
No related merge requests found
...@@ -49,9 +49,12 @@ public class ConfigUpdateHandler extends FormHandler { ...@@ -49,9 +49,12 @@ public class ConfigUpdateHandler extends FormHandler {
if ("Check for update now".equals(_action)) { if ("Check for update now".equals(_action)) {
NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext()); NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext());
fetcher.fetchNews(); fetcher.fetchNews();
if (fetcher.updateAvailable()) if (fetcher.updateAvailable()) {
addFormNotice("Update available, click link on left"); if ( (_updatePolicy == null) || (!_updatePolicy.equals("notify")) )
else addFormNotice("Update available, attempting to download now");
else
addFormNotice("Update available, click link on left to download");
} else
addFormNotice("No update available"); addFormNotice("No update available");
} }
......
...@@ -102,10 +102,15 @@ public class ConfigUpdateHelper { ...@@ -102,10 +102,15 @@ public class ConfigUpdateHelper {
else else
buf.append("<option value=\"notify\">Notify only</option>"); buf.append("<option value=\"notify\">Notify only</option>");
if ("download".equals(policy))
buf.append("<option value=\"download\" selected=\"true\">Download and verify only</option>");
else
buf.append("<option value=\"download\">Download and verify only</option>");
if ("install".equals(policy)) if ("install".equals(policy))
buf.append("<option value=\"install\" selected=\"true\">Download and install</option>"); buf.append("<option value=\"install\" selected=\"true\">Download, verify, and restart</option>");
else else
buf.append("<option value=\"install\">Download and install</option>"); buf.append("<option value=\"install\">Download, verify, and restart</option>");
buf.append("</select>\n"); buf.append("</select>\n");
return buf.toString(); return buf.toString();
......
...@@ -9,6 +9,7 @@ import java.util.StringTokenizer; ...@@ -9,6 +9,7 @@ import java.util.StringTokenizer;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.crypto.TrustedUpdate; import net.i2p.crypto.TrustedUpdate;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.router.Router;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.router.RouterVersion; import net.i2p.router.RouterVersion;
import net.i2p.util.EepGet; import net.i2p.util.EepGet;
...@@ -68,7 +69,10 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener { ...@@ -68,7 +69,10 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
private boolean shouldInstall() { private boolean shouldInstall() {
String policy = _context.getProperty(ConfigUpdateHandler.PROP_UPDATE_POLICY); 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() { private boolean shouldFetchNews() {
......
...@@ -159,18 +159,23 @@ public class UpdateHandler { ...@@ -159,18 +159,23 @@ public class UpdateHandler {
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) { public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
_status = "<b>Update downloaded</b>"; _status = "<b>Update downloaded</b>";
TrustedUpdate up = new TrustedUpdate(_context); 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); File f = new File(SIGNED_UPDATE_FILE);
f.delete(); f.delete();
if (ok) { if (err == null) {
_log.log(Log.CRIT, "Update was VERIFIED, restarting to install it"); String policy = _context.getProperty(ConfigUpdateHandler.PROP_UPDATE_POLICY);
_status = "<b>Update verified</b><br />Restarting"; if ("install".equals(policy)) {
restart(); _log.log(Log.CRIT, "Update was VERIFIED, restarting to install it");
_status = "<b>Update verified</b><br />Restarting";
restart();
} else {
_log.log(Log.CRIT, "Update was VERIFIED, will be installed at next restart");
_status = "<b>Update downloaded</b><br />Click Restart to Install";
}
} else { } else {
// One other possibility, the version in the file is not sufficient err = err + " from " + url;
// Perhaps need an int return code - but version problem unlikely? _log.log(Log.CRIT, err);
_log.log(Log.CRIT, "Update was INVALID - signing key is not trusted or file is corrupt from " + url); _status = "<b>" + err + "</b>";
_status = "<b>Update signing key invalid or file is corrupt from " + url + "</b>";
System.setProperty(PROP_UPDATE_IN_PROGRESS, "false"); System.setProperty(PROP_UPDATE_IN_PROGRESS, "false");
} }
} }
......
...@@ -405,15 +405,15 @@ D8usM7Dxp5yrDrCYZ5AIijc= ...@@ -405,15 +405,15 @@ D8usM7Dxp5yrDrCYZ5AIijc=
* @param signedFile A signed update file. * @param signedFile A signed update file.
* @param outputFile The file to write the verified data to. * @param outputFile The file to write the verified data to.
* *
* @return <code>true</code> if the signature and version were valid and the * @return <code>null</code> if the signature and version were valid and the
* data was moved, <code>false</code> otherwise. * data was moved, and an error <code>String</code> otherwise.
*/ */
public boolean migrateVerified(String currentVersion, String signedFile, String outputFile) { public String migrateVerified(String currentVersion, String signedFile, String outputFile) {
if (!isUpdatedVersion(currentVersion, signedFile)) if (!isUpdatedVersion(currentVersion, signedFile))
return false; return "Downloaded version is not greater than current version";
if (!verify(signedFile)) if (!verify(signedFile))
return false; return "Unknown signing key or corrupt file";
FileInputStream fileInputStream = null; FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null; FileOutputStream fileOutputStream = null;
...@@ -432,7 +432,7 @@ D8usM7Dxp5yrDrCYZ5AIijc= ...@@ -432,7 +432,7 @@ D8usM7Dxp5yrDrCYZ5AIijc=
while ( (bytesRead = fileInputStream.read(buffer)) != -1) while ( (bytesRead = fileInputStream.read(buffer)) != -1)
fileOutputStream.write(buffer, 0, bytesRead); fileOutputStream.write(buffer, 0, bytesRead);
} catch (IOException ioe) { } catch (IOException ioe) {
return false; return "I/O Exception during file extraction";
} finally { } finally {
if (fileInputStream != null) if (fileInputStream != null)
try { try {
...@@ -447,7 +447,7 @@ D8usM7Dxp5yrDrCYZ5AIijc= ...@@ -447,7 +447,7 @@ D8usM7Dxp5yrDrCYZ5AIijc=
} }
} }
return true; return null;
} }
/** /**
......
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 2008-05-07 zzz
* Reachability: * Reachability:
- Restrict peers requiring introducers from inbound tunnels, - Restrict peers requiring introducers from inbound tunnels,
......
...@@ -998,7 +998,7 @@ public class Router { ...@@ -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() { private static void installUpdates() {
File updateFile = new File(UPDATE_FILE); File updateFile = new File(UPDATE_FILE);
......
...@@ -17,7 +17,7 @@ import net.i2p.CoreVersion; ...@@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
public class RouterVersion { public class RouterVersion {
public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $"; 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 String VERSION = "0.6.1.33";
public final static long BUILD = 3; public final static long BUILD = 4;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment