Changeset 84dc7d9


Ignore:
Timestamp:
Jan 1, 2005 12:57:01 AM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
48b0399
Parents:
70d6332
git-author:
jrandom <jrandom> (01/01/05 00:57:01)
git-committer:
zzz <zzz@…> (01/01/05 00:57:01)
Message:

2004-12-31 ragnarok

  • Integrated latest addressbook changes (2.0.3) which include support for deploying as a .war file with no existing addressbook configuration.
  • Updated main build process to bundle the addressbook.war in the i2pinstall.jar and i2pupdate.zip.
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • apps/addressbook/README.txt

    r70d6332 r84dc7d9  
    2929Aside from the daemon itself, the other elements of the addressbook interface
    3030are the config.txt, myhosts.txt, and subscriptions.txt files found in the addressbook
    31 directory.  Those files are largely self-documenting, so if you want to know what they
    32 do, just read them.
     31directory.
     32
     33config.txt is the configuration file for addressbook.
     34
     35myhosts.txt is the addressbook master address book.  Addresses placed in this file
     36take precidence over those in the router address book and in remote address books. 
     37If changes are made to this file, they will be reflected in the router address book
     38and published address book after the next update. Do not make changes directly to the
     39router address book, as they could be lost during an update.
     40
     41subscriptions.txt is the subscription list for addressbook.  Each entry is an absolute
     42url to a file in hosts.txt format. Since the list is checked in order, url's should be
     43listed in order of trust.
  • apps/addressbook/java/src/addressbook/ConfigParser.java

    r70d6332 r84dc7d9  
    100100        InputStream urlStream;
    101101        urlStream = url.openConnection().getInputStream();
    102         BufferedReader br = new BufferedReader(new InputStreamReader(urlStream));
    103         return ConfigParser.parse(br);
     102        BufferedReader input = new BufferedReader(new InputStreamReader(
     103                urlStream));
     104        return ConfigParser.parse(input);
    104105    }
    105106
     
    115116     */
    116117    public static Map parse(File file) throws IOException {
    117         FileInputStream fileStream;
    118         fileStream = new FileInputStream(file);
    119         BufferedReader br = new BufferedReader(
    120                 new InputStreamReader(fileStream));
    121         return ConfigParser.parse(br);
     118        FileInputStream fileStream = new FileInputStream(file);
     119        BufferedReader input = new BufferedReader(new InputStreamReader(
     120                fileStream));
     121        return ConfigParser.parse(input);
     122    }
     123
     124    /**
     125     * Return a Map using the contents of the String string. See
     126     * parseBufferedReader for details of the input format.
     127     *
     128     * @param string
     129     *            A String to parse.
     130     * @return A Map containing the key, value pairs from string.
     131     * @throws IOException
     132     *             if file cannot be read.
     133     */
     134    public static Map parse(String string) throws IOException {
     135        StringReader stringReader = new StringReader(string);
     136        BufferedReader input = new BufferedReader(stringReader);
     137        return ConfigParser.parse(input);
     138    }
     139   
     140    /**
     141     * Return a Map using the contents of the File file. If file cannot be read,
     142     * use map instead, and write the result to where file should have been.
     143     *
     144     * @param file
     145     *            A File to attempt to parse.
     146     * @param map
     147     *            A Map to use as the default, if file fails.
     148     * @return A Map containing the key, value pairs from file, or if file
     149     *         cannot be read, map.
     150     */
     151    public static Map parse(File file, Map map) {
     152        Map result = new HashMap();
     153        try {
     154            result = ConfigParser.parse(file);
     155        } catch (IOException exp) {
     156            result = map;
     157            try {
     158                ConfigParser.write(result, file);
     159            } catch (IOException exp2) {
     160            }
     161        }
     162        return result;
     163    }
     164
     165    /**
     166     * Return a List where each element is a line from the BufferedReader input.
     167     *
     168     * @param input
     169     *            A BufferedReader to parse.
     170     * @return A List consisting of one element for each line in input.
     171     * @throws IOException
     172     *             if input cannot be read.
     173     */
     174    public static List parseSubscriptions(BufferedReader input)
     175            throws IOException {
     176        List result = new LinkedList();
     177        String inputLine = input.readLine();
     178        while (inputLine != null) {
     179            inputLine = ConfigParser.stripComments(inputLine).trim();
     180            if (inputLine.length() > 0) {
     181                result.add(inputLine);
     182            }
     183            inputLine = input.readLine();
     184        }
     185        input.close();
     186        return result;
    122187    }
    123188
     
    133198    public static List parseSubscriptions(File file) throws IOException {
    134199        FileInputStream fileStream = new FileInputStream(file);
    135         BufferedReader br = new BufferedReader(
    136                 new InputStreamReader(fileStream));
     200        BufferedReader input = new BufferedReader(new InputStreamReader(
     201                fileStream));
     202        return ConfigParser.parseSubscriptions(input);
     203    }
     204
     205    /**
     206     * Return a List where each element is a line from the String string.
     207     *
     208     * @param string
     209     *            A String to parse.
     210     * @return A List consisting of one element for each line in string.
     211     * @throws IOException
     212     *             if string cannot be read.
     213     */
     214    public static List parseSubscriptions(String string) throws IOException {
     215        StringReader stringReader = new StringReader(string);
     216        BufferedReader input = new BufferedReader(stringReader);
     217        return ConfigParser.parseSubscriptions(input);
     218    }
     219   
     220    /**
     221     * Return a List using the contents of the File file. If file cannot be
     222     * read, use list instead, and write the result to where file should have
     223     * been.
     224     *
     225     * @param file
     226     *            A File to attempt to parse.
     227     * @param string
     228     *            A List to use as the default, if file fails.
     229     * @return A List consisting of one element for each line in file, or if
     230     *         file cannot be read, list.
     231     */
     232    public static List parseSubscriptions(File file, List list) {
    137233        List result = new LinkedList();
    138         String inputLine = br.readLine();
    139         while (inputLine != null) {
    140             inputLine = ConfigParser.stripComments(inputLine);
    141             if (inputLine.trim().length() > 0) {
    142                 result.add(inputLine.trim());
     234        try {
     235            result = ConfigParser.parseSubscriptions(file);
     236        } catch (IOException exp) {
     237            result = list;
     238            try {
     239                ConfigParser.writeSubscriptions(result, file);
     240            } catch (IOException exp2) {
    143241            }
    144             inputLine = br.readLine();
    145         }
    146         br.close();
     242        }
    147243        return result;
    148244    }
    149245
    150246    /**
    151      * Write contents of Map hash to BufferedWriter output. Output is written
     247     * Write contents of Map map to BufferedWriter output. Output is written
    152248     * with one key, value pair on each line, in the format: key=value.
    153249     *
    154      * @param hash
     250     * @param map
    155251     *            A Map to write to output.
    156252     * @param output
     
    159255     *             if the BufferedWriter cannot be written to.
    160256     */
    161     public static void write(Map hash, BufferedWriter output)
    162             throws IOException {
    163         Iterator keyIter = hash.keySet().iterator();
     257    public static void write(Map map, BufferedWriter output) throws IOException {
     258        Iterator keyIter = map.keySet().iterator();
    164259
    165260        while (keyIter.hasNext()) {
    166261            String key = (String) keyIter.next();
    167             output.write(key + "=" + (String) hash.get(key));
     262            output.write(key + "=" + (String) map.get(key));
    168263            output.newLine();
    169264        }
     
    172267
    173268    /**
    174      * Write contents of Map hash to the file at location. Output is written
     269     * Write contents of Map map to the File file. Output is written
    175270     * with one key, value pair on each line, in the format: key=value.
    176271     *
    177      * @param hash
     272     * @param map
    178273     *            A Map to write to file.
    179274     * @param file
     
    182277     *             if file cannot be written to.
    183278     */
    184     public static void write(Map hash, File file) throws IOException {
    185         ConfigParser.write(hash,
    186                 new BufferedWriter(new FileWriter(file, false)));
    187     }
     279    public static void write(Map map, File file) throws IOException {
     280        ConfigParser
     281                .write(map, new BufferedWriter(new FileWriter(file, false)));
     282    }
     283
     284    /**
     285     * Write contents of List list to BufferedReader output. Output is written
     286     * with each element of list on a new line.
     287     *
     288     * @param list
     289     *            A List to write to file.
     290     * @param output
     291     *            A BufferedReader to write list to.
     292     * @throws IOException
     293     *             if output cannot be written to.
     294     */
     295    public static void writeSubscriptions(List list, BufferedWriter output)
     296            throws IOException {
     297        Iterator iter = list.iterator();
     298
     299        while (iter.hasNext()) {
     300            output.write((String) iter.next());
     301            output.newLine();
     302        }
     303        output.close();
     304    }
     305   
     306    /**
     307     * Write contents of List list to File file. Output is written with each
     308     * element of list on a new line.
     309     *
     310     * @param list
     311     *            A List to write to file.
     312     * @param file
     313     *            A File to write list to.
     314     * @throws IOException
     315     *             if output cannot be written to.
     316     */
     317    public static void writeSubscriptions(List list, File file)
     318            throws IOException {
     319        ConfigParser.writeSubscriptions(list, new BufferedWriter(
     320                new FileWriter(file, false)));
     321    }
     322
    188323}
  • apps/addressbook/java/src/addressbook/Daemon.java

    r70d6332 r84dc7d9  
    2525import java.util.Map;
    2626import java.util.HashMap;
     27import java.util.List;
     28import java.util.LinkedList;
    2729import java.io.File;
    28 import java.io.IOException;
    2930
    3031/**
     
    9293        AddressBook master = new AddressBook(masterFile);
    9394        AddressBook router = new AddressBook(routerFile);
     95       
     96        List defaultSubs = new LinkedList();
     97        defaultSubs.add("http://dev.i2p/i2p/hosts.txt");
     98        defaultSubs.add("http://duck.i2p/hosts.txt");
     99       
    94100        SubscriptionList subscriptions = new SubscriptionList(subscriptionFile,
    95                 etagsFile, lastModifiedFile);
     101                etagsFile, lastModifiedFile, defaultSubs);
    96102        Log log = new Log(logFile);
    97103
     
    118124            home = ".";
    119125        }
    120         try {
    121             settings = ConfigParser.parse(new File(home, settingsLocation));
    122         } catch (IOException exp) {
    123             System.out.println("Could not load " + settingsLocation);
     126       
     127        Map defaultSettings = new HashMap();
     128        defaultSettings.put("proxy_host", "localhost");
     129        defaultSettings.put("proxy_port", "4444");
     130        defaultSettings.put("master_addressbook", "myhosts.txt");
     131        defaultSettings.put("router_addressbook", "../userhosts.txt");
     132        defaultSettings.put("published_addressbook", "../eepsite/docroot/hosts.txt");
     133        defaultSettings.put("log", "log.txt");
     134        defaultSettings.put("subscriptions", "subscriptions.txt");
     135        defaultSettings.put("etags", "etags");
     136        defaultSettings.put("last_modified", "last_modified");
     137        defaultSettings.put("update_delay", "1");
     138       
     139        File homeFile = new File(home);
     140        if (!homeFile.exists()) {
     141            boolean created = homeFile.mkdirs();
     142            if (created)
     143                System.out.println("INFO:  Addressbook directory " + homeFile.getName() + " created");
     144            else
     145                System.out.println("ERROR: Addressbook directory " + homeFile.getName() + " could not be created");
    124146        }
     147        settings = ConfigParser.parse(new File(homeFile, settingsLocation), defaultSettings);
    125148
    126149        System.setProperty("proxySet", "true");
  • apps/addressbook/java/src/addressbook/Servlet.java

    r70d6332 r84dc7d9  
    5353        args[0] = config.getInitParameter("home");
    5454        DaemonThread thread = new DaemonThread(args);
     55        thread.setDaemon(true);
    5556        thread.start();
    5657    }
  • apps/addressbook/java/src/addressbook/SubscriptionList.java

    r70d6332 r84dc7d9  
    5959     */
    6060    public SubscriptionList(File locationsFile, File etagsFile,
    61             File lastModifiedFile) {
     61            File lastModifiedFile, List defaultSubs) {
    6262        this.subscriptions = new LinkedList();
    6363        this.etagsFile = etagsFile;
     
    6767        Map lastModified;
    6868        String location;
    69         try {
    70             locations = ConfigParser.parseSubscriptions(locationsFile);
    71         } catch (IOException exp) {
    72             locations = new LinkedList();
    73         }
     69        locations = ConfigParser.parseSubscriptions(locationsFile, defaultSubs);
    7470        try {
    7571            etags = ConfigParser.parse(etagsFile);
     
    9187        iter = this.iterator();
    9288    }
    93 
     89   
    9490    /**
    9591     * Return an iterator over the AddressBooks represented by the Subscriptions
  • build.xml

    r70d6332 r84dc7d9  
    182182        <copy file="build/i2ptunnel.war" todir="pkg-temp/webapps/" />
    183183        <copy file="build/routerconsole.war" todir="pkg-temp/webapps/" />
    184 
    185         <!--
    186         <mkdir dir="pkg-temp/addressbook" />
    187         <copy file="apps/addressbook/config.txt" todir="pkg-temp/addressbook/" />
    188         <copy file="apps/addressbook/myhosts.txt" todir="pkg-temp/addressbook/" />
    189         <copy file="apps/addressbook/subscriptions.txt" todir="pkg-temp/addressbook/" />
    190184        <copy file="build/addressbook.war" todir="pkg-temp/webapps/" />
    191         -->
    192 
    193185        <copy file="installer/resources/clients.config" todir="pkg-temp/" />
    194186        <copy file="installer/resources/i2prouter" todir="pkg-temp/" />
     
    252244        <copy file="build/i2ptunnel.war" todir="pkg-temp/webapps/" />
    253245        <copy file="build/routerconsole.war" todir="pkg-temp/webapps/" />
    254        
    255         <!--
    256         <mkdir dir="pkg-temp/addressbook" />
    257246        <copy file="build/addressbook.war" todir="pkg-temp/webapps/" />
    258         -->
    259 
    260247        <copy file="history.txt" todir="pkg-temp/" />
    261248        <copy file="hosts.txt" todir="pkg-temp/" />
  • history.txt

    r70d6332 r84dc7d9  
    1 $Id: history.txt,v 1.122 2004/12/30 17:51:16 jrandom Exp $
     1$Id: history.txt,v 1.123 2004/12/31 12:18:05 jrandom Exp $
     2
     32004-12-31  ragnarok
     4    * Integrated latest addressbook changes (2.0.3) which include support for
     5      deploying as a .war file with no existing addressbook configuration.
     6    * Updated main build process to bundle the addressbook.war in the
     7      i2pinstall.jar and i2pupdate.zip.
    28
    392004-12-31  jrandom
  • router/java/src/net/i2p/router/RouterVersion.java

    r70d6332 r84dc7d9  
    1616 */
    1717public class RouterVersion {
    18     public final static String ID = "$Revision: 1.127 $ $Date: 2004/12/30 17:51:16 $";
     18    public final static String ID = "$Revision: 1.128 $ $Date: 2004/12/31 12:18:05 $";
    1919    public final static String VERSION = "0.4.2.5";
    20     public final static long BUILD = 5;
     20    public final static long BUILD = 6;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION);
Note: See TracChangeset for help on using the changeset viewer.