Addressbook: Rename the book nobody uses

Config migration
Version the svg
Remove very old standalone files
This commit is contained in:
zzz
2020-07-09 16:45:37 +00:00
parent ed14aa130c
commit 31d7d7d9bb
18 changed files with 53 additions and 166 deletions

View File

@@ -1,43 +0,0 @@
addressbook v2.0.2 - A simple name resolution mechanism for I2P
addressbook is a simple implementation of subscribable address books for I2P.
Addresses are stored in userhosts.txt and a second copy of the address book is
placed on your eepsite as hosts.txt.
subscriptions.txt contains a list of urls to check for new addresses.
Since the urls are checked in order, and conflicting addresses are not added,
addressbook.subscriptions can be considered to be ranked in order of trust.
The system created by addressbook is similar to the early days of DNS,
when everyone ran a local name server. The major difference is the lack of
authority. Name cannot be guaranteed to be globally unique, but in practise
they probably will be, for a variety of social reasons.
Requirements
************
i2p with a running http proxy
Installation and Usage
**********************
1. Unzip addressbook-%ver.zip into your i2p directory.
2. Restart your router.
The addressbook daemon will automatically run while the router is up.
Aside from the daemon itself, the other elements of the addressbook interface
are the config.txt, myhosts.txt, and subscriptions.txt files found in the addressbook
directory.
config.txt is the configuration file for addressbook.
myhosts.txt is the addressbook master address book. Addresses placed in this file
take precidence over those in the router address book and in remote address books.
If changes are made to this file, they will be reflected in the router address book
and published address book after the next update. Do not make changes directly to the
router address book, as they could be lost during an update.
subscriptions.txt is the subscription list for addressbook. Each entry is an absolute
url to a file in hosts.txt format. Since the list is checked in order, url's should be
listed in order of trust.

View File

@@ -1,48 +0,0 @@
# This is the configuration file for addressbook.
#
# Options
# *******
# All paths are realitive to i2p/addressbook. Default value for
# each option is given in parentheses.
#
# proxy_host The hostname of your I2P http proxy.
# (localhost)
#
# proxy_port The port of your I2P http proxy. (4444)
#
# master_addressbook The path to your master address book, used for local
# changes only. (myhosts.txt)
#
# router_addressbook The path to the address book used by the router.
# 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)
#
# log The path to your addressbook log. (log.txt)
#
# subscriptions The path to your subscription file. (subscriptions.txt)
#
# etags The path to the etags header storage file. (etags)
#
# last_modified The path to the last-modified header storage file.
# (last_modified)
#
# update_delay The time (in hours) between each update. (1)
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
etags=etags
last_modified=last_modified
update_delay=1

View File

