Changes in / [554a3a6:90cc71d]


Ignore:
Files:
33 added
62 deleted
41 edited

Legend:

Unmodified
Added
Removed
  • .tx/config

    r554a3a6 r90cc71d  
    1919trans.vi = apps/i2ptunnel/locale/messages_vi.po
    2020trans.zh_CN = apps/i2ptunnel/locale/messages_zh.po
     21
     22[I2P.proxy]
     23source_file = apps/i2ptunnel/locale-proxy/messages_en.po
     24source_lang = en
     25trans.ar = apps/i2ptunnel/locale-proxy/messages_ar.po
     26trans.cs = apps/i2ptunnel/locale-proxy/messages_cs.po
     27trans.de = apps/i2ptunnel/locale-proxy/messages_de.po
     28trans.es = apps/i2ptunnel/locale-proxy/messages_es.po
     29trans.fr = apps/i2ptunnel/locale-proxy/messages_fr.po
     30trans.hu = apps/i2ptunnel/locale-proxy/messages_hu.po
     31trans.it = apps/i2ptunnel/locale-proxy/messages_it.po
     32trans.nb = apps/i2ptunnel/locale-proxy/messages_nb.po
     33trans.nl = apps/i2ptunnel/locale-proxy/messages_nl.po
     34trans.pl = apps/i2ptunnel/locale-proxy/messages_pl.po
     35trans.pt = apps/i2ptunnel/locale-proxy/messages_pt.po
     36trans.ru_RU = apps/i2ptunnel/locale-proxy/messages_ru.po
     37trans.sv_SE = apps/i2ptunnel/locale-proxy/messages_sv.po
     38trans.uk_UA = apps/i2ptunnel/locale-proxy/messages_uk.po
     39trans.vi = apps/i2ptunnel/locale-proxy/messages_vi.po
     40trans.zh_CN = apps/i2ptunnel/locale-proxy/messages_zh.po
    2141
    2242[I2P.routerconsole]
     
    4464trans.vi = apps/routerconsole/locale/messages_vi.po
    4565trans.zh_CN = apps/routerconsole/locale/messages_zh.po
     66
     67[I2P.welcome]
     68source_file = apps/routerconsole/locale-news/messages_en.po
     69source_lang = en
     70trans.ar = apps/routerconsole/locale-news/messages_ar.po
     71trans.de = apps/routerconsole/locale-news/messages_de.po
     72trans.es = apps/routerconsole/locale-news/messages_es.po
     73trans.fr = apps/routerconsole/locale-news/messages_fr.po
     74trans.nl = apps/routerconsole/locale-news/messages_nl.po
     75trans.pt = apps/routerconsole/locale-news/messages_pt.po
     76trans.ru_RU = apps/routerconsole/locale-news/messages_ru.po
     77trans.sv_SE = apps/routerconsole/locale-news/messages_sv.po
    4678
    4779[I2P.i2psnark]
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r554a3a6 r90cc71d  
    15431543                if (isValid) {
    15441544                    pct = (float) (100.0 * peer.completed() / meta.getPieces());
    1545                     if (pct == 100.0)
     1545                    if (pct >= 100.0)
    15461546                        out.write(_("Seed"));
    15471547                    else {
  • apps/i2ptunnel/java/build.xml

    r554a3a6 r90cc71d  
    5757
    5858    <!-- The web classes are now in the war not the jar - they are not part of the API -->
    59     <target name="jar" depends="builddep, compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
     59    <target name="jar" depends="builddep, compile, bundle-proxy, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
    6060        <!-- set if unset -->
    6161        <property name="workspace.changes.j.tr" value="" />
     
    8888    </target>
    8989
     90    <!-- servlet translations go in the war, not the jar -->
    9091    <target name="bundle" depends="compile, precompilejsp" unless="no.bundle">
    9192        <!-- Update the messages_*.po files.
     
    115116        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
    116117            <arg value="./bundle-messages.sh" />
     118            <arg value="-p" />
     119        </exec>
     120    </target>
     121
     122    <!-- proxy error page translations go in the jar, not the war -->
     123    <target name="bundle-proxy" unless="no.bundle">
     124        <!-- Update the messages_*.po files.
     125             We need to supply the bat file for windows, and then change the fail property to true -->
     126        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
     127            <arg value="./bundle-messages-proxy.sh" />
     128        </exec>
     129        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
     130            <arg value="./bundle-messages-proxy.sh" />
     131        </exec>
     132                <!-- multi-lang is optional -->
     133        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
     134            <arg value="./bundle-messages-proxy.sh" />
     135        </exec>
     136    </target>
     137
     138    <target name="extractProxyTags">
     139        <java classname="net.i2p.util.TranslateReader" fork="true" failonerror="true">
     140            <classpath>
     141                <pathelement location="../../../build/i2p.jar" />
     142            </classpath>
     143            <arg value="tag" />
     144            <arg value="../../../installer/resources/proxy/" />
     145            <arg value="build/Proxy.java" />
     146        </java>
     147    </target>
     148
     149    <target name="poupdate-proxy" depends="extractProxyTags">
     150        <!-- Update the messages_*.po files. -->
     151        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
     152            <arg value="./bundle-messages-proxy.sh" />
     153            <arg value="-p" />
     154        </exec>
     155        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
     156            <arg value="./bundle-messages-proxy.sh" />
     157            <arg value="-p" />
     158        </exec>
     159        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
     160            <arg value="./bundle-messages-proxy.sh" />
    117161            <arg value="-p" />
    118162        </exec>
  • apps/i2ptunnel/java/bundle-messages.sh

    r554a3a6 r90cc71d  
    3030
    3131# add ../java/ so the refs will work in the po file
    32 JPATHS="../java/src ../jsp/WEB-INF"
     32JPATHS="../java/src/net/i2p/i2ptunnel/web ../jsp/WEB-INF"
    3333for i in ../locale/messages_*.po
    3434do
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java

    r554a3a6 r90cc71d  
    14101410    }
    14111411     ****/
    1412     /** */
    1413     private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.web.messages";
     1412
     1413    /** these strings go in the jar, not the war */
     1414    private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.proxy.messages";
    14141415
    14151416    /** lang in routerconsole.lang property, else current locale */
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java

    r554a3a6 r90cc71d  
    44package net.i2p.i2ptunnel;
    55
    6 import java.io.ByteArrayOutputStream;
    76import java.io.FileInputStream;
    87import java.io.IOException;
     8import java.io.Reader;
    99import java.io.UnsupportedEncodingException;
    1010import java.net.Socket;
     
    2828import net.i2p.util.Log;
    2929import net.i2p.util.PasswordManager;
     30import net.i2p.util.TranslateReader;
    3031
    3132/**
     
    497498    protected static byte[] getErrorPage(I2PAppContext ctx, String base, byte[] backup) {
    498499        File errorDir = new File(ctx.getBaseDir(), "docs");
    499         String lang = ctx.getProperty("routerconsole.lang", Locale.getDefault().getLanguage());
    500         if(lang != null && lang.length() > 0 && !lang.equals("en")) {
    501             File file = new File(errorDir, base + "-header_" + lang + ".ht");
    502             try {
    503                 return readFile(file);
    504             } catch(IOException ioe) {
    505                 // try the english version now
    506             }
    507         }
    508500        File file = new File(errorDir, base + "-header.ht");
    509501        try {
    510             return readFile(file);
     502            return readFile(ctx, file);
    511503        } catch(IOException ioe) {
    512504            return backup;
     
    514506    }
    515507
     508    private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.proxy.messages";
     509
    516510    /**
    517511     *  @since 0.9.4 moved from I2PTunnelHTTPClient
    518512     */
    519     private static byte[] readFile(File file) throws IOException {
    520         FileInputStream fis = null;
    521         byte[] buf = new byte[2048];
    522         ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
     513    private static byte[] readFile(I2PAppContext ctx, File file) throws IOException {
     514        Reader reader = null;
     515        char[] buf = new char[512];
     516        StringBuilder out = new StringBuilder(2048);
    523517        try {
    524             int len = 0;
    525             fis = new FileInputStream(file);
    526             while((len = fis.read(buf)) > 0) {
    527                 baos.write(buf, 0, len);
     518            int len;
     519            reader = new TranslateReader(ctx, BUNDLE_NAME, new FileInputStream(file));
     520            while((len = reader.read(buf)) > 0) {
     521                out.append(buf, 0, len);
    528522            }
    529             return baos.toByteArray();
     523            return out.toString().getBytes("UTF-8");
    530524        } finally {
    531525            try {
    532                 if(fis != null) {
    533                     fis.close();
    534                 }
    535             } catch(IOException foo) {
    536             }
     526                if(reader != null)
     527                    reader.close();
     528            } catch(IOException foo) {}
    537529        }
    538530        // we won't ever get here
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java

    r554a3a6 r90cc71d  
    2626import net.i2p.I2PAppContext;
    2727import net.i2p.I2PException;
     28import net.i2p.client.I2PSessionException;
    2829import net.i2p.client.streaming.I2PServerSocket;
    2930import net.i2p.client.streaming.I2PSocket;
     
    3839
    3940    protected final Log _log;
    40     protected I2PSocketManager sockMgr;
     41    protected final I2PSocketManager sockMgr;
    4142    protected I2PServerSocket i2pss;
    4243
     
    4445    protected final Object slock = new Object();
    4546
    46     protected InetAddress remoteHost;
    47     protected int remotePort;
    48     private boolean _usePool;
    49 
    50     protected Logging l;
     47    protected final InetAddress remoteHost;
     48    protected final int remotePort;
     49    private final boolean _usePool;
     50    protected final Logging l;
    5151
    5252    private static final long DEFAULT_READ_TIMEOUT = 5*60*1000;
     
    5757    private static final String PROP_USE_POOL = "i2ptunnel.usePool";
    5858    private static final boolean DEFAULT_USE_POOL = true;
     59    /** apparently unused */
    5960    protected static volatile long __serverId = 0;
    6061    /** max number of threads  - this many slowlorisses will DOS this server, but too high could OOM the JVM */
     
    6667    private static final long HANDLER_KEEPALIVE_MS = 30*1000;
    6768
    68     protected I2PTunnelTask task = null;
    69     protected boolean bidir = false;
     69    protected I2PTunnelTask task;
     70    protected boolean bidir;
    7071    private ThreadPoolExecutor _executor;
    7172
     
    7576
    7677    /**
    77      * Warning, blocks in constructor while connecting to router and building tunnels;
    78      * TODO move that to startRunning()
     78     *  Non-blocking
    7979     *
    8080     * @param privData Base64-encoded private key data,
     
    8787        _log = tunnel.getContext().logManager().getLog(getClass());
    8888        ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decode(privData));
    89         init(host, port, bais, privData, l);
    90     }
    91 
    92     /**
    93      * Warning, blocks in constructor while connecting to router and building tunnels;
    94      * TODO move that to startRunning()
     89        this.l = l;
     90        this.remoteHost = host;
     91        this.remotePort = port;
     92        _usePool = getUsePool();
     93        sockMgr = createManager(bais);
     94    }
     95
     96    /**
     97     *  Non-blocking
    9598     *
    9699     * @param privkey file containing the private key data,
    97100     *                format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
    98      * @param privkeyname the name of the privKey file, not clear why we need this too
     101     * @param privkeyname the name of the privKey file, just for logging
    99102     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
    100103     *                                  badly that we cant create a socketManager
     
    104107        super("Server at " + host + ':' + port, notifyThis, tunnel);
    105108        _log = tunnel.getContext().logManager().getLog(getClass());
     109        this.l = l;
     110        this.remoteHost = host;
     111        this.remotePort = port;
     112        _usePool = getUsePool();
    106113        FileInputStream fis = null;
    107114        try {
    108115            fis = new FileInputStream(privkey);
    109             init(host, port, fis, privkeyname, l);
     116            sockMgr = createManager(fis);
    110117        } catch (IOException ioe) {
    111             _log.error("Error starting server", ioe);
     118            _log.error("Cannot read private key data for " + privkeyname, ioe);
    112119            notifyEvent("openServerResult", "error");
     120            throw new IllegalArgumentException("Error starting server", ioe);
    113121        } finally {
    114122            if (fis != null)
     
    118126
    119127    /**
    120      * Warning, blocks in constructor while connecting to router and building tunnels;
    121      * TODO move that to startRunning()
     128     *  Non-blocking
    122129     *
    123130     * @param privData stream containing the private key data,
    124131     *                 format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
    125      * @param privkeyname the name of the privKey file, not clear why we need this too
     132     * @param privkeyname the name of the privKey file, just for logging
    126133     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
    127134     *                                  badly that we cant create a socketManager
     
    130137        super("Server at " + host + ':' + port, notifyThis, tunnel);
    131138        _log = tunnel.getContext().logManager().getLog(getClass());
    132         init(host, port, privData, privkeyname, l);
     139        this.l = l;
     140        this.remoteHost = host;
     141        this.remotePort = port;
     142        _usePool = getUsePool();
     143        sockMgr = createManager(privData);
    133144    }
    134145
     
    146157        this.remotePort = port;
    147158        _log = tunnel.getContext().logManager().getLog(getClass());
     159        _usePool = false;
    148160        sockMgr = sktMgr;
    149161        open = true;
    150162    }
    151163
     164    /** @since 0.9.8 */
     165    private boolean getUsePool() {
     166        // extending classes default to threaded, but for a standard server, we can't get slowlorissed
     167        boolean rv = !getClass().equals(I2PTunnelServer.class);
     168        if (rv) {
     169            String usePool = getTunnel().getClientOptions().getProperty(PROP_USE_POOL);
     170            if (usePool != null)
     171                rv = Boolean.parseBoolean(usePool);
     172            else
     173                rv = DEFAULT_USE_POOL;
     174        }
     175        return rv;
     176    }
     177
    152178    private static final int RETRY_DELAY = 20*1000;
    153179    private static final int MAX_RETRIES = 4;
    154180
    155181    /**
    156      * Warning, blocks while connecting to router and building tunnels;
    157      * TODO move that to startRunning()
    158      *
    159      * @param privData stream containing the private key data,
    160      *                 format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
    161      * @param privkeyname the name of the privKey file, not clear why we need this too
    162      * @throws IllegalArgumentException if the I2CP configuration is b0rked so
    163      *                                  badly that we cant create a socketManager
    164      */
    165     private void init(InetAddress host, int port, InputStream privData, String privkeyname, Logging l) {
    166         this.l = l;
    167         this.remoteHost = host;
    168         this.remotePort = port;
     182     *
     183     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     184     *                                  badly that we cant create a socketManager
     185     * @since 0.9.8
     186     */
     187    private I2PSocketManager createManager(InputStream privData) {
    169188        Properties props = new Properties();
    170189        props.putAll(getTunnel().getClientOptions());
     
    177196            }
    178197        }
    179 
    180         // copy the privData to a new BAIS, so we can always reset() it if we have to retry
    181         ByteArrayInputStream privDataCopy;
    182198        try {
    183             privDataCopy = copyOfInputStream(privData);
    184         } catch (IOException ioe) {
    185             _log.log(Log.CRIT, "Cannot read private key data for " + privkeyname, ioe);
    186             return;
    187         }
    188 
    189         // extending classes default to threaded, but for a standard server, we can't get slowlorissed
    190         _usePool = !getClass().equals(I2PTunnelServer.class);
    191         if (_usePool) {
    192             String usePool = getTunnel().getClientOptions().getProperty(PROP_USE_POOL);
    193             if (usePool != null)
    194                 _usePool = Boolean.parseBoolean(usePool);
    195             else
    196                 _usePool = DEFAULT_USE_POOL;
    197         }
    198 
    199         // Todo: Can't stop a tunnel from the UI while it's in this loop (no session yet)
     199            I2PSocketManager rv = I2PSocketManagerFactory.createDisconnectedManager(privData, getTunnel().host,
     200                                                                                    portNum, props);
     201            rv.setName("Server");
     202            getTunnel().addSession(rv.getSession());
     203            return rv;
     204        } catch (I2PSessionException ise) {
     205            throw new IllegalArgumentException("Can't create socket manager", ise);
     206        } finally {
     207            try { privData.close(); } catch (IOException ioe) {}
     208        }
     209    }
     210
     211
     212    /**
     213     * Warning, blocks while connecting to router and building tunnels;
     214     *
     215     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     216     *                                  badly that we cant create a socketManager
     217     * @since 0.9.8
     218     */
     219    private void connectManager() {
    200220        int retries = 0;
    201         while (sockMgr == null) {
    202             synchronized (slock) {
    203                 sockMgr = I2PSocketManagerFactory.createManager(privDataCopy, getTunnel().host, portNum,
    204                                                                 props);
    205 
    206             }
    207             if (sockMgr == null) {
     221        while (sockMgr.getSession().isClosed()) {
     222            try {
     223                sockMgr.getSession().connect();
     224            } catch (I2PSessionException ise) {
    208225                // try to make this error sensible as it will happen...
     226                String portNum = getTunnel().port;
     227                if (portNum == null)
     228                    portNum = "7654";
    209229                String msg = "Unable to connect to the router at " + getTunnel().host + ':' + portNum +
    210                              " and build tunnels for the server at " + host.getHostAddress() + ':' + port;
     230                             " and build tunnels for the server at " + remoteHost.getHostAddress() + ':' + remotePort;
    211231                if (++retries < MAX_RETRIES) {
    212                     this.l.log(msg + ", retrying in " + (RETRY_DELAY / 1000) + " seconds");
    213                     _log.error(msg + ", retrying in " + (RETRY_DELAY / 1000) + " seconds");
     232                    msg += ", retrying in " + (RETRY_DELAY / 1000) + " seconds";
     233                    this.l.log(msg);
     234                    _log.error(msg);
    214235                } else {
    215                     this.l.log(msg + ", giving up");
    216                     _log.log(Log.CRIT, msg + ", giving up");
    217                     throw new IllegalArgumentException(msg);
     236                    msg += ", giving up";
     237                    this.l.log(msg);
     238                    _log.log(Log.CRIT, msg, ise);
     239                    throw new IllegalArgumentException(msg, ise);
    218240                }
    219241                try { Thread.sleep(RETRY_DELAY); } catch (InterruptedException ie) {}
    220                 privDataCopy.reset();
    221             }
    222         }
    223 
    224         sockMgr.setName("Server");
    225         getTunnel().addSession(sockMgr.getSession());
    226         l.log("Tunnels ready for server at " + host.getHostAddress() + ':' + port);
     242            }
     243        }
     244
     245        l.log("Tunnels ready for server at " + remoteHost.getHostAddress() + ':' + remotePort);
    227246        notifyEvent("openServerResult", "ok");
    228247        open = true;
     
    250269    /**
    251270     * Start running the I2PTunnelServer.
    252      *
    253      * TODO: Wait to connect to router until here.
    254      */
    255     public void startRunning() {
     271     * Warning, blocks while connecting to router and building tunnels;
     272     *
     273     * @throws IllegalArgumentException if the I2CP configuration is b0rked so
     274     *                                  badly that we cant create a socketManager
     275     */
     276    public synchronized void startRunning() {
     277        connectManager();
    256278        // prevent JVM exit when running outside the router
    257279        boolean isDaemon = getTunnel().getContext().isRouterContext();
     
    406428    /** just to set the name and set Daemon */
    407429    private static class CustomThreadFactory implements ThreadFactory {
    408         private String _name;
     430        private final String _name;
    409431
    410432        public CustomThreadFactory(String name) {
     
    426448     */
    427449    private class Handler implements Runnable {
    428         private I2PSocket _i2ps;
     450        private final I2PSocket _i2ps;
    429451
    430452        public Handler(I2PSocket socket) {
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java

    r554a3a6 r90cc71d  
    234234    }
    235235
    236     private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.web.messages";
     236    /** these strings go in the jar, not the war */
     237    private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.proxy.messages";
    237238
    238239    /** lang in routerconsole.lang property, else current locale */
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java

    r554a3a6 r90cc71d  
    2727
    2828    public static final String PROP_MANAGER = "i2p.streaming.manager";
    29     //public static final String DEFAULT_MANAGER = "net.i2p.client.streaming.I2PSocketManagerImpl";
    3029    public static final String DEFAULT_MANAGER = "net.i2p.client.streaming.I2PSocketManagerFull";
    3130   
     
    4847     * Blocks for a long time while the router builds tunnels.
    4948     *
    50      * @param opts I2CP options
     49     * @param opts Streaming and I2CP options, may be null
    5150     * @return the newly created socket manager, or null if there were errors
    5251     */
     
    6160     * Blocks for a long time while the router builds tunnels.
    6261     *
    63      * @param host I2CP host
    64      * @param port I2CP port
     62     * @param host I2CP host null to use default
     63     * @param port I2CP port <= 0 to use default
    6564     * @return the newly created socket manager, or null if there were errors
    6665     */
     
    7574     * Blocks for a long time while the router builds tunnels.
    7675     *
    77      * @param i2cpHost I2CP host
    78      * @param i2cpPort I2CP port
    79      * @param opts I2CP options
     76     * @param i2cpHost I2CP host null to use default
     77     * @param i2cpPort I2CP port <= 0 to use default
     78     * @param opts Streaming and I2CP options, may be null
    8079     * @return the newly created socket manager, or null if there were errors
    8180     */
     
    103102     *
    104103     * @param myPrivateKeyStream private key stream, format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
     104     *                           or null for a transient destination. Caller must close.
    105105     * @return the newly created socket manager, or null if there were errors
    106106     */
     
    116116     *
    117117     * @param myPrivateKeyStream private key stream, format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
    118      * @param opts I2CP options
     118     *                           or null for a transient destination. Caller must close.
     119     * @param opts Streaming and I2CP options, may be null
    119120     * @return the newly created socket manager, or null if there were errors
    120121     */
     
    131132     *
    132133     * @param myPrivateKeyStream private key stream, format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
    133      * @param i2cpHost I2CP host
    134      * @param i2cpPort I2CP port
    135      * @param opts I2CP options
     134     *                           or null for a transient destination. Caller must close.
     135     * @param i2cpHost I2CP host null to use default
     136     * @param i2cpPort I2CP port <= 0 to use default
     137     * @param opts Streaming and I2CP options, may be null
    136138     * @return the newly created socket manager, or null if there were errors
    137139     */
    138140    public static I2PSocketManager createManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort,
    139141                                                 Properties opts) {
     142        try {
     143            return createManager(myPrivateKeyStream, i2cpHost, i2cpPort, opts, true);
     144        } catch (I2PSessionException ise) {
     145            getLog().error("Error creating session for socket manager", ise);
     146            return null;
     147        }
     148    }
     149   
     150    /**
     151     * Create a disconnected socket manager using the destination loaded from the given private key
     152     * stream, or null for a transient destination.
     153     *
     154     * Non-blocking. Does not connect to the router or build tunnels.
     155     * For servers, caller MUST call getSession().connect() to build tunnels and start listening.
     156     * For clients, caller may do that to build tunnels in advance;
     157     * otherwise, the first call to connect() will initiate a connection to the router,
     158     * with significant delay for tunnel building.
     159     *
     160     * @param myPrivateKeyStream private key stream, format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
     161     *                           or null for a transient destination. Caller must close.
     162     * @param i2cpHost I2CP host null to use default
     163     * @param i2cpPort I2CP port <= 0 to use default
     164     * @param opts Streaming and I2CP options, may be null
     165     * @return the newly created socket manager, non-null (throws on error)
     166     * @since 0.9.8
     167     */
     168    public static I2PSocketManager createDisconnectedManager(InputStream myPrivateKeyStream, String i2cpHost,
     169                                                             int i2cpPort, Properties opts) throws I2PSessionException {
     170        if (myPrivateKeyStream == null) {
     171            I2PClient client = I2PClientFactory.createClient();
     172            ByteArrayOutputStream keyStream = new ByteArrayOutputStream(512);
     173            try {
     174                client.createDestination(keyStream);
     175            } catch (Exception e) {
     176                throw new I2PSessionException("Error creating keys", e);
     177            }
     178            myPrivateKeyStream = new ByteArrayInputStream(keyStream.toByteArray());
     179        }
     180        return createManager(myPrivateKeyStream, i2cpHost, i2cpPort, opts, false);
     181    }
     182   
     183    /**
     184     * Create a socket manager using the destination loaded from the given private key
     185     * stream and connected to the I2CP router on the specified machine on the given
     186     * port.
     187     *
     188     * Blocks for a long time while the router builds tunnels if connect is true.
     189     *
     190     * @param myPrivateKeyStream private key stream, format is specified in {@link net.i2p.data.PrivateKeyFile PrivateKeyFile}
     191     *                           non-null. Caller must close.
     192     * @param i2cpHost I2CP host null to use default
     193     * @param i2cpPort I2CP port <= 0 to use default
     194     * @param opts Streaming and I2CP options, may be null
     195     * @param connect true to connect (blocking)
     196     * @return the newly created socket manager, non-null (throws on error)
     197     * @since 0.9.7
     198     */
     199    private static I2PSocketManager createManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort,
     200                                                 Properties opts, boolean connect) throws I2PSessionException {
    140201        I2PClient client = I2PClientFactory.createClient();
    141202        if (opts == null)
     
    147208                opts.setProperty(name, (String) e.getValue());
    148209        }
    149         //boolean oldLib = DEFAULT_MANAGER.equals(opts.getProperty(PROP_MANAGER, DEFAULT_MANAGER));
    150         //if (oldLib && false) {
    151             // for the old streaming lib
    152         //    opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_GUARANTEED);
    153             //opts.setProperty("tunnels.depthInbound", "0");
    154         //} else {
    155             // for new streaming lib:
    156             //opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_BEST_EFFORT);
    157             // as of 0.8.1 (I2CP default is BestEffort)
    158             if (!opts.containsKey(I2PClient.PROP_RELIABILITY))
    159                 opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_NONE);
    160             //p.setProperty("tunnels.depthInbound", "0");
    161         //}
     210        // as of 0.8.1 (I2CP default is BestEffort)
     211        if (!opts.containsKey(I2PClient.PROP_RELIABILITY))
     212            opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_NONE);
    162213
    163214        if (i2cpHost != null)
     
    166217            opts.setProperty(I2PClient.PROP_TCP_PORT, "" + i2cpPort);
    167218       
    168         try {
    169             I2PSession session = client.createSession(myPrivateKeyStream, opts);
     219        I2PSession session = client.createSession(myPrivateKeyStream, opts);
     220        if (connect)
    170221            session.connect();
    171             I2PSocketManager sockMgr = createManager(session, opts, "manager");
    172             return sockMgr;
    173         } catch (I2PSessionException ise) {
    174             getLog().error("Error creating session for socket manager", ise);
    175             return null;
    176         }
     222        I2PSocketManager sockMgr = createManager(session, opts, "manager");
     223        return sockMgr;
    177224    }
    178225
  • apps/routerconsole/java/build.xml

    r554a3a6 r90cc71d  
    9898    </target>
    9999
    100     <target name="jar1" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
     100    <target name="jar1" depends="compile, bundle-news, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
    101101        <!-- set if unset -->
    102102        <property name="workspace.changes.j.tr" value="" />
     
    135135    </target>
    136136
    137 
    138137    <target name="jarUpToDate">
    139138        <uptodate property="jar.uptodate" targetfile="build/routerconsole.jar" >
     
    163162        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
    164163            <arg value="./bundle-messages.sh" />
     164            <arg value="-p" />
     165        </exec>
     166    </target>
     167
     168    <target name="bundle-news" unless="no.bundle">
     169        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
     170            <arg value="./bundle-messages-news.sh" />
     171        </exec>
     172        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
     173            <arg value="./bundle-messages-news.sh" />
     174        </exec>
     175        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
     176            <arg value="./bundle-messages-news.sh" />
     177        </exec>
     178    </target>
     179
     180    <target name="extractProxyTags">
     181        <java classname="net.i2p.util.TranslateReader" fork="true" failonerror="true">
     182            <classpath>
     183                <pathelement location="../../../build/i2p.jar" />
     184            </classpath>
     185            <arg value="tag" />
     186            <arg value="../../../installer/resources/initialNews/initialNews.xml" />
     187            <arg value="build/News.java" />
     188        </java>
     189    </target>
     190
     191    <target name="poupdate-news" depends="extractProxyTags">
     192        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
     193            <arg value="./bundle-messages-news.sh" />
     194            <arg value="-p" />
     195        </exec>
     196        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
     197            <arg value="./bundle-messages-news.sh" />
     198            <arg value="-p" />
     199        </exec>
     200        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
     201            <arg value="./bundle-messages-news.sh" />
    165202            <arg value="-p" />
    166203        </exec>
  • apps/routerconsole/java/src/net/i2p/router/web/NewsHelper.java

    r554a3a6 r90cc71d  
    22
    33import java.io.File;
     4import java.io.FileInputStream;
     5import java.io.IOException;
     6import java.io.Reader;
    47import java.text.SimpleDateFormat;
    58import java.util.Date;
     
    912import net.i2p.router.update.ConsoleUpdateManager;
    1013import static net.i2p.update.UpdateType.*;
     14import net.i2p.util.TranslateReader;
    1115
    1216/**
     
    139143    }
    140144
     145    private static final String BUNDLE_NAME = "net.i2p.router.news.messages";
     146
     147    /**
     148     *  If we haven't downloaded news yet, use the translated initial news file
     149     */
    141150    @Override
    142151    public String getContent() {
    143152        File news = new File(_page);
    144         if (!news.exists())
     153        if (!news.exists()) {
    145154            _page = (new File(_context.getBaseDir(), "docs/initialNews/initialNews.xml")).getAbsolutePath();
     155            // don't use super, translate on-the-fly
     156            Reader reader = null;
     157            try {
     158                char[] buf = new char[512];
     159                StringBuilder out = new StringBuilder(2048);
     160                reader = new TranslateReader(_context, BUNDLE_NAME, new FileInputStream(_page));
     161                int len;
     162                while((len = reader.read(buf)) > 0) {
     163                    out.append(buf, 0, len);
     164                }
     165                return out.toString();
     166            } catch (IOException ioe) {
     167                return "";
     168            } finally {
     169                try {
     170                    if (reader != null)
     171                        reader.close();
     172                } catch (IOException foo) {}
     173            }
     174        }
    146175        return super.getContent();
    147176    }
  • apps/streaming/java/src/net/i2p/client/streaming/Packet.java

    r554a3a6 r90cc71d  
    6262 * packet that should not be ACKed</p>
    6363 *
     64 * NOTE: All setters unsynchronized.
     65 *
    6466 */
    6567class Packet {
     
    210212     * if FLAG_NO_ACK is set.
    211213     *
    212      * @return The highest packet sequence number received on receiveStreamId
     214     * @return The highest packet sequence number received on receiveStreamId, or -1 if FLAG_NO_ACK
    213215     */
    214216    public long getAckThrough() {
     
    218220            return _ackThrough;
    219221    }
     222
     223    /**
     224     * @param id if < 0, sets FLAG_NO_ACK
     225     */
    220226    public void setAckThrough(long id) {
    221227        if (id < 0)
     
    673679    }
    674680   
    675         @Override
     681    @Override
    676682    public String toString() {
    677683        StringBuilder str = formatAsString();
     
    690696        buf.append(' ');
    691697        buf.append(toFlagString());
    692         buf.append(" ACK ").append(getAckThrough());
     698        if (isFlagSet(FLAG_NO_ACK))
     699            buf.append(" NO_ACK ");
     700        else
     701            buf.append(" ACK ").append(getAckThrough());
    693702        if (_nacks != null) {
    694703            buf.append(" NACK");
  • build.xml

    r554a3a6 r90cc71d  
    433433        <echo message="Setting environment variable LG2 to a lang code (eg: de,zh,nl etc)" />
    434434        <echo message=" will restrict language update to the language you specified, leaving other language untact." />
    435         <ant dir="apps/routerconsole/java/" target="poupdate" />
     435        <ant dir="apps/routerconsole/java/" >
     436            <target name="poupdate" />
     437            <target name="poupdate-news" />
     438        </ant>
    436439        <ant dir="apps/i2psnark/java/" target="poupdate" />
    437         <ant dir="apps/i2ptunnel/java/" target="poupdate" />
     440        <ant dir="apps/i2ptunnel/java/" >
     441            <target name="poupdate" />
     442            <target name="poupdate-proxy" />
     443        </ant>
    438444        <ant dir="apps/susidns/src/" target="poupdate" />
    439445        <ant dir="apps/susimail/" target="poupdate" />
  • core/java/src/net/i2p/client/I2PSessionImpl.java

    r554a3a6 r90cc71d  
    8181    /** writer message queue */
    8282    protected ClientWriterRunner _writer;
    83     /** where we pipe our messages */
    84     protected /* FIXME final FIXME */OutputStream _out;
    8583
    8684    /**
    8785     *  Used for internal connections to the router.
    88      *  If this is set, _socket, _writer, and _out will be null.
     86     *  If this is set, _socket and _writer will be null.
    8987     *  @since 0.8.3
    9088     */
     
    9593
    9694    /** class that generates new messages */
    97     protected I2CPMessageProducer _producer;
     95    protected final I2CPMessageProducer _producer;
    9896    /** map of Long --> MessagePayloadMessage */
    9997    protected Map<Long, MessagePayloadMessage> _availableMessages;
     
    104102    protected volatile int[] _bwLimits;
    105103   
    106     protected I2PClientMessageHandlerMap _handlerMap;
     104    protected final I2PClientMessageHandlerMap _handlerMap;
    107105   
    108106    /** used to seperate things out so we can get rid of singletons */
     
    112110    private final Object _leaseSetWait = new Object();
    113111
    114     /** whether the session connection has already been closed (or not yet opened) */
    115     protected volatile boolean _closed;
    116 
    117     /** whether the session connection is in the process of being closed */
    118     protected volatile boolean _closing;
     112    /**
     113     *  @since 0.9.8
     114     */
     115    protected enum State {
     116        OPENING,
     117        OPEN,
     118        CLOSING,
     119        CLOSED
     120    }
     121
     122    private State _state = State.CLOSED;
     123    protected final Object _stateLock = new Object();
    119124
    120125    /** have we received the current date from the router yet? */
     
    123128    private final Object _dateReceivedLock = new Object();
    124129
    125     /** whether the session connection is in the process of being opened */
    126     protected volatile boolean _opening;
    127 
    128     /** monitor for waiting until opened */
    129     private final Object _openingWait = new Object();
    130130    /**
    131131     * thread that we tell when new messages are available who then tells us
     
    169169
    170170    private static final int BUF_SIZE = 32*1024;
    171    
     171
    172172    /**
    173173     * for extension by SimpleSession (no dest)
    174174     */
    175     protected I2PSessionImpl(I2PAppContext context, Properties options) {
    176         this(context, options, false);
     175    protected I2PSessionImpl(I2PAppContext context, Properties options,
     176                             I2PClientMessageHandlerMap handlerMap) {
     177        this(context, options, handlerMap, false);
    177178    }
    178179   
     
    181182     * @since 0.9.7
    182183     */
    183     private I2PSessionImpl(I2PAppContext context, Properties options, boolean hasDest) {
     184    private I2PSessionImpl(I2PAppContext context, Properties options,
     185                           I2PClientMessageHandlerMap handlerMap, boolean hasDest) {
    184186        _context = context;
     187        _handlerMap = handlerMap;
    185188        _log = context.logManager().getLog(getClass());
    186         _closed = true;
    187189        if (options == null)
    188190            options = (Properties) System.getProperties().clone();
     
    192194        _fastReceive = Boolean.parseBoolean(_options.getProperty(I2PClient.PROP_FAST_RECEIVE));
    193195        if (hasDest) {
     196            _producer = new I2CPMessageProducer(context);
     197            _availableMessages = new ConcurrentHashMap();
    194198            _myDestination = new Destination();
    195199            _privateKey = new PrivateKey();
    196200            _signingPrivateKey = new SigningPrivateKey();
    197201        } else {
     202            _producer = null;
     203            _availableMessages = null;
    198204            _myDestination = null;
    199205            _privateKey = null;
     
    212218     */
    213219    public I2PSessionImpl(I2PAppContext context, InputStream destKeyStream, Properties options) throws I2PSessionException {
    214         this(context, options, true);
    215         _handlerMap = new I2PClientMessageHandlerMap(context);
    216         _producer = new I2CPMessageProducer(context);
     220        this(context, options, new I2PClientMessageHandlerMap(context), true);
    217221        _availabilityNotifier = new AvailabilityNotifier();
    218         _availableMessages = new ConcurrentHashMap();
    219222        try {
    220223            readDestination(destKeyStream);
     
    352355    }
    353356
    354     void setOpening(boolean ls) {
    355         _opening = ls;
    356         synchronized (_openingWait) {
    357             _openingWait.notifyAll();
    358         }
    359     }
    360 
    361     boolean getOpening() {
    362         return _opening;
     357    protected void changeState(State state) {
     358        synchronized (_stateLock) {
     359            _state = state;
     360            _stateLock.notifyAll();
     361        }
    363362    }
    364363
     
    379378     * a session is granted.
    380379     *
     380     * Should be threadsafe, other threads will block until complete.
     381     * Disconnect / destroy from another thread may be called simultaneously and
     382     * will (should?) interrupt the connect.
     383     *
    381384     * @throws I2PSessionException if there is a configuration error or the router is
    382385     *                             not reachable
    383386     */
    384387    public void connect() throws I2PSessionException {
    385         setOpening(true);
    386         _closed = false;
     388        synchronized(_stateLock) {
     389            boolean wasOpening = false;
     390            boolean loop = true;
     391            while (loop) {
     392                switch (_state) {
     393                    case CLOSED:
     394                        if (wasOpening)
     395                            throw new I2PSessionException("connect by other thread failed");
     396                        loop = false;
     397                        break;
     398                    case OPENING:
     399                        wasOpening = true;
     400                        try {
     401                            _stateLock.wait(10*1000);
     402                        } catch (InterruptedException ie) {
     403                            throw new I2PSessionException("Interrupted", ie);
     404                        }
     405                        break;
     406                    case CLOSING:
     407                        throw new I2PSessionException("close in progress");
     408                    case OPEN:
     409                        return;
     410                }
     411            }
     412            changeState(State.OPENING);
     413        }
     414
    387415        _availabilityNotifier.stopNotifying();
    388416       
     
    393421        }
    394422           
     423        boolean success = false;
    395424        long startConnect = _context.clock().now();
    396425        try {
    397             // If we are in the router JVM, connect using the interal queue
    398             if (_context.isRouterContext()) {
    399                 // _socket, _out, and _writer remain null
    400                 InternalClientManager mgr = _context.internalClientManager();
    401                 if (mgr == null)
    402                     throw new I2PSessionException("Router is not ready for connections");
    403                 // the following may throw an I2PSessionException
    404                 _queue = mgr.connect();
    405                 _reader = new QueuedI2CPMessageReader(_queue, this);
    406             } else {
    407                 if (Boolean.parseBoolean(_options.getProperty(PROP_ENABLE_SSL)))
    408                     _socket = I2CPSSLSocketFactory.createSocket(_context, _hostname, _portNum);
    409                 else
    410                     _socket = new Socket(_hostname, _portNum);
    411                 // _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
    412                 _out = _socket.getOutputStream();
    413                 _out.write(I2PClient.PROTOCOL_BYTE);
    414                 _out.flush();
    415                 _writer = new ClientWriterRunner(_out, this);
    416                 InputStream in = new BufferedInputStream(_socket.getInputStream(), BUF_SIZE);
    417                 _reader = new I2CPMessageReader(in, this);
    418             }
    419             Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getPrefix(), true);
    420             notifier.start();
     426            // protect w/ closeSocket()
     427            synchronized(_stateLock) {
     428                // If we are in the router JVM, connect using the interal queue
     429                if (_context.isRouterContext()) {
     430                    // _socket and _writer remain null
     431                    InternalClientManager mgr = _context.internalClientManager();
     432                    if (mgr == null)
     433                        throw new I2PSessionException("Router is not ready for connections");
     434                    // the following may throw an I2PSessionException
     435                    _queue = mgr.connect();
     436                    _reader = new QueuedI2CPMessageReader(_queue, this);
     437                } else {
     438                    if (Boolean.parseBoolean(_options.getProperty(PROP_ENABLE_SSL)))
     439                        _socket = I2CPSSLSocketFactory.createSocket(_context, _hostname, _portNum);
     440                    else
     441                        _socket = new Socket(_hostname, _portNum);
     442                    // _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
     443                    OutputStream out = _socket.getOutputStream();
     444                    out.write(I2PClient.PROTOCOL_BYTE);
     445                    out.flush();
     446                    _writer = new ClientWriterRunner(out, this);
     447                    InputStream in = new BufferedInputStream(_socket.getInputStream(), BUF_SIZE);
     448                    _reader = new I2CPMessageReader(in, this);
     449                }
     450            }
    421451            if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "before startReading");
    422452            _reader.startReading();
     
    427457            while (!_dateReceived) {
    428458                if (waitcount++ > 30) {
    429                     closeSocket();
    430459                    throw new IOException("No handshake received from the router");
    431460                }
    432                 try {
    433                     synchronized (_dateReceivedLock) {
    434                         _dateReceivedLock.wait(1000);
    435                     }
    436                 } catch (InterruptedException ie) { // nop
     461                synchronized (_dateReceivedLock) {
     462                    // InterruptedException caught below
     463                    _dateReceivedLock.wait(1000);
    437464                }
    438465            }
     
    441468            if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Before producer.connect()");
    442469            _producer.connect(this);
    443             if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After  producer.connect()");
     470            if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After producer.connect()");
    444471
    445472            // wait until we have created a lease set
     
    447474            while (_leaseSet == null) {
    448475                if (waitcount++ > 5*60) {
     476                    throw new IOException("No tunnels built after waiting 5 minutes. Your network connection may be down, or there is severe network congestion.");
     477                }
     478                synchronized (_leaseSetWait) {
     479                    // InterruptedException caught below
     480                    _leaseSetWait.wait(1000);
     481                }
     482            }
     483            if (_log.shouldLog(Log.INFO)) {
     484                long connected = _context.clock().now();
     485                 _log.info(getPrefix() + "Lease set created with inbound tunnels after "
     486                           + (connected - startConnect)
     487                           + "ms - ready to participate in the network!");
     488            }
     489            Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getPrefix(), true);
     490            notifier.start();
     491            startIdleMonitor();
     492            startVerifyUsage();
     493            success = true;
     494        } catch (InterruptedException ie) {
     495            throw new I2PSessionException("Interrupted", ie);
     496        } catch (UnknownHostException uhe) {
     497            throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, uhe);
     498        } catch (IOException ioe) {
     499            throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, ioe);
     500        } finally {
     501            if (success) {
     502                changeState(State.OPEN);
     503            } else {
     504                _availabilityNotifier.stopNotifying();
     505                synchronized(_stateLock) {
     506                    changeState(State.CLOSING);
    449507                    try {
    450508                        _producer.disconnect(this);
    451509                    } catch (I2PSessionException ipe) {}
    452510                    closeSocket();
    453                     throw new IOException("No tunnels built after waiting 5 minutes. Your network connection may be down, or there is severe network congestion.");
    454                 }
    455                 synchronized (_leaseSetWait) {
    456                     try {
    457                         _leaseSetWait.wait(1000);
    458                     } catch (InterruptedException ie) { // nop
    459                     }
    460                 }
    461             }
    462             long connected = _context.clock().now();
    463             if (_log.shouldLog(Log.INFO))
    464                  _log.info(getPrefix() + "Lease set created with inbound tunnels after "
    465                            + (connected - startConnect)
    466                            + "ms - ready to participate in the network!");
    467             startIdleMonitor();
    468             startVerifyUsage();
    469              setOpening(false);
    470         } catch (UnknownHostException uhe) {
    471             _closed = true;
    472             setOpening(false);
    473             throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, uhe);
    474         } catch (IOException ioe) {
    475             _closed = true;
    476             setOpening(false);
    477             throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, ioe);
     511                }
     512            }
    478513        }
    479514    }
     
    571606     */
    572607    protected class AvailabilityNotifier implements Runnable {
    573         private final List _pendingIds;
    574         private final List _pendingSizes;
     608        private final List<Long> _pendingIds;
     609        private final List<Integer> _pendingSizes;
    575610        private volatile boolean _alive;
    576611 
     
    607642                    }
    608643                    if (!_pendingIds.isEmpty()) {
    609                         msgId = (Long)_pendingIds.remove(0);
    610                         size = (Integer)_pendingSizes.remove(0);
     644                        msgId = _pendingIds.remove(0);
     645                        size = _pendingSizes.remove(0);
    611646                    }
    612647                }
     
    696731    public void setSessionListener(I2PSessionListener lsnr) { _sessionListener = lsnr; }
    697732
    698     /** has the session been closed (or not yet connected)? */
    699     public boolean isClosed() { return _closed; }
     733    /**
     734     *  Has the session been closed (or not yet connected)?
     735     *  False when open and during transitions. Unsynchronized.
     736     */
     737    public boolean isClosed() {
     738        synchronized (_stateLock) {
     739            return _state == State.CLOSED;
     740        }
     741    }
    700742
    701743    /**
     
    714756                    throw new I2PSessionException("Timed out waiting while write queue was full");
    715757            } catch (InterruptedException ie) {
    716                 throw new I2PSessionException("Interrupted while write queue was full", ie);
     758                throw new I2PSessionException("Interrupted", ie);
    717759            }
    718760        } else if (_writer == null) {
     
    757799     * Tear down the session, and do NOT reconnect.
    758800     *
    759      * Blocks if session has not been fully started.
     801     * Will interrupt an open in progress.
    760802     */
    761803    public void destroySession(boolean sendDisconnect) {
    762         while (_opening) {
    763             synchronized (_openingWait) {
    764                 try {
    765                     _openingWait.wait(1000);
    766                 } catch (InterruptedException ie) { // nop
    767                 }
    768             }
    769         }
    770         if (_closed) return;
     804        synchronized(_stateLock) {
     805            if (_state == State.CLOSING || _state == State.CLOSED)
     806                return;
     807            changeState(State.CLOSING);
     808        }
    771809       
    772810        if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Destroy the session", new Exception("DestroySession()"));
    773         _closing = true;   // we use this to prevent a race
    774811        if (sendDisconnect && _producer != null) {    // only null if overridden by I2PSimpleSession
    775812            try {
     
    784821        if (_availabilityNotifier != null)
    785822            _availabilityNotifier.stopNotifying();
    786         _closed = true;
    787         _closing = false;
    788823        closeSocket();
    789824        if (_sessionListener != null) _sessionListener.disconnected(this);
     
    791826
    792827    /**
    793      * Close the socket carefully
    794      *
     828     * Close the socket carefully.
    795829     */
    796830    private void closeSocket() {
     831        synchronized(_stateLock) {
     832            changeState(State.CLOSING);
     833            locked_closeSocket();
     834            changeState(State.CLOSED);
     835        }
     836    }
     837
     838    /**
     839     * Close the socket carefully.
     840     * Caller must change state.
     841     */
     842    private void locked_closeSocket() {
    797843        if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Closing the socket", new Exception("closeSocket"));
    798         _closed = true;
    799844        if (_reader != null) {
    800845            _reader.stopReading();
     
    831876    }
    832877
     878    /**
     879     * Will interrupt a connect in progress.
     880     */
    833881    protected void disconnect() {
    834         if (_closed || _closing) return;
     882        synchronized(_stateLock) {
     883            if (_state == State.CLOSING || _state == State.CLOSED)
     884                return;
     885            changeState(State.CLOSING);
     886        }
    835887        if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Disconnect() called", new Exception("Disconnect"));
    836888        if (shouldReconnect()) {
     
    843895
    844896        if (_log.shouldLog(Log.ERROR))
    845             _log.error(getPrefix() + "Disconned from the router, and not trying to reconnect further.  I hope you're not hoping anything else will happen");
     897            _log.error(getPrefix() + "Disconned from the router, and not trying to reconnect");
    846898        if (_sessionListener != null) _sessionListener.disconnected(this);
    847899
    848         _closed = true;
    849900        closeSocket();
     901        changeState(State.CLOSED);
    850902    }
    851903
     
    866918            if ( (delay > MAX_RECONNECT_DELAY) || (delay <= 0) )
    867919                delay = MAX_RECONNECT_DELAY;
    868             try { Thread.sleep(delay); } catch (InterruptedException ie) {}
     920            try {
     921                Thread.sleep(delay);
     922            } catch (InterruptedException ie) {
     923                return false;
     924            }
    869925           
    870926            try {
     
    9711027                return rv;
    9721028        }
    973         if (_closed)
     1029        if (isClosed())
    9741030            return null;
    9751031        LookupWaiter waiter = new LookupWaiter(h);
     
    9811037                    waiter.wait(maxWait);
    9821038                }
    983             } catch (InterruptedException ie) {}
     1039            } catch (InterruptedException ie) {
     1040                throw new I2PSessionException("Interrupted", ie);
     1041            }
    9841042        } finally {
    9851043            _pendingLookups.remove(waiter);
     
    9971055     */
    9981056    public int[] bandwidthLimits() throws I2PSessionException {
    999         if (_closed)
     1057        if (isClosed())
    10001058            return null;
    10011059        sendMessage(new GetBandwidthLimitsMessage());
     
    10041062                _bwReceivedLock.wait(5*1000);
    10051063            }
    1006         } catch (InterruptedException ie) {}
     1064        } catch (InterruptedException ie) {
     1065            throw new I2PSessionException("Interrupted", ie);
     1066        }
    10071067        return _bwLimits;
    10081068    }
  • core/java/src/net/i2p/client/I2PSessionImpl2.java

    r554a3a6 r90cc71d  
    4545    protected boolean _noEffort;
    4646
    47     /** for extension */
    48     protected I2PSessionImpl2(I2PAppContext context, Properties options) {
    49         super(context, options);
     47     /**
     48      * for extension by SimpleSession (no dest)
     49      */
     50    protected I2PSessionImpl2(I2PAppContext context, Properties options,
     51                              I2PClientMessageHandlerMap handlerMap) {
     52        super(context, options, handlerMap);
    5053    }
    5154
  • core/java/src/net/i2p/client/I2PSimpleSession.java

    r554a3a6 r90cc71d  
    99import java.io.IOException;
    1010import java.io.InputStream;
     11import java.io.OutputStream;
    1112import java.net.Socket;
    1213import java.net.UnknownHostException;
     
    3839     */
    3940    public I2PSimpleSession(I2PAppContext context, Properties options) throws I2PSessionException {
    40         super(context, options);
    41         _handlerMap = new SimpleMessageHandlerMap(context);
     41        super(context, options, new SimpleMessageHandlerMap(context));
    4242    }
    4343
     
    4646     * a session is granted.
    4747     *
     48     * NOT threadsafe, do not call from multiple threads.
     49     *
    4850     * @throws I2PSessionException if there is a configuration error or the router is
    4951     *                             not reachable
     
    5153    @Override
    5254    public void connect() throws I2PSessionException {
    53         _closed = false;
    54        
     55        changeState(State.OPENING);
     56        boolean success = false;
    5557        try {
    56             // If we are in the router JVM, connect using the interal queue
    57             if (_context.isRouterContext()) {
    58                 // _socket, _out, and _writer remain null
    59                 InternalClientManager mgr = _context.internalClientManager();
    60                 if (mgr == null)
    61                     throw new I2PSessionException("Router is not ready for connections");
    62                 // the following may throw an I2PSessionException
    63                 _queue = mgr.connect();
    64                 _reader = new QueuedI2CPMessageReader(_queue, this);
    65             } else {
    66                 if (Boolean.parseBoolean(getOptions().getProperty(PROP_ENABLE_SSL)))
    67                     _socket = I2CPSSLSocketFactory.createSocket(_context, _hostname, _portNum);
    68                 else
    69                     _socket = new Socket(_hostname, _portNum);
    70                 _out = _socket.getOutputStream();
    71                 _out.write(I2PClient.PROTOCOL_BYTE);
    72                 _out.flush();
    73                 _writer = new ClientWriterRunner(_out, this);
    74                 InputStream in = new BufferedInputStream(_socket.getInputStream(), BUF_SIZE);
    75                 _reader = new I2CPMessageReader(in, this);
     58            // protect w/ closeSocket()
     59            synchronized(_stateLock) {
     60                // If we are in the router JVM, connect using the interal queue
     61                if (_context.isRouterContext()) {
     62                    // _socket and _writer remain null
     63                    InternalClientManager mgr = _context.internalClientManager();
     64                    if (mgr == null)
     65                        throw new I2PSessionException("Router is not ready for connections");
     66                    // the following may throw an I2PSessionException
     67                    _queue = mgr.connect();
     68                    _reader = new QueuedI2CPMessageReader(_queue, this);
     69                } else {
     70                    if (Boolean.parseBoolean(getOptions().getProperty(PROP_ENABLE_SSL)))
     71                        _socket = I2CPSSLSocketFactory.createSocket(_context, _hostname, _portNum);
     72                    else
     73                        _socket = new Socket(_hostname, _portNum);
     74                    OutputStream out = _socket.getOutputStream();
     75                    out.write(I2PClient.PROTOCOL_BYTE);
     76                    out.flush();
     77                    _writer = new ClientWriterRunner(out, this);
     78                    InputStream in = new BufferedInputStream(_socket.getInputStream(), BUF_SIZE);
     79                    _reader = new I2CPMessageReader(in, this);
     80                }
    7681            }
    7782            // we do not receive payload messages, so we do not need an AvailabilityNotifier
    7883            // ... or an Idle timer, or a VerifyUsage
    7984            _reader.startReading();
    80 
     85            success = true;
    8186        } catch (UnknownHostException uhe) {
    82             _closed = true;
    8387            throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, uhe);
    8488        } catch (IOException ioe) {
    85             _closed = true;
    8689            throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, ioe);
     90        } finally {
     91            changeState(success ? State.OPEN : State.CLOSED);
    8792        }
    8893    }
  • core/java/src/net/i2p/util/Translate.java

    r554a3a6 r90cc71d  
    22
    33import java.text.MessageFormat;
     4import java.util.Arrays;
    45import java.util.Locale;
    56import java.util.Map;
     
    6566     */
    6667    public static String getString(String s, Object o, I2PAppContext ctx, String bun) {
     68        return getString(s, ctx, bun, o);
     69    }
     70
     71    /** for {0} and {1} */
     72    public static String getString(String s, Object o, Object o2, I2PAppContext ctx, String bun) {
     73        return getString(s, ctx, bun, o, o2);
     74    }
     75
     76    /**
     77     *  Varargs
     78     *  @param oArray parameters
     79     *  @since 0.9.8
     80     */
     81    public static String getString(String s, I2PAppContext ctx, String bun, Object... oArray) {
    6782        String lang = getLanguage(ctx);
    6883        if (lang.equals(TEST_LANG))
    69             return TEST_STRING + '(' + o + ')' + TEST_STRING;
     84            return TEST_STRING + Arrays.toString(oArray) + TEST_STRING;
    7085        String x = getString(s, ctx, bun);
    71         Object[] oArray = new Object[1];
    72         oArray[0] = o;
    7386        try {
    7487            MessageFormat fmt = new MessageFormat(x, new Locale(lang));
     
    7790            System.err.println("Bad format: orig: \"" + s +
    7891                               "\" trans: \"" + x +
    79                                "\" param: \"" + o +
    80                                "\" lang: " + lang);
    81             return "FIXME: " + x + ' ' + o;
    82         }
    83     }
    84 
    85     /** for {0} and {1} */
    86     public static String getString(String s, Object o, Object o2, I2PAppContext ctx, String bun) {
    87         String lang = getLanguage(ctx);
    88         if (lang.equals(TEST_LANG))
    89             return TEST_STRING + '(' + o + ',' + o2 + ')' + TEST_STRING;
    90         String x = getString(s, ctx, bun);
    91         Object[] oArray = new Object[2];
    92         oArray[0] = o;
    93         oArray[1] = o2;
    94         try {
    95             MessageFormat fmt = new MessageFormat(x, new Locale(lang));
    96             return fmt.format(oArray, new StringBuffer(), null).toString();
    97         } catch (IllegalArgumentException iae) {
    98             System.err.println("Bad format: orig: \"" + s +
    99                                "\" trans: \"" + x +
    100                                "\" param1: \"" + o +
    101                                "\" param2: \"" + o2 +
    102                                "\" lang: " + lang);
    103             return "FIXME: " + x + ' ' + o + ',' + o2;
     92                               "\" params: " + Arrays.toString(oArray) +
     93                               " lang: " + lang);
     94            return "FIXME: " + x + ' ' + Arrays.toString(oArray);
    10495        }
    10596    }
  • installer/resources/deletelist.txt

    r554a3a6 r90cc71d  
    55certificates/forum.i2p2.de.crt
    66certificates/cowpuncher.drollette.com.crt
     7# old translated proxy error pages
     8docs/ahelper-conflict-header_ar.ht
     9docs/ahelper-conflict-header_de.ht
     10docs/ahelper-conflict-header_fr.ht
     11docs/ahelper-conflict-header_nl.ht
     12docs/ahelper-conflict-header_ru.ht
     13docs/ahelper-conflict-header_zh.ht
     14docs/auth-header_de.ht
     15docs/auth-header_fr.ht
     16docs/denied-header_ar.ht
     17docs/denied-header_de.ht
     18docs/denied-header_fr.ht
     19docs/denied-header_nl.ht
     20docs/denied-header_ru.ht
     21docs/denied-header_zh.ht
     22docs/dnf-header_de.ht
     23docs/dnf-header_fr.ht
     24docs/dnf-header_nl.ht
     25docs/dnf-header_ru.ht
     26docs/dnf-header_zh.ht
     27docs/dnfb-header_ar.ht
     28docs/dnfb-header_de.ht
     29docs/dnfb-header_fr.ht
     30docs/dnfb-header_nl.ht
     31docs/dnfb-header_ru.ht
     32docs/dnfb-header_zh.ht
     33docs/dnfh-header_de.ht
     34docs/dnfh-header_fr.ht
     35docs/dnfh-header_nl.ht
     36docs/dnfh-header_ru.ht
     37docs/dnfh-header_zh.ht
     38docs/dnfp-header_ar.ht
     39docs/dnfp-header_de.ht
     40docs/dnfp-header_fr.ht
     41docs/dnfp-header_nl.ht
     42docs/dnfp-header_ru.ht
     43docs/dnfp-header_zh.ht
     44docs/localhost-header_ar.ht
     45docs/localhost-header_de.ht
     46docs/localhost-header_fr.ht
     47docs/localhost-header_nl.ht
     48docs/localhost-header_ru.ht
     49docs/localhost-header_zh.ht
     50docs/noproxy-header_ar.ht
     51docs/noproxy-header_de.ht
     52docs/noproxy-header_fr.ht
     53docs/noproxy-header_nl.ht
     54docs/noproxy-header_ru.ht
     55docs/noproxy-header_zh.ht
     56docs/protocol-header_ar.ht
     57docs/protocol-header_de.ht
     58docs/protocol-header_fr.ht
     59docs/protocol-header_nl.ht
     60docs/protocol-header_ru.ht
     61docs/protocol-header_zh.ht
     62# old translated initial news
     63docs/initialNews/initialNews_ar.xml
     64docs/initialNews/initialNews_de.xml
     65docs/initialNews/initialNews_es.xml
     66docs/initialNews/initialNews_fr.xml
     67docs/initialNews/initialNews_nl.xml
     68docs/initialNews/initialNews_pt.xml
     69docs/initialNews/initialNews_ru.xml
     70docs/initialNews/initialNews_sv.xml
  • installer/resources/initialNews/initialNews.xml

    r554a3a6 r90cc71d  
    1 <div lang="en">
    2 <h3>Congratulations on getting I2P installed!</h3>
     1<div>
     2<h3>_("Congratulations on getting I2P installed!")</h3>
    33<p>
    4 <b>Welcome to I2P!</b>
    5 Please <b>have patience</b> as I2P boots up and finds peers.
     4<b>_("Welcome to I2P!")</b>
     5_("Please {0}have patience{1} as I2P boots up and finds peers.", "<b>", "</b>")
    66</p>
    77<p>
    8 While you are waiting, please <b>adjust your bandwidth settings</b> on the
    9 <a href="config.jsp">configuration page</a>.
     8_("While you are waiting, please {0}adjust your bandwidth settings{1} on the {2}configuration page{3}.", "<b>", "</b>", "<a href=\"config.jsp\">", "</a>")
    109</p>
    1110<p>
    12 Also you can setup your browser to use the I2P proxy to reach eepsites. Just enter 127.0.0.1 (or localhost)
    13 port 4444 as a http proxy into your browser settings. Do not use SOCKS for this. More information
    14 can be found on <a href="https://www.i2p2.de/htproxyports.html">I2P browser proxy setup page</a>.
     11_("Also you can setup your browser to use the I2P proxy to reach eepsites.")
     12_("Just enter 127.0.0.1 (or localhost) port 4444 as a http proxy into your browser settings.")
     13_("Do not use SOCKS for this.")
     14_("More information can be found on the {0}I2P browser proxy setup page{1}.", "<a href=\"https://www.i2p2.de/htproxyports.html\">", "</a>")
    1515</p>
    1616<p>
    17 Once you have a "shared clients" destination listed on the left,
    18 please <b>check out</b> our
    19 <a href="http://www.i2p2.i2p/faq.html">FAQ</a>.
     17_("Once you have a \"shared clients\" destination listed on the left, please {0}check out{1} our {2}FAQ{3}.", "<b>", "</b>", "<a href=\"http://www.i2p2.i2p/faq.html\">", "</a>")
    2018</p>
    2119<p>
    22 Point your IRC client to <b>localhost:6668</b> and say hi to us on
    23 <a href="irc://127.0.0.1:6668/i2p-help">#i2p-help</a> or <a href="irc://127.0.0.1:6668/i2p">#i2p</a>.
     20_("Point your IRC client to {0}localhost:6668{1} and say hi to us on {2}#i2p-help{3} or {4}#i2p{5}.", "<b>", "</b>", "<a href=\"irc://127.0.0.1:6668/i2p-help\">", "</a>", "<a href=\"irc://127.0.0.1:6668/i2p\">", "</a>")
    2421</p>
    2522</div>
  • installer/resources/proxy/ahelper-conflict-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Destination key conflict</title>
     9<title>_("Warning: Destination Key Conflict")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
    1715</div>
    1816<div class="warning" id="warning">
    19 <h3>Warning: Destination Key Conflict</h3>
     17<h3>_("Warning: Destination Key Conflict")</h3>
    2018<p>
    21 The addresshelper link you followed specifies a different destination key
    22 than a host entry in your host database.
    23 Someone could be trying to impersonate another eepsite,
    24 or people have given two eepsites identical names.
     19_("The addresshelper link you followed specifies a different destination key than a host entry in your host database.")
     20_("Someone could be trying to impersonate another eepsite, or people have given two eepsites identical names.")
    2521</p>
    2622<p>
    27 You can resolve the conflict by considering which key you trust,
    28 and either discarding the addresshelper link,
    29 discarding the host entry from your host database,
    30 or naming one of them differently.
     23_("You can resolve the conflict by considering which key you trust, and either discarding the addresshelper link, discarding the host entry from your host database, or naming one of them differently.")
    3124</p>
  • installer/resources/proxy/ahelper-new-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Information: New Host Name</title>
     9<title>_("Information: New Host Name")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Information: New Host Name with Address Helper</h3>
     19<h3>_("Information: New Host Name with Address Helper")</h3>
    2020<p>
    21 The address helper link you followed is for a new host name that is not in your address book.
    22 You may save this host name to your local address book.
    23 If you save it to your address book, you will not see this message again.
    24 If you do not save it, the host name will be forgotten after the next router restart.
    25 If you do not wish to visit this host, click the "back" button on your browser.
     21_("The address helper link you followed is for a new host name that is not in your address book.")
     22_("You may save this host name to your local address book.")
     23_("If you save it to your address book, you will not see this message again.")
     24_("If you do not save it, the host name will be forgotten after the next router restart.")
     25_("If you do not wish to visit this host, click the \"back\" button on your browser.")
    2626</p>
  • installer/resources/proxy/ahelper-notfound-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Bad Address Helper</title>
     9<title>_("Warning: Bad Address Helper")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/index.jsp" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: Bad Address Helper</h3>
     19<h3>_("Warning: Bad Address Helper")</h3>
    2020<p>
    21 The helper key you put for i2paddresshelper= is not resolvable.
    22 It seems to be garbage data, or a mistyped b32. Check your URL
    23 to try and fix the helper key to be a valid Base 32 hostname or Base 64 key.
     21_("The helper key in the URL ({0}i2paddresshelper={1}) is not resolvable.", "<code>", "</code>")
     22_("It seems to be garbage data, or a mistyped Base 32 address.")
     23_("Check your URL to try and fix the helper key to be a valid Base 32 hostname or Base 64 key.")
    2424</p>
  • installer/resources/proxy/auth-header.ht

    r554a3a6 r90cc71d  
    99<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    1010<html><head>
    11 <title>Proxy Authorization Required</title>
     11<title>_("Proxy Authorization Required")</title>
    1212<!-- we cannot have links to CSS or images here, but we could put in some simple inline style -->
    1313</head>
    1414<body>
    1515<div class="warning" id="warning">
    16 <h3>I2P HTTP Proxy Authorization Required</h3>
     16<h3>_("I2P HTTP Proxy Authorization Required")</h3>
    1717<p>
    18 This proxy is configured to require a username and password for access.
    19 Please enter your username and password, or check your
    20 <a href="http://127.0.0.1:7657/advancedconfig.jsp">router configuration</a>
    21 or
    22 <a href="http://127.0.0.1:7657/i2ptunnel/index.jsp">I2PTunnel configuration</a>.
    23 To disable authorization, remove the configuration
    24 <code>i2ptunnel.proxy.auth=basic</code>, then stop and restart the HTTP Proxy tunnel.
     18_("This proxy is configured to require a username and password for access.")
     19_("Please enter your username and password, or check your {0}router configuration{1} or {2}I2PTunnel configuration{3}.", "<a href=\"http://127.0.0.1:7657/advancedconfig.jsp\">", "/a>", "<a href=\"http://127.0.0.1:7657/i2ptunnel/index.jsp\">", "</a>")
     20_("To disable authorization, remove the configuration {0}i2ptunnel.proxy.auth=basic{1}, then stop and restart the HTTP Proxy tunnel.", "<code>", "</code>"))
    2521</p>
    2622</div>
  • installer/resources/proxy/baduri-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Invalid Request URI</title>
     9<title>_("Warning: Invalid Request URI")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: Invalid Request URI</h3>
     19<h3>_("Warning: Invalid Request URI")</h3>
    2020<p>
    21 The request URI is invalid, and probably contains illegal characters.
    22 If you clicked e.g. a forum link, check the end of the URI for any characters the browser has mistakenly added on.
     21_("The request URI is invalid, and probably contains illegal characters.")
     22_("If you clicked a link, check the end of the URI for any characters the browser has mistakenly added on.")
    2323</p>
    2424</div>
  • installer/resources/proxy/denied-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Request Denied</title>
     9<title>_("Warning: Request Denied")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: Request Denied</h3>
     19<h3>_("Warning: Request Denied")</h3>
    2020<p>
    21 You attempted to connect to a non-I2P website or location.
     21_("You attempted to connect to a non-I2P website or location.")
    2222</p>
    2323</div>
  • installer/resources/proxy/dnf-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Eepsite not reachable</title>
     9<title>_("Warning: Eepsite Unreachable")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/index">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: Eepsite Unreachable</h3>
     19<h3>_("Warning: Eepsite Unreachable")</h3>
    2020<p>
    21 The eepsite was not reachable.
    22 The eepsite is offline, there is network congestion,
    23 or your router is not yet well-integrated with peers.
    24 You may want to
    25 <a href="javascript:window.location.reload()">retry</a>.</p>
     21_("The eepsite was not reachable.")
     22_("The eepsite is offline, there is network congestion, or your router is not yet well-integrated with peers.")
     23_("You may want to {0}retry{1}.", "<a href=\"javascript:window.location.reload()\">", "</a>")</p>
    2624<hr>
    27 <p><b>Could not find the following destination:</b>
     25<p><b>_("Could not find the following destination:")</b>
    2826</p>
  • installer/resources/proxy/dnfb-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Invalid eepsite destination</title>
     9<title>_("Warning: Invalid Destination")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: Invalid Destination</h3>
     19<h3>_("Warning: Invalid Destination")</h3>
    2020<p>
    21 The eepsite destination specified was not valid, or was
    22 otherwise unreachable.  Perhaps you pasted in the
    23 wrong BASE64 string or the link you are following is
    24 bad. The I2P host could also be offline.  You may want to
    25 <a href="javascript:window.location.reload()">retry</a>.
    26 <hr><b>Could not find the following destination:</b>
     21_("The eepsite destination specified was not valid, or was otherwise unreachable.")
     22_("Perhaps you pasted in the wrong Base 64 string or the link you are following is bad.")
     23_("The I2P host could also be offline.")
     24_("You may want to {0}retry{1}.", "<a href=\"javascript:window.location.reload()\">", "</a>")
     25<hr><b>_("Could not find the following destination:")</b>
    2726</p>
  • installer/resources/proxy/dnfh-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Eepsite unknown</title>
     9<title>_("Warning: Eepsite Unknown")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/index">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: Eepsite Not Found in Addressbook</h3>
     19<h3>_("Warning: Eepsite Not Found in Addressbook")</h3>
    2020<p>
    21 The eepsite was not found in your router's addressbook.
    22 Check the link or find a Base 32 or Base 64 address.
    23 If you have the Base 64 address,
    24 <a href="http://127.0.0.1:7657/susidns/addressbook.jsp?book=router">add it to your addressbook</a>.
    25 Otherwise, find a Base 32 or address helper link, or use a jump service link below.
     21_("The eepsite was not found in your router's addressbook.")
     22_("Check the link or find a Base 32 or Base 64 address.")
     23_("If you have the Base 64 address, {0}add it to your addressbook{1}.", "<a href=\"http://127.0.0.1:7657/susidns/addressbook.jsp?book=router\">", "</a>")
     24_("Otherwise, find a Base 32 or address helper link, or use a jump service link below.")
    2625</p>
    2726<p>
    28 Seeing this page often? See <a href="http://www.i2p2.i2p/faq.html#subscriptions">the FAQ</a>
    29 for help in <a href="http://127.0.0.1:7657/susidns/config.jsp">adding some subscriptions</a>
    30 to your addressbook.</p><hr>
     27_("Seeing this page often? See {0}the FAQ{1} for help in {2}adding some subscriptions{3} to your addressbook.", "<a href=\"http://www.i2p2.i2p/faq.html#subscriptions\">", "</a>", "<a href=\"http://127.0.0.1:7657/susidns/config.jsp\">", "</a>")
     28</p><hr>
    3129<p>
    32 <b>Could not find the following destination:</b>
     30<b>_("Could not find the following destination:")</b>
    3331</p>
  • installer/resources/proxy/dnfp-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Outproxy Not Found</title>
     9<title>_("Warning: Outproxy Not Found")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: Outproxy Not Found</h3>
     19<h3>_("Warning: Outproxy Not Found")</h3>
    2020<p>
    21 The HTTP Outproxy was not found.
    22 It is offline, there is network congestion,
    23 or your router is not yet well-integrated with peers.
    24 You may want to
    25 <a href="javascript:parent.window.location.reload()">retry</a>
    26 as this will randomly reselect an outproxy from the pool you have defined
    27 <a href="http://127.0.0.1:7657/i2ptunnel/index.jsp">here</a>
    28 (if you have more than one configured).
    29 If you continue to have trouble you may want to edit your outproxy list
    30 <a href="http://127.0.0.1:7657/i2ptunnel/edit.jsp?tunnel=0">here</a>.
     21_("The HTTP Outproxy was not found.")
     22_("It is offline, there is network congestion, or your router is not yet well-integrated with peers.")
     23_("You may want to {0}retry{1} as this will randomly reselect an outproxy from the pool you have defined {2}here{3} (if you have more than one configured).", "<a href=\"javascript:parent.window.location.reload()\">", "</a>", "<a href=\"http://127.0.0.1:7657/i2ptunnel/index.jsp\">", "</a>")
     24_("If you continue to have trouble you may want to edit your outproxy list {0}here{1}.", "<a href=\"http://127.0.0.1:7657/i2ptunnel/edit.jsp?tunnel=0\">", "</a>")
    3125</p>
    32 <hr><p><b>Could not find the following destination:</b></p>
     26<hr><p><b>_("Could not find the following destination:")</b></p>
  • installer/resources/proxy/localhost-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Error: Request Denied</title>
     9<title>_("Error: Request Denied")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1515  Let's not infinite loop here....
    1616<div class="logo">
    17  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    18  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     17 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     18 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1919</div>
    2020------------------------------>
    2121<div class="warning" id="warning">
    22 <h3>Error: Local Access</h3>
     22<h3>_("Error: Local Access")</h3>
    2323<p>
    24 Your browser is misconfigured. Do not use the proxy to access the router console,
    25 localhost, or local LAN destinations.
     24_("Your browser is misconfigured.")
     25_("Do not use the proxy to access the router console, localhost, or local LAN destinations.")
    2626</p>
    2727</div>
  • installer/resources/proxy/noproxy-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: No outproxy configured</title>
     9<title>_("Warning: No Outproxy Configured")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: No Outproxy Configured</h3>
     19<h3>_("Warning: No Outproxy Configured")</h3>
    2020<p>
    21 Your request was for a site outside of I2P, but you have no
    22 HTTP outproxy configured.  Please configure an outproxy in I2PTunnel.
     21_("Your request was for a site outside of I2P, but you have no HTTP outproxy configured.")
     22_("Please configure an outproxy in I2PTunnel.")
    2323</p>
    2424</div>
  • installer/resources/proxy/protocol-header.ht

    r554a3a6 r90cc71d  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    88<html><head>
    9 <title>I2P Warning: Non-HTTP Protocol</title>
     9<title>_("Warning: Non-HTTP Protocol")</title>
    1010<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
    1111<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
     
    1313<body>
    1414<div class="logo">
    15  <a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
    16  <a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
     15 <a href="http://127.0.0.1:7657/" title="_("Router Console")"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="_("I2P Router Console")" border="0"></a><hr>
     16 <a href="http://127.0.0.1:7657/config.jsp">_("Configuration")</a> <a href="http://127.0.0.1:7657/help.jsp">_("Help")</a> <a href="http://127.0.0.1:7657/susidns/index">_("Addressbook")</a>
    1717</div>
    1818<div class="warning" id="warning">
    19 <h3>Warning: Non-HTTP Protocol</h3>
     19<h3>_("Warning: Non-HTTP Protocol")</h3>
    2020<p>
    21 The request uses a bad protocol.
    22 The I2P HTTP Proxy supports <code>http://</code> requests ONLY. Other protocols such as <code>https://</code> and <code>ftp://</code> are not allowed.
     21_("The request uses a bad protocol.")
     22_("The I2P HTTP Proxy supports {0}http://{1} requests ONLY.", "<code>", "</code>")
     23_("Other protocols such as {0}https://{1} and {0}ftp://{1} are not allowed.", "<code>", "</code>")
    2324</p>
    2425</div>
  • router/java/src/net/i2p/router/client/ClientConnectionRunner.java

    r554a3a6 r90cc71d  
    5959    protected final Log _log;
    6060    protected final RouterContext _context;
    61     private final ClientManager _manager;
     61    protected final ClientManager _manager;
    6262    /** socket for this particular peer connection */
    6363    private final Socket _socket;
     
    138138                throw new IllegalStateException();
    139139            _reader = new I2CPMessageReader(new BufferedInputStream(_socket.getInputStream(), BUF_SIZE),
    140                                             new ClientMessageEventListener(_context, this, true));
     140                                            createListener());
    141141            _writer = new ClientWriterRunner(_context, this);
    142142            I2PThread t = new I2PThread(_writer);
     
    149149    }
    150150   
     151    /**
     152     *  Allow override for testing
     153     *  @since 0.9.8
     154     */
     155    protected I2CPMessageReader.I2CPMessageEventListener createListener() {
     156        return new ClientMessageEventListener(_context, this, true);
     157    }
     158
    151159    /**
    152160     *  Die a horrible death. Cannot be restarted.
     
    461469     *            signed version (as well as any changed/added/removed Leases)
    462470     * @param expirationTime ms to wait before failing
    463      * @param onCreateJob Job to run after the LeaseSet is authorized
    464      * @param onFailedJob Job to run after the timeout passes without receiving authorization
     471     * @param onCreateJob Job to run after the LeaseSet is authorized, null OK
     472     * @param onFailedJob Job to run after the timeout passes without receiving authorization, null OK
    465473     */
    466474    void requestLeaseSet(LeaseSet set, long expirationTime, Job onCreateJob, Job onFailedJob) {
  • router/java/src/net/i2p/router/client/ClientManager.java

    r554a3a6 r90cc71d  
    1111import java.io.IOException;
    1212import java.io.Writer;
     13import java.util.Collections;
    1314import java.util.HashMap;
    1415import java.util.HashSet;
     
    4546class ClientManager {
    4647    private final Log _log;
    47     private ClientListenerRunner _listener;
     48    protected ClientListenerRunner _listener;
    4849    // Destination --> ClientConnectionRunner
    4950    // Locked for adds/removes but not lookups
     
    5455    // ClientConnectionRunner for clients w/out a Dest yet
    5556    private final Set<ClientConnectionRunner> _pendingRunners;
    56     private final RouterContext _ctx;
    57     private volatile boolean _isStarted;
     57    protected final RouterContext _ctx;
     58    protected final int _port;
     59    protected volatile boolean _isStarted;
    5860
    5961    /** Disable external interface, allow internal clients only @since 0.8.3 */
     
    6668    private static final long REQUEST_LEASESET_TIMEOUT = 60*1000;
    6769
     70    /**
     71     *  Does not start the listeners.
     72     *  Caller must call start()
     73     */
    6874    public ClientManager(RouterContext context, int port) {
    6975        _ctx = context;
     
    7682        _runnersByHash = new ConcurrentHashMap();
    7783        _pendingRunners = new HashSet();
    78         startListeners(port);
     84        _port = port;
    7985        // following are for RequestLeaseSetJob
    8086        _ctx.statManager().createRateStat("client.requestLeaseSetSuccess", "How frequently the router requests successfully a new leaseSet?", "ClientMessages", new long[] { 60*60*1000 });
     
    8389    }
    8490
     91    /** @since 0.9.8 */
     92    public synchronized void start() {
     93        startListeners();
     94    }
     95
    8596    /** Todo: Start a 3rd listener for IPV6? */
    86     private void startListeners(int port) {
     97    protected void startListeners() {
    8798        if (!_ctx.getBooleanProperty(PROP_DISABLE_EXTERNAL)) {
    8899            // there's no option to start both an SSL and non-SSL listener
    89100            if (_ctx.getBooleanProperty(PROP_ENABLE_SSL))
    90                 _listener = new SSLClientListenerRunner(_ctx, this, port);
     101                _listener = new SSLClientListenerRunner(_ctx, this, _port);
    91102            else
    92                 _listener = new ClientListenerRunner(_ctx, this, port);
    93             Thread t = new I2PThread(_listener, "ClientListener:" + port, true);
     103                _listener = new ClientListenerRunner(_ctx, this, _port);
     104            Thread t = new I2PThread(_listener, "ClientListener:" + _port, true);
    94105            t.start();
    95106        }
     
    103114        try { Thread.sleep(2*1000); } catch (InterruptedException ie) {}
    104115       
    105         int port = _ctx.getProperty(ClientManagerFacadeImpl.PROP_CLIENT_PORT,
    106                                     ClientManagerFacadeImpl.DEFAULT_PORT);
    107         startListeners(port);
     116        startListeners();
    108117    }
    109118   
     
    405414    }
    406415   
     416    /**
     417     *  @return unmodifiable, not a copy
     418     */
    407419    Set<Destination> getRunnerDestinations() {
    408         Set<Destination> dests = new HashSet();
    409         dests.addAll(_runners.keySet());
    410         return dests;
    411     }
    412    
     420        return Collections.unmodifiableSet(_runners.keySet());
     421    }
     422   
     423    /**
     424     *  Unused
     425     *
     426     *  @param dest null for all local destinations
     427     */
    413428    public void reportAbuse(Destination dest, String reason, int severity) {
    414429        if (dest != null) {
     
    418433            }
    419434        } else {
    420             Set dests = getRunnerDestinations();
    421             for (Iterator iter = dests.iterator(); iter.hasNext(); ) {
    422                 Destination d = (Destination)iter.next();
     435            for (Destination d : _runners.keySet()) {
    423436                reportAbuse(d, reason, severity);
    424437            }
  • router/java/src/net/i2p/router/client/ClientManagerFacadeImpl.java

    r554a3a6 r90cc71d  
    5757        int port = _context.getProperty(PROP_CLIENT_PORT, DEFAULT_PORT);
    5858        _manager = new ClientManager(_context, port);
     59        _manager.start();
    5960    }   
    6061   
     
    8384
    8485    private static final long MAX_TIME_TO_REBUILD = 10*60*1000;
     86
    8587    @Override
    8688    public boolean verifyClientLiveliness() {
    8789        if (_manager == null) return true;
    8890        boolean lively = true;
    89         for (Iterator iter = _manager.getRunnerDestinations().iterator(); iter.hasNext(); ) {
    90             Destination dest = (Destination)iter.next();
     91        for (Destination dest : _manager.getRunnerDestinations()) {
    9192            ClientConnectionRunner runner = _manager.getRunner(dest);
    9293            if ( (runner == null) || (runner.getIsDead())) continue;
  • router/java/src/net/i2p/router/client/ClientMessageEventListener.java

    r554a3a6 r90cc71d  
    4747class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventListener {
    4848    private final Log _log;
    49     private final RouterContext _context;
    50     private final ClientConnectionRunner _runner;
     49    protected final RouterContext _context;
     50    protected final ClientConnectionRunner _runner;
    5151    private final boolean  _enforceAuth;
    5252   
     
    7474        switch (message.getType()) {
    7575            case GetDateMessage.MESSAGE_TYPE:
    76                 handleGetDate(reader, (GetDateMessage)message);
     76                handleGetDate((GetDateMessage)message);
    7777                break;
    7878            case SetDateMessage.MESSAGE_TYPE:
    79                 handleSetDate(reader, (SetDateMessage)message);
     79                handleSetDate((SetDateMessage)message);
    8080                break;
    8181            case CreateSessionMessage.MESSAGE_TYPE:
    82                 handleCreateSession(reader, (CreateSessionMessage)message);
     82                handleCreateSession((CreateSessionMessage)message);
    8383                break;
    8484            case SendMessageMessage.MESSAGE_TYPE:
    85                 handleSendMessage(reader, (SendMessageMessage)message);
     85                handleSendMessage((SendMessageMessage)message);
    8686                break;
    8787            case SendMessageExpiresMessage.MESSAGE_TYPE:
    88                 handleSendMessage(reader, (SendMessageExpiresMessage)message);
     88                handleSendMessage((SendMessageExpiresMessage)message);
    8989                break;
    9090            case ReceiveMessageBeginMessage.MESSAGE_TYPE:
    91                 handleReceiveBegin(reader, (ReceiveMessageBeginMessage)message);
     91                handleReceiveBegin((ReceiveMessageBeginMessage)message);
    9292                break;
    9393            case ReceiveMessageEndMessage.MESSAGE_TYPE:
    94                 handleReceiveEnd(reader, (ReceiveMessageEndMessage)message);
     94                handleReceiveEnd((ReceiveMessageEndMessage)message);
    9595                break;
    9696            case CreateLeaseSetMessage.MESSAGE_TYPE:
    97                 handleCreateLeaseSet(reader, (CreateLeaseSetMessage)message);
     97                handleCreateLeaseSet((CreateLeaseSetMessage)message);
    9898                break;
    9999            case DestroySessionMessage.MESSAGE_TYPE:
    100                 handleDestroySession(reader, (DestroySessionMessage)message);
     100                handleDestroySession((DestroySessionMessage)message);
    101101                break;
    102102            case DestLookupMessage.MESSAGE_TYPE:
    103                 handleDestLookup(reader, (DestLookupMessage)message);
     103                handleDestLookup((DestLookupMessage)message);
    104104                break;
    105105            case ReconfigureSessionMessage.MESSAGE_TYPE:
    106                 handleReconfigureSession(reader, (ReconfigureSessionMessage)message);
     106                handleReconfigureSession((ReconfigureSessionMessage)message);
    107107                break;
    108108            case GetBandwidthLimitsMessage.MESSAGE_TYPE:
    109                 handleGetBWLimits(reader, (GetBandwidthLimitsMessage)message);
     109                handleGetBWLimits((GetBandwidthLimitsMessage)message);
    110110                break;
    111111            default:
     
    132132    }
    133133   
    134     private void handleGetDate(I2CPMessageReader reader, GetDateMessage message) {
     134    private void handleGetDate(GetDateMessage message) {
    135135        // sent by clients >= 0.8.7
    136136        String clientVersion = message.getVersion();
     
    149149     *  As of 0.8.7, does nothing. Do not allow a client to set the router's clock.
    150150     */
    151     private void handleSetDate(I2CPMessageReader reader, SetDateMessage message) {
     151    private void handleSetDate(SetDateMessage message) {
    152152        //_context.clock().setNow(message.getDate().getTime());
    153153    }
     
    161161     * So keep it simple.
    162162     */
    163     private void handleCreateSession(I2CPMessageReader reader, CreateSessionMessage message) {
     163    private void handleCreateSession(CreateSessionMessage message) {
    164164        SessionConfig in = message.getSessionConfig();
    165165        if (in.verifySignature()) {
     
    210210        if (_log.shouldLog(Log.DEBUG))
    211211            _log.debug("after sessionEstablished for " + message.getSessionConfig().getDestination().calculateHash().toBase64());
    212 
     212        startCreateSessionJob();
     213    }
     214   
     215    /**
     216     *  Override for testing
     217     *  @since 0.9.8
     218     *
     219     */
     220    protected void startCreateSessionJob() {
    213221        _context.jobQueue().addJob(new CreateSessionJob(_context, _runner));
    214222    }
    215    
    216223   
    217224    /**
     
    220227     *
    221228     */
    222     private void handleSendMessage(I2CPMessageReader reader, SendMessageMessage message) {
     229    private void handleSendMessage(SendMessageMessage message) {
    223230        if (_log.shouldLog(Log.DEBUG))
    224231            _log.debug("handleSendMessage called");
     
    237244     *
    238245     */
    239     private void handleReceiveBegin(I2CPMessageReader reader, ReceiveMessageBeginMessage message) {
     246    private void handleReceiveBegin(ReceiveMessageBeginMessage message) {
    240247        if (_runner.isDead()) return;
    241248        if (_log.shouldLog(Log.DEBUG))
     
    267274     *
    268275     */
    269     private void handleReceiveEnd(I2CPMessageReader reader, ReceiveMessageEndMessage message) {
     276    private void handleReceiveEnd(ReceiveMessageEndMessage message) {
    270277        _runner.removePayload(new MessageId(message.getMessageId()));
    271278    }
    272279   
    273     private void handleDestroySession(I2CPMessageReader reader, DestroySessionMessage message) {
     280    private void handleDestroySession(DestroySessionMessage message) {
    274281        if (_log.shouldLog(Log.INFO))
    275282            _log.info("Destroying client session " + _runner.getSessionId());
     
    277284    }
    278285   
    279     private void handleCreateLeaseSet(I2CPMessageReader reader, CreateLeaseSetMessage message) {       
     286    /** override for testing */
     287    protected void handleCreateLeaseSet(CreateLeaseSetMessage message) {       
    280288        if ( (message.getLeaseSet() == null) || (message.getPrivateKey() == null) || (message.getSigningPrivateKey() == null) ) {
    281289            if (_log.shouldLog(Log.ERROR))
     
    294302    }
    295303
    296     private void handleDestLookup(I2CPMessageReader reader, DestLookupMessage message) {
     304    /** override for testing */
     305    protected void handleDestLookup(DestLookupMessage message) {
    297306        _context.jobQueue().addJob(new LookupDestJob(_context, _runner, message.getHash()));
    298307    }
     
    306315     * ClientConnectionRunner.sessionEstablished(). Those can't be changed later.
    307316     */
    308     private void handleReconfigureSession(I2CPMessageReader reader, ReconfigureSessionMessage message) {
     317    private void handleReconfigureSession(ReconfigureSessionMessage message) {
    309318        if (_log.shouldLog(Log.INFO))
    310319            _log.info("Updating options - old: " + _runner.getConfig() + " new: " + message.getSessionConfig());
     
    344353     * But it's not enforced anywhere.
    345354     */
    346     private void handleGetBWLimits(I2CPMessageReader reader, GetBandwidthLimitsMessage message) {
     355    protected void handleGetBWLimits(GetBandwidthLimitsMessage message) {
    347356        if (_log.shouldLog(Log.INFO))
    348357            _log.info("Got BW Limits request");
  • router/java/src/net/i2p/router/transport/TransportImpl.java

    r554a3a6 r90cc71d  
    4444import net.i2p.util.SimpleTimer;
    4545import net.i2p.util.SystemVersion;
     46import net.i2p.util.Translate;
    4647
    4748/**
     
    655656        }
    656657    }
     658
     659    private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
     660
     661    /**
     662     *  Translate
     663     *  @since 0.9.8 moved from transports
     664     */
     665    protected String _(String s) {
     666        return Translate.getString(s, _context, BUNDLE_NAME);
     667    }
     668
     669    /**
     670     *  Translate
     671     *  @since 0.9.8 moved from transports
     672     */
     673    protected String _(String s, Object o) {
     674        return Translate.getString(s, o, _context, BUNDLE_NAME);
     675    }
     676
     677    /**
     678     *  Translate
     679     *  @since 0.9.8
     680     */
     681    protected String ngettext(String s, String p, int n) {
     682        return Translate.getString(n, s, p, _context, BUNDLE_NAME);
     683    }
    657684}
  • router/java/src/net/i2p/router/transport/crypto/DHSessionKeyBuilder.java

    r554a3a6 r90cc71d  
    262262     * Retrieve the extra bytes beyond the session key resulting from the DH exchange.
    263263     * If there aren't enough bytes (with all of them being consumed by the 32 byte key),
    264      * the SHA256 of the key itself is used.
     264     * the SHA256 of the key itself is used - but that won't ever happen.
     265     *
     266     * Used only by UDP. getData() will be non-null and have at least 32 bytes after call to getSessionKey()
    265267     *
    266268     * @return non-null (but rv.getData() may be null)
     
    271273
    272274    /**
    273      * Calculate a session key based on the private value and the public peer value
    274      *
     275     * Calculate a session key based on the private value and the public peer value.
     276     *
     277     * This is the first 32 bytes of the exchanged key (nominally 256 bytes),
     278     * EXCEPT that the first byte will be zero if the most significant bit was a 1
     279     * (Java BigInteger.toByteArray() format)
     280     *
     281     * Side effect - sets extraExchangedBytes to the next 32 bytes.
    275282     */
    276283    private final SessionKey calculateSessionKey(BigInteger myPrivateValue, BigInteger publicPeerValue) {
     
    278285        SessionKey key = new SessionKey();
    279286        BigInteger exchangedKey = publicPeerValue.modPow(myPrivateValue, CryptoConstants.elgp);
     287        // surprise! leading zero byte half the time!
     288        // probably was a mistake, too late now...
    280289        byte buf[] = exchangedKey.toByteArray();
    281         byte val[] = new byte[32];
    282         if (buf.length < val.length) {
    283             System.arraycopy(buf, 0, val, 0, buf.length);
    284             byte remaining[] = SHA256Generator.getInstance().calculateHash(val).getData();
     290        byte val[] = new byte[SessionKey.KEYSIZE_BYTES];
     291        if (buf.length < 2 * SessionKey.KEYSIZE_BYTES) {
     292            // UDP requires at least 32 bytes in _extraExchangedBytes for the mac key
     293            // Won't ever happen, typ buf is 256 or 257 bytes
     294            System.arraycopy(buf, 0, val, 0, Math.min(buf.length, SessionKey.KEYSIZE_BYTES));
     295            byte remaining[] = new byte[SessionKey.KEYSIZE_BYTES];  // == Hash.HASH_LENGTH
     296            // non-caching version
     297            SHA256Generator.getInstance().calculateHash(buf, 0, buf.length, remaining, 0);
    285298            _extraExchangedBytes.setData(remaining);
    286299            //if (_log.shouldLog(Log.DEBUG))
    287300            //    _log.debug("Storing " + remaining.length + " bytes from the DH exchange by SHA256 the session key");
    288         } else { // (buf.length >= val.length)
    289             System.arraycopy(buf, 0, val, 0, val.length);
     301        } else {
     302            // Will always be here, typ buf is 256 or 257 bytes
     303            System.arraycopy(buf, 0, val, 0, SessionKey.KEYSIZE_BYTES);
    290304            // feed the extra bytes into the PRNG
    291305            RandomSource.getInstance().harvester().feedEntropy("DH", buf, val.length, buf.length-val.length);
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r554a3a6 r90cc71d  
    3737import net.i2p.util.ConcurrentHashSet;
    3838import net.i2p.util.Log;
    39 import net.i2p.util.Translate;
    4039
    4140/**
     
    844843        if (!peers.isEmpty()) {
    845844//            buf.append("<tr> <td colspan=\"11\"><hr></td></tr>\n");
    846             buf.append("<tr class=\"tablefooter\"><td align=\"center\"><b>").append(peers.size()).append(' ').append(_("peers")).append("</b></td><td>&nbsp;</td><td>&nbsp;");
     845            buf.append("<tr class=\"tablefooter\"><td align=\"center\"><b>")
     846               .append(ngettext("{0} peer", "{0} peers", peers.size()))
     847               .append("</b></td><td>&nbsp;</td><td>&nbsp;");
    847848            buf.append("</td><td align=\"center\"><b>").append(formatRate(bpsRecv/1024)).append(THINSP).append(formatRate(bpsSend/1024)).append("</b>");
    848849            buf.append("</td><td align=\"center\"><b>").append(DataHelper.formatDuration2(totalUptime/peers.size()));
     
    889890    }
    890891
    891     private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
    892 
    893     /**
    894      *  Translate
    895      */
    896     private final String _(String s) {
    897         return Translate.getString(s, _context, BUNDLE_NAME);
    898     }
    899 
    900892    /**
    901893     * Cache the bid to reduce object churn
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r554a3a6 r90cc71d  
    4545import net.i2p.util.SimpleTimer;
    4646import net.i2p.util.SimpleTimer2;
    47 import net.i2p.util.Translate;
    4847
    4948/**
     
    24152414       
    24162415//        buf.append("<tr><td colspan=\"16\"><hr></td></tr>\n");
    2417         buf.append("<tr class=\"tablefooter\"><td colspan=\"3\" align=\"left\"><b>").append(_("SUMMARY")).append("</b></td>" +
     2416        buf.append("<tr class=\"tablefooter\"><td colspan=\"3\" align=\"left\"><b>")
     2417           .append(ngettext("{0} peer", "{0} peers", peers.size()))
     2418           .append("</b></td>" +
    24182419                   "<td align=\"center\" nowrap><b>");
    24192420        buf.append(formatKBps(bpsIn)).append(THINSP).append(formatKBps(bpsOut));
     
    24752476    }
    24762477    private static final DecimalFormat _pctFmt = new DecimalFormat("#0.0%");
    2477     private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
    2478 
    2479     /**
    2480      *  Translate
    2481      */
    2482     private final String _(String s) {
    2483         return Translate.getString(s, _context, BUNDLE_NAME);
    2484     }
    2485 
    2486     /**
    2487      *  Translate
    2488      */
    2489     private final String _(String s, Object o) {
    2490         return Translate.getString(s, o, _context, BUNDLE_NAME);
    2491     }
    24922478
    24932479    /*
  • tests/scripts/checkpo.sh

    r554a3a6 r90cc71d  
    1111DIRS="\
    1212  apps/routerconsole/locale \
     13  apps/routerconsole/locale-news \
    1314  apps/i2ptunnel/locale \
     15  apps/i2ptunnel/locale-proxy \
    1416  apps/i2psnark/locale \
    1517  apps/susidns/locale \
Note: See TracChangeset for help on using the changeset viewer.