forked from I2P_Developers/i2p.i2p
Update:
- New config for proxying news, separate from proxying update - Default logic cleanup
This commit is contained in:
@ -73,7 +73,7 @@ class NewsFetcher extends UpdateRunner {
|
||||
}
|
||||
|
||||
public void fetchNews() {
|
||||
boolean shouldProxy = Boolean.valueOf(_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY)).booleanValue();
|
||||
boolean shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY_NEWS, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY_NEWS);
|
||||
String proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
|
||||
int proxyPort = ConfigUpdateHandler.proxyPort(_context);
|
||||
|
||||
|
@ -98,7 +98,7 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
} else {
|
||||
updateStatus("<b>" + _("Downloading plugin from {0}", _xpi2pURL) + "</b>");
|
||||
// use the same settings as for updater
|
||||
boolean shouldProxy = Boolean.valueOf(_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY)).booleanValue();
|
||||
boolean shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
|
||||
String proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
|
||||
int proxyPort = ConfigUpdateHandler.proxyPort(_context);
|
||||
try {
|
||||
|
@ -149,7 +149,7 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
||||
int proxyPort;
|
||||
boolean isSSL = false;
|
||||
if (_method == HTTP) {
|
||||
shouldProxy = Boolean.valueOf(_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY)).booleanValue();
|
||||
shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
|
||||
proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
|
||||
proxyPort = ConfigUpdateHandler.proxyPort(_context);
|
||||
} else if (_method == HTTP_CLEARNET) {
|
||||
|
@ -23,6 +23,7 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
private String _proxyHost;
|
||||
private String _proxyPort;
|
||||
private boolean _updateThroughProxy;
|
||||
private boolean _newsThroughProxy;
|
||||
private String _trustedKeys;
|
||||
private boolean _updateUnsigned;
|
||||
private String _zipURL;
|
||||
@ -37,7 +38,11 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
public static final String PROP_UPDATE_POLICY = "router.updatePolicy";
|
||||
public static final String DEFAULT_UPDATE_POLICY = "download";
|
||||
public static final String PROP_SHOULD_PROXY = "router.updateThroughProxy";
|
||||
public static final String DEFAULT_SHOULD_PROXY = Boolean.TRUE.toString();
|
||||
public static final boolean DEFAULT_SHOULD_PROXY = true;
|
||||
/** @since 0.9.9 */
|
||||
public static final String PROP_SHOULD_PROXY_NEWS = "router.fetchNewsThroughProxy";
|
||||
/** @since 0.9.9 */
|
||||
public static final boolean DEFAULT_SHOULD_PROXY_NEWS = true;
|
||||
public static final String PROP_PROXY_HOST = "router.updateProxyHost";
|
||||
public static final String DEFAULT_PROXY_HOST = "127.0.0.1";
|
||||
public static final String PROP_PROXY_PORT = "router.updateProxyPort";
|
||||
@ -164,6 +169,8 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
Map<String, String> changes = new HashMap();
|
||||
|
||||
if ( (_newsURL != null) && (_newsURL.length() > 0) ) {
|
||||
if (_newsURL.startsWith("https"))
|
||||
_newsThroughProxy = false;
|
||||
String oldURL = ConfigUpdateHelper.getNewsURL(_context);
|
||||
if ( (oldURL == null) || (!_newsURL.equals(oldURL)) ) {
|
||||
changes.put(PROP_NEWS_URL, _newsURL);
|
||||
@ -189,8 +196,9 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
}
|
||||
}
|
||||
|
||||
changes.put(PROP_SHOULD_PROXY, "" + _updateThroughProxy);
|
||||
changes.put(PROP_UPDATE_UNSIGNED, "" + _updateUnsigned);
|
||||
changes.put(PROP_SHOULD_PROXY, Boolean.toString(_updateThroughProxy));
|
||||
changes.put(PROP_SHOULD_PROXY_NEWS, Boolean.toString(_newsThroughProxy));
|
||||
changes.put(PROP_UPDATE_UNSIGNED, Boolean.toString(_updateUnsigned));
|
||||
|
||||
String oldFreqStr = _context.getProperty(PROP_REFRESH_FREQUENCY, DEFAULT_REFRESH_FREQUENCY);
|
||||
long oldFreq = DEFAULT_REFRESH_FREQ;
|
||||
@ -252,4 +260,6 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
public void setProxyPort(String port) { _proxyPort = port; }
|
||||
public void setUpdateUnsigned(String foo) { _updateUnsigned = true; }
|
||||
public void setZipURL(String url) { _zipURL = url; }
|
||||
/** @since 0.9.9 */
|
||||
public void setNewsThroughProxy(String foo) { _newsThroughProxy = true; }
|
||||
}
|
||||
|
@ -73,13 +73,20 @@ public class ConfigUpdateHelper extends HelperBase {
|
||||
}
|
||||
|
||||
public String getUpdateThroughProxy() {
|
||||
String proxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
|
||||
if (Boolean.parseBoolean(proxy))
|
||||
if (_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY))
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" checked=\"checked\" >";
|
||||
else
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateThroughProxy\" >";
|
||||
}
|
||||
|
||||
/** @since 0.9.9 */
|
||||
public String getNewsThroughProxy() {
|
||||
if (_context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY_NEWS, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY_NEWS))
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"newsThroughProxy\" checked=\"checked\" >";
|
||||
else
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"newsThroughProxy\" >";
|
||||
}
|
||||
|
||||
public String getUpdateUnsigned() {
|
||||
if (_context.getBooleanProperty(ConfigUpdateHandler.PROP_UPDATE_UNSIGNED))
|
||||
return "<input type=\"checkbox\" class=\"optbox\" value=\"true\" name=\"updateUnsigned\" checked=\"checked\" >";
|
||||
|
Reference in New Issue
Block a user