2005-03-23 21:13:03 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
2013-09-22 18:03:56 +00:00
|
|
|
import java.io.File;
|
2012-01-18 01:54:34 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2012-01-18 16:57:27 +00:00
|
|
|
import net.i2p.I2PAppContext;
|
2007-12-26 08:14:54 +00:00
|
|
|
import net.i2p.crypto.TrustedUpdate;
|
2008-07-16 13:42:54 +00:00
|
|
|
import net.i2p.data.DataHelper;
|
Big refactor of the router console update subsystem, in preparation for
implementing out-of-console updaters like i2psnark.
- Add new update interfaces in net.i2p.update
- All update implementations moved to routerconsole update/
- Implement an UpdateManager that registers with the RouterContext
- UpdateManager handles multiple types of things to update
(router, plugins, news, ...) and methods of updating (HTTP, ...)
- UpdateManager maintains list of installed, downloaded, and available versions of everything
- Define Updaters that can check for a new version and/or download an item
- Individual Updaters register with the UpdateManager obtained from
I2PAppContext, identifying the type of update item and
update method they can handle.
- Updaters need only core libs, no router.jar or routerconsole access required.
- All checks and updates are initiated via the UpdateManager.
- All status on checks and updates in-progress or completed are
obtained from the UpdateManager. No more use of System properties
to broadcast update state.
- All update and checker tasks are intantiated on demand and threaded;
no more static references left over.
- Split out the Runners and Checkers from the Handlers and make the inheritance more sane.
- No more permanent NewsFetcher thread; run on the SimpleScheduler queue
and thread a checker task only to fetch the news.
- No more static NewsFetcher instance in routerconsole.
All helper methods that are still required are moved to NewsHelper.
The UpdateManager implements the policy for when to check and download.
All requests go through the UpdateManager.
For each update type, there's several parts:
- The xxxUpdateHandler implements the Updater
- The xxxUpdateChecker implements the UpdateTask for checking
- The xxxUpdateRunner implements the UpdateTask for downloading
New and moved classes:
web/ update/
---- -------
new ConsoleUpdateManager.java
new PluginUpdateChecker.java from PluginUpdateChecker
PluginUpdateChecker -> PluginUpdateHandler.java
PluginUpdateHandler.java -> PluginUpdateRunner
new UnsignedUpdateHandler.java
UnsignedUpdateHandler -> UnsignedUpdateRunner.java
new UnsignedUpdateChecker from NewsFetcher
UpdateHandler.java remains
new UpdateHandler.java
new UpdateRunner.java from UpdateHandler
move NewsHandler from NewsFetcher
new NewsFetcher
new NewsTimerTask
new DummyHandler
Initial checkin. Unfinished, untested, unpolished.
2012-06-18 22:09:45 +00:00
|
|
|
import net.i2p.router.update.ConsoleUpdateManager;
|
|
|
|
import static net.i2p.update.UpdateType.*;
|
2010-12-13 15:28:06 +00:00
|
|
|
import net.i2p.util.FileUtil;
|
2012-01-18 16:57:27 +00:00
|
|
|
import net.i2p.util.PortMapper;
|
2005-03-23 21:13:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class ConfigUpdateHandler extends FormHandler {
|
|
|
|
private String _newsURL;
|
|
|
|
private long _refreshFrequency;
|
|
|
|
private String _updateURL;
|
|
|
|
private String _updatePolicy;
|
2005-03-24 01:19:52 +00:00
|
|
|
private String _proxyHost;
|
|
|
|
private String _proxyPort;
|
2005-03-23 21:13:03 +00:00
|
|
|
private boolean _updateThroughProxy;
|
|
|
|
private String _trustedKeys;
|
2009-08-09 14:28:20 +00:00
|
|
|
private boolean _updateUnsigned;
|
|
|
|
private String _zipURL;
|
2005-03-23 21:13:03 +00:00
|
|
|
|
|
|
|
public static final String PROP_NEWS_URL = "router.newsURL";
|
2007-12-29 22:15:11 +00:00
|
|
|
// public static final String DEFAULT_NEWS_URL = "http://dev.i2p.net/cgi-bin/cvsweb.cgi/i2p/news.xml?rev=HEAD";
|
2009-06-19 00:04:19 +00:00
|
|
|
public static final String OLD_DEFAULT_NEWS_URL = "http://complication.i2p/news.xml";
|
|
|
|
public static final String DEFAULT_NEWS_URL = "http://echelon.i2p/i2p/news.xml";
|
2005-03-23 21:13:03 +00:00
|
|
|
public static final String PROP_REFRESH_FREQUENCY = "router.newsRefreshFrequency";
|
2011-10-15 17:09:04 +00:00
|
|
|
public static final long DEFAULT_REFRESH_FREQ = 36*60*60*1000l;
|
|
|
|
public static final String DEFAULT_REFRESH_FREQUENCY = Long.toString(DEFAULT_REFRESH_FREQ);
|
2005-03-23 21:13:03 +00:00
|
|
|
public static final String PROP_UPDATE_POLICY = "router.updatePolicy";
|
2009-04-03 21:42:48 +00:00
|
|
|
public static final String DEFAULT_UPDATE_POLICY = "download";
|
2005-03-23 21:13:03 +00:00
|
|
|
public static final String PROP_SHOULD_PROXY = "router.updateThroughProxy";
|
2007-12-22 23:58:46 +00:00
|
|
|
public static final String DEFAULT_SHOULD_PROXY = Boolean.TRUE.toString();
|
2005-03-23 21:13:03 +00:00
|
|
|
public static final String PROP_PROXY_HOST = "router.updateProxyHost";
|
2009-04-08 01:34:12 +00:00
|
|
|
public static final String DEFAULT_PROXY_HOST = "127.0.0.1";
|
2005-03-23 21:13:03 +00:00
|
|
|
public static final String PROP_PROXY_PORT = "router.updateProxyPort";
|
2009-08-09 14:28:20 +00:00
|
|
|
public static final int DEFAULT_PROXY_PORT_INT = 4444;
|
|
|
|
public static final String DEFAULT_PROXY_PORT = "" + DEFAULT_PROXY_PORT_INT;
|
|
|
|
/** default false */
|
|
|
|
public static final String PROP_UPDATE_UNSIGNED = "router.updateUnsigned";
|
2010-02-02 15:25:26 +00:00
|
|
|
/** default false - use for distros */
|
|
|
|
public static final String PROP_UPDATE_DISABLED = "router.updateDisabled";
|
2009-08-09 14:28:20 +00:00
|
|
|
/** no default */
|
|
|
|
public static final String PROP_ZIP_URL = "router.updateUnsignedURL";
|
2005-03-23 21:13:03 +00:00
|
|
|
|
2007-12-26 08:14:54 +00:00
|
|
|
public static final String PROP_UPDATE_URL = "router.updateURL";
|
2013-09-22 18:03:56 +00:00
|
|
|
|
2010-06-02 18:13:45 +00:00
|
|
|
/**
|
2010-06-16 13:29:41 +00:00
|
|
|
* Changed as of release 0.8 to support both .sud and .su2
|
|
|
|
* Some JVMs (IcedTea) don't have pack200
|
|
|
|
* Update hosts must maintain both
|
2010-06-02 18:13:45 +00:00
|
|
|
*/
|
2010-06-16 13:29:41 +00:00
|
|
|
private static final String PACK200_URLS =
|
2010-06-02 18:13:45 +00:00
|
|
|
"http://echelon.i2p/i2p/i2pupdate.su2\r\n" +
|
2011-05-13 21:04:58 +00:00
|
|
|
"http://inr.i2p/i2p/i2pupdate.su2\r\n" +
|
2013-08-08 22:13:38 +00:00
|
|
|
"http://meeh.i2p/i2pupdate/i2pupdate.su2\r\n" +
|
2010-06-02 18:13:45 +00:00
|
|
|
"http://stats.i2p/i2p/i2pupdate.su2\r\n" +
|
|
|
|
"http://www.i2p2.i2p/_static/i2pupdate.su2\r\n" +
|
2013-08-08 22:13:38 +00:00
|
|
|
"http://update.dg.i2p/files/i2pupdate.su2\r\n" +
|
2011-11-03 21:58:44 +00:00
|
|
|
"http://update.killyourtv.i2p/i2pupdate.su2\r\n" +
|
2010-06-02 18:13:45 +00:00
|
|
|
"http://update.postman.i2p/i2pupdate.su2" ;
|
2010-06-16 13:29:41 +00:00
|
|
|
|
|
|
|
private static final String NO_PACK200_URLS =
|
|
|
|
"http://echelon.i2p/i2p/i2pupdate.sud\r\n" +
|
2011-05-13 21:04:58 +00:00
|
|
|
"http://inr.i2p/i2p/i2pupdate.sud\r\n" +
|
2013-08-08 22:13:38 +00:00
|
|
|
"http://meeh.i2p/i2pupdate/i2pupdate.sud\r\n" +
|
2010-06-16 13:29:41 +00:00
|
|
|
"http://stats.i2p/i2p/i2pupdate.sud\r\n" +
|
|
|
|
"http://www.i2p2.i2p/_static/i2pupdate.sud\r\n" +
|
2013-08-08 22:13:38 +00:00
|
|
|
"http://update.dg.i2p/files/i2pupdate.sud\r\n" +
|
2011-11-03 21:58:44 +00:00
|
|
|
"http://update.killyourtv.i2p/i2pupdate.sud\r\n" +
|
2010-06-16 13:29:41 +00:00
|
|
|
"http://update.postman.i2p/i2pupdate.sud" ;
|
|
|
|
|
2013-09-22 18:03:56 +00:00
|
|
|
/**
|
|
|
|
* These are only for .sud and .su2.
|
|
|
|
* Do NOT use this for .su3
|
|
|
|
*/
|
2010-06-16 13:29:41 +00:00
|
|
|
public static final String DEFAULT_UPDATE_URL;
|
|
|
|
static {
|
2010-12-13 15:28:06 +00:00
|
|
|
if (FileUtil.isPack200Supported())
|
|
|
|
DEFAULT_UPDATE_URL = PACK200_URLS;
|
|
|
|
else
|
|
|
|
DEFAULT_UPDATE_URL = NO_PACK200_URLS;
|
2010-06-16 13:29:41 +00:00
|
|
|
}
|
|
|
|
|
2013-09-22 18:03:56 +00:00
|
|
|
private static final String SU3_CERT_DIR = "certificates/update";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Only enabled if we have pack200 and trusted public key certificates installed
|
|
|
|
* @since 0.9.9
|
|
|
|
*/
|
|
|
|
public static final boolean USE_SU3_UPDATE;
|
|
|
|
static {
|
|
|
|
String[] files = (new File(I2PAppContext.getGlobalContext().getBaseDir(), SU3_CERT_DIR)).list();
|
|
|
|
USE_SU3_UPDATE = FileUtil.isPack200Supported() && files != null && files.length > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final String DEFAULT_SU3_UPDATE_URLS =
|
|
|
|
"http://echelon.i2p/i2p/i2pupdate.su3\r\n" +
|
|
|
|
"http://inr.i2p/i2p/i2pupdate.su3\r\n" +
|
|
|
|
"http://meeh.i2p/i2pupdate/i2pupdate.su3\r\n" +
|
|
|
|
"http://stats.i2p/i2p/i2pupdate.su3\r\n" +
|
|
|
|
"http://www.i2p2.i2p/_static/i2pupdate.su3\r\n" +
|
|
|
|
"http://update.dg.i2p/files/i2pupdate.su3\r\n" +
|
|
|
|
"http://update.killyourtv.i2p/i2pupdate.su3\r\n" +
|
|
|
|
"http://update.postman.i2p/i2pupdate.su3" ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Empty string if disabled. Cannot be overridden by config.
|
|
|
|
* @since 0.9.9
|
|
|
|
*/
|
|
|
|
public static final String SU3_UPDATE_URLS = USE_SU3_UPDATE ? DEFAULT_SU3_UPDATE_URLS : "";
|
|
|
|
|
2007-12-26 08:14:54 +00:00
|
|
|
public static final String PROP_TRUSTED_KEYS = "router.trustedUpdateKeys";
|
|
|
|
|
2012-01-18 16:57:27 +00:00
|
|
|
/**
|
|
|
|
* Convenience method for updaters
|
|
|
|
* @return the configured value, else the registered HTTP proxy, else the default
|
|
|
|
* @since 0.8.13
|
|
|
|
*/
|
Big refactor of the router console update subsystem, in preparation for
implementing out-of-console updaters like i2psnark.
- Add new update interfaces in net.i2p.update
- All update implementations moved to routerconsole update/
- Implement an UpdateManager that registers with the RouterContext
- UpdateManager handles multiple types of things to update
(router, plugins, news, ...) and methods of updating (HTTP, ...)
- UpdateManager maintains list of installed, downloaded, and available versions of everything
- Define Updaters that can check for a new version and/or download an item
- Individual Updaters register with the UpdateManager obtained from
I2PAppContext, identifying the type of update item and
update method they can handle.
- Updaters need only core libs, no router.jar or routerconsole access required.
- All checks and updates are initiated via the UpdateManager.
- All status on checks and updates in-progress or completed are
obtained from the UpdateManager. No more use of System properties
to broadcast update state.
- All update and checker tasks are intantiated on demand and threaded;
no more static references left over.
- Split out the Runners and Checkers from the Handlers and make the inheritance more sane.
- No more permanent NewsFetcher thread; run on the SimpleScheduler queue
and thread a checker task only to fetch the news.
- No more static NewsFetcher instance in routerconsole.
All helper methods that are still required are moved to NewsHelper.
The UpdateManager implements the policy for when to check and download.
All requests go through the UpdateManager.
For each update type, there's several parts:
- The xxxUpdateHandler implements the Updater
- The xxxUpdateChecker implements the UpdateTask for checking
- The xxxUpdateRunner implements the UpdateTask for downloading
New and moved classes:
web/ update/
---- -------
new ConsoleUpdateManager.java
new PluginUpdateChecker.java from PluginUpdateChecker
PluginUpdateChecker -> PluginUpdateHandler.java
PluginUpdateHandler.java -> PluginUpdateRunner
new UnsignedUpdateHandler.java
UnsignedUpdateHandler -> UnsignedUpdateRunner.java
new UnsignedUpdateChecker from NewsFetcher
UpdateHandler.java remains
new UpdateHandler.java
new UpdateRunner.java from UpdateHandler
move NewsHandler from NewsFetcher
new NewsFetcher
new NewsTimerTask
new DummyHandler
Initial checkin. Unfinished, untested, unpolished.
2012-06-18 22:09:45 +00:00
|
|
|
public static int proxyPort(I2PAppContext ctx) {
|
2012-01-18 16:57:27 +00:00
|
|
|
return ctx.getProperty(PROP_PROXY_PORT,
|
|
|
|
ctx.portMapper().getPort(PortMapper.SVC_HTTP_PROXY, DEFAULT_PROXY_PORT_INT));
|
|
|
|
}
|
|
|
|
|
2009-08-15 16:08:33 +00:00
|
|
|
@Override
|
2005-03-23 21:13:03 +00:00
|
|
|
protected void processForm() {
|
2009-10-26 21:48:46 +00:00
|
|
|
if (_action == null)
|
|
|
|
return;
|
|
|
|
if (_action.equals(_("Check for updates"))) {
|
Big refactor of the router console update subsystem, in preparation for
implementing out-of-console updaters like i2psnark.
- Add new update interfaces in net.i2p.update
- All update implementations moved to routerconsole update/
- Implement an UpdateManager that registers with the RouterContext
- UpdateManager handles multiple types of things to update
(router, plugins, news, ...) and methods of updating (HTTP, ...)
- UpdateManager maintains list of installed, downloaded, and available versions of everything
- Define Updaters that can check for a new version and/or download an item
- Individual Updaters register with the UpdateManager obtained from
I2PAppContext, identifying the type of update item and
update method they can handle.
- Updaters need only core libs, no router.jar or routerconsole access required.
- All checks and updates are initiated via the UpdateManager.
- All status on checks and updates in-progress or completed are
obtained from the UpdateManager. No more use of System properties
to broadcast update state.
- All update and checker tasks are intantiated on demand and threaded;
no more static references left over.
- Split out the Runners and Checkers from the Handlers and make the inheritance more sane.
- No more permanent NewsFetcher thread; run on the SimpleScheduler queue
and thread a checker task only to fetch the news.
- No more static NewsFetcher instance in routerconsole.
All helper methods that are still required are moved to NewsHelper.
The UpdateManager implements the policy for when to check and download.
All requests go through the UpdateManager.
For each update type, there's several parts:
- The xxxUpdateHandler implements the Updater
- The xxxUpdateChecker implements the UpdateTask for checking
- The xxxUpdateRunner implements the UpdateTask for downloading
New and moved classes:
web/ update/
---- -------
new ConsoleUpdateManager.java
new PluginUpdateChecker.java from PluginUpdateChecker
PluginUpdateChecker -> PluginUpdateHandler.java
PluginUpdateHandler.java -> PluginUpdateRunner
new UnsignedUpdateHandler.java
UnsignedUpdateHandler -> UnsignedUpdateRunner.java
new UnsignedUpdateChecker from NewsFetcher
UpdateHandler.java remains
new UpdateHandler.java
new UpdateRunner.java from UpdateHandler
move NewsHandler from NewsFetcher
new NewsFetcher
new NewsTimerTask
new DummyHandler
Initial checkin. Unfinished, untested, unpolished.
2012-06-18 22:09:45 +00:00
|
|
|
ConsoleUpdateManager mgr = (ConsoleUpdateManager) _context.updateManager();
|
|
|
|
if (mgr == null) {
|
|
|
|
addFormError("Update manager not registered, cannot check");
|
|
|
|
return;
|
|
|
|
}
|
2012-10-18 14:28:14 +00:00
|
|
|
if (mgr.isUpdateInProgress() || mgr.isCheckInProgress()) {
|
|
|
|
addFormError(_("Update or check already in progress"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
boolean a1 = mgr.checkAvailable(NEWS, 30*1000) != null;
|
Big refactor of the router console update subsystem, in preparation for
implementing out-of-console updaters like i2psnark.
- Add new update interfaces in net.i2p.update
- All update implementations moved to routerconsole update/
- Implement an UpdateManager that registers with the RouterContext
- UpdateManager handles multiple types of things to update
(router, plugins, news, ...) and methods of updating (HTTP, ...)
- UpdateManager maintains list of installed, downloaded, and available versions of everything
- Define Updaters that can check for a new version and/or download an item
- Individual Updaters register with the UpdateManager obtained from
I2PAppContext, identifying the type of update item and
update method they can handle.
- Updaters need only core libs, no router.jar or routerconsole access required.
- All checks and updates are initiated via the UpdateManager.
- All status on checks and updates in-progress or completed are
obtained from the UpdateManager. No more use of System properties
to broadcast update state.
- All update and checker tasks are intantiated on demand and threaded;
no more static references left over.
- Split out the Runners and Checkers from the Handlers and make the inheritance more sane.
- No more permanent NewsFetcher thread; run on the SimpleScheduler queue
and thread a checker task only to fetch the news.
- No more static NewsFetcher instance in routerconsole.
All helper methods that are still required are moved to NewsHelper.
The UpdateManager implements the policy for when to check and download.
All requests go through the UpdateManager.
For each update type, there's several parts:
- The xxxUpdateHandler implements the Updater
- The xxxUpdateChecker implements the UpdateTask for checking
- The xxxUpdateRunner implements the UpdateTask for downloading
New and moved classes:
web/ update/
---- -------
new ConsoleUpdateManager.java
new PluginUpdateChecker.java from PluginUpdateChecker
PluginUpdateChecker -> PluginUpdateHandler.java
PluginUpdateHandler.java -> PluginUpdateRunner
new UnsignedUpdateHandler.java
UnsignedUpdateHandler -> UnsignedUpdateRunner.java
new UnsignedUpdateChecker from NewsFetcher
UpdateHandler.java remains
new UpdateHandler.java
new UpdateRunner.java from UpdateHandler
move NewsHandler from NewsFetcher
new NewsFetcher
new NewsTimerTask
new DummyHandler
Initial checkin. Unfinished, untested, unpolished.
2012-06-18 22:09:45 +00:00
|
|
|
boolean a2 = false;
|
|
|
|
if ((!a1) && _updateUnsigned && _zipURL != null && _zipURL.length() > 0)
|
2012-10-18 14:28:14 +00:00
|
|
|
a2 = mgr.checkAvailable(ROUTER_UNSIGNED, 30*1000) != null;
|
Big refactor of the router console update subsystem, in preparation for
implementing out-of-console updaters like i2psnark.
- Add new update interfaces in net.i2p.update
- All update implementations moved to routerconsole update/
- Implement an UpdateManager that registers with the RouterContext
- UpdateManager handles multiple types of things to update
(router, plugins, news, ...) and methods of updating (HTTP, ...)
- UpdateManager maintains list of installed, downloaded, and available versions of everything
- Define Updaters that can check for a new version and/or download an item
- Individual Updaters register with the UpdateManager obtained from
I2PAppContext, identifying the type of update item and
update method they can handle.
- Updaters need only core libs, no router.jar or routerconsole access required.
- All checks and updates are initiated via the UpdateManager.
- All status on checks and updates in-progress or completed are
obtained from the UpdateManager. No more use of System properties
to broadcast update state.
- All update and checker tasks are intantiated on demand and threaded;
no more static references left over.
- Split out the Runners and Checkers from the Handlers and make the inheritance more sane.
- No more permanent NewsFetcher thread; run on the SimpleScheduler queue
and thread a checker task only to fetch the news.
- No more static NewsFetcher instance in routerconsole.
All helper methods that are still required are moved to NewsHelper.
The UpdateManager implements the policy for when to check and download.
All requests go through the UpdateManager.
For each update type, there's several parts:
- The xxxUpdateHandler implements the Updater
- The xxxUpdateChecker implements the UpdateTask for checking
- The xxxUpdateRunner implements the UpdateTask for downloading
New and moved classes:
web/ update/
---- -------
new ConsoleUpdateManager.java
new PluginUpdateChecker.java from PluginUpdateChecker
PluginUpdateChecker -> PluginUpdateHandler.java
PluginUpdateHandler.java -> PluginUpdateRunner
new UnsignedUpdateHandler.java
UnsignedUpdateHandler -> UnsignedUpdateRunner.java
new UnsignedUpdateChecker from NewsFetcher
UpdateHandler.java remains
new UpdateHandler.java
new UpdateRunner.java from UpdateHandler
move NewsHandler from NewsFetcher
new NewsFetcher
new NewsTimerTask
new DummyHandler
Initial checkin. Unfinished, untested, unpolished.
2012-06-18 22:09:45 +00:00
|
|
|
if (a1 || a2) {
|
2008-05-10 14:31:18 +00:00
|
|
|
if ( (_updatePolicy == null) || (!_updatePolicy.equals("notify")) )
|
2009-10-26 02:21:15 +00:00
|
|
|
addFormNotice(_("Update available, attempting to download now"));
|
2008-05-10 14:31:18 +00:00
|
|
|
else
|
2009-10-26 02:21:15 +00:00
|
|
|
addFormNotice(_("Update available, click button on left to download"));
|
2010-02-06 20:25:13 +00:00
|
|
|
// So that update() will post a status to the summary bar before we reload
|
|
|
|
try {
|
|
|
|
Thread.sleep(1000);
|
|
|
|
} catch (InterruptedException ie) {}
|
2008-05-10 14:31:18 +00:00
|
|
|
} else
|
2009-10-26 02:21:15 +00:00
|
|
|
addFormNotice(_("No update available"));
|
2009-10-26 21:48:46 +00:00
|
|
|
return;
|
2005-04-26 02:59:23 +00:00
|
|
|
}
|
|
|
|
|
2012-01-18 01:54:34 +00:00
|
|
|
Map<String, String> changes = new HashMap();
|
|
|
|
|
2005-03-23 21:13:03 +00:00
|
|
|
if ( (_newsURL != null) && (_newsURL.length() > 0) ) {
|
2009-06-19 00:04:19 +00:00
|
|
|
String oldURL = ConfigUpdateHelper.getNewsURL(_context);
|
2005-03-23 21:13:03 +00:00
|
|
|
if ( (oldURL == null) || (!_newsURL.equals(oldURL)) ) {
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_NEWS_URL, _newsURL);
|
Big refactor of the router console update subsystem, in preparation for
implementing out-of-console updaters like i2psnark.
- Add new update interfaces in net.i2p.update
- All update implementations moved to routerconsole update/
- Implement an UpdateManager that registers with the RouterContext
- UpdateManager handles multiple types of things to update
(router, plugins, news, ...) and methods of updating (HTTP, ...)
- UpdateManager maintains list of installed, downloaded, and available versions of everything
- Define Updaters that can check for a new version and/or download an item
- Individual Updaters register with the UpdateManager obtained from
I2PAppContext, identifying the type of update item and
update method they can handle.
- Updaters need only core libs, no router.jar or routerconsole access required.
- All checks and updates are initiated via the UpdateManager.
- All status on checks and updates in-progress or completed are
obtained from the UpdateManager. No more use of System properties
to broadcast update state.
- All update and checker tasks are intantiated on demand and threaded;
no more static references left over.
- Split out the Runners and Checkers from the Handlers and make the inheritance more sane.
- No more permanent NewsFetcher thread; run on the SimpleScheduler queue
and thread a checker task only to fetch the news.
- No more static NewsFetcher instance in routerconsole.
All helper methods that are still required are moved to NewsHelper.
The UpdateManager implements the policy for when to check and download.
All requests go through the UpdateManager.
For each update type, there's several parts:
- The xxxUpdateHandler implements the Updater
- The xxxUpdateChecker implements the UpdateTask for checking
- The xxxUpdateRunner implements the UpdateTask for downloading
New and moved classes:
web/ update/
---- -------
new ConsoleUpdateManager.java
new PluginUpdateChecker.java from PluginUpdateChecker
PluginUpdateChecker -> PluginUpdateHandler.java
PluginUpdateHandler.java -> PluginUpdateRunner
new UnsignedUpdateHandler.java
UnsignedUpdateHandler -> UnsignedUpdateRunner.java
new UnsignedUpdateChecker from NewsFetcher
UpdateHandler.java remains
new UpdateHandler.java
new UpdateRunner.java from UpdateHandler
move NewsHandler from NewsFetcher
new NewsFetcher
new NewsTimerTask
new DummyHandler
Initial checkin. Unfinished, untested, unpolished.
2012-06-18 22:09:45 +00:00
|
|
|
// this invalidates the news
|
|
|
|
changes.put(NewsHelper.PROP_LAST_CHECKED, "0");
|
2011-10-15 17:09:04 +00:00
|
|
|
addFormNotice(_("Updating news URL to {0}", _newsURL));
|
2005-03-23 21:13:03 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-26 02:59:23 +00:00
|
|
|
|
2012-01-18 16:57:27 +00:00
|
|
|
if (_proxyHost != null && _proxyHost.length() > 0 && !_proxyHost.equals(_("internal"))) {
|
2005-03-24 01:19:52 +00:00
|
|
|
String oldHost = _context.router().getConfigSetting(PROP_PROXY_HOST);
|
|
|
|
if ( (oldHost == null) || (!_proxyHost.equals(oldHost)) ) {
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_PROXY_HOST, _proxyHost);
|
2011-10-15 17:09:04 +00:00
|
|
|
addFormNotice(_("Updating proxy host to {0}", _proxyHost));
|
2005-03-24 01:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-18 16:57:27 +00:00
|
|
|
if (_proxyPort != null && _proxyPort.length() > 0 && !_proxyPort.equals(_("internal"))) {
|
2005-03-24 01:19:52 +00:00
|
|
|
String oldPort = _context.router().getConfigSetting(PROP_PROXY_PORT);
|
2005-04-26 02:59:23 +00:00
|
|
|
if ( (oldPort == null) || (!_proxyPort.equals(oldPort)) ) {
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_PROXY_PORT, _proxyPort);
|
2011-10-15 17:09:04 +00:00
|
|
|
addFormNotice(_("Updating proxy port to {0}", _proxyPort));
|
2005-03-24 01:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_SHOULD_PROXY, "" + _updateThroughProxy);
|
|
|
|
changes.put(PROP_UPDATE_UNSIGNED, "" + _updateUnsigned);
|
2005-03-23 21:13:03 +00:00
|
|
|
|
2011-10-15 17:09:04 +00:00
|
|
|
String oldFreqStr = _context.getProperty(PROP_REFRESH_FREQUENCY, DEFAULT_REFRESH_FREQUENCY);
|
|
|
|
long oldFreq = DEFAULT_REFRESH_FREQ;
|
|
|
|
try { oldFreq = Long.parseLong(oldFreqStr); } catch (NumberFormatException nfe) {}
|
2005-03-23 21:13:03 +00:00
|
|
|
if (_refreshFrequency != oldFreq) {
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_REFRESH_FREQUENCY, ""+_refreshFrequency);
|
2011-10-15 17:09:04 +00:00
|
|
|
addFormNotice(_("Updating refresh frequency to {0}",
|
|
|
|
_refreshFrequency <= 0 ? _("Never") : DataHelper.formatDuration2(_refreshFrequency)));
|
2005-03-23 21:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( (_updatePolicy != null) && (_updatePolicy.length() > 0) ) {
|
|
|
|
String oldPolicy = _context.router().getConfigSetting(PROP_UPDATE_POLICY);
|
|
|
|
if ( (oldPolicy == null) || (!_updatePolicy.equals(oldPolicy)) ) {
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_UPDATE_POLICY, _updatePolicy);
|
2011-10-15 17:09:04 +00:00
|
|
|
addFormNotice(_("Updating update policy to {0}", _updatePolicy));
|
2005-03-23 21:13:03 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-26 08:14:54 +00:00
|
|
|
|
|
|
|
if ( (_updateURL != null) && (_updateURL.length() > 0) ) {
|
2010-10-19 14:39:29 +00:00
|
|
|
_updateURL = _updateURL.replace("\r\n", ",").replace("\n", ",");
|
2007-12-26 08:14:54 +00:00
|
|
|
String oldURL = _context.router().getConfigSetting(PROP_UPDATE_URL);
|
|
|
|
if ( (oldURL == null) || (!_updateURL.equals(oldURL)) ) {
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_UPDATE_URL, _updateURL);
|
2009-10-26 02:21:15 +00:00
|
|
|
addFormNotice(_("Updating update URLs."));
|
2007-12-26 08:14:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (_trustedKeys != null) && (_trustedKeys.length() > 0) ) {
|
2010-10-19 14:39:29 +00:00
|
|
|
_trustedKeys = _trustedKeys.replace("\r\n", ",").replace("\n", ",");
|
2007-12-26 08:14:54 +00:00
|
|
|
String oldKeys = new TrustedUpdate(_context).getTrustedKeysString();
|
2011-10-15 17:09:04 +00:00
|
|
|
oldKeys = oldKeys.replace("\r\n", ",");
|
|
|
|
if (!_trustedKeys.equals(oldKeys)) {
|
|
|
|
// note that keys are not validated here and no console error message will be generated
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_TRUSTED_KEYS, _trustedKeys);
|
2009-10-26 02:21:15 +00:00
|
|
|
addFormNotice(_("Updating trusted keys."));
|
2007-12-26 08:14:54 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-23 21:13:03 +00:00
|
|
|
|
2009-08-09 14:28:20 +00:00
|
|
|
if ( (_zipURL != null) && (_zipURL.length() > 0) ) {
|
|
|
|
String oldURL = _context.router().getConfigSetting(PROP_ZIP_URL);
|
|
|
|
if ( (oldURL == null) || (!_zipURL.equals(oldURL)) ) {
|
2012-01-18 01:54:34 +00:00
|
|
|
changes.put(PROP_ZIP_URL, _zipURL);
|
2011-10-15 17:09:04 +00:00
|
|
|
addFormNotice(_("Updating unsigned update URL to {0}", _zipURL));
|
2009-08-09 14:28:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-18 01:54:34 +00:00
|
|
|
_context.router().saveConfig(changes, null);
|
2005-03-23 21:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setNewsURL(String url) { _newsURL = url; }
|
|
|
|
public void setRefreshFrequency(String freq) {
|
|
|
|
try { _refreshFrequency = Long.parseLong(freq); } catch (NumberFormatException nfe) {}
|
|
|
|
}
|
|
|
|
public void setUpdateURL(String url) { _updateURL = url; }
|
|
|
|
public void setUpdatePolicy(String policy) { _updatePolicy = policy; }
|
|
|
|
public void setTrustedKeys(String keys) { _trustedKeys = keys; }
|
|
|
|
public void setUpdateThroughProxy(String foo) { _updateThroughProxy = true; }
|
2005-03-24 01:19:52 +00:00
|
|
|
public void setProxyHost(String host) { _proxyHost = host; }
|
|
|
|
public void setProxyPort(String port) { _proxyPort = port; }
|
2009-08-09 14:28:20 +00:00
|
|
|
public void setUpdateUnsigned(String foo) { _updateUnsigned = true; }
|
|
|
|
public void setZipURL(String url) { _zipURL = url; }
|
2005-03-23 21:13:03 +00:00
|
|
|
}
|