Changeset 49325d4


Ignore:
Timestamp:
Nov 19, 2010 10:46:27 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d23fdd6
Parents:
1a8406e (diff), 635b53c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge of '50335c064a9992f4ba8707d62d35bbbbe752d231'

and 'b93c1c7b2b01fc43af5bc07470d9997f3edba6da'

Files:
2 added
2 deleted
66 edited

Legend:

Unmodified
Added
Removed
  • apps/addressbook/java/src/net/i2p/addressbook/AddressBook.java

    r1a8406e r49325d4  
    3939 * 
    4040 */
    41 public class AddressBook {
     41class AddressBook {
    4242
    4343    private String location;
     
    8989     * Set a maximum size of the remote book to make it a little harder for a malicious book-sender.
    9090     *
     91     * Yes, the EepGet fetch() is done in this constructor.
     92     *
    9193     * @param subscription
    9294     *            A Subscription instance pointing at a remote address book.
     
    103105            subscription.setEtag(get.getETag());
    104106            subscription.setLastModified(get.getLastModified());
     107            subscription.setLastFetched(I2PAppContext.getGlobalContext().clock().now());
    105108        }
    106109        try {           
  • apps/addressbook/java/src/net/i2p/addressbook/ConfigParser.java

    r1a8406e r49325d4  
    3636import java.util.Map;
    3737
     38import net.i2p.util.SecureFile;
    3839import net.i2p.util.SecureFileOutputStream;
    3940
     
    4748 * @author Ragnarok
    4849 */
    49 public class ConfigParser {
     50class ConfigParser {
    5051
    5152    /**
     
    143144     *            A File to attempt to parse.
    144145     * @param map
    145      *            A Map to use as the default, if file fails.
     146     *            A Map containing values to use as defaults.
    146147     * @return A Map containing the key, value pairs from file, or if file
    147148     *         cannot be read, map.
     
    151152        try {
    152153            result = ConfigParser.parse(file);
     154            for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
     155                String key = (String) iter.next();
     156                if (!result.containsKey(key))
     157                    result.put(key, map.get(key));
     158            }
    153159        } catch (IOException exp) {
    154160            result = map;
     
    281287     */
    282288    public static void write(Map map, File file) throws IOException {
    283         File tmp = File.createTempFile("hoststxt-", ".tmp", file.getAbsoluteFile().getParentFile());
     289        File tmp = SecureFile.createTempFile("hoststxt-", ".tmp", file.getAbsoluteFile().getParentFile());
    284290        ConfigParser
    285291                .write(map, new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(tmp), "UTF-8")));
  • apps/addressbook/java/src/net/i2p/addressbook/Daemon.java

    r1a8406e r49325d4  
    3939 */
    4040public class Daemon {
    41     public static final String VERSION = "2.0.3";
     41    public static final String VERSION = "2.0.4";
    4242    private static final Daemon _instance = new Daemon();
    4343    private boolean _running;
     
    6767        Iterator iter = subscriptions.iterator();
    6868        while (iter.hasNext()) {
     69            // yes, the EepGet fetch() is done in next()
    6970            router.merge((AddressBook) iter.next(), false, log);
    7071        }
     
    9899        File lastModifiedFile = new File(home, (String) settings
    99100                .get("last_modified"));
     101        File lastFetchedFile = new File(home, (String) settings
     102                .get("last_fetched"));
     103        long delay;
     104        try {
     105            delay = Long.parseLong((String) settings.get("update_delay"));
     106        } catch (NumberFormatException nfe) {
     107            delay = 12;
     108        }
     109        delay *= 60 * 60 * 1000;
    100110
    101111        AddressBook master = new AddressBook(masterFile);
     
    107117       
    108118        SubscriptionList subscriptions = new SubscriptionList(subscriptionFile,
    109                 etagsFile, lastModifiedFile, defaultSubs, (String) settings
     119                etagsFile, lastModifiedFile, lastFetchedFile, delay, defaultSubs, (String) settings
    110120                .get("proxy_host"), Integer.parseInt((String) settings.get("proxy_port")));
    111121        Log log = new Log(logFile);
     
    151161        defaultSettings.put("etags", "etags");
    152162        defaultSettings.put("last_modified", "last_modified");
     163        defaultSettings.put("last_fetched", "last_fetched");
    153164        defaultSettings.put("update_delay", "12");
    154165       
     
    166177        // wait
    167178        try {
    168             Thread.sleep(5*60*1000);
     179            Thread.sleep(5*60*1000 + I2PAppContext.getGlobalContext().random().nextLong(5*60*1000));
    169180            // Static method, and redundent Thread.currentThread().sleep(5*60*1000);
    170181        } catch (InterruptedException ie) {}
  • apps/addressbook/java/src/net/i2p/addressbook/DaemonThread.java

    r1a8406e r49325d4  
    2828 *
    2929 */
    30 public class DaemonThread extends Thread {
     30class DaemonThread extends Thread {
    3131
    3232    private String[] args;
  • apps/addressbook/java/src/net/i2p/addressbook/Log.java

    r1a8406e r49325d4  
    3434 * 
    3535 */
    36 public class Log {
     36class Log {
    3737
    3838    private File file;
  • apps/addressbook/java/src/net/i2p/addressbook/Subscription.java

    r1a8406e r49325d4  
    2828 * 
    2929 */
    30 public class Subscription {
     30class Subscription {
    3131
    3232    private String location;
     
    3535
    3636    private String lastModified;
     37    private long lastFetched;
    3738
    3839    /**
     
    4849     *            the last-modified header we recieved the last time we read
    4950     *            this subscription.
     51     * @param lastFetched when the subscription was last fetched (Java time, as a String)
    5052     */
    51     public Subscription(String location, String etag, String lastModified) {
     53    public Subscription(String location, String etag, String lastModified, String lastFetched) {
    5254        this.location = location;
    5355        this.etag = etag;
    5456        this.lastModified = lastModified;
     57        if (lastFetched != null) {
     58            try {
     59                this.lastFetched = Long.parseLong(lastFetched);
     60            } catch (NumberFormatException nfe) {}
     61        }
    5562    }
    5663
     
    103110        this.lastModified = lastModified;
    104111    }
     112
     113    /** @since 0.8.2 */
     114    public long getLastFetched() {
     115        return this.lastFetched;
     116    }
     117
     118    /** @since 0.8.2 */
     119    public void setLastFetched(long t) {
     120        this.lastFetched = t;
     121    }
    105122}
  • apps/addressbook/java/src/net/i2p/addressbook/SubscriptionIterator.java

    r1a8406e r49325d4  
    2222package net.i2p.addressbook;
    2323
     24import java.util.Collections;
    2425import java.util.Iterator;
    2526import java.util.List;
     27
     28import net.i2p.I2PAppContext;
     29import net.i2p.data.DataHelper;  // debug
    2630
    2731/**
    2832 * An iterator over the subscriptions in a SubscriptionList.  Note that this iterator
    2933 * returns AddressBook objects, and not Subscription objects.
     34 * Yes, the EepGet fetch() is done in here in next().
    3035 *
    3136 * @author Ragnarok
    3237 */
    33 public class SubscriptionIterator implements Iterator {
     38class SubscriptionIterator implements Iterator {
    3439
    3540    private Iterator subIterator;
    3641    private String proxyHost;
    3742    private int proxyPort;
     43    private final long delay;
    3844
    3945    /**
     
    4248     * @param subscriptions
    4349     *            List of Subscription objects that represent address books.
     50     * @param delay the minimum delay since last fetched for the iterator to actually fetch
    4451     * @param proxyHost proxy hostname
    4552     * @param proxyPort proxt port number
    4653     */
    47     public SubscriptionIterator(List subscriptions, String proxyHost, int proxyPort) {
     54    public SubscriptionIterator(List subscriptions, long delay, String proxyHost, int proxyPort) {
    4855        this.subIterator = subscriptions.iterator();
     56        this.delay = delay;
    4957        this.proxyHost = proxyHost;
    5058        this.proxyPort = proxyPort;
     
    5967    }
    6068
    61     /* (non-Javadoc)
    62      * @see java.util.Iterator#next()
     69    /**
     70     * Yes, the EepGet fetch() is done in here in next().
     71     *
     72     * see java.util.Iterator#next()
     73     * @return an AddressBook (empty if the minimum delay has not been met)
    6374     */
    6475    public Object next() {
    6576        Subscription sub = (Subscription) this.subIterator.next();
    66         return new AddressBook(sub, this.proxyHost, this.proxyPort);
     77        if (sub.getLastFetched() + this.delay < I2PAppContext.getGlobalContext().clock().now()) {
     78            //System.err.println("Fetching addressbook from " + sub.getLocation());
     79            return new AddressBook(sub, this.proxyHost, this.proxyPort);
     80        } else {
     81            //System.err.println("Addressbook " + sub.getLocation() + " was last fetched " +
     82            //                   DataHelper.formatDuration(I2PAppContext.getGlobalContext().clock().now() - sub.getLastFetched()) +
     83            //                   " ago but the minimum delay is " +
     84            //                   DataHelper.formatDuration(this.delay));
     85            return new AddressBook(Collections.EMPTY_MAP);
     86        }
    6787    }
    6888
  • apps/addressbook/java/src/net/i2p/addressbook/SubscriptionList.java

    r1a8406e r49325d4  
    3636 * 
    3737 */
    38 public class SubscriptionList {
     38class SubscriptionList {
    3939
    4040    private List subscriptions;
     
    4343
    4444    private File lastModifiedFile;
     45    private File lastFetchedFile;
     46    private final long delay;
    4547   
    4648    private String proxyHost;
     
    6163     *            A file containg the last-modified headers used for conditional
    6264     *            GET. The file is in the format "url=leastmodified".
     65     * @param delay the minimum delay since last fetched for the iterator to actually fetch
    6366     * @param defaultSubs default subscription file
    6467     * @param proxyHost proxy hostname
     
    6669     */
    6770    public SubscriptionList(File locationsFile, File etagsFile,
    68             File lastModifiedFile, List defaultSubs, String proxyHost,
     71            File lastModifiedFile, File lastFetchedFile, long delay, List defaultSubs, String proxyHost,
    6972            int proxyPort) {
    7073        this.subscriptions = new LinkedList();
    7174        this.etagsFile = etagsFile;
    7275        this.lastModifiedFile = lastModifiedFile;
     76        this.lastFetchedFile = lastFetchedFile;
     77        this.delay = delay;
    7378        this.proxyHost = proxyHost;
    7479        this.proxyPort = proxyPort;
    7580        Map etags;
    7681        Map lastModified;
     82        Map lastFetched;
    7783        String location;
    7884        List locations = ConfigParser.parseSubscriptions(locationsFile,
     
    8894            lastModified = new HashMap();
    8995        }
     96        try {
     97            lastFetched = ConfigParser.parse(lastFetchedFile);
     98        } catch (IOException exp) {
     99            lastFetched = new HashMap();
     100        }
    90101        Iterator iter = locations.iterator();
    91102        while (iter.hasNext()) {
    92103            location = (String) iter.next();
    93             this.subscriptions.add(new Subscription(location, (String) etags
    94                     .get(location), (String) lastModified.get(location)));
     104            this.subscriptions.add(new Subscription(location, (String) etags.get(location),
     105                                   (String) lastModified.get(location),
     106                                   (String) lastFetched.get(location)));
    95107        }
    96108    }
     
    103115     */
    104116    public SubscriptionIterator iterator() {
    105         return new SubscriptionIterator(this.subscriptions, this.proxyHost,
     117        return new SubscriptionIterator(this.subscriptions, this.delay, this.proxyHost,
    106118                this.proxyPort);
    107119    }
    108120
    109121    /**
    110      * Write the etag and last-modified headers for each Subscription to files.
     122     * Write the etag and last-modified headers,
     123     * and the last-fetched time, for each Subscription to files.
     124     * BUG - If the subscription URL is a cgi containing an '=' the files
     125     * won't be read back correctly; the '=' should be escaped.
    111126     */
    112127    public void write() {
     
    115130        Map etags = new HashMap();
    116131        Map lastModified = new HashMap();
     132        Map lastFetched = new HashMap();
    117133        while (iter.hasNext()) {
    118134            sub = (Subscription) iter.next();
     
    123139                lastModified.put(sub.getLocation(), sub.getLastModified());
    124140            }
     141            lastFetched.put(sub.getLocation(), "" + sub.getLastFetched());
    125142        }
    126143        try {
    127144            ConfigParser.write(etags, this.etagsFile);
    128145            ConfigParser.write(lastModified, this.lastModifiedFile);
     146            ConfigParser.write(lastFetched, this.lastFetchedFile);
    129147        } catch (IOException exp) {
    130148        }
  • apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java

    r1a8406e r49325d4  
    2828import net.i2p.util.Log;
    2929import net.i2p.util.SecureDirectory;
     30import net.i2p.util.SecureFile;
    3031import net.i2p.util.SimpleScheduler;
    3132import net.i2p.util.SimpleTimer;
     
    245246        try {
    246247            // we could use the system tmp dir but deleteOnExit() doesn't seem to work on all platforms...
    247             out = File.createTempFile("i2psnark", null, _tmpDir);
     248            out = SecureFile.createTempFile("i2psnark", null, _tmpDir);
    248249        } catch (IOException ioe) {
    249250            ioe.printStackTrace();
  • apps/i2psnark/java/src/org/klomp/snark/Storage.java

    r1a8406e r49325d4  
    3030
    3131import net.i2p.crypto.SHA1;
     32import net.i2p.util.SecureFile;
    3233
    3334/**
     
    463464  public void check(String rootDir, long savedTime, BitField savedBitField) throws IOException
    464465  {
    465     File base = new File(rootDir, filterName(metainfo.getName()));
     466    File base = new SecureFile(rootDir, filterName(metainfo.getName()));
    466467    boolean useSavedBitField = savedTime > 0 && savedBitField != null;
    467468
     
    624625          {
    625626            // The final element (file) in the hierarchy.
    626             f = new File(base, name);
     627            f = new SecureFile(base, name);
    627628            if (!f.createNewFile() && !f.exists())
    628629              throw new IOException("Could not create file " + f);
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r1a8406e r49325d4  
    175175                  "<title>");
    176176        out.write(_("I2PSnark - Anonymous BitTorrent Client"));
     177        if ("2".equals(peerParam))
     178            out.write(" | Debug Mode");
    177179        out.write("</title>\n");
    178180                                         
     
    781783        String announce = snark.meta.getAnnounce();
    782784        if (announce.startsWith("http://YRgrgTLG") || announce.startsWith("http://8EoJZIKr") ||
    783             announce.startsWith("http://lnQ6yoBT") || announce.startsWith("http://tracker2.postman.i2p/")) {
     785            announce.startsWith("http://lnQ6yoBT") || announce.startsWith("http://tracker2.postman.i2p/") || announce.startsWith("http://ahsplxkbhemefwvvml7qovzl5a2b5xo5i7lyai7ntdunvcyfdtna.b32.i2p/")) {
    784786            Map trackers = _manager.getTrackers();
    785787            for (Iterator iter = trackers.entrySet().iterator(); iter.hasNext(); ) {
     
    788790                String baseURL = (String)entry.getValue();
    789791                if (!(baseURL.startsWith(announce) || // vvv hack for non-b64 announce in list vvv
    790                       (announce.startsWith("http://lnQ6yoBT") && baseURL.startsWith("http://tracker2.postman.i2p/"))))
     792                      (announce.startsWith("http://lnQ6yoBT") && baseURL.startsWith("http://tracker2.postman.i2p/")) ||
     793                      (announce.startsWith("http://ahsplxkbhemefwvvml7qovzl5a2b5xo5i7lyai7ntdunvcyfdtna.b32.i2p/") && baseURL.startsWith("http://tracker2.postman.i2p/"))))
    791794                    continue;
    792795                int e = baseURL.indexOf('=');
     
    15531556        else if (mime.startsWith("audio/") || mime.equals("application/ogg") ||
    15541557                 plc.endsWith(".flac") || plc.endsWith(".m4a") || plc.endsWith(".wma") ||
    1555                  plc.endsWith(".ape"))
     1558                 plc.endsWith(".ape") || plc.endsWith(".oga"))
    15561559            icon = "music";
    15571560        else if (mime.startsWith("video/") || plc.endsWith(".mkv") || plc.endsWith(".m4v") ||
    15581561                 plc.endsWith(".mp4") || plc.endsWith(".wmv") || plc.endsWith(".flv") ||
    1559                  plc.endsWith(".ogm"))
     1562                 plc.endsWith(".ogm") || plc.endsWith(".ogv"))
    15601563            icon = "film";
    15611564        else if (mime.equals("application/zip") || mime.equals("application/x-gtar") ||
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java

    r1a8406e r49325d4  
    8686    public boolean ownDest = false;
    8787
     88    /** the I2CP port */
    8889    public String port = System.getProperty(I2PClient.PROP_TCP_PORT, "7654");
     90    /** the I2CP host */
    8991    public String host = System.getProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1");
     92    /** the listen-on host. Sadly the listen-on port does not have a field. */
    9093    public String listenHost = host;
    9194
     
    690693                notifyEvent("clientTaskId", Integer.valueOf(task.getId()));
    691694            } catch (IllegalArgumentException iae) {
    692                 _log.error(getPrefix() + "Invalid I2PTunnel config to create a client [" + host + ":"+ port + "]", iae);
    693                 l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]");
     695                String msg = "Invalid I2PTunnel configuration to create an HTTP Proxy connecting to the router at " + host + ':'+ port +
     696                             " and listening on " + listenHost + ':' + port;
     697                _log.error(getPrefix() + msg, iae);
     698                l.log(msg);
    694699                notifyEvent("clientTaskId", Integer.valueOf(-1));
    695700                // Since nothing listens to TaskID events, use this to propagate the error to TunnelController
     
    764769                notifyEvent("httpclientTaskId", Integer.valueOf(task.getId()));
    765770            } catch (IllegalArgumentException iae) {
    766                 _log.error(getPrefix() + "Invalid I2PTunnel config to create an httpclient [" + host + ":"+ clientPort + "]", iae);
    767                 l.log("Invalid I2PTunnel configuration [" + host + ":" + clientPort + "]");
     771                String msg = "Invalid I2PTunnel configuration to create an HTTP Proxy connecting to the router at " + host + ':'+ port +
     772                             " and listening on " + listenHost + ':' + port;
     773                _log.error(getPrefix() + msg, iae);
     774                l.log(msg);
    768775                notifyEvent("httpclientTaskId", Integer.valueOf(-1));
    769776                // Since nothing listens to TaskID events, use this to propagate the error to TunnelController
     
    830837                addtask(task);
    831838            } catch (IllegalArgumentException iae) {
    832                 _log.error(getPrefix() + "Invalid I2PTunnel config to create a connect client [" + host + ":"+ _port + "]", iae);
     839                String msg = "Invalid I2PTunnel configuration to create a CONNECT client connecting to the router at " + host + ':'+ port +
     840                             " and listening on " + listenHost + ':' + port;
     841                _log.error(getPrefix() + msg, iae);
     842                l.log(msg);
    833843                // Since nothing listens to TaskID events, use this to propagate the error to TunnelController
    834844                // Otherwise, the tunnel stays up even though the port is down
     
    893903                notifyEvent("ircclientTaskId", Integer.valueOf(task.getId()));
    894904            } catch (IllegalArgumentException iae) {
    895                 _log.error(getPrefix() + "Invalid I2PTunnel config to create an ircclient [" + host + ":"+ _port + "]", iae);
    896                 l.log("Invalid I2PTunnel configuration [" + host + ":" + _port + "]");
     905                String msg = "Invalid I2PTunnel configuration to create an IRC client connecting to the router at " + host + ':'+ port +
     906                             " and listening on " + listenHost + ':' + port;
     907                _log.error(getPrefix() + msg, iae);
     908                l.log(msg);
    897909                notifyEvent("ircclientTaskId", Integer.valueOf(-1));
    898910                // Since nothing listens to TaskID events, use this to propagate the error to TunnelController
     
    940952
    941953            ownDest = !isShared;
    942             I2PTunnelTask task;
    943             task = new I2PSOCKSTunnel(_port, l, ownDest, (EventDispatcher) this, this, null);
    944             addtask(task);
    945             notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId()));
     954            try {
     955                I2PTunnelTask task = new I2PSOCKSTunnel(_port, l, ownDest, (EventDispatcher) this, this, null);
     956                addtask(task);
     957                notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId()));
     958            } catch (IllegalArgumentException iae) {
     959                String msg = "Invalid I2PTunnel configuration to create a SOCKS Proxy connecting to the router at " + host + ':'+ port +
     960                             " and listening on " + listenHost + ':' + port;
     961                _log.error(getPrefix() + msg, iae);
     962                l.log(msg);
     963                notifyEvent("sockstunnelTaskId", Integer.valueOf(-1));
     964                throw iae;
     965            }
    946966        } else {
    947967            l.log("sockstunnel <port>");
     
    979999            if (args.length == 3)
    9801000                privateKeyFile = args[2];
    981             I2PTunnelTask task;
    982             task = new I2PSOCKSIRCTunnel(_port, l, ownDest, (EventDispatcher) this, this, privateKeyFile);
    983             addtask(task);
    984             notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId()));
     1001            try {
     1002                I2PTunnelTask task = new I2PSOCKSIRCTunnel(_port, l, ownDest, (EventDispatcher) this, this, privateKeyFile);
     1003                addtask(task);
     1004                notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId()));
     1005            } catch (IllegalArgumentException iae) {
     1006                String msg = "Invalid I2PTunnel configuration to create a SOCKS IRC Proxy connecting to the router at " + host + ':'+ port +
     1007                             " and listening on " + listenHost + ':' + port;
     1008                _log.error(getPrefix() + msg, iae);
     1009                l.log(msg);
     1010                notifyEvent("sockstunnelTaskId", Integer.valueOf(-1));
     1011                throw iae;
     1012            }
    9851013        } else {
    9861014            l.log("socksirctunnel <port> [<sharedClient> [<privKeyFile>]]");
     
    10201048                throw new IllegalArgumentException(getPrefix() + "Bad port " + args[0]);
    10211049
    1022             StreamrConsumer task = new StreamrConsumer(_host, _port, args[2], l, (EventDispatcher) this, this);
    1023             task.startRunning();
    1024             addtask(task);
    1025             notifyEvent("streamrtunnelTaskId", Integer.valueOf(task.getId()));
     1050            try {
     1051                StreamrConsumer task = new StreamrConsumer(_host, _port, args[2], l, (EventDispatcher) this, this);
     1052                task.startRunning();
     1053                addtask(task);
     1054                notifyEvent("streamrtunnelTaskId", Integer.valueOf(task.getId()));
     1055            } catch (IllegalArgumentException iae) {
     1056                String msg = "Invalid I2PTunnel configuration to create a Streamr Client connecting to the router at " + host + ':'+ port +
     1057                             " and sending to " + _host + ':' + port;
     1058                _log.error(getPrefix() + msg, iae);
     1059                l.log(msg);
     1060                notifyEvent("streamrtunnnelTaskId", Integer.valueOf(-1));
     1061                throw iae;
     1062            }
    10261063        } else {
    10271064            l.log("streamrclient <host> <port> <destination>");
     
    14101447                I2PTunnelTask t = (I2PTunnelTask) it.next();
    14111448                int id = t.getId();
    1412                 _log.debug(getPrefix() + "closetask(): parsing task " + id + " (" + t.toString() + ")");
     1449                if (_log.shouldLog(Log.DEBUG))
     1450                    _log.debug(getPrefix() + "closetask(): parsing task " + id + " (" + t.toString() + ")");
    14131451                if (id == num) {
    14141452                    closed = closetask(t, forced, l);
     
    14281466     */
    14291467    private boolean closetask(I2PTunnelTask t, boolean forced, Logging l) {
    1430         l.log("Closing task " + t.getId() + (forced ? " forced..." : "..."));
     1468        if (_log.shouldLog(Log.INFO))
     1469            _log.info("Closing task " + t.getId() + (forced ? " forced..." : "..."));
     1470        //l.log("Closing task " + t.getId() + (forced ? " forced..." : "..."));
    14311471        if (t.close(forced)) {
    1432             l.log("Task " + t.getId() + " closed.");
     1472            if (_log.shouldLog(Log.INFO))
     1473                _log.info("Task " + t.getId() + " closed.");
     1474            //l.log("Task " + t.getId() + " closed.");
    14331475            return true;
    14341476        }
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java

    r1a8406e r49325d4  
    129129
    130130        if (open && listenerReady) {
    131             l.log("Ready! Port " + getLocalPort());
     131            l.log("Client ready, listening on " + tunnel.listenHost + ':' + localPort);
    132132            notifyEvent("openBaseClientResult", "ok");
    133133        } else {
    134             l.log("Error listening - please see the logs!");
     134            l.log("Client error for " + tunnel.listenHost + ':' + localPort + ", check logs");
    135135            notifyEvent("openBaseClientResult", "error");
    136136        }
     
    182182                verifySocketManager();
    183183                if (sockMgr == null) {
    184                     _log.log(Log.CRIT, "Unable to create socket manager (our own? " + ownDest + ")");
     184                    _log.error("Unable to connect to router and build tunnels for " + handlerName);
     185                    // FIXME there is a loop in buildSocketManager(), do we really need another one here?
     186                    // no matter, buildSocketManager() now throws an IllegalArgumentException
    185187                    try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
    186188                }
     
    213215        if (open && listenerReady) {
    214216            if (openNow)
    215                 l.log("Ready! Port " + getLocalPort());
     217                l.log("Client ready, listening on " + tunnel.listenHost + ':' + localPort);
    216218            else
    217                 l.log("Listening on port " + getLocalPort() + ", delaying tunnel open until required");
     219                l.log("Client ready, listening on " + tunnel.listenHost + ':' + localPort + ", delaying tunnel open until required");
    218220            notifyEvent("openBaseClientResult", "ok");
    219221        } else {
    220             l.log("Error listening - please see the logs!");
     222            l.log("Client error for " + tunnel.listenHost + ':' + localPort + ", check logs");
    221223            notifyEvent("openBaseClientResult", "error");
    222224        }
     
    258260     *
    259261     * We need a socket manager before getDefaultOptions() and most other things
     262     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     263     *                                  badly that we cant create a socketManager
    260264     */
    261265    protected void verifySocketManager() {
     
    290294    private static I2PSocketManager socketManager;
    291295
    292     /** this is ONLY for shared clients */
     296
     297    /**
     298     * this is ONLY for shared clients
     299     * @return non-null
     300     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     301     *                                  badly that we cant create a socketManager
     302     */
    293303    protected synchronized I2PSocketManager getSocketManager() {
    294304        return getSocketManager(getTunnel(), this.privKeyFile);
    295305    }
    296     /** this is ONLY for shared clients */
     306
     307    /**
     308     * this is ONLY for shared clients
     309     * @return non-null
     310     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     311     *                                  badly that we cant create a socketManager
     312     */
    297313    protected static synchronized I2PSocketManager getSocketManager(I2PTunnel tunnel) {
    298314        return getSocketManager(tunnel, null);
    299315    }
    300     /** this is ONLY for shared clients */
     316
     317    /**
     318     * this is ONLY for shared clients
     319     * @return non-null
     320     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     321     *                                  badly that we cant create a socketManager
     322     */
    301323    protected static synchronized I2PSocketManager getSocketManager(I2PTunnel tunnel, String pkf) {
    302324        if (socketManager != null) {
     
    320342    }
    321343
     344    /**
     345     * @return non-null
     346     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     347     *                                  badly that we cant create a socketManager
     348     */
    322349    protected I2PSocketManager buildSocketManager() {
    323         return buildSocketManager(getTunnel(), this.privKeyFile);
    324     }
     350        return buildSocketManager(getTunnel(), this.privKeyFile, this.l);
     351    }
     352    /**
     353     * @return non-null
     354     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     355     *                                  badly that we cant create a socketManager
     356     */
    325357    protected static I2PSocketManager buildSocketManager(I2PTunnel tunnel) {
    326358        return buildSocketManager(tunnel, null);
    327359    }
    328360
    329     /** @param pkf absolute path or null */
     361    private static final int RETRY_DELAY = 20*1000;
     362    private static final int MAX_RETRIES = 4;
     363
     364    /**
     365     * @param pkf absolute path or null
     366     * @return non-null
     367     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     368     *                                  badly that we cant create a socketManager
     369     */
    330370    protected static I2PSocketManager buildSocketManager(I2PTunnel tunnel, String pkf) {
     371        return buildSocketManager(tunnel, pkf, null);
     372    }
     373
     374    /**
     375     * @param pkf absolute path or null
     376     * @return non-null
     377     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     378     *                                  badly that we cant create a socketManager
     379     */
     380    protected static I2PSocketManager buildSocketManager(I2PTunnel tunnel, String pkf, Logging log) {
    331381        Properties props = new Properties();
    332382        props.putAll(tunnel.getClientOptions());
     
    341391       
    342392        I2PSocketManager sockManager = null;
     393        // Todo: Can't stop a tunnel from the UI while it's in this loop (no session yet)
     394        int retries = 0;
    343395        while (sockManager == null) {
    344396            if (pkf != null) {
     
    349401                    sockManager = I2PSocketManagerFactory.createManager(fis, tunnel.host, portNum, props);
    350402                } catch (IOException ioe) {
     403                    if (log != null)
     404                        log.log("Error opening key file " + ioe);
    351405                    _log.error("Error opening key file", ioe);
    352                     // this is going to loop but if we break we'll get a NPE
     406                    throw new IllegalArgumentException("Error opening key file " + ioe);
    353407                } finally {
    354408                    if (fis != null)
     
    360414           
    361415            if (sockManager == null) {
    362                 _log.log(Log.CRIT, "Unable to create socket manager");
    363                 try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
     416                // try to make this error sensible as it will happen... sadly we can't get to the listenPort, only the listenHost
     417                String msg = "Unable to connect to the router at " + tunnel.host + ':' + portNum +
     418                             " and build tunnels for the client";
     419                if (++retries < MAX_RETRIES) {
     420                    if (log != null)
     421                        log.log(msg + ", retrying in " + (RETRY_DELAY / 1000) + " seconds");
     422                    _log.error(msg + ", retrying in " + (RETRY_DELAY / 1000) + " seconds");
     423                } else {
     424                    if (log != null)
     425                        log.log(msg + ", giving up");
     426                    _log.log(Log.CRIT, msg + ", giving up");
     427                    // not clear if callers can handle null
     428                    //return null;
     429                    throw new IllegalArgumentException(msg);
     430                }
     431                try { Thread.sleep(RETRY_DELAY); } catch (InterruptedException ie) {}
    364432            }
    365433        }
     
    480548            }
    481549            notifyEvent("clientLocalPort", new Integer(ss.getLocalPort()));
    482             l.log("Listening for clients on port " + localPort + " of " + getTunnel().listenHost);
     550            // duplicates message in constructor
     551            //l.log("Listening for clients on port " + localPort + " of " + getTunnel().listenHost);
    483552
    484553            // Notify constructor that port is ready
     
    609678                } // else the app chaining to this one closes it!
    610679            }
    611             l.log("Closing client " + toString());
     680            l.log("Stopping client " + toString());
    612681            open = false;
    613682            try {
     
    617686                return false;
    618687            }
    619             l.log("Client closed.");
     688            //l.log("Client closed.");
    620689        }
    621690       
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java

    r1a8406e r49325d4  
    116116                               String wwwProxy, EventDispatcher notifyThis,
    117117                               I2PTunnel tunnel) throws IllegalArgumentException {
    118         super(localPort, ownDest, l, notifyThis, "HTTPHandler " + (++__clientId), tunnel);
     118        super(localPort, ownDest, l, notifyThis, "HTTPS Proxy on " + tunnel.listenHost + ':' + localPort + " #" + (++__clientId), tunnel);
    119119
    120120        if (waitEventValue("openBaseClientResult").equals("error")) {
     
    129129        }
    130130
    131         setName(getLocalPort() + " -> ConnectClient [Outproxy list: " + wwwProxy + "]");
     131        setName("HTTPS Proxy on " + tunnel.listenHost + ':' + localPort);
    132132
    133133        startRunning();
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java

    r1a8406e r49325d4  
    167167       // proxyList = new ArrayList();
    168168
    169         setName(getLocalPort() + " -> HTTPClient [NO PROXIES]");
     169        setName("HTTP Proxy on " + getTunnel().listenHost + ':' + localPort);
    170170        startRunning();
    171171
     
    179179                               String wwwProxy, EventDispatcher notifyThis,
    180180                               I2PTunnel tunnel) throws IllegalArgumentException {
    181         super(localPort, ownDest, l, notifyThis, "HTTPHandler " + (++__clientId), tunnel);
     181        super(localPort, ownDest, l, notifyThis, "HTTP Proxy on " + tunnel.listenHost + ':' + localPort + " #" + (++__clientId), tunnel);
    182182
    183183        //proxyList = new ArrayList(); // We won't use outside of i2p
     
    193193        }
    194194
    195         setName(getLocalPort() + " -> HTTPClient [WWW outproxy list: " + wwwProxy + "]");
     195        setName("HTTP Proxy on " + tunnel.listenHost + ':' + localPort);
    196196
    197197        startRunning();
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java

    r1a8406e r49325d4  
    4747              l,
    4848              notifyThis,
    49               "IRCHandler " + (++__clientId), tunnel, pkf);
     49              "IRC Client on " + tunnel.listenHost + ':' + localPort + " #" + (++__clientId), tunnel, pkf);
    5050       
    5151        StringTokenizer tok = new StringTokenizer(destinations, ", ");
     
    8181        }
    8282       
    83         setName(getLocalPort() + " -> IRCClient");
     83        setName("IRC Client on " + tunnel.listenHost + ':' + localPort);
    8484
    8585        startRunning();
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java

    r1a8406e r49325d4  
    6262    protected int localPort = DEFAULT_LOCALPORT;
    6363
     64    /**
     65     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     66     *                                  badly that we cant create a socketManager
     67     */
    6468    public I2PTunnelServer(InetAddress host, int port, String privData, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) {
    65         super(host + ":" + port + " <- " + privData, notifyThis, tunnel);
     69        super("Server at " + host + ':' + port, notifyThis, tunnel);
    6670        ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decode(privData));
    6771        SetUsePool(tunnel);
     
    6973    }
    7074
     75    /**
     76     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     77     *                                  badly that we cant create a socketManager
     78     */
    7179    public I2PTunnelServer(InetAddress host, int port, File privkey, String privkeyname, Logging l,
    7280                           EventDispatcher notifyThis, I2PTunnel tunnel) {
    73         super(host + ":" + port + " <- " + privkeyname, notifyThis, tunnel);
     81        super("Server at " + host + ':' + port, notifyThis, tunnel);
    7482        SetUsePool(tunnel);
    7583        FileInputStream fis = null;
     
    8694    }
    8795
     96    /**
     97     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     98     *                                  badly that we cant create a socketManager
     99     */
    88100    public I2PTunnelServer(InetAddress host, int port, InputStream privData, String privkeyname, Logging l,  EventDispatcher notifyThis, I2PTunnel tunnel) {
    89         super(host + ":" + port + " <- " + privkeyname, notifyThis, tunnel);
     101        super("Server at " + host + ':' + port, notifyThis, tunnel);
    90102        SetUsePool(tunnel);
    91103        init(host, port, privData, privkeyname, l);
     
    101113    }
    102114
     115    private static final int RETRY_DELAY = 20*1000;
     116    private static final int MAX_RETRIES = 4;
     117
     118    /**
     119     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     120     *                                  badly that we cant create a socketManager
     121     */
    103122    private void init(InetAddress host, int port, InputStream privData, String privkeyname, Logging l) {
    104123        this.l = l;
     
    112131                portNum = Integer.parseInt(getTunnel().port);
    113132            } catch (NumberFormatException nfe) {
    114                 _log.log(Log.CRIT, "Invalid port specified [" + getTunnel().port + "], reverting to " + portNum);
     133                _log.error("Invalid port specified [" + getTunnel().port + "], reverting to " + portNum);
    115134            }
    116135        }
     
    126145
    127146        // Todo: Can't stop a tunnel from the UI while it's in this loop (no session yet)
     147        int retries = 0;
    128148        while (sockMgr == null) {
    129149            synchronized (slock) {
     
    133153            }
    134154            if (sockMgr == null) {
    135                 _log.log(Log.CRIT, "Unable to create socket manager");
    136                 try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
     155                // try to make this error sensible as it will happen...
     156                String msg = "Unable to connect to the router at " + getTunnel().host + ':' + portNum +
     157                             " and build tunnels for the server at " + getTunnel().listenHost + ':' + port;
     158                if (++retries < MAX_RETRIES) {
     159                    this.l.log(msg + ", retrying in " + (RETRY_DELAY / 1000) + " seconds");
     160                    _log.error(msg + ", retrying in " + (RETRY_DELAY / 1000) + " seconds");
     161                } else {
     162                    this.l.log(msg + ", giving up");
     163                    _log.log(Log.CRIT, msg + ", giving up");
     164                    throw new IllegalArgumentException(msg);
     165                }
     166                try { Thread.sleep(RETRY_DELAY); } catch (InterruptedException ie) {}
    137167                privDataCopy.reset();
    138168            }
     
    141171        sockMgr.setName("Server");
    142172        getTunnel().addSession(sockMgr.getSession());
    143         l.log("Ready!");
     173        l.log("Tunnels ready for server at " + getTunnel().listenHost + ':' + port);
    144174        notifyEvent("openServerResult", "ok");
    145175        open = true;
     
    207237                return false;
    208238            }
    209             l.log("Shutting down server " + toString());
     239            l.log("Stopping tunnels for server at " + getTunnel().listenHost + ':' + this.remotePort);
    210240            try {
    211241                if (i2pss != null) i2pss.close();
     
    216246                //System.exit(1);
    217247            }
    218             l.log("Server shut down.");
     248            //l.log("Server shut down.");
    219249            open = false;
    220250            return true;
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/InternalSocketRunner.java

    r1a8406e r49325d4  
    4040        } catch (IOException ex) {
    4141            if (this.open) {
    42                 _log.error("Error listening for internal connections on " + this.port, ex);
     42                _log.error("Error listening for internal connections on port " + this.port, ex);
    4343            }
    4444            this.open = false;
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java

    r1a8406e r49325d4  
    129129            doStartTunnel();
    130130        } catch (Exception e) {
    131             _log.error("Error starting up the tunnel", e);
    132             log("Error starting up the tunnel - " + e.getMessage());
     131            _log.error("Error starting the tunnel " + getName(), e);
     132            log("Error starting the tunnel " + getName() + ": " + e.getMessage());
    133133            // if we don't acquire() then the release() in stopTunnel() won't work
    134134            acquire();
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSIRCTunnel.java

    r1a8406e r49325d4  
    3737    public I2PSOCKSIRCTunnel(int localPort, Logging l, boolean ownDest, EventDispatcher notifyThis, I2PTunnel tunnel, String pkf) {
    3838        super(localPort, l, ownDest, notifyThis, tunnel, pkf);
    39         setName(getLocalPort() + " -> SOCKSIRCTunnel");
     39        setName("SOCKS IRC Proxy on " + tunnel.listenHost + ':' + localPort);
    4040    }
    4141
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java

    r1a8406e r49325d4  
    3737    /** @param pkf private key file name or null for transient key */
    3838    public I2PSOCKSTunnel(int localPort, Logging l, boolean ownDest, EventDispatcher notifyThis, I2PTunnel tunnel, String pkf) {
    39         super(localPort, ownDest, l, notifyThis, "SOCKSHandler", tunnel, pkf);
     39        super(localPort, ownDest, l, notifyThis, "SOCKS Proxy on " + tunnel.listenHost + ':' + localPort, tunnel, pkf);
    4040
    4141        if (waitEventValue("openBaseClientResult").equals("error")) {
     
    4444        }
    4545
    46         setName(getLocalPort() + " -> SOCKSTunnel");
     46        setName("SOCKS Proxy on " + tunnel.listenHost + ':' + localPort);
    4747        parseOptions();
    4848        startRunning();
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java

    r1a8406e r49325d4  
    9191    //static final String PROP_NONCE_OLD = PROP_NONCE + '2';
    9292    /** 3 wasn't enough for some browsers. They are reloading the page for some reason - maybe HEAD? @since 0.8.1 */
    93     private static final int MAX_NONCES = 5;
     93    private static final int MAX_NONCES = 8;
    9494    /** store nonces in a static FIFO instead of in System Properties @since 0.8.1 */
    9595    private static final List<String> _nonces = new ArrayList(MAX_NONCES + 1);
     
    227227        try { Thread.sleep(1000); } catch (InterruptedException ie) {}
    228228        // and give them something to look at in any case
    229         return _("Starting tunnel...");
     229        return _("Starting tunnel") + ' ' + getTunnelName(_tunnel) + " &hellip";
    230230    }
    231231   
     
    240240        try { Thread.sleep(1000); } catch (InterruptedException ie) {}
    241241        // and give them something to look at in any case
    242         return _("Stopping tunnel...");
     242        return _("Stopping tunnel") + ' ' + getTunnelName(_tunnel) + " &hellip";
    243243    }
    244244   
  • apps/i2ptunnel/jsp/editClient.jsp

    r1a8406e r49325d4  
    3030    </div>
    3131
    32     <form method="post" action="index.jsp">
     32    <form method="post" action="list">
    3333
    3434        <div id="tunnelEditPanel" class="panel">
  • apps/i2ptunnel/jsp/editServer.jsp

    r1a8406e r49325d4  
    3030    </div>
    3131
    32     <form method="post" action="index.jsp">
     32    <form method="post" action="list">
    3333
    3434        <div id="tunnelEditPanel" class="panel">
  • apps/i2ptunnel/jsp/index.jsp

    r1a8406e r49325d4  
    4545        <div class="footer">
    4646            <div class="toolbox">
    47                 <a class="control" href="index.jsp"><%=intl._("Refresh")%></a>
     47                <a class="control" href="list"><%=intl._("Refresh")%></a>
    4848            </div>
    4949        </div>   
     
    5454        <div class="footer">
    5555            <div class="toolbox">
    56                 <a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=Stop%20all"><%=intl._("Stop All")%></a> <a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=Start%20all"><%=intl._("Start All")%></a> <a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=Restart%20all"><%=intl._("Restart All")%></a> <a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=Reload%20configuration"><%=intl._("Reload Config")%></a>
     56                <a class="control" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=Stop%20all"><%=intl._("Stop All")%></a> <a class="control" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=Start%20all"><%=intl._("Start All")%></a> <a class="control" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=Restart%20all"><%=intl._("Restart All")%></a> <a class="control" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=Reload%20configuration"><%=intl._("Reload Config")%></a>
    5757            </div>
    5858        </div>
     
    9090        <div class="nameField rowItem">
    9191            <label><%=intl._("Name")%>:</label>
    92             <span class="text"><a href="edit.jsp?tunnel=<%=curServer%>" title="Edit Server Tunnel Settings for <%=indexBean.getTunnelName(curServer)%>"><%=indexBean.getTunnelName(curServer)%></a></span>
     92            <span class="text"><a href="edit?tunnel=<%=curServer%>" title="Edit Server Tunnel Settings for <%=indexBean.getTunnelName(curServer)%>"><%=indexBean.getTunnelName(curServer)%></a></span>
    9393        </div>
    9494        <div class="previewField rowItem">
     
    126126                case IndexBean.STARTING:
    127127          %><div class="statusStarting text"><%=intl._("Starting...")%></div>   
    128             <a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curServer%>"><%=intl._("Stop")%></a>
     128            <a class="control" title="Stop this Tunnel" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curServer%>"><%=intl._("Stop")%></a>
    129129        <%
    130130                break;
    131131                case IndexBean.RUNNING:
    132132          %><div class="statusRunning text"><%=intl._("Running")%></div>   
    133             <a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curServer%>"><%=intl._("Stop")%></a>
     133            <a class="control" title="Stop this Tunnel" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curServer%>"><%=intl._("Stop")%></a>
    134134        <%
    135135                break;
    136136                case IndexBean.NOT_RUNNING:
    137137          %><div class="statusNotRunning text"><%=intl._("Stopped")%></div>   
    138             <a class="control" title="Start this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=start&amp;tunnel=<%=curServer%>"><%=intl._("Start")%></a>
     138            <a class="control" title="Start this Tunnel" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=start&amp;tunnel=<%=curServer%>"><%=intl._("Start")%></a>
    139139        <%
    140140                break;
     
    158158           
    159159        <div class="footer">
    160             <form id="addNewServerTunnelForm" action="edit.jsp">
     160            <form id="addNewServerTunnelForm" action="edit">
    161161            <div class="toolbox">
    162162                   
     
    210210        <div class="nameField rowItem">
    211211            <label><%=intl._("Name")%>:</label>
    212             <span class="text"><a href="edit.jsp?tunnel=<%=curClient%>" title="Edit Tunnel Settings for <%=indexBean.getTunnelName(curClient)%>"><%=indexBean.getTunnelName(curClient)%></a></span>
     212            <span class="text"><a href="edit?tunnel=<%=curClient%>" title="Edit Tunnel Settings for <%=indexBean.getTunnelName(curClient)%>"><%=indexBean.getTunnelName(curClient)%></a></span>
    213213        </div>
    214214        <div class="portField rowItem">
     
    230230                case IndexBean.STARTING:
    231231          %><div class="statusStarting text"><%=intl._("Starting...")%></div>
    232             <a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curClient%>"><%=intl._("Stop")%></a>
     232            <a class="control" title="Stop this Tunnel" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curClient%>"><%=intl._("Stop")%></a>
    233233        <%
    234234                break;
    235235                case IndexBean.STANDBY:
    236236          %><div class="statusStarting text"><%=intl._("Standby")%></div>
    237             <a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curClient%>"><%=intl._("Stop")%></a>
     237            <a class="control" title="Stop this Tunnel" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curClient%>"><%=intl._("Stop")%></a>
    238238        <%
    239239                break;
    240240                case IndexBean.RUNNING:
    241241          %><div class="statusRunning text"><%=intl._("Running")%></div>
    242             <a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curClient%>"><%=intl._("Stop")%></a>
     242            <a class="control" title="Stop this Tunnel" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=stop&amp;tunnel=<%=curClient%>"><%=intl._("Stop")%></a>
    243243        <%
    244244                break;
    245245                case IndexBean.NOT_RUNNING:
    246246          %><div class="statusNotRunning text"><%=intl._("Stopped")%></div>
    247             <a class="control" title="Start this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&amp;action=start&amp;tunnel=<%=curClient%>"><%=intl._("Start")%></a>
     247            <a class="control" title="Start this Tunnel" href="list?nonce=<%=indexBean.getNextNonce()%>&amp;action=start&amp;tunnel=<%=curClient%>"><%=intl._("Start")%></a>
    248248        <%
    249249                break;
     
    286286   
    287287        <div class="footer">
    288             <form id="addNewClientTunnelForm" action="edit.jsp">
     288            <form id="addNewClientTunnelForm" action="edit">
    289289                <div class="toolbox">
    290290                   
  • apps/i2ptunnel/jsp/web.xml

    r1a8406e r49325d4  
    66<web-app>
    77    <!-- precompiled servlets -->
     8
     9    <!-- yeah we could do this in a handler but this is easier -->
     10    <servlet-mapping>
     11        <servlet-name>net.i2p.i2ptunnel.jsp.index_jsp</servlet-name>
     12        <!-- this becomes the default so it also covers /index and /index.html -->
     13        <url-pattern>/</url-pattern>
     14    </servlet-mapping>
     15
     16    <servlet-mapping>
     17        <servlet-name>net.i2p.i2ptunnel.jsp.edit_jsp</servlet-name>
     18        <url-pattern>/edit</url-pattern>
     19    </servlet-mapping>
     20
    821    <session-config>
    922        <session-timeout>
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigNavHelper.java

    r1a8406e r49325d4  
    2323        StringBuilder buf = new StringBuilder(1024);
    2424        for (int i = 0; i < pages.length; i++) {
    25             String page = "config" + pages[i] + ".jsp";
    26             if (requestURI.indexOf(page) != -1) {
     25            String page = "config" + pages[i];
     26            if (requestURI.endsWith(page) || requestURI.endsWith(page + ".jsp")) {
    2727                // we are there
    2828                buf.append(_(titles[i]));
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigPeerHandler.java

    r1a8406e r49325d4  
    2121            Hash h = getHash();
    2222            if (h != null) {
    23                 _context.shitlist().shitlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer.jsp\">configpeer.jsp</a>");
     23                _context.shitlist().shitlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer\">configpeer</a>");
    2424                addFormNotice(_("Peer") + " " + _peer + " " + _("banned until restart") );
    2525                return;
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigRestartBean.java

    r1a8406e r49325d4  
    8282    /** @param s value,label,... pairs */
    8383    private static void buttons(RouterContext ctx, StringBuilder buf, String url, String nonce, String[] s) {
    84         buf.append("<form action=\"").append(url).append("\" method=\"GET\">\n");
     84        buf.append("<form action=\"").append(url).append("\" method=\"POST\">\n");
    8585        buf.append("<input type=\"hidden\" name=\"consoleNonce\" value=\"").append(nonce).append("\" >\n");
    8686        for (int i = 0; i < s.length; i+= 2)
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigUIHandler.java

    r1a8406e r49325d4  
    3030            if (!oldTheme.equals(_config))
    3131                addFormNotice(_("Theme change saved.") +
    32                               " <a href=\"configui.jsp\">" +
     32                              " <a href=\"configui\">" +
    3333                              _("Refresh the page to view.") +
    3434                              "</a>");
  • apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java

    r1a8406e r49325d4  
    128128        saveSettings();
    129129        try {
    130             _out.write("<br><h3>" + _("Configure Graph Display") + " [<a href=\"configstats.jsp\">" + _("Select Stats") + "</a>]</h3>");
    131             _out.write("<form action=\"graphs.jsp\" method=\"GET\">");
     130            _out.write("<br><h3>" + _("Configure Graph Display") + " [<a href=\"configstats\">" + _("Select Stats") + "</a>]</h3>");
     131            _out.write("<form action=\"graphs\" method=\"POST\">");
    132132            _out.write(_("Periods") + ": <input size=\"3\" type=\"text\" name=\"periodCount\" value=\"" + _periodCount + "\"><br>\n");
    133133            _out.write(_("Plot averages") + ": <input type=\"radio\" class=\"optbox\" name=\"showEvents\" value=\"false\" " + (_showEvents ? "" : "checked=\"true\" ") + "> ");
  • apps/routerconsole/java/src/net/i2p/router/web/LocaleWebAppHandler.java

    r1a8406e r49325d4  
    1414 * Convert foo.jsp to foo_xx.jsp for language xx.
    1515 * This is appropriate for jsps with large amounts of text.
    16  * This does not work for included jsps (e.g. summary*)
     16 *
     17 * Also, as of 0.8.2, rewrite "/" and "/index.html" to "/index.jsp",x
     18 * and "/foo" to "/foo.jsp".
    1719 *
    1820 * @author zzz
     
    4749        }
    4850
     51        // transparent rewriting
     52        if (pathInContext.equals("/") || pathInContext.equals("/index.html")) {
     53            // home page
     54            pathInContext = "/index.jsp";
     55        } else if (pathInContext.indexOf("/", 1) < 0 &&
     56                   !pathInContext.endsWith(".jsp")) {
     57            // add .jsp to pages at top level
     58            pathInContext += ".jsp";
     59        }
     60
    4961        //System.err.println("Path: " + pathInContext);
    5062        String newPath = pathInContext;
    51         if (pathInContext.endsWith(".jsp")) {
     63        //if (pathInContext.endsWith(".jsp")) {
     64        // We only ended up doing this for help.jsp, so save some effort
     65        // unless we translate more pages like this
     66        if (pathInContext.equals("/help.jsp")) {
    5267            int len = pathInContext.length();
    5368            // ...but leave foo_xx.jsp alone
  • apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java

    r1a8406e r49325d4  
    106106        StringBuilder buf = new StringBuilder(4*1024);
    107107        buf.append("<h2>" + _("Network Database Contents") + "</h2>\n");
    108         buf.append("<a href=\"netdb.jsp\">" + _("View RouterInfo") + "</a>");
     108        buf.append("<a href=\"netdb\">" + _("View RouterInfo") + "</a>");
    109109        buf.append("<h3>").append(_("LeaseSets")).append("</h3>\n");
    110110        Hash ourRKey;
     
    131131            buf.append("<b>").append(_("LeaseSet")).append(": ").append(key.toBase64());
    132132            if (_context.clientManager().isLocal(dest)) {
    133                 buf.append(" (<a href=\"tunnels.jsp#" + key.toBase64().substring(0,4) + "\">" + _("Local") + "</a> ");
     133                buf.append(" (<a href=\"tunnels#" + key.toBase64().substring(0,4) + "\">" + _("Local") + "</a> ");
    134134                if (! _context.clientManager().shouldPublishLeaseSet(key))
    135135                    buf.append(_("Unpublished") + ' ');
     
    213213     */
    214214    public void renderStatusHTML(Writer out, int mode) throws IOException {
    215         out.write("<h2>" + _("Network Database Contents") + " (<a href=\"netdb.jsp?l=1\">" + _("View LeaseSets") + "</a>)</h2>\n");
     215        out.write("<h2>" + _("Network Database Contents") + " (<a href=\"netdb?l=1\">" + _("View LeaseSets") + "</a>)</h2>\n");
    216216        if (!_context.netDb().isInitialized()) {
    217217            out.write(_("Not initialized"));
     
    224224        boolean showStats = full || shortStats;
    225225        Hash us = _context.routerHash();
    226         out.write("<a name=\"routers\" ></a><h3>" + _("Routers") + " (<a href=\"netdb.jsp");
     226        out.write("<a name=\"routers\" ></a><h3>" + _("Routers") + " (<a href=\"netdb");
    227227        if (full || !showStats)
    228228            out.write("?f=2#routers\" >" + _("Show all routers"));
     
    344344            buf.append("<b>" + _("Peer info for") + ":</b> ").append(hash).append("\n");
    345345            if (full) {
    346                 buf.append("[<a href=\"netdb.jsp\" >Back</a>]</th></tr><td>\n");
     346                buf.append("[<a href=\"netdb\" >Back</a>]</th></tr><td>\n");
    347347            } else {
    348                 buf.append("[<a href=\"netdb.jsp?r=").append(hash.substring(0, 6)).append("\" >").append(_("Full entry")).append("</a>]</th></tr><td>\n");
     348                buf.append("[<a href=\"netdb?r=").append(hash.substring(0, 6)).append("\" >").append(_("Full entry")).append("</a>]</th></tr><td>\n");
    349349            }
    350350        }
  • apps/routerconsole/java/src/net/i2p/router/web/NewsFetcher.java

    r1a8406e r49325d4  
    5050    /** @since 0.7.14 not configurable */
    5151    private static final String BACKUP_NEWS_URL = "http://www.i2p2.i2p/_static/news/news.xml";
     52    private static final String PROP_LAST_CHECKED = "router.newsLastChecked";
    5253   
    5354    private NewsFetcher(I2PAppContext ctx) {
     
    5556        _log = ctx.logManager().getLog(NewsFetcher.class);
    5657        _instance = this;
    57         _lastFetch = 0;
     58        try {
     59            String last = ctx.getProperty(PROP_LAST_CHECKED);
     60            if (last != null)
     61                _lastFetch = Long.parseLong(last);
     62        } catch (NumberFormatException nfe) {}
    5863        _newsFile = new File(_context.getRouterDir(), NEWS_FILE);
    5964        _tempFile = new File(_context.getTempDir(), TEMP_NEWS_FILE);
    6065        updateLastFetched();
    61         _lastUpdated = _lastFetch;
    6266        _updateVersion = "";
    6367    }
     
    6569    private void updateLastFetched() {
    6670        if (_newsFile.exists()) {
     71            if (_lastUpdated == 0)
     72                _lastUpdated = _newsFile.lastModified();
    6773            if (_lastFetch == 0)
    68                 _lastFetch = _newsFile.lastModified();
    69         } else
     74                _lastFetch = _lastUpdated;
     75            if (_lastModified == null)
     76                _lastModified = to822Date(_lastFetch);
     77        } else {
     78            _lastUpdated = 0;
    7079            _lastFetch = 0;
     80            _lastModified = null;
     81        }
    7182    }
    7283   
     
    137148            } else {
    138149                if (_log.shouldLog(Log.DEBUG))
    139                     _log.debug("Last fetched " + DataHelper.formatDuration2(_context.clock().now() - _lastFetch) + " ago");
     150                    _log.debug("Last fetched " + DataHelper.formatDuration(_context.clock().now() - _lastFetch) + " ago");
    140151                return false;
    141152            }
     
    272283        }
    273284        return -1;
     285    }
     286
     287    /** @since 0.8.2 */
     288    private static String to822Date(long t) {
     289        return (new SimpleDateFormat("d MMM yyyy HH:mm:ss z", Locale.US)).format(new Date(t));
    274290    }
    275291
     
    375391        }
    376392        _lastFetch = now;
     393        if (_context.isRouterContext()) {
     394            ((RouterContext)_context).router().setConfigSetting(PROP_LAST_CHECKED, "" + now);
     395            ((RouterContext)_context).router().saveConfig();
     396        }
    377397    }
    378398   
  • apps/routerconsole/java/src/net/i2p/router/web/ProfileOrganizerRenderer.java

    r1a8406e r49325d4  
    7575            buf.append(_("Hiding {0} older profiles.", older)).append('\n');
    7676        if (standard > 0)
    77             buf.append("<a href=\"/profiles.jsp?f=1\">").append(_("Hiding {0} standard profiles.", standard)).append("</a>\n");
     77            buf.append("<a href=\"/profiles?f=1\">").append(_("Hiding {0} standard profiles.", standard)).append("</a>\n");
    7878        buf.append("</p>");
    7979                   buf.append("<table>");
     
    174174            buf.append("<td nowrap align=\"center\"><a target=\"_blank\" href=\"dumpprofile.jsp?peer=")
    175175               .append(peer.toBase64().substring(0,6)).append("\">").append(_("profile")).append("</a>");
    176             buf.append("&nbsp;<a href=\"configpeer.jsp?peer=").append(peer.toBase64()).append("\">+-</a></td>\n");
     176            buf.append("&nbsp;<a href=\"configpeer?peer=").append(peer.toBase64()).append("\">+-</a></td>\n");
    177177            buf.append("</tr>");
    178178            // let's not build the whole page in memory (~500 bytes per peer)
  • apps/routerconsole/java/src/net/i2p/router/web/ShitlistRenderer.java

    r1a8406e r49325d4  
    6868                    buf.append(_(entry.cause));
    6969            }
    70             buf.append(" (<a href=\"configpeer.jsp?peer=").append(key.toBase64())
     70            buf.append(" (<a href=\"configpeer?peer=").append(key.toBase64())
    7171               .append("#unsh\">").append(_("unban now")).append("</a>)");
    7272            buf.append("</li>\n");
  • apps/routerconsole/java/src/net/i2p/router/web/StatsGenerator.java

    r1a8406e r49325d4  
    3131    public void generateStatsPage(Writer out, boolean showAll) throws IOException {
    3232        StringBuilder buf = new StringBuilder(16*1024);
    33         buf.append("<div class=\"joblog\"><form action=\"/stats.jsp\">");
     33        buf.append("<div class=\"joblog\"><form action=\"\">");
    3434        buf.append("<select name=\"go\" onChange='location.href=this.value'>");
    3535        out.write(buf.toString());
     
    4040            Map.Entry entry = (Map.Entry)iter.next();
    4141            String group = (String)entry.getKey();
    42             buf.append("<option value=\"/stats.jsp#").append(group).append("\">");
     42            buf.append("<option value=\"#").append(group).append("\">");
    4343            buf.append(_(group)).append("</option>\n");
    4444            // let's just do the groups
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java

    r1a8406e r49325d4  
    2929        String theme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
    3030       
    31         buf.append("<a href=\"/index.jsp\" target=\"_top\"><img src=\"")
     31        buf.append("<a href=\"/\" target=\"_top\"><img src=\"")
    3232           .append(CSSHelper.BASE_THEME_PATH)
    3333           .append(theme)
     
    3838           .append("\"></a><hr>")
    3939           
    40            .append("<h3><a href=\"/help.jsp\" target=\"_top\" title=\"")
     40           .append("<h3><a href=\"/help\" target=\"_top\" title=\"")
    4141           .append(_("I2P Router Help &amp; FAQ"))
    4242           .append("\">")
     
    5252            buf.append(linkhelper.getContent());
    5353        } else {
    54             buf.append("<h3><a href=\"/configclients.jsp\" target=\"_top\" title=\"")
     54            buf.append("<h3><a href=\"/configclients\" target=\"_top\" title=\"")
    5555               .append(_("Configure startup of clients and webapps (services); manually start dormant services"))
    5656               .append("\">")
     
    8888               .append("</td></tr></table>\n" +
    8989
    90                        "<hr><h3><a href=\"/config.jsp\" target=\"_top\" title=\"")
     90                       "<hr><h3><a href=\"/config\" target=\"_top\" title=\"")
    9191               .append(_("Configure I2P Router"))
    9292               .append("\">")
     
    9696                       "<table><tr><td>\n" +
    9797
    98                        "<a href=\"/tunnels.jsp\" target=\"_top\" title=\"")
     98                       "<a href=\"/tunnels\" target=\"_top\" title=\"")
    9999               .append(_("View existing tunnels and tunnel build status"))
    100100               .append("\">")
     
    102102               .append("</a>\n" +
    103103
    104                        "<a href=\"/peers.jsp\" target=\"_top\" title=\"")
     104                       "<a href=\"/peers\" target=\"_top\" title=\"")
    105105               .append(_("Show all current peer connections"))
    106106               .append("\">")
     
    108108               .append("</a>\n" +
    109109
    110                        "<a href=\"/profiles.jsp\" target=\"_top\" title=\"")
     110                       "<a href=\"/profiles\" target=\"_top\" title=\"")
    111111               .append(_("Show recent peer performance profiles"))
    112112               .append("\">")
     
    114114               .append("</a>\n" +
    115115
    116                        "<a href=\"/netdb.jsp\" target=\"_top\" title=\"")
     116                       "<a href=\"/netdb\" target=\"_top\" title=\"")
    117117               .append(_("Show list of all known I2P routers"))
    118118               .append("\">")
     
    120120               .append("</a>\n" +
    121121
    122                        "<a href=\"/logs.jsp\" target=\"_top\" title=\"")
     122                       "<a href=\"/logs\" target=\"_top\" title=\"")
    123123               .append(_("Health Report"))
    124124               .append("\">")
     
    132132           //  .append("</a>\n" +
    133133
    134                        "<a href=\"/graphs.jsp\" target=\"_top\" title=\"")
     134                       "<a href=\"/graphs\" target=\"_top\" title=\"")
    135135               .append(_("Graph router performance"))
    136136               .append("\">")
     
    138138               .append("</a>\n" +
    139139
    140                        "<a href=\"/stats.jsp\" target=\"_top\" title=\"")
     140                       "<a href=\"/stats\" target=\"_top\" title=\"")
    141141               .append(_("Textual router performance statistics"))
    142142               .append("\">")
     
    144144               .append("</a>\n" +
    145145
    146                         "<a href=\"/i2ptunnel/index.jsp\" target=\"_blank\" title=\"")
     146                        "<a href=\"/i2ptunnel/\" target=\"_blank\" title=\"")
    147147               .append(_("Local Destinations"))
    148148               .append("\">")
     
    157157
    158158
    159         buf.append("<hr><h3><a href=\"/help.jsp\" target=\"_top\" title=\"")
     159        buf.append("<hr><h3><a href=\"/help\" target=\"_top\" title=\"")
    160160           .append(_("I2P Router Help"))
    161161           .append("\">")
     
    174174           .append(", ")
    175175           .append(_("never reveal it to anyone"))
    176            .append("\" href=\"/netdb.jsp?r=.\" target=\"_top\">")
     176           .append("\" href=\"/netdb?r=.\" target=\"_top\">")
    177177           .append(_("show"))
    178178           .append("</a></td></tr>\n" +
     
    195195           .append("</td></tr></table>\n" +
    196196
    197                    "<hr><h4><a href=\"/config.jsp#help\" target=\"_top\" title=\"")
     197                   "<hr><h4><a href=\"/config#help\" target=\"_top\" title=\"")
    198198           .append(_("Help with configuring your firewall and router for optimal I2P performance"))
    199199           .append("\">")
     
    221221                System.setProperty("net.i2p.router.web.UpdateHandler.nonce", nonce+"");
    222222                String uri = _helper.getRequestURI();
    223                 buf.append("<p><form action=\"").append(uri).append("\" method=\"GET\">\n");
     223                buf.append("<p><form action=\"").append(uri).append("\" method=\"POST\">\n");
    224224                buf.append("<input type=\"hidden\" name=\"updateNonce\" value=\"").append(nonce).append("\" >\n");
    225225                if (_helper.updateAvailable()) {
     
    251251           .append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
    252252
    253            .append("</p><hr><h3><a href=\"/peers.jsp\" target=\"_top\" title=\"")
     253           .append("</p><hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
    254254           .append(_("Show all current peer connections"))
    255255           .append("\">")
     
    261261                   "<tr><td align=\"left\"><b>")
    262262           .append(_("Active"))
    263            .append(":</b></td><td align=\"right\">")
    264            .append(_helper.getActivePeers())
     263           .append(":</b></td><td align=\"right\">");
     264        int active = _helper.getActivePeers();
     265        buf.append(active)
    265266           .append("&thinsp;/&thinsp;")
    266            .append(_helper.getActiveProfiles())
     267           .append(Math.max(active, _helper.getActiveProfiles()))
    267268           .append("</td></tr>\n" +
    268269
     
    300301        boolean anotherLine = false;
    301302        if (_helper.showFirewallWarning()) {
    302             buf.append("<h4><a href=\"/config.jsp\" target=\"_top\" title=\"")
     303            buf.append("<h4><a href=\"/config\" target=\"_top\" title=\"")
    303304               .append(_("Help with firewall configuration"))
    304305               .append("\">")
     
    321322                System.setProperty("net.i2p.router.web.ReseedHandler.nonce", nonce+"");
    322323                String uri = _helper.getRequestURI();
    323                 buf.append("<p><form action=\"").append(uri).append("\" method=\"GET\">\n");
     324                buf.append("<p><form action=\"").append(uri).append("\" method=\"POST\">\n");
    324325                buf.append("<input type=\"hidden\" name=\"reseedNonce\" value=\"").append(nonce).append("\" >\n");
    325326                buf.append("<button type=\"submit\" value=\"Reseed\" >").append(_("Reseed")).append("</button></form></p>\n");
     
    339340
    340341
    341         buf.append("<h3><a href=\"/config.jsp\" title=\"")
     342        buf.append("<h3><a href=\"/config\" title=\"")
    342343           .append(_("Configure router bandwidth allocation"))
    343344           .append("\" target=\"_top\">")
     
    376377           .append("</td></tr></table>\n" +
    377378
    378                    "<hr><h3><a href=\"/tunnels.jsp\" target=\"_top\" title=\"")
     379                   "<hr><h3><a href=\"/tunnels\" target=\"_top\" title=\"")
    379380           .append(_("View existing tunnels and tunnel build status"))
    380381           .append("\">")
     
    407408           .append("</td></tr>\n" +
    408409
    409                    "</table><hr><h3><a href=\"/jobs.jsp\" target=\"_top\" title=\"")
     410                   "</table><hr><h3><a href=\"/jobs\" target=\"_top\" title=\"")
    410411           .append(_("What's in the router's job queue?"))
    411412           .append("\">")
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java

    r1a8406e r49325d4  
    363363       
    364364        StringBuilder buf = new StringBuilder(512);
    365         buf.append("<h3><a href=\"/i2ptunnel/index.jsp\" target=\"_blank\" title=\"").append(_("Add/remove/edit &amp; control your client and server tunnels")).append("\">").append(_("Local Destinations")).append("</a></h3><hr><div class=\"tunnels\">");
     365        buf.append("<h3><a href=\"/i2ptunnel/\" target=\"_blank\" title=\"").append(_("Add/remove/edit &amp; control your client and server tunnels")).append("\">").append(_("Local Destinations")).append("</a></h3><hr><div class=\"tunnels\">");
    366366        if (!clients.isEmpty()) {
    367367            Collections.sort(clients, new AlphaComparator());
     
    378378                else
    379379                    buf.append("client.png\" alt=\"Client\" title=\"" + _("Client") + "\">");
    380                 buf.append("</td><td align=\"left\"><b><a href=\"tunnels.jsp#").append(h.toBase64().substring(0,4));
     380                buf.append("</td><td align=\"left\"><b><a href=\"tunnels#").append(h.toBase64().substring(0,4));
    381381                buf.append("\" target=\"_top\" title=\"" + _("Show tunnels") + "\">");
    382382                if (name.length() < 16)
  • apps/routerconsole/java/src/net/i2p/router/web/TunnelRenderer.java

    r1a8406e r49325d4  
    3939   
    4040    public void renderStatusHTML(Writer out) throws IOException {
    41         out.write("<div class=\"wideload\"><h2><a name=\"exploratory\" ></a>" + _("Exploratory tunnels") + " (<a href=\"/configtunnels.jsp#exploratory\">" + _("configure") + "</a>)</h2>\n");
     41        out.write("<div class=\"wideload\"><h2><a name=\"exploratory\" ></a>" + _("Exploratory tunnels") + " (<a href=\"/configtunnels#exploratory\">" + _("configure") + "</a>)</h2>\n");
    4242        renderPool(out, _context.tunnelManager().getInboundExploratoryPool(), _context.tunnelManager().getOutboundExploratoryPool());
    4343       
     
    6161                      + "\" ></a>" + _("Client tunnels for") + ' ' + _(name));
    6262            if (_context.clientManager().isLocal(client))
    63                 out.write(" (<a href=\"/configtunnels.jsp#" + client.toBase64().substring(0,4) +"\">" + _("configure") + "</a>)</h2>\n");
     63                out.write(" (<a href=\"/configtunnels#" + client.toBase64().substring(0,4) +"\">" + _("configure") + "</a>)</h2>\n");
    6464            else
    6565                out.write(" (" + _("dead") + ")</h2>\n");
  • apps/routerconsole/jsp/config.jsp

    r1a8406e r49325d4  
    2121 <jsp:getProperty name="formhandler" property="allMessages" />
    2222<div class="configure">
    23  <form action="config.jsp" method="POST">
     23 <form action="" method="POST">
    2424 <% String prev = System.getProperty("net.i2p.router.web.ConfigNetHandler.nonce");
    2525    if (prev != null) System.setProperty("net.i2p.router.web.ConfigNetHandler.noncePrev", prev);
     
    9797 </p><p><b><%=intl._("UPnP Configuration")%>:</b><br>
    9898    <input type="checkbox" class="optbox" name="upnp" value="true" <jsp:getProperty name="nethelper" property="upnpChecked" /> >
    99     <%=intl._("Enable UPnP to open firewall ports")%> - <a href="peers.jsp#upnp"><%=intl._("UPnP status")%></a>
     99    <%=intl._("Enable UPnP to open firewall ports")%> - <a href="peers#upnp"><%=intl._("UPnP status")%></a>
    100100 </p><p><b><%=intl._("IP Configuration")%>:</b><br>
    101101 <%=intl._("Externally reachable hostname or IP address")%>:<br>
     
    197197<li class="tidylist"><%=intl._("UPnP device change, reset, or address change")%>
    198198</ul></p><p>
    199 <a href="peers.jsp#upnp"><%=intl._("Review the UPnP status here.")%></a>
     199<a href="peers#upnp"><%=intl._("Review the UPnP status here.")%></a>
    200200<%=intl._("UPnP may be enabled or disabled above, but a change requires a router restart to take effect.")%></p>
    201201<p><%=intl._("Hostnames entered above will be published in the network database.")%>
  • apps/routerconsole/jsp/configadvanced.jsp

    r1a8406e r49325d4  
    2424 <div class="configure">
    2525 <div class="wideload">
    26  <form action="configadvanced.jsp" method="POST">
     26 <form action="" method="POST">
    2727 <% String prev = System.getProperty("net.i2p.router.web.ConfigAdvancedHandler.nonce");
    2828    if (prev != null) System.setProperty("net.i2p.router.web.ConfigAdvancedHandler.noncePrev", prev);
  • apps/routerconsole/jsp/configclients.jsp

    r1a8406e r49325d4  
    2727 <jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
    2828 <jsp:getProperty name="formhandler" property="allMessages" />
    29  <div class="configure"><form action="configclients.jsp" method="POST">
     29 <div class="configure"><form action="" method="POST">
    3030 <% String prev = System.getProperty("net.i2p.router.web.ConfigClientsHandler.nonce");
    3131    if (prev != null) System.setProperty("net.i2p.router.web.ConfigClientsHandler.noncePrev", prev);
  • apps/routerconsole/jsp/configkeyring.jsp

    r1a8406e r49325d4  
    2626</p></div>
    2727
    28  <form action="configkeyring.jsp" method="POST">
     28 <form action="" method="POST">
    2929 <% String prev = System.getProperty("net.i2p.router.web.ConfigKeyringHandler.nonce");
    3030    if (prev != null) System.setProperty("net.i2p.router.web.ConfigKeyringHandler.noncePrev", prev);
     
    3333 <h3><%=intl._("Manual Keyring Addition")%></h3><p>
    3434 <%=intl._("Enter keys for encrypted remote destinations here.")%>
    35  <%=intl._("Keys for local destinations must be entered on the")%> <a href="i2ptunnel/index.jsp"><%=intl._("I2PTunnel page")%></a>.
     35 <%=intl._("Keys for local destinations must be entered on the")%> <a href="i2ptunnel/"><%=intl._("I2PTunnel page")%></a>.
    3636</p>
    3737  <div class="wideload">
  • apps/routerconsole/jsp/configlogging.jsp

    r1a8406e r49325d4  
    2020 <jsp:getProperty name="formhandler" property="allMessages" />
    2121<div class="configure">
    22  <form action="configlogging.jsp" method="POST">
     22 <form action="" method="POST">
    2323 <% String prev = System.getProperty("net.i2p.router.web.ConfigLoggingHandler.nonce");
    2424    if (prev != null) System.setProperty("net.i2p.router.web.ConfigLoggingHandler.noncePrev", prev);
  • apps/routerconsole/jsp/configpeer.jsp

    r1a8406e r49325d4  
    2828 %>
    2929 <div class="configure">
    30  <form action="configpeer.jsp" method="POST">
     30 <form action="" method="POST">
    3131 <% String prev = System.getProperty("net.i2p.router.web.ConfigPeerHandler.nonce");
    3232    if (prev != null) System.setProperty("net.i2p.router.web.ConfigPeerHandler.noncePrev", prev);
     
    5050
    5151 <h3><%=intl._("Adjust Profile Bonuses")%></h3>
    52  <p><%=intl._("Bonuses may be positive or negative, and affect the peer's inclusion in Fast and High Capacity tiers. Fast peers are used for client tunnels, and High Capacity peers are used for some exploratory tunnels. Current bonuses are displayed on the")%> <a href="profiles.jsp"><%=intl._("profiles page")%></a>.</p>
     52 <p><%=intl._("Bonuses may be positive or negative, and affect the peer's inclusion in Fast and High Capacity tiers. Fast peers are used for client tunnels, and High Capacity peers are used for some exploratory tunnels. Current bonuses are displayed on the")%> <a href="profiles"><%=intl._("profiles page")%></a>.</p>
    5353 <% long speed = 0; long capacity = 0;
    5454    if (! "".equals(peer)) {
  • apps/routerconsole/jsp/configservice.jsp

    r1a8406e r49325d4  
    1818 <jsp:getProperty name="formhandler" property="allMessages" />
    1919 <div class="configure">
    20  <form action="configservice.jsp" method="POST">
     20 <form action="" method="POST">
    2121 <% String prev = System.getProperty("net.i2p.router.web.ConfigServiceHandler.nonce");
    2222    if (prev != null) System.setProperty("net.i2p.router.web.ConfigServiceHandler.noncePrev", prev);
     
    6161
    6262 <h3><%=intl._("Debugging")%></h3>
    63  <p><a href="/jobs.jsp"><%=intl._("View the job queue")%></a>
     63 <p><a href="/jobs"><%=intl._("View the job queue")%></a>
    6464 <% if (System.getProperty("wrapper.version") != null) { %>
    6565 <p><%=intl._("At times, it may be helpful to debug I2P by getting a thread dump. To do so, please select the following option and review the thread dumped to <a href=\"logs.jsp#servicelogs\">wrapper.log</a>.")%></p>
     
    7171 <h3><%=intl._("Launch browser on router startup?")%></h3>
    7272 <p><%=intl._("I2P's main configuration interface is this web console, so for your convenience I2P can launch a web browser on startup pointing at")%>
    73  <a href="http://127.0.0.1:7657/index.jsp">http://127.0.0.1:7657/index.jsp</a> .</p>
     73 <a href="http://127.0.0.1:7657/">http://127.0.0.1:7657/</a> .</p>
    7474 <hr><div class="formaction">
    7575 <input type="submit" name="action" value="<%=intl._("View console on startup")%>" >
  • apps/routerconsole/jsp/configstats.jsp

    r1a8406e r49325d4  
    6666 <jsp:setProperty name="statshelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    6767 <div class="configure">
    68  <form id="statsForm" name="statsForm" action="configstats.jsp" method="POST">
     68 <form id="statsForm" name="statsForm" action="" method="POST">
    6969 <% String prev = System.getProperty("net.i2p.router.web.ConfigStatsHandler.nonce");
    7070    if (prev != null) System.setProperty("net.i2p.router.web.ConfigStatsHandler.noncePrev", prev);
  • apps/routerconsole/jsp/configtunnels.jsp

    r1a8406e r49325d4  
    3030 <%=intl._("Change these settings with care, and adjust them if you have problems.")%>
    3131<div class="wideload">
    32 <form action="configtunnels.jsp" method="POST">
     32<form action="" method="POST">
    3333 <% String prev = System.getProperty("net.i2p.router.web.ConfigTunnelsHandler.nonce");
    3434    if (prev != null) System.setProperty("net.i2p.router.web.ConfigTunnelsHandler.noncePrev", prev);
  • apps/routerconsole/jsp/configui.jsp

    r1a8406e r49325d4  
    2323 <jsp:getProperty name="formhandler" property="allMessages" />
    2424<div class="configure"><div class="topshimten"><h3><%=uihelper._("Router Console Theme")%></h3></div>
    25  <form action="configui.jsp" method="POST">
     25 <form action="" method="POST">
    2626 <% String prev = System.getProperty("net.i2p.router.web.ConfigUIHandler.nonce");
    2727    if (prev != null) System.setProperty("net.i2p.router.web.ConfigUIHandler.noncePrev", prev);
  • apps/routerconsole/jsp/configupdate.jsp

    r1a8406e r49325d4  
    2222<i><jsp:getProperty name="updatehelper" property="newsStatus" /></i></div>
    2323<div class="configure">
    24  <form action="configupdate.jsp" method="POST">
     24 <form action="" method="POST">
    2525 <% String prev = System.getProperty("net.i2p.router.web.ConfigUpdateHandler.nonce");
    2626    if (prev != null) System.setProperty("net.i2p.router.web.ConfigUpdateHandler.noncePrev", prev);
  • apps/routerconsole/jsp/summary.jsi

    r1a8406e r49325d4  
    2525        // since we don't have an iframe this will reload the base page, and
    2626        // the new delay will be passed to the iframe above
    27         out.print("<div class=\"refresh\"><form action=\"" + request.getRequestURI() + "\" method=\"GET\">\n");
     27        out.print("<div class=\"refresh\"><form action=\"" + request.getRequestURI() + "\" method=\"POST\">\n");
    2828        out.print("<b>");
    2929        // We have intl defined when this is included, but not when compiled standalone.
  • apps/routerconsole/jsp/summaryframe.jsp

    r1a8406e r49325d4  
    5353    // d and shutdownSoon defined above
    5454    if (!shutdownSoon) {
    55         out.print("<div class=\"refresh\"><form action=\"summaryframe.jsp\" method=\"GET\">\n");
     55        out.print("<div class=\"refresh\"><form action=\"summaryframe.jsp\" method=\"POST\">\n");
    5656        if ("0".equals(d)) {
    5757            out.print("<b>");
  • build.xml

    r1a8406e r49325d4  
    159159    </target>
    160160    <target name="javadoc">
     161        <ant dir="apps/jetty" target="ensureJettylib" />
    161162        <mkdir dir="./build" />
    162163        <mkdir dir="./build/javadoc" />
     
    582583            <arg value="EARLIER HISTORY IS AVAILABLE IN THE SOURCE PACKAGE" />
    583584        </exec>
    584         <!-- may be pointless now, people with split directories will never see this -->
     585      <!-- May be pointless now, people with split directories will never see this,
     586           and for flat installs we don't want to overwrite news more recent than the update package.
    585587        <copy file="installer/resources/news.xml" todir="pkg-temp/docs/" />
     588       -->
    586589    </target>
    587590    <target name="prepupdateSmall" depends="buildSmall, prepupdateRouter, prepthemeupdates">
  • core/java/src/net/i2p/I2PAppContext.java

    r1a8406e r49325d4  
    115115     */
    116116    public static I2PAppContext getGlobalContext() {
     117        // skip the global lock
     118        I2PAppContext rv = _globalAppContext;
     119        if (rv != null)
     120            return rv;
     121
    117122        synchronized (I2PAppContext.class) {
    118123            if (_globalAppContext == null) {
     
    120125            }
    121126        }
     127        return _globalAppContext;
     128    }
     129   
     130    /**
     131     * Pull the default context, WITHOUT creating a new one.
     132     * Use this in static methods used early in router initialization,
     133     * where creating a context messes things up.
     134     *
     135     * @return context or null
     136     * @since 0.8.2
     137     */
     138    public static I2PAppContext getCurrentContext() {
    122139        return _globalAppContext;
    123140    }
     
    258275        }
    259276        /******
     277        (new Exception("Initialized by")).printStackTrace();
    260278        System.err.println("Base directory:   " + _baseDir.getAbsolutePath());
    261279        System.err.println("Config directory: " + _configDir.getAbsolutePath());
  • core/java/src/net/i2p/I2PException.java

    r1a8406e r49325d4  
    1616 * Base class of I2P exceptions
    1717 *
     18 * This was originally used to provide chained exceptions, but
     19 * those were added to Exception in Java 1.4, so this class provides nothing
     20 * extra at the moment.
     21 *
    1822 * @author jrandom
    1923 */
    2024public class I2PException extends Exception {
    21     private Throwable _source;
    2225
    2326    public I2PException() {
    24         this(null, null);
     27        super();
    2528    }
    2629
    2730    public I2PException(String msg) {
    28         this(msg, null);
     31        super(msg);
    2932    }
    3033
    31     public I2PException(String msg, Throwable source) {
    32         super(msg);
    33         _source = source;
     34    public I2PException(String msg, Throwable cause) {
     35        super(msg, cause);
    3436    }
    3537   
    36     @Override
    37     public void printStackTrace() {
    38         if (_source != null) _source.printStackTrace();
    39         super.printStackTrace();
    40     }
    41    
    42     @Override
    43     public void printStackTrace(PrintStream ps) {
    44         if (_source != null) _source.printStackTrace(ps);
    45         super.printStackTrace(ps);
    46     }
    47 
    48     @Override
    49     public void printStackTrace(PrintWriter pw) {
    50         if (_source != null) _source.printStackTrace(pw);
    51         super.printStackTrace(pw);
     38    /** @since 0.8.2 */
     39    public I2PException(Throwable cause) {
     40        super(cause);
    5241    }
    5342}
  • core/java/src/net/i2p/client/I2PSessionImpl.java

    r1a8406e r49325d4  
    305305                if (waitcount++ > 30) {
    306306                    closeSocket();
    307                     throw new IOException("no date handshake");
     307                    throw new IOException("No handshake received from the router");
    308308                }
    309309                try {
     
    328328                    } catch (I2PSessionException ipe) {}
    329329                    closeSocket();
    330                     throw new IOException("no leaseset");
     330                    throw new IOException("No tunnels built after waiting 5 minutes... are there network problems?");
    331331                }
    332332                synchronized (_leaseSetWait) {
     
    347347            _closed = true;
    348348            setOpening(false);
    349             throw new I2PSessionException(getPrefix() + "Invalid session configuration", uhe);
     349            throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, uhe);
    350350        } catch (IOException ioe) {
    351351            _closed = true;
    352352            setOpening(false);
    353             throw new I2PSessionException(getPrefix() + "Problem connecting to " + _hostname + " on port " + _portNum, ioe);
     353            throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, ioe);
    354354        }
    355355    }
  • core/java/src/net/i2p/client/I2PSessionListener.java

    r1a8406e r49325d4  
    4040    /**
    4141     * Notify the client that some error occurred
    42      * @param null can be null? or not?
     42     * @param error can be null? or not?
    4343     */
    4444    void errorOccurred(I2PSession session, String message, Throwable error);
  • core/java/src/net/i2p/client/I2PSimpleSession.java

    r1a8406e r49325d4  
    8787        } catch (UnknownHostException uhe) {
    8888            _closed = true;
    89             throw new I2PSessionException(getPrefix() + "Bad host ", uhe);
     89            throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, uhe);
    9090        } catch (IOException ioe) {
    9191            _closed = true;
    92             throw new I2PSessionException(getPrefix() + "Problem connecting to " + _hostname + " on port " + _portNum, ioe);
     92            throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, ioe);
    9393        }
    9494    }
  • core/java/src/net/i2p/crypto/TrustedUpdate.java

    r1a8406e r49325d4  
    165165
    166166        } else {
    167             addKey(DEFAULT_TRUSTED_KEY, "jrandom@mail.i2p");
     167            //addKey(DEFAULT_TRUSTED_KEY, "jrandom@mail.i2p");
    168168            addKey(DEFAULT_TRUSTED_KEY2, "zzz@mail.i2p");
    169169            //addKey(DEFAULT_TRUSTED_KEY3, "complication@mail.i2p");
  • core/java/src/net/i2p/data/PrivateKeyFile.java

    r1a8406e r49325d4  
    8181                // Cert constructor generates a null cert
    8282                pkf.setCertType(Certificate.CERTIFICATE_TYPE_NULL);
     83                System.out.println("New destination with null cert is:");
    8384            } else if (args[0].equals("-u")) {
    8485                pkf.setCertType(99);
     86                System.out.println("New destination with unknown cert is:");
    8587            } else if (args[0].equals("-x")) {
    8688                pkf.setCertType(Certificate.CERTIFICATE_TYPE_HIDDEN);
     89                System.out.println("New destination with hidden cert is:");
    8790            } else if (args[0].equals("-h")) {
    8891                int hashEffort = HASH_EFFORT;
     
    9295                System.out.println(estimateHashCashTime(hashEffort));
    9396                pkf.setHashCashCert(hashEffort);
     97                System.out.println("New destination with hashcash cert is:");
    9498            } else if (args.length == 3 && args[0].equals("-s")) {
    9599                // Sign dest1 with dest2's Signing Private Key
    96100                PrivateKeyFile pkf2 = new PrivateKeyFile(args[2]);
    97101                pkf.setSignedCert(pkf2);
     102                System.out.println("New destination with signed cert is:");
    98103            }
    99             System.out.println("New signed destination is:");
    100104            System.out.println(pkf);
    101105            pkf.write();
     
    319323        System.arraycopy(d.getPublicKey().getData(), 0, data, 0, PublicKey.KEYSIZE_BYTES);
    320324        System.arraycopy(d.getSigningPublicKey().getData(), 0, data, PublicKey.KEYSIZE_BYTES, SigningPublicKey.KEYSIZE_BYTES);
    321         Signature sig = new Signature(d.getCertificate().getPayload());
     325        Signature sig = new Signature();
     326        byte[] payload = d.getCertificate().getPayload();
     327        Hash signerHash = null;
     328        if (payload == null) {
     329            System.out.println("Bad signed cert - no payload");
     330            return false;
     331        } else if (payload.length == Signature.SIGNATURE_BYTES) {
     332            sig.setData(payload);
     333        } else if (payload.length == Certificate.CERTIFICATE_LENGTH_SIGNED_WITH_HASH) {
     334            byte[] pl = new byte[Signature.SIGNATURE_BYTES];
     335            System.arraycopy(payload, 0, pl, 0, Signature.SIGNATURE_BYTES);
     336            sig.setData(pl);
     337            byte[] hash = new byte[Hash.HASH_LENGTH];
     338            System.arraycopy(payload, Signature.SIGNATURE_BYTES, hash, 0, Hash.HASH_LENGTH);
     339            signerHash = new Hash(hash);
     340            System.out.println("Destination is signed by " + Base32.encode(hash) + ".b32.i2p");
     341        } else {
     342            System.out.println("Bad signed cert - length = " + payload.length);
     343            return false;
     344        }
    322345     
    323346        String[] filenames = new String[] {"privatehosts.txt", "userhosts.txt", "hosts.txt"};
     347        int tried = 0;
    324348        for (int i = 0; i < filenames.length; i++) {
    325349            Properties hosts = new Properties();
     
    328352                if ( (f.exists()) && (f.canRead()) ) {
    329353                    DataHelper.loadProps(hosts, f, true);
     354                    int sz = hosts.size();
     355                    if (sz > 0) {
     356                        tried += sz;
     357                        if (signerHash == null)
     358                            System.out.println("Attempting to verify using " + sz + " hosts, this may take a while");
     359                    }
    330360                   
    331361                    for (Iterator iter = hosts.entrySet().iterator(); iter.hasNext(); )  {
     
    333363                        String s = (String) entry.getValue();
    334364                        Destination signer = new Destination(s);
    335                         if (checkSignature(sig, data, signer.getSigningPublicKey())) {
    336                             System.out.println("Good signature from: " + entry.getKey());
    337                             return true;
     365                        // make it go faster if we have the signerHash hint
     366                        if (signerHash == null || signer.calculateHash().equals(signerHash)) {
     367                            if (checkSignature(sig, data, signer.getSigningPublicKey())) {
     368                                System.out.println("Good signature from: " + entry.getKey());
     369                                return true;
     370                            }
     371                            if (signerHash != null) {
     372                                System.out.println("Bad signature from: " + entry.getKey());
     373                                // could probably return false here but keep going anyway
     374                            }
    338375                        }
    339376                    }
     
    343380            // not found, continue to the next file
    344381        }
    345         System.out.println("No valid signer found");
     382        if (tried > 0)
     383            System.out.println("No valid signer found");
     384        else
     385            System.out.println("No addressbooks found to valididate signer");
    346386        return false;
    347387    }
  • core/java/src/net/i2p/util/SecureDirectory.java

    r1a8406e r49325d4  
    66 * Same as File but sets the file mode after mkdir() so it can
    77 * be read and written by the owner only (i.e. 700 on linux)
     8 * As of 0.8.2, just use SecureFile instead of this.
    89 *
    910 * @since 0.8.1
     
    1213public class SecureDirectory extends File {
    1314
    14     private static final boolean canSetPerms =
    15         (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0;
    16     private static final boolean isNotWindows = !System.getProperty("os.name").startsWith("Win");
     15    protected static final boolean isNotWindows = !System.getProperty("os.name").startsWith("Win");
    1716
    1817    public SecureDirectory(String pathname) {
     
    5554     *  ignores errors
    5655     */
    57     private void setPerms() {
    58         if (!canSetPerms)
     56    protected void setPerms() {
     57        if (!SecureFileOutputStream.canSetPerms())
    5958            return;
    6059        try {
  • core/java/src/net/i2p/util/SecureFileOutputStream.java

    r1a8406e r49325d4  
    44import java.io.FileNotFoundException;
    55import java.io.FileOutputStream;
     6
     7import net.i2p.I2PAppContext;
    68
    79/**
     
    1416public class SecureFileOutputStream extends FileOutputStream {
    1517
    16     private static final boolean canSetPerms =
     18    private static final boolean oneDotSix =
    1719        (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0;
    1820
     
    5254    }
    5355
     56    /** @since 0.8.2 */
     57    static boolean canSetPerms() {
     58        if (!oneDotSix)
     59            return false;
     60        I2PAppContext ctx = I2PAppContext.getCurrentContext();
     61        if (ctx == null)
     62            return true;
     63        return !ctx.getBooleanProperty("i2p.insecureFiles");
     64    }
     65
    5466    /**
    5567     *  Tries to set the permissions to 600,
     
    5769     */
    5870    public static void setPerms(File f) {
    59         if (!canSetPerms)
     71        if (!canSetPerms())
    6072            return;
    6173        try {
  • installer/resources/clients.config

    r1a8406e r49325d4  
    3535clientApp.4.main=net.i2p.apps.systray.UrlLauncher
    3636clientApp.4.name=Open Router Console in web browser at startup
    37 clientApp.4.args=http://127.0.0.1:7657/index.jsp
     37clientApp.4.args=http://127.0.0.1:7657/
    3838clientApp.4.delay=3
    3939clientApp.4.startOnLoad=true
  • router/java/src/net/i2p/router/transport/TransportManager.java

    r1a8406e r49325d4  
    493493        }
    494494       
    495         if (_transports.size() > 0) {
     495        if (!_transports.isEmpty()) {
    496496            out.write(getTransportsLegend());
    497497        }
     
    517517    private final String getTransportsLegend() {
    518518        StringBuilder buf = new StringBuilder(1024);
     519        buf.append("<h3 id=\"help\">").append(_("Help")).append("</h3><div class=\"configure\"><p>")
     520           .append(_("Your transport connection limits are automatically set based on your configured bandwidth."))
     521           .append('\n')
     522           .append(_("To override these limits, add the settings i2np.ntcp.maxConnections=nnn and i2np.udp.maxConnections=nnn on the advanced configuration page."))
     523           .append("</p></div>\n");
    519524        buf.append("<h3>").append(_("Definitions")).append("</h3><div class=\"configure\">" +
    520525                   "<p><b id=\"def.peer\">").append(_("Peer")).append("</b>: ").append(_("The remote peer, identified by router hash")).append("<br>\n" +
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r1a8406e r49325d4  
    19791979            buf.append("</td>");
    19801980           
    1981             long idleIn = (now-peer.getLastReceiveTime())/1000;
    1982             long idleOut = (now-peer.getLastSendTime())/1000;
    1983             if (idleIn < 0) idleIn = 0;
    1984             if (idleOut < 0) idleOut = 0;
     1981            long idleIn = Math.max(now-peer.getLastReceiveTime(), 0);
     1982            long idleOut = Math.max(now-peer.getLastSendTime(), 0);
    19851983           
    19861984            buf.append("<td class=\"cells\" align=\"right\">");
    1987             buf.append(DataHelper.formatDuration2(1000 * idleIn));
     1985            buf.append(DataHelper.formatDuration2(idleIn));
    19881986            buf.append("&thinsp/&thinsp;");
    1989             buf.append(DataHelper.formatDuration2(1000 * idleOut));
     1987            buf.append(DataHelper.formatDuration2(idleOut));
    19901988            buf.append("</td>");
    19911989 
     
    20112009           
    20122010            buf.append("<td class=\"cells\" align=\"right\">");
    2013             buf.append(DataHelper.formatDuration2(peer.getClockSkew()));
     2011            long skew = peer.getClockSkew();
     2012            buf.append(formatDuration3(peer.getClockSkew()));
    20142013            buf.append("</td>");
    20152014            offsetTotal = offsetTotal + peer.getClockSkew();
     
    20332032           
    20342033            buf.append("<td class=\"cells\" align=\"right\">");
    2035             buf.append(rtt);
     2034            buf.append(DataHelper.formatDuration2(rtt));
    20362035            buf.append("</td>");
    20372036           
    20382037            buf.append("<td class=\"cells\" align=\"right\">");
    2039             buf.append(peer.getRTTDeviation());
     2038            buf.append(DataHelper.formatDuration2(peer.getRTTDeviation()));
    20402039            buf.append("</td>");
    20412040
    20422041            buf.append("<td class=\"cells\" align=\"right\">");
    2043             buf.append(rto);
     2042            buf.append(DataHelper.formatDuration2(rto));
    20442043            buf.append("</td>");
    20452044           
     
    21052104        buf.append("<tr class=\"tablefooter\"> <td colspan=\"3\" align=\"left\"><b>").append(_("SUMMARY")).append("</b></td>" +
    21062105                   "<td align=\"center\" nowrap><b>");
    2107         buf.append(formatKBps(bpsIn)).append("thinsp;/&thinsp;").append(formatKBps(bpsOut));
     2106        buf.append(formatKBps(bpsIn)).append("&thinsp;/&thinsp;").append(formatKBps(bpsOut));
    21082107        long x = numPeers > 0 ? uptimeMsTotal/numPeers : 0;
    21092108        buf.append("</b></td>" +
    21102109                   "<td align=\"center\"><b>").append(DataHelper.formatDuration2(x));
    21112110        x = numPeers > 0 ? offsetTotal/numPeers : 0;
    2112         buf.append("</b></td><td align=\"center\"><b>").append(DataHelper.formatDuration2(x)).append("</b></td>\n" +
     2111        buf.append("</b></td><td align=\"center\"><b>").append(formatDuration3(x)).append("</b></td>\n" +
    21132112                   "<td align=\"center\"><b>");
    21142113        buf.append(numPeers > 0 ? cwinTotal/(numPeers*1024) + "K" : "0K");
    21152114        buf.append("</b></td><td>&nbsp;</td>\n" +
    21162115                   "<td align=\"center\"><b>");
    2117         buf.append(numPeers > 0 ? rttTotal/numPeers : 0);
     2116        buf.append(numPeers > 0 ? DataHelper.formatDuration2(rttTotal/numPeers) : '0');
    21182117        buf.append("</b></td><td>&nbsp;</td> <td align=\"center\"><b>");
    2119         buf.append(numPeers > 0 ? rtoTotal/numPeers : 0);
     2118        buf.append(numPeers > 0 ? DataHelper.formatDuration2(rtoTotal/numPeers) : '0');
    21202119        buf.append("</b></td><td>&nbsp;</td> <td align=\"center\"><b>");
    21212120        buf.append(sendTotal).append("</b></td> <td align=\"center\"><b>").append(recvTotal).append("</b></td>\n" +
     
    21402139    }
    21412140   
     2141    /**
     2142     *  @return e.g. 3 sec or -3 sec
     2143     *  formatDuration2() always prints negative numbers in ms
     2144     *  @since 0.8.2
     2145     */
     2146    private static String formatDuration3(long x) {
     2147        if (x >= 0)
     2148            return DataHelper.formatDuration2(x);
     2149        return "-" + DataHelper.formatDuration2(0 - x);
     2150    }
     2151
    21422152    private static final DecimalFormat _fmt = new DecimalFormat("#,##0.00");
    21432153    private static final String formatKBps(int bps) {
Note: See TracChangeset for help on using the changeset viewer.