diff --git a/apps/addressbook/config.txt b/apps/addressbook/config.txt index 53e03127e9..49a4212f43 100644 --- a/apps/addressbook/config.txt +++ b/apps/addressbook/config.txt @@ -17,6 +17,10 @@ # Contains the addresses from your master address book # and your subscribed address books. (../userhosts.txt) # +# private_addressbook The path to the private address book used by the router. +# This is used only by the router and SusiDNS. +# It is not published by addressbook. (../privatehosts.txt) +# # published_addressbook The path to the copy of your address book made # available on i2p. (../eepsite/docroot/hosts.txt) # @@ -35,6 +39,7 @@ proxy_host=localhost proxy_port=4444 master_addressbook=myhosts.txt router_addressbook=../userhosts.txt +private_addressbook=../privatehosts.txt published_addressbook=../eepsite/docroot/hosts.txt log=log.txt subscriptions=subscriptions.txt diff --git a/apps/addressbook/java/src/addressbook/AddressBook.java b/apps/addressbook/java/src/addressbook/AddressBook.java index 6184111d45..94049f2da1 100644 --- a/apps/addressbook/java/src/addressbook/AddressBook.java +++ b/apps/addressbook/java/src/addressbook/AddressBook.java @@ -152,6 +152,27 @@ public class AddressBook { return this.addresses.toString(); } + /** + * Do basic validation of the hostname and dest + * hostname was already converted to lower case by ConfigParser.parse() + */ + private static boolean valid(String host, String dest) { + return + host.endsWith(".i2p") && + host.length() > 4 && + host.length() <= 67 && // 63 + ".i2p" + (! host.startsWith(".")) && + (! host.startsWith("-")) && + (! host.endsWith("-.i2p")) && + host.indexOf("..") < 0 && + host.replaceAll("[a-z0-9.-]", "").length() == 0 && + + dest.length() == 516 && + dest.endsWith("AAAA") && + dest.replaceAll("[a-zA-Z0-9~-]", "").length() == 0 + ; + } + /** * Merge this AddressBook with AddressBook other, writing messages about new * addresses or conflicts to log. Addresses in AddressBook other that are @@ -170,7 +191,7 @@ public class AddressBook { String otherKey = (String) otherIter.next(); String otherValue = (String) other.addresses.get(otherKey); - if (otherKey.endsWith(".i2p") && otherValue.length() == 516) { + if (valid(otherKey, otherValue)) { if (this.addresses.containsKey(otherKey) && !overwrite) { if (!this.addresses.get(otherKey).equals(otherValue) && log != null) { diff --git a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java index 0636c5c63f..8cdca45c6f 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Revision: 1.1 $ + * $Revision: 1.2 $ */ package i2p.susi.dns; @@ -76,6 +76,8 @@ public class AddressbookBean deletionMarks = new LinkedList(); } private long configLastLoaded = 0; + private static final String PRIVATE_BOOK = "private_addressbook"; + private static final String DEFAULT_PRIVATE_BOOK = "../privatehosts.txt"; private void loadConfig() { long currentTime = System.currentTimeMillis(); @@ -86,6 +88,9 @@ public class AddressbookBean try { properties.clear(); properties.load( new FileInputStream( ConfigBean.configFileName ) ); + // added in 0.5, for compatibility with 0.4 config.txt + if( properties.getProperty(PRIVATE_BOOK) == null) + properties.setProperty(PRIVATE_BOOK, DEFAULT_PRIVATE_BOOK); configLastLoaded = currentTime; } catch (Exception e) { @@ -112,8 +117,9 @@ public class AddressbookBean public String getBook() { if( book == null || ( book.compareToIgnoreCase( "master" ) != 0 && - book.compareToIgnoreCase( "router" ) != 0 ) && - book.compareToIgnoreCase( "published" ) != 0 ) + book.compareToIgnoreCase( "router" ) != 0 && + book.compareToIgnoreCase( "private" ) != 0 && + book.compareToIgnoreCase( "published" ) != 0 )) book = "master"; return book; @@ -163,7 +169,11 @@ public class AddressbookBean list.addLast( new AddressBean( name, destination ) ); } // Format a message about filtered addressbook size, and the number of displayed entries - message = "Filtered list contains " + list.size() + " entries"; + if( filter != null && filter.length() > 0 ) + message = "Filtered l"; + else + message = "L"; + message += "ist contains " + list.size() + " entries"; if (list.size() > 300) message += ", displaying the first 300."; else message += "."; Object array[] = list.toArray(); @@ -251,6 +261,10 @@ public class AddressbookBean { return getBook().compareToIgnoreCase( "published" ) == 0; } + public boolean isPrivate() + { + return getBook().compareToIgnoreCase( "private" ) == 0; + } public void setFilter(String filter) { if( filter != null && ( filter.length() == 0 || filter.compareToIgnoreCase( "none" ) == 0 ) ) { filter = null; diff --git a/apps/susidns/src/java/src/i2p/susi/dns/VersionBean.java b/apps/susidns/src/java/src/i2p/susi/dns/VersionBean.java index 3e7a572e73..ffc7010462 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/VersionBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/VersionBean.java @@ -19,14 +19,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Revision: 1.4 $ + * $Revision: 1.1 $ */ package i2p.susi.dns; public class VersionBean { - private static String version = "0.4"; + private static String version = "0.5"; private static String url = "http://susi.i2p/?i2paddresshelper=T2DU1KAz3meB0B53U8Y06-I7vHR7XmC0qXAJfLW6b-1L1FVKoySRZz4xazHAwyv2xtRpvKrv6ukLm1tThEW0zQWtZPtX8G6KkzMibD8t7IS~4yw-9VkBtUydyYfsX08AK3v~-egSW8HCXTdyIJVtrETJb337VDUHW-7D4L1JLbwSH4if2ooks6yFTrljK5aVMi-16dZOVvmoyJc3jBqSdK6kraO4gW5-vHTmbLwL498p9nug1KOg1DqgN2GeU5X1QlVrlpFb~IIfdP~O8NT7u-LAjW3jSJsMbLDHMSYTIhC7xmJIiBoi-qk8p6TLynAmvJ7HRvbx4N1EB-uJHyD16wsZkkHyEOfmXbj0ZqLyKEGb3thPwCz-M9v~c2Qt3WbwjXJAtHpjlHkdJ4Fg91cX2oak~JoapnPf6Syw8hko5syf6VVoCYLnrrYyM8oGl8mLclHkj~VCidQNqMSM74IhrHfK6HmRikqtZBexb5M6wfMTTqBvaHURdD21GOpFKYBUAAAA"; public String getVersion() { diff --git a/apps/susidns/src/jsp/addressbook.jsp b/apps/susidns/src/jsp/addressbook.jsp index eec222aee5..1e78118b9e 100644 --- a/apps/susidns/src/jsp/addressbook.jsp +++ b/apps/susidns/src/jsp/addressbook.jsp @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Revision: 1.2 $ + * $Revision: 1.3 $ */ %> <%@ page contentType="text/html"%> @@ -48,9 +48,11 @@
addressbooks master | router | -published * +published | +private * subscriptions * -configuration +configuration * +overview
@@ -92,7 +94,8 @@ 0-9 allCurrent filter: ${book.filter}
+Current filter: ${book.filter} +(clear filter)
${addr.name} - @@ -139,7 +142,7 @@ |