2006-02-16 jrandom
* Bugfix to the I2PTunnel web config to properly accept i2cp port settings * Initial sucker refactoring to simplify reuse of the html parsing * Beginnings of hooks to push imported rss/atom out to remote syndie archives automatically (though not enabled currently) * Further SSU peer test cleanup
This commit is contained in:
@ -1,10 +1,10 @@
|
|||||||
package net.i2p.syndie;
|
package net.i2p.syndie;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
|
import net.i2p.client.naming.PetName;
|
||||||
|
import net.i2p.client.naming.PetNameDB;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.syndie.web.RemoteArchiveBean;
|
import net.i2p.syndie.web.RemoteArchiveBean;
|
||||||
|
|
||||||
@ -15,6 +15,8 @@ public class Updater {
|
|||||||
private long _lastUpdate;
|
private long _lastUpdate;
|
||||||
private static boolean _woken;
|
private static boolean _woken;
|
||||||
|
|
||||||
|
private static boolean ALLOW_REMOTE_PUSH = false;
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
BlogManager bm = BlogManager.instance();
|
BlogManager bm = BlogManager.instance();
|
||||||
if (_lastUpdate + bm.getUpdateDelay()*60*60*1000 > System.currentTimeMillis()) {
|
if (_lastUpdate + bm.getUpdateDelay()*60*60*1000 > System.currentTimeMillis()) {
|
||||||
@ -31,17 +33,56 @@ public class Updater {
|
|||||||
}
|
}
|
||||||
_log.debug("Done fetching archives");
|
_log.debug("Done fetching archives");
|
||||||
List rssFeeds = bm.getRssFeeds();
|
List rssFeeds = bm.getRssFeeds();
|
||||||
|
List allEntries = new ArrayList();
|
||||||
Iterator iter = rssFeeds.iterator();
|
Iterator iter = rssFeeds.iterator();
|
||||||
while(iter.hasNext()) {
|
while(iter.hasNext()) {
|
||||||
String args[] = (String[])iter.next();
|
String args[] = (String[])iter.next();
|
||||||
_log.debug("rss feed begin: " + args[0]);
|
_log.debug("rss feed begin: " + args[0]);
|
||||||
Sucker sucker = new Sucker(args);
|
Sucker sucker = new Sucker(args);
|
||||||
sucker.suck();
|
allEntries.addAll(sucker.suck());
|
||||||
_log.debug("rss feed end: " + args[0]);
|
_log.debug("rss feed end: " + args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ALLOW_REMOTE_PUSH && (allEntries.size() > 0) ) {
|
||||||
|
String pushedRemoteArchive = getAutomaticallyPushedArchive();
|
||||||
|
if (pushedRemoteArchive != null) {
|
||||||
|
_log.debug("Pushing all of the new entries to " + pushedRemoteArchive + ": " + allEntries);
|
||||||
|
// push all of the new entries to the configured default archive
|
||||||
|
User user = new User();
|
||||||
|
RemoteArchiveBean rab = new RemoteArchiveBean();
|
||||||
|
|
||||||
|
rab.fetchIndex(user, "web", pushedRemoteArchive, bm.getDefaultProxyHost(), bm.getDefaultProxyPort(), true);
|
||||||
|
if (rab.getRemoteIndex() != null) {
|
||||||
|
rab.postSelectedEntries(user, allEntries, pushedRemoteArchive);
|
||||||
|
_log.debug(rab.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_log.debug("Done with all updating");
|
_log.debug("Done with all updating");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pick the archive to which any posts imported from a feed should be pushed to,
|
||||||
|
* beyond the local archive. This currently pushes it to the first (alphabetically)
|
||||||
|
* syndie archive in the default user's addressbook that is marked as 'public'.
|
||||||
|
*
|
||||||
|
* @return archive location, or null if no archive should be used
|
||||||
|
*/
|
||||||
|
private String getAutomaticallyPushedArchive() {
|
||||||
|
BlogManager bm = BlogManager.instance();
|
||||||
|
User user = bm.getDefaultUser();
|
||||||
|
PetNameDB db = user.getPetNameDB();
|
||||||
|
for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) {
|
||||||
|
String name = (String)iter.next();
|
||||||
|
PetName pn = db.getByName(name);
|
||||||
|
String proto = pn.getProtocol();
|
||||||
|
if ( (proto != null) && ("syndiearchive".equals(proto)) )
|
||||||
|
if (pn.getIsPublic())
|
||||||
|
return pn.getLocation();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void fetchArchive(String archive) {
|
public void fetchArchive(String archive) {
|
||||||
if ( (archive == null) || (archive.trim().length() <= 0) ) {
|
if ( (archive == null) || (archive.trim().length() <= 0) ) {
|
||||||
_log.error("Fetch a null archive?" + new Exception("source"));
|
_log.error("Fetch a null archive?" + new Exception("source"));
|
||||||
|
@ -74,8 +74,8 @@ public class HopProcessor {
|
|||||||
|
|
||||||
boolean okIV = _validator.receiveIV(orig, offset, orig, offset + IV_LENGTH);
|
boolean okIV = _validator.receiveIV(orig, offset, orig, offset + IV_LENGTH);
|
||||||
if (!okIV) {
|
if (!okIV) {
|
||||||
if (_log.shouldLog(Log.ERROR))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.error("Invalid IV received on tunnel " + _config.getReceiveTunnelId());
|
_log.warn("Invalid IV received on tunnel " + _config.getReceiveTunnelId());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user