@@ -166,6 +166,10 @@ class ConfigParser {
Map<String, String> result;
try {
result = parse(file);
// migrate
String local = result.remove("master_addressbook");
if (local != null)
result.put("local_addressbook", local);
for (Map.Entry<String, String> entry : map.entrySet()) {
if (!result.containsKey(entry.getKey()))
result.put(entry.getKey(), entry.getValue());

View File

@@ -67,8 +67,8 @@ class Daemon {
* Update the router and published address books using remote data from the
* subscribed address books listed in subscriptions.
*
* @param master
* The master AddressBook. This address book is never
* @param local
* The local AddressBook. This address book is never
* overwritten, so it is safe for the user to write to.
* It is only merged to the published addressbook.
* May be null.
@@ -87,7 +87,7 @@ class Daemon {
* The log to write changes and conflicts to.
* May be null.
*/
public static void update(AddressBook master, AddressBook router,
public static void update(AddressBook local, AddressBook router,
File published, SubscriptionList subscriptions, Log log) {
for (AddressBook book : subscriptions) {
// yes, the EepGet fetch() is done in next()
@@ -95,8 +95,8 @@ class Daemon {
}
router.write();
if (published != null) {
if (master != null)
router.merge(master, true, null);
if (local != null)
router.merge(local, true, null);
router.write(published);
}
subscriptions.write();
@@ -105,7 +105,7 @@ class Daemon {
/**
* Update the router and published address books using remote data from the
* subscribed address books listed in subscriptions.
* Merging of the "master" addressbook is NOT supported.
* Merging of the "local" addressbook is NOT supported.
*
* @param router
* The NamingService to update, generally the root NamingService from the context.
@@ -751,17 +751,17 @@ class Daemon {
if (Boolean.parseBoolean(settings.get("update_direct"))) {
// Direct hosts.txt access
File routerFile = new File(home, settings.get("router_addressbook"));
AddressBook master;
AddressBook local;
if (should_publish) {
File masterFile = new File(home, settings.get("master_addressbook"));
master = new AddressBook(masterFile);
File localFile = new File(home, settings.get("local_addressbook"));
local = new AddressBook(localFile);
} else {
master = null;
local = null;
}
AddressBook router = new AddressBook(routerFile);
update(master, router, published, subscriptions, log);
update(local, router, published, subscriptions, log);
} else {
// Naming service - no merging of master to router and published is supported.
// Naming service - no merging of local to router and published is supported.
update(getNamingService(settings.get("naming_service")), published, subscriptions, log);
}
}
@@ -841,7 +841,7 @@ class Daemon {
Map<String, String> defaultSettings = new HashMap<String, String>();
defaultSettings.put("proxy_host", "127.0.0.1");
defaultSettings.put("proxy_port", "4444");
defaultSettings.put("master_addressbook", "../userhosts.txt");
defaultSettings.put("local_addressbook", "../userhosts.txt");
defaultSettings.put("router_addressbook", "../hosts.txt");
defaultSettings.put("published_addressbook", "../eepsite/docroot/hosts.txt");
defaultSettings.put("should_publish", "false");
@@ -868,7 +868,7 @@ class Daemon {
// wait
try {
Thread.sleep(5*60*1000 + I2PAppContext.getGlobalContext().random().nextLong(5*60*1000));
// Static method, and redundent Thread.currentThread().sleep(5*60*1000);
// Static method, and redundant Thread.currentThread().sleep(5*60*1000);
} catch (InterruptedException ie) {}
while (_running) {

View File

@@ -1,10 +0,0 @@
# addressbook master address book. Addresses placed in this file take precidence
# over those in the router address book and in remote address books. If changes
# are made to this file, they will be reflected in the router address book and
# published address book after the next update.
#
# Do not make changes directly to the router address book, as they could be lost
# during an update.
#
# This file takes addresses in the hosts.txt format, i.e.
# example.i2p=somereallylongbase64thingAAAA

View File

@@ -1,7 +0,0 @@
# Subscription list for addressbook
#
# Each entry is an absolute url to a file in hosts.txt format.
# Since the list is checked in order, url's should be listed in order of trust.
#
http://dev.i2p/i2p/hosts.txt
http://duck.i2p/hosts.txt

View File

@@ -1460,7 +1460,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
"<h4>" + _t("Save {0} to router address book and continue to website", destination) + "</h4>\n<p>" +
_t("This address will be saved to your Router address book where your subscription-based addresses are stored."));
if(_context.namingService().getName().equals("BlockfileNamingService")) {
out.write(" " + _t("If you want to keep track of sites you have added manually, add to your Master or Private address book instead."));
out.write(" " + _t("If you want to keep track of sites you have added manually, add to your Local or Private address book instead."));
}
// FIXME wasn't escaped
String label = _t("Save & continue").replace("&", "&amp;");
@@ -1470,9 +1470,9 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
if(_context.namingService().getName().equals("BlockfileNamingService")) {
// only blockfile supports multiple books
out.write("<h4>" + _t("Save {0} to master address book and continue to website", destination) + "</h4>\n<p>" +
_t("This address will be saved to your Master address book. Select this option for addresses you wish to keep separate from the main router address book, but don't mind publishing.") +
"</p>\n<div class=\"formaction\"><button type=\"submit\" class=\"accept\" name=\"master\" value=\"master\">" +
out.write("<h4>" + _t("Save {0} to local address book and continue to website", destination) + "</h4>\n<p>" +
_t("This address will be saved to your Local address book. Select this option for addresses you wish to keep separate from the main router address book, but don't mind publishing.") +
"</p>\n<div class=\"formaction\"><button type=\"submit\" class=\"accept\" name=\"local\" value=\"local\">" +
label + "</button></div>\n");
out.write("<h4>" + _t("Save {0} to private address book and continue to website", destination) + "</h4>\n<p>" +

View File

@@ -155,7 +155,7 @@ public abstract class LocalHTTPServer {
}
// Add to addressbook (form submit)
// Parameters are url, host, dest, nonce, and master | router | private.
// Parameters are url, host, dest, nonce, and local | router | private.
// Do the add and redirect.
if (targetRequest.equals("/add")) {
if (query == null) {
@@ -170,7 +170,7 @@ public abstract class LocalHTTPServer {
String nonce = opts.get("nonce");
String referer = opts.get("referer");
String book = "privatehosts.txt";
if (opts.get("master") != null)
if (opts.get("local") != null)
book = "userhosts.txt";
else if (opts.get("router") != null)
book = "hosts.txt";
@@ -345,7 +345,7 @@ public abstract class LocalHTTPServer {
if ("hosts.txt".equals(book))
tbook = _t("router");
else if ("userhosts.txt".equals(book))
tbook = _t("master");
tbook = _t("local");
else if ("privatehosts.txt".equals(book))
tbook = _t("private");
else

View File

@@ -118,7 +118,7 @@ public class AddressbookBean extends BaseBean
*/
public String getBook()
{
if( book == null || ( !book.equalsIgnoreCase( "master" ) &&
if( book == null || ( !book.equalsIgnoreCase( "local" ) &&
!book.equalsIgnoreCase( "router" ) &&
!book.equalsIgnoreCase( "private" ) &&
!book.equalsIgnoreCase( "published" )))
@@ -127,6 +127,8 @@ public class AddressbookBean extends BaseBean
return book;
}
public void setBook(String book) {
if ("master".equals(book))
book = "local";
this.book = DataHelper.stripHTML(book); // XSS
}
@@ -403,25 +405,6 @@ public class AddressbookBean extends BaseBean
return filter;
}
/****
public boolean isMaster()
{
return getBook().equalsIgnoreCase("master");
}
public boolean isRouter()
{
return getBook().equalsIgnoreCase("router");
}
public boolean isPublished()
{
return getBook().equalsIgnoreCase("published");
}
public boolean isPrivate()
{
return getBook().equalsIgnoreCase("private");
}
****/
/**
* Because the following from addressbook.jsp fails parsing in the new EL:
* javax.el.ELException: Failed to parse the expression
@@ -437,7 +420,7 @@ public class AddressbookBean extends BaseBean
public boolean isValidBook() {
String s = getBook().toLowerCase(Locale.US);
return s.equals("router") ||
s.equals("master") ||
s.equals("local") ||
s.equals("published") ||
s.equals("private");
}

View File

@@ -79,6 +79,12 @@ public class BaseBean
// added in 0.5, for compatibility with 0.4 config.txt
if( properties.getProperty(PRIVATE_BOOK) == null)
properties.setProperty(PRIVATE_BOOK, DEFAULT_PRIVATE_BOOK);
// migrate
String local = properties.getProperty("master_addressbook");
if (local != null) {
properties.setProperty("local_addressbook", local);
properties.remove("master_addressbook");
}
configLastLoaded = System.currentTimeMillis();
}
}

View File

@@ -103,6 +103,8 @@ public class NamingServiceBean extends AddressbookBean
return super.getFileName();
loadConfig();
String filename = properties.getProperty( getBook() + "_addressbook" );
if (filename == null)
return getBook();
return basename(filename);
}

View File

@@ -66,7 +66,7 @@
<div id="navi" class="${book.getBook()}">
<a id="overview" href="index"><%=intl._t("Overview")%></a>&nbsp;
<a class="abook private" href="addressbook?book=private&amp;filter=none"><%=intl._t("Private")%></a>&nbsp;
<a class="abook master" href="addressbook?book=master&amp;filter=none"><%=intl._t("Master")%></a>&nbsp;
<a class="abook local" href="addressbook?book=local&amp;filter=none"><%=intl._t("Local")%></a>&nbsp;
<a class="abook router" href="addressbook?book=router&amp;filter=none"><%=intl._t("Router")%></a>&nbsp;
<a class="abook published" href="addressbook?book=published&amp;filter=none"><%=intl._t("Published")%></a>&nbsp;
<a id="subs" href="subscriptions"><%=intl._t("Subscriptions")%></a>&nbsp;

View File

@@ -45,7 +45,7 @@
<div id="navi">
<a id="overview" href="index"><%=intl._t("Overview")%></a>&nbsp;
<a class="abook" href="addressbook?book=private&amp;filter=none"><%=intl._t("Private")%></a>&nbsp;
<a class="abook" href="addressbook?book=master&amp;filter=none"><%=intl._t("Master")%></a>&nbsp;
<a class="abook" href="addressbook?book=local&amp;filter=none"><%=intl._t("Local")%></a>&nbsp;
<a class="abook" href="addressbook?book=router&amp;filter=none"><%=intl._t("Router")%></a>&nbsp;
<a class="abook" href="addressbook?book=published&amp;filter=none"><%=intl._t("Published")%></a>&nbsp;
<a id="subs" href="subscriptions"><%=intl._t("Subscriptions")%></a>&nbsp;
@@ -74,11 +74,11 @@
<%=intl._t("File and directory paths here are relative to the addressbook's working directory, which is normally ~/.i2p/addressbook/ (Linux) or %LOCALAPPDATA%\\I2P\\addressbook\\ (Windows).")%>
</li>
<li>
<%=intl._t("If you want to manually add lines to an addressbook, add them to the private or master addressbooks.")%>
<%=intl._t("If you want to manually add lines to an addressbook, add them to the private or local addressbooks.")%>
<%=intl._t("The router addressbook and the published addressbook are updated by the addressbook application.")%>
</li>
<li>
<%=intl._t("When you publish your addressbook, ALL destinations from the master and router addressbooks appear there.")%>
<%=intl._t("When you publish your addressbook, ALL destinations from the local and router addressbooks appear there.")%>
<%=intl._t("Use the private addressbook for private destinations, these are not published.")%>
</li>
</ol>
@@ -96,7 +96,7 @@
<li><b>router_addressbook</b> -
<%=intl._t("Your hosts.txt (don't change)")%>
</li>
<li><b>master_addressbook</b> -
<li><b>local_addressbook</b> -
<%=intl._t("Your personal addressbook, these hosts will be published")%>
</li>
<li><b>private_addressbook</b> -

View File

@@ -42,7 +42,7 @@
<div id="navi">
<a id="overview" href="index"><%=intl._t("Overview")%></a>&nbsp;
<a class="abook" href="addressbook?book=private&amp;filter=none"><%=intl._t("Private")%></a>&nbsp;
<a class="abook" href="addressbook?book=master&amp;filter=none"><%=intl._t("Master")%></a>&nbsp;
<a class="abook" href="addressbook?book=local&amp;filter=none"><%=intl._t("Local")%></a>&nbsp;
<a class="abook" href="addressbook?book=router&amp;filter=none"><%=intl._t("Router")%></a>&nbsp;
<a class="abook" href="addressbook?book=published&amp;filter=none"><%=intl._t("Published")%></a>&nbsp;
<a id="subs" href="subscriptions"><%=intl._t("Subscriptions")%></a>&nbsp;

View File

@@ -54,7 +54,7 @@
<div id="navi">
<a id="overview" class="active" href="index"><%=intl._t("Overview")%></a>&nbsp;
<a class="abook" href="addressbook?book=private&amp;filter=none"><%=intl._t("Private")%></a>&nbsp;
<a class="abook" href="addressbook?book=master&amp;filter=none"><%=intl._t("Master")%></a>&nbsp;
<a class="abook" href="addressbook?book=local&amp;filter=none"><%=intl._t("Local")%></a>&nbsp;
<a class="abook" href="addressbook?book=router&amp;filter=none"><%=intl._t("Router")%></a>&nbsp;
<a class="abook" href="addressbook?book=published&amp;filter=none"><%=intl._t("Published")%></a>&nbsp;
<a id="subs" href="subscriptions"><%=intl._t("Subscriptions")%></a>&nbsp;
@@ -77,7 +77,7 @@
<h3><%=intl._t("How does the addressbook application work?")%></h3>
<p>
<%=intl._t("The addressbook application regularly polls your subscriptions and merges their content into your \"router\" address book.")%>
<%=intl._t("Then it merges your \"master\" address book into the router address book as well.")%>
<%=intl._t("Then it merges your \"local\" address book into the router address book as well.")%>
<%=intl._t("If configured, the router address book is now written to the \"published\" address book, which will be publicly available if you are running an eepsite.")%>
</p><p>
<%=intl._t("The router also uses a private address book, which is not merged or published.")%>
@@ -85,7 +85,7 @@
<%=intl._t("The private address book can also be used for aliases of hosts in your other address books.")%>
</p>
<div class="illustrate">
<object type="image/svg+xml" data="images/how.svg">
<object type="image/svg+xml" data="images/how.svg?<%=net.i2p.CoreVersion.VERSION%>">
<img src="/themes/susidns/images/how.png" border="0" alt="address book working scheme" title="How the address book works" class="illustrate" />
</object>
</div>

View File

@@ -44,7 +44,7 @@
<div id="navi">
<a id="overview" href="index"><%=intl._t("Overview")%></a>&nbsp;
<a class="abook" href="addressbook?book=private&amp;filter=none"><%=intl._t("Private")%></a>&nbsp;
<a class="abook" href="addressbook?book=master&amp;filter=none"><%=intl._t("Master")%></a>&nbsp;
<a class="abook" href="addressbook?book=local&amp;filter=none"><%=intl._t("Local")%></a>&nbsp;
<a class="abook" href="addressbook?book=router&amp;filter=none"><%=intl._t("Router")%></a>&nbsp;
<a class="abook" href="addressbook?book=published&amp;filter=none"><%=intl._t("Published")%></a>&nbsp;
<a id="subs" class="active" href="subscriptions"><%=intl._t("Subscriptions")%></a>&nbsp;

View File

@@ -32,7 +32,7 @@
<title>_("To configure SusiDNS to push your Router address book to your Published address book, set 'should_publish=true' on the configuration page.")</title>
</path>
<a xlink:href="/susidns/addressbook?book=router" target="_parent" class="book">
<title>_("All hosts derived from subscriptions will appear in this address book, in addition to any you manually add here or to your Master address book.")</title>
<title>_("All hosts derived from subscriptions will appear in this address book, in addition to any you manually add here or to your Local address book.")</title>
<rect class="a tooltip" width="428" height="66" x="264" y="362" ry="10">
</rect>
<text class="b" x="477" y="403">
@@ -72,17 +72,17 @@
</text>
</a>
</g>
<a xlink:href="/susidns/addressbook?book=master" target="_parent" class="book">
<a xlink:href="/susidns/addressbook?book=local" target="_parent" class="book">
<title>_("If you manually add hosts here, they will be included your Published address book (if configured).")</title>
<rect class="a tooltip" width="419" height="64" x="34" y="94" ry="10">
</rect>
<text class="b" x="243" y="134">
<tspan class="c" x="243" y="134">_("Master Addressbook")</tspan>
<tspan class="c" x="243" y="134">_("Local Addressbook")</tspan>
</text>
</a>
<text class="f tooltip" x="817" y="389">
<tspan class="g" x="817" y="389">_("Searchable by")</tspan> <tspan class="g" x="817" y="416">_("I2P applications")</tspan>
<title>_("The Master, Router and Private address books collectively serve as the DNS authority for I2P applications.")</title>
<title>_("The Local, Router and Private address books collectively serve as the DNS authority for I2P applications.")</title>
</text>
<a xlink:href="/susidns/config" target="_parent">
<text class="f" x="817" y="518">
@@ -91,7 +91,7 @@
</text>
</a>
<path class="a tooltip" d="M382 164v133h-21l22 31 22 31 23-31 22-31h-19V164h-49z">
<title>_("Addresses manually added to your Master address book will merge with your Router address book.")</title>
<title>_("Addresses manually added to your Local address book will merge with your Router address book.")</title>
</path>
<path class="a tooltip" d="M553 164v133h-21l22 31 22 31 23-31 22-31h-19V164z">
<title>_("Hosts you receive from your subscriptions will merge with your Router address book.")</title>

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -6,6 +6,6 @@ log=../log/addrbook_log.txt
last_modified=../log/addrbook_last_modified.txt
etags=../log/addrbook_etags.txt
subscriptions=subscriptions.txt
master_addressbook=userhosts.txt
local_addressbook=userhosts.txt
router_addressbook=../hosts.txt
published_addressbook=../eepsite/hosts.txt