2005-02-06 Sugadude

* Added a filter to the addressbook to remove entries that dont end in ".i2p"
(thanks Sugadude!)
This commit is contained in:
jrandom
2005-02-06 22:14:46 +00:00
committed by zzz
parent 80120b7b7d
commit 27e92653fe
3 changed files with 30 additions and 3 deletions

View File

@ -243,4 +243,27 @@ public class AddressBook {
public void write() {
this.write(new File(this.location));
}
}
/**
* Filter out bad addresses in this addressbook, and write them to log.
* Returns the number of addresses removed.
*
* @author Sugadude
*/
public int filter(Log log) {
Iterator iter = this.addresses.keySet().iterator();
int removed = 0;
while(iter.hasNext()) {
String aKey = (String) iter.next();
if(!aKey.endsWith(".i2p")) {
iter.remove();
removed++;
if(log != null)
log.append("Invalid address " + aKey + " filtered out.");
}
}
if(removed > 0)
this.modified = true;
return removed;
}
}

View File

@ -64,6 +64,7 @@ public class Daemon {
while (iter.hasNext()) {
master.merge((AddressBook) iter.next(), log);
}
master.filter(log); /** @author Sugadude */
master.write(new File(routerLocation));
master.write(published);
subscriptions.write();
@ -168,4 +169,4 @@ public class Daemon {
}
}
}
}
}

View File

@ -1,4 +1,7 @@
$Id: history.txt,v 1.136 2005/01/26 23:48:41 smeghead Exp $
$Id: history.txt,v 1.137 2005/02/03 08:39:47 smeghead Exp $
2005-02-06 Sugadude
* Added a filter to the addressbook to remove entries that dont end in ".i2p"
2005-02-03 smeghead
* Added Ant buildfile in apps/fortuna for creating a custom Fortuna PRNG jar