* Update Handler:
- Add option to download and verify only - Add distinct error message if version check fails
This commit is contained in:
@ -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");
|
||||
}
|
||||
|
||||
|
@ -102,10 +102,15 @@ public class ConfigUpdateHelper {
|
||||
else
|
||||
buf.append("<option value=\"notify\">Notify only</option>");
|
||||
|
||||
if ("install".equals(policy))
|
||||
buf.append("<option value=\"install\" selected=\"true\">Download and install</option>");
|
||||
if ("download".equals(policy))
|
||||
buf.append("<option value=\"download\" selected=\"true\">Download and verify only</option>");
|
||||
else
|
||||
buf.append("<option value=\"install\">Download and install</option>");
|
||||
buf.append("<option value=\"download\">Download and verify only</option>");
|
||||
|
||||
if ("install".equals(policy))
|
||||
buf.append("<option value=\"install\" selected=\"true\">Download, verify, and restart</option>");
|
||||
else
|
||||
buf.append("<option value=\"install\">Download, verify, and restart</option>");
|
||||
|
||||
buf.append("</select>\n");
|
||||
return buf.toString();
|
||||
|
@ -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() {
|
||||
|
@ -159,18 +159,23 @@ public class UpdateHandler {
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
_status = "<b>Update downloaded</b>";
|
||||
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 = "<b>Update verified</b><br />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 = "<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 {
|
||||
// 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 = "<b>Update signing key invalid or file is corrupt from " + url + "</b>";
|
||||
err = err + " from " + url;
|
||||
_log.log(Log.CRIT, err);
|
||||
_status = "<b>" + err + "</b>";
|
||||
System.setProperty(PROP_UPDATE_IN_PROGRESS, "false");
|
||||
}
|
||||
}
|
||||
|
@ -405,15 +405,15 @@ D8usM7Dxp5yrDrCYZ5AIijc=
|
||||
* @param signedFile A signed update file.
|
||||
* @param outputFile The file to write the verified data to.
|
||||
*
|
||||
* @return <code>true</code> if the signature and version were valid and the
|
||||
* data was moved, <code>false</code> otherwise.
|
||||
* @return <code>null</code> if the signature and version were valid and the
|
||||
* 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))
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
13
history.txt
13
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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user