susidns, addressbook: Don't attempt to fetch subscriptions if

HTTP proxy is down (ticket #1530)
This commit is contained in:
zzz
2015-05-30 13:53:56 +00:00
parent 89745f5002
commit 280fc05c91
2 changed files with 8 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.List;
import net.i2p.I2PAppContext;
import net.i2p.util.PortMapper;
/**
* An iterator over the subscriptions in a SubscriptionList. Note that this iterator
@@ -69,11 +70,13 @@ class SubscriptionIterator implements Iterator<AddressBook> {
* Yes, the EepGet fetch() is done in here in next().
*
* see java.util.Iterator#next()
* @return an AddressBook (empty if the minimum delay has not been met)
* @return non-null AddressBook (empty if the minimum delay has not been met,
* or there is no proxy tunnel, or the fetch otherwise fails)
*/
public AddressBook next() {
Subscription sub = this.subIterator.next();
if (sub.getLastFetched() + this.delay < I2PAppContext.getGlobalContext().clock().now()) {
if (sub.getLastFetched() + this.delay < I2PAppContext.getGlobalContext().clock().now() &&
I2PAppContext.getGlobalContext().portMapper().getPort(PortMapper.SVC_HTTP_PROXY) >= 0) {
//System.err.println("Fetching addressbook from " + sub.getLocation());
return new AddressBook(sub, this.proxyHost, this.proxyPort);
} else {

View File

@@ -36,6 +36,7 @@ import java.util.Collections;
import java.util.List;
import net.i2p.data.DataHelper;
import net.i2p.util.PortMapper;
import net.i2p.util.SecureFileOutputStream;
public class SubscriptionsBean extends BaseBean
@@ -136,7 +137,8 @@ public class SubscriptionsBean extends BaseBean
// with the correct parameters will kick off a
// config reload and fetch.
*******/
if (content != null && content.length() > 2) {
if (content != null && content.length() > 2 &&
_context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY) > 0) {
message = _("Subscriptions saved, updating addressbook from subscription sources now.");
// + "<img height=\"1\" width=\"1\" alt=\"\" " +
// "src=\"/addressbook/?wakeup=1&nonce=" + nonce + "\">";