Changeset 88ea451


Ignore:
Timestamp:
Dec 5, 2013 4:07:32 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d87d4eb
Parents:
822ec4a (diff), 7b0b079 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

propagate from branch 'i2p.i2p' (head 2634e424f06e58231c47f1ec318e9ae21c94a8b3)

to branch 'i2p.i2p.zzz.test2' (head 68ca880caf69a06c0fd01fc70675df795aef1de2)

Files:
25 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java

    r822ec4a r88ea451  
    113113     *  '=' in announceURL must be escaped as &#44;
    114114     */
    115     public static final String DEFAULT_TRACKERS[] = {
     115    private static final String DEFAULT_TRACKERS[] = {
    116116//       "Postman", "http://YRgrgTLGnbTq2aZOZDJQ~o6Uk5k6TK-OZtx0St9pb0G-5EGYURZioxqYG8AQt~LgyyI~NCj6aYWpPO-150RcEvsfgXLR~CxkkZcVpgt6pns8SRc3Bi-QSAkXpJtloapRGcQfzTtwllokbdC-aMGpeDOjYLd8b5V9Im8wdCHYy7LRFxhEtGb~RL55DA8aYOgEXcTpr6RPPywbV~Qf3q5UK55el6Kex-6VCxreUnPEe4hmTAbqZNR7Fm0hpCiHKGoToRcygafpFqDw5frLXToYiqs9d4liyVB-BcOb0ihORbo0nS3CLmAwZGvdAP8BZ7cIYE3Z9IU9D1G8JCMxWarfKX1pix~6pIA-sp1gKlL1HhYhPMxwyxvuSqx34o3BqU7vdTYwWiLpGM~zU1~j9rHL7x60pVuYaXcFQDR4-QVy26b6Pt6BlAZoFmHhPcAuWfu-SFhjyZYsqzmEmHeYdAwa~HojSbofg0TMUgESRXMw6YThK1KXWeeJVeztGTz25sL8AAAA.i2p/announce.php=http://tracker.postman.i2p/"
    117117//       , "eBook", "http://E71FRom6PZNEqTN2Lr8P-sr23b7HJVC32KoGnVQjaX6zJiXwhJy2HsXob36Qmj81TYFZdewFZa9mSJ533UZgGyQkXo2ahctg82JKYZfDe5uDxAn1E9YPjxZCWJaFJh0S~UwSs~9AZ7UcauSJIoNtpxrtbmRNVFLqnkEDdLZi26TeucfOmiFmIWnVblLniWv3tG1boE9Abd-6j3FmYVrRucYuepAILYt6katmVNOk6sXmno1Eynrp~~MBuFq0Ko6~jsc2E2CRVYXDhGHEMdt-j6JUz5D7S2RIVzDRqQyAZLKJ7OdQDmI31przzmne1vOqqqLC~1xUumZVIvF~yOeJUGNjJ1Vx0J8i2BQIusn1pQJ6UCB~ZtZZLQtEb8EPVCfpeRi2ri1M5CyOuxN0V5ekmPHrYIBNevuTCRC26NP7ZS5VDgx1~NaC3A-CzJAE6f1QXi0wMI9aywNG5KGzOPifcsih8eyGyytvgLtrZtV7ykzYpPCS-rDfITncpn5hliPUAAAA.i2p/pub/bt/announce.php=http://de-ebook-archiv.i2p/pub/bt/"
     
    130130    };
    131131   
     132    public static final Set<String> DEFAULT_TRACKER_ANNOUNCES;
     133
     134    static {
     135        Set<String> ann = new HashSet();
     136        for (int i = 1; i < DEFAULT_TRACKERS.length; i += 2) {
     137            String urls[] = DEFAULT_TRACKERS[i].split("=", 2);
     138            ann.add(urls[0]);
     139        }
     140        DEFAULT_TRACKER_ANNOUNCES = Collections.unmodifiableSet(ann);
     141    }
     142
    132143    /** comma delimited list of name=announceURL=baseURL for the trackers to be displayed */
    133144    public static final String PROP_TRACKERS = "i2psnark.trackers";
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r822ec4a r88ea451  
    20082008                buf.append(" checked=\"checked\"");
    20092009            } else {
    2010                 for (int i = 1; i < SnarkManager.DEFAULT_TRACKERS.length; i += 2) {
    2011                     if (SnarkManager.DEFAULT_TRACKERS[i].contains(t.announceURL)) {
    2012                         buf.append(" disabled=\"disabled\"");
    2013                         break;
    2014                     }
    2015                 }
     2010                if (SnarkManager.DEFAULT_TRACKER_ANNOUNCES.contains(t.announceURL))
     2011                    buf.append(" disabled=\"disabled\"");
    20162012            }
    20172013            buf.append(">" +
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java

    r822ec4a r88ea451  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    5 
    61package net.i2p.i2ptunnel.udp;
    72
    8 // i2p
    93import net.i2p.client.I2PSession;
    104import net.i2p.client.I2PSessionException;
     
    2014 */
    2115public class I2PSink implements Sink {
     16
    2217    public I2PSink(I2PSession sess, Destination dest) {
    2318        this(sess, dest, false);
    2419    }
     20
    2521    public I2PSink(I2PSession sess, Destination dest, boolean raw) {
    2622        this.sess = sess;
     
    2925       
    3026        // create maker
    31         if (!raw)
     27        if (raw) {
     28            this.maker = null;
     29        } else {
     30            this.maker = new I2PDatagramMaker();
    3231            this.maker.setI2PDatagramMaker(this.sess);
     32        }
    3333    }
    3434   
     
    4747        // send message
    4848        try {
    49             this.sess.sendMessage(this.dest, payload, I2PSession.PROTO_DATAGRAM,
     49            this.sess.sendMessage(this.dest, payload,
     50                                  (this.raw ? I2PSession.PROTO_DATAGRAM_RAW : I2PSession.PROTO_DATAGRAM),
    5051                                  I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
    5152        } catch(I2PSessionException exc) {
     
    5556    }
    5657   
    57     protected boolean raw;
    58     protected I2PSession sess;
    59     protected Destination dest;
    60     protected final I2PDatagramMaker maker= new I2PDatagramMaker(); // FIXME should be final and use a factory. FIXME
     58    protected final boolean raw;
     59    protected final I2PSession sess;
     60    protected final Destination dest;
     61    protected final I2PDatagramMaker maker;
    6162}
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java

    r822ec4a r88ea451  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    5 
    61package net.i2p.i2ptunnel.udp;
    72
    8 // i2p
    93import net.i2p.client.I2PSession;
    104import net.i2p.client.I2PSessionException;
     
    2014 */
    2115public class I2PSinkAnywhere implements Sink {
     16
    2217    public I2PSinkAnywhere(I2PSession sess) {
    2318        this(sess, false);
    2419    }
     20
    2521    public I2PSinkAnywhere(I2PSession sess, boolean raw) {
    2622        this.sess = sess;
     
    2824       
    2925        // create maker
    30         if (!raw)
     26        if (raw) {
     27            this.maker = null;
     28        } else {
     29            this.maker = new I2PDatagramMaker();
    3130            this.maker.setI2PDatagramMaker(this.sess);
     31        }
    3232    }
    3333   
     
    4545        // send message
    4646        try {
    47             this.sess.sendMessage(to, payload, I2PSession.PROTO_DATAGRAM,
     47            this.sess.sendMessage(to, payload,
     48                                  (this.raw ? I2PSession.PROTO_DATAGRAM_RAW : I2PSession.PROTO_DATAGRAM),
    4849                                  I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
    4950        } catch(I2PSessionException exc) {
     
    5354    }
    5455   
    55     protected boolean raw;
    56     protected I2PSession sess;
    57     protected Destination dest;
    58     protected final I2PDatagramMaker maker = new I2PDatagramMaker();
     56    protected final boolean raw;
     57    protected final I2PSession sess;
     58    protected final I2PDatagramMaker maker;
    5959}
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSource.java

    r822ec4a r88ea451  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    5 
    61package net.i2p.i2ptunnel.udp;
    72
    8 // system
    93import java.util.concurrent.ArrayBlockingQueue;
    104import java.util.concurrent.BlockingQueue;
    115
    12 // i2p
    136import net.i2p.client.I2PSession;
    147import net.i2p.client.I2PSessionListener;
     
    2013 */
    2114public class I2PSource implements Source, Runnable {
     15
    2216    public I2PSource(I2PSession sess) {
    2317        this(sess, true, false);
    2418    }
     19
    2520    public I2PSource(I2PSession sess, boolean verify) {
    2621        this(sess, verify, false);
    2722    }
     23
    2824    public I2PSource(I2PSession sess, boolean verify, boolean raw) {
    2925        this.sess = sess;
    30         this.sink = null;
    3126        this.verify = verify;
    3227        this.raw = raw;
     
    8176    }
    8277   
    83    
    84    
    85    
    86    
    87    
    8878    protected class Listener implements I2PSessionListener {
    8979
     
    110100    }
    111101   
    112    
    113    
    114    
    115    
    116    
    117     protected I2PSession sess;
    118     protected BlockingQueue<Integer> queue;
     102    protected final I2PSession sess;
     103    protected final BlockingQueue<Integer> queue;
    119104    protected Sink sink;
    120     protected Thread thread;
    121     protected boolean verify;
    122     protected boolean raw;
     105    protected final Thread thread;
     106    protected final boolean verify;
     107    protected final boolean raw;
    123108}
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/Sink.java

    r822ec4a r88ea451  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    5 
    61package net.i2p.i2ptunnel.udp;
    72
    8 // i2p
    93import net.i2p.data.Destination;
    104
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/Source.java

    r822ec4a r88ea451  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    5 
    61package net.i2p.i2ptunnel.udp;
    72
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/Stream.java

    r822ec4a r88ea451  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    5 
    61package net.i2p.i2ptunnel.udp;
    72
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/UDPSink.java

    r822ec4a r88ea451  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    5 
    61package net.i2p.i2ptunnel.udp;
    72
    8 // system
    93import java.net.DatagramSocket;
    104import java.net.DatagramPacket;
    115import java.net.InetAddress;
    126
    13 // i2p
    147import net.i2p.data.Destination;
    158
     
    1912 */
    2013public class UDPSink implements Sink {
     14
    2115    public UDPSink(InetAddress host, int port) {
    2216        // create socket
     
    6256    }   
    6357   
    64    
    65    
    66    
    67    
    68    
    69    
    70    
    71    
    72    
    73     protected DatagramSocket sock;
    74     protected InetAddress remoteHost;
    75     protected int remotePort;
     58    protected final DatagramSocket sock;
     59    protected final InetAddress remoteHost;
     60    protected final int remotePort;
    7661
    7762}
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/UDPSource.java

    r822ec4a r88ea451  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    5 
    61package net.i2p.i2ptunnel.udp;
    72
    8 // system
    93import java.net.DatagramSocket;
    104import java.net.DatagramPacket;
     
    1610public class UDPSource implements Source, Runnable {
    1711    public static final int MAX_SIZE = 15360;
     12
    1813    public UDPSource(int port) {
    19         this.sink = null;
    20        
    2114        // create udp-socket
    2215        try {
     
    3225    /** use socket from UDPSink */
    3326    public UDPSource(DatagramSocket sock) {
    34         this.sink = null;
    3527        this.sock = sock;
    3628        this.thread = new Thread(this);
     
    7466    }   
    7567   
    76    
    77    
    78    
    79    
    80    
    81    
    82    
    83    
    84    
    85    
    86    
    87    
    88     protected DatagramSocket sock;
     68    protected final DatagramSocket sock;
    8969    protected Sink sink;
    90     protected Thread thread;
     70    protected final Thread thread;
    9171}
  • apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java

    r822ec4a r88ea451  
    11package net.i2p.router.web;
    22
     3import java.util.HashMap;
     4import java.util.Locale;
    35import java.util.Map;
    46import java.util.concurrent.ConcurrentHashMap;
     
    5052    }
    5153
    52     /** change default language for the router AND save it */
     54    /**
     55     * change default language for the router AND save it
     56     * @param lang xx OR xx_XX
     57     */
    5358    public void setLang(String lang) {
    5459        // Protected with nonce in css.jsi
    55         if (lang != null && lang.length() == 2 && !lang.equals(_context.getProperty(Messages.PROP_LANG))) {
    56             _context.router().saveConfig(Messages.PROP_LANG, lang);
     60        if (lang != null) {
     61            Map m = new HashMap(2);
     62            if (lang.length() == 2) {
     63                m.put(Messages.PROP_LANG, lang.toLowerCase(Locale.US));
     64                m.put(Messages.PROP_COUNTRY, "");
     65                _context.router().saveConfig(m, null);
     66            } else if (lang.length() == 5) {
     67                m.put(Messages.PROP_LANG, lang.substring(0, 2).toLowerCase(Locale.US));
     68                m.put(Messages.PROP_COUNTRY, lang.substring(3, 5).toUpperCase(Locale.US));
     69                _context.router().saveConfig(m, null);
     70            }
    5771        }
    5872    }
    5973
    60     /** needed for conditional css loads for zh */
     74    /**
     75     * needed for conditional css loads for zh
     76     * @return two-letter only, lower-case
     77     */
    6178    public String getLang() {
    6279        return Messages.getLanguage(_context);
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigUIHelper.java

    r822ec4a r88ea451  
    6666
    6767    /**
    68      *  Each language has the ISO code, the flag, and the name.
     68     *  Each language has the ISO code, the flag, the name, and the optional country name.
    6969     *  Alphabetical by the ISO code please.
    7070     *  See http://en.wikipedia.org/wiki/ISO_639-1 .
     
    7272     *  added to the top-level build.xml for the updater.
    7373     */
    74     private static final String langs[] = {"ar", "cs", "da", "de", "et", "el", "en", "es", "fi",
    75                                            "fr", "hu", "it", "ja", "nb", "nl", "pl", "pt", "ro", "ru",
    76                                            "sv", "tr", "uk", "vi", "zh"};
    77     private static final String flags[] = {"lang_ar", "cz", "dk", "de", "ee", "gr", "us", "es", "fi",
    78                                            "fr", "hu", "it", "jp", "nl", "no", "pl", "pt", "ro", "ru",
    79                                            "se", "tr", "ua", "vn", "cn"};
    80     private static final String xlangs[] = {_x("Arabic"), _x("Czech"), _x("Danish"),
    81                                             _x("German"), _x("Estonian"), _x("Greek"), _x("English"), _x("Spanish"), _x("Finnish"),
    82                                             _x("French"), _x("Hungarian"), _x("Italian"), _x("Japanese"), _x("Dutch"), _x("Norwegian Bokmaal"), _x("Polish"),
    83                                             _x("Portuguese"), _x("Romanian"), _x("Russian"), _x("Swedish"),
    84                                             _x("Turkish"), _x("Ukrainian"), _x("Vietnamese"), _x("Chinese")};
     74    private static final String langs[][] = {
     75        { "ar", "lang_ar", _x("Arabic"), null },
     76        { "cs", "cz", _x("Czech"), null },
     77        { "da", "dk", _x("Danish"), null },
     78        { "de", "de", _x("German"), null },
     79        { "et", "ee", _x("Estonian"), null },
     80        { "el", "gr", _x("Greek"), null },
     81        { "en", "us", _x("English"), null },
     82        { "es", "es", _x("Spanish"), null },
     83        { "fi", "fi", _x("Finnish"), null },
     84        { "fr", "fr", _x("French"), null },
     85        { "hu", "hu", _x("Hungarian"), null },
     86        { "it", "it", _x("Italian"), null },
     87        { "ja", "jp", _x("Japanese"), null },
     88        { "nb", "nl", _x("Dutch"), null },
     89        { "nl", "no", _x("Norwewgian Bokmaal"), null },
     90        { "pl", "pl", _x("Polish"), null },
     91        { "pt", "pt", _x("Portuguese"), null },
     92     //   { "pt_BR", "br", _x("Portuguese"), "Brazil" },
     93        { "ro", "ro", _x("Romainian"), null },
     94        { "ru", "ru", _x("Russian"), null },
     95        { "sv", "se", _x("Swedish"), null },
     96        { "tr", "tr", _x("Turkish"), null },
     97        { "uk", "ua", _x("Ukrainian"), null },
     98        { "vi", "vn", _x("Vietnamese"), null },
     99        { "zh", "cn", _x("Chinese"), null }
     100    };
     101
     102
    85103
    86104    /** todo sort by translated string */
     
    88106        StringBuilder buf = new StringBuilder(512);
    89107        String current = Messages.getLanguage(_context);
     108        String country = Messages.getCountry(_context);
     109        if (country != null && country.length() > 0)
     110            current += '_' + country;
    90111        for (int i = 0; i < langs.length; i++) {
    91112            // we use "lang" so it is set automagically in CSSHelper
    92113            buf.append("<input type=\"radio\" class=\"optbox\" name=\"lang\" ");
    93             if (langs[i].equals(current))
     114            String lang = langs[i][0];
     115            if (lang.equals(current))
    94116                buf.append("checked=\"checked\" ");
    95             buf.append("value=\"").append(langs[i]).append("\">")
    96                .append("<img height=\"11\" width=\"16\" alt=\"\" src=\"/flags.jsp?c=").append(flags[i]).append("\"> ")
    97                .append(Messages.getDisplayLanguage(langs[i], xlangs[i], _context)).append("<br>\n");
     117            buf.append("value=\"").append(lang).append("\">")
     118               .append("<img height=\"11\" width=\"16\" alt=\"\" src=\"/flags.jsp?c=").append(langs[i][1]).append("\"> ");
     119            String slang = lang.length() > 2 ? lang.substring(0, 2) : lang;
     120            buf.append(Messages.getDisplayLanguage(slang, langs[i][2], _context));
     121            String name = langs[i][3];
     122            if (name != null) {
     123                buf.append(" (")
     124                   .append(Messages.getString(name, _context, Messages.COUNTRY_BUNDLE_NAME))
     125                   .append(')');
     126            }
     127            buf.append("<br>\n");
    98128        }
    99129        return buf.toString();
  • apps/routerconsole/java/src/net/i2p/router/web/Messages.java

    r822ec4a r88ea451  
    99public class Messages extends Translate {
    1010    private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
     11
     12    static final String COUNTRY_BUNDLE_NAME = "net.i2p.router.countries.messages";
    1113
    1214    /** lang in routerconsole.lang property, else current locale */
  • apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java

    r822ec4a r88ea451  
    351351    }
    352352   
    353     private static final String COUNTRY_BUNDLE_NAME = "net.i2p.router.countries.messages";
    354 
    355353    /**
    356354     * Countries now in a separate bundle
     
    360358    private String getTranslatedCountry(String code) {
    361359        String name = _context.commSystem().getCountryName(code);
    362         return Translate.getString(name, _context, COUNTRY_BUNDLE_NAME);
     360        return Translate.getString(name, _context, Messages.COUNTRY_BUNDLE_NAME);
    363361    }
    364362
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java

    r822ec4a r88ea451  
    253253           .append("</a>\n");
    254254
     255        if (_context.getBooleanProperty(HelperBase.PROP_ADVANCED))
     256            buf.append("<a href=\"/debug\">Debug</a>\n");
    255257        File javadoc = new File(_context.getBaseDir(), "docs/javadoc/index.html");
    256258        if (javadoc.exists())
  • core/java/src/net/i2p/crypto/DummyDSAEngine.java

    r822ec4a r88ea451  
    1111 */
    1212public class DummyDSAEngine extends DSAEngine {
     13
     14    private static final Signature FAKE_SIGNATURE = new Signature(new byte[Signature.SIGNATURE_BYTES]);
     15
    1316    public DummyDSAEngine(I2PAppContext context) {
    1417        super(context);
     
    2225    @Override
    2326    public Signature sign(byte data[], SigningPrivateKey signingKey) {
    24         Signature sig = new Signature();
    25         sig.setData(Signature.FAKE_SIGNATURE);
    26         return sig;
     27        return FAKE_SIGNATURE;
    2728    }
    2829}
  • core/java/src/net/i2p/data/DataHelper.java

    r822ec4a r88ea451  
    400400     * - '=' is the only key-termination character (not ':' or whitespace)
    401401     *
     402     * As of 0.9.10, an empty value is allowed.
    402403     */
    403404    public static void loadProps(Properties props, File file) throws IOException {
     
    443444                //val = val.replaceAll("\\\\r","\r");
    444445                //val = val.replaceAll("\\\\n","\n");
    445                 if ( (key.length() > 0) && (val.length() > 0) )
    446                     if (forceLowerCase)
    447                         props.setProperty(key.toLowerCase(Locale.US), val);
    448                     else
    449                         props.setProperty(key, val);
     446
     447                // as of 0.9.10, an empty value is allowed
     448                if (forceLowerCase)
     449                    props.setProperty(key.toLowerCase(Locale.US), val);
     450                else
     451                    props.setProperty(key, val);
    450452            }
    451453        } finally {
  • core/java/src/net/i2p/data/Signature.java

    r822ec4a r88ea451  
    2626    /** 40 */
    2727    public final static int SIGNATURE_BYTES = DEF_TYPE.getSigLen();
    28     /** all zeros */
     28
     29    /**
     30     * all zeros
     31     * @deprecated to be removed
     32     */
    2933    public final static byte[] FAKE_SIGNATURE = new byte[SIGNATURE_BYTES];
    3034
  • core/java/src/net/i2p/util/Translate.java

    r822ec4a r88ea451  
    2626public abstract class Translate {
    2727    public static final String PROP_LANG = "routerconsole.lang";
     28    /** @since 0.9.10 */
     29    public static final String PROP_COUNTRY = "routerconsole.country";
     30    /** non-null, two-letter lower case, may be "" */
    2831    private static final String _localeLang = Locale.getDefault().getLanguage();
     32    /** non-null, two-letter upper case, may be "" */
     33    private static final String _localeCountry = Locale.getDefault().getCountry();
    2934    private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap<String, ResourceBundle>(16);
    3035    private static final Set<String> _missing = new ConcurrentHashSet<String>(16);
     
    4348        if (key.equals(""))
    4449            return key;
    45         ResourceBundle bundle = findBundle(bun, lang);
     50        ResourceBundle bundle = findBundle(bun, lang, getCountry(ctx));
    4651        if (bundle == null)
    4752            return key;
     
    111116        ResourceBundle bundle = null;
    112117        if (!lang.equals("en"))
    113             bundle = findBundle(bun, lang);
     118            bundle = findBundle(bun, lang, getCountry(ctx));
    114119        String x;
    115120        if (bundle == null)
     
    130135    }
    131136
    132     /** @return lang in routerconsole.lang property, else current locale */
     137    /**
     138     *  Two-letter lower case
     139     *  @return lang in routerconsole.lang property, else current locale
     140     */
    133141    public static String getLanguage(I2PAppContext ctx) {
    134142        String lang = ctx.getProperty(PROP_LANG);
     
    138146    }
    139147
    140     /** cache both found and not found for speed */
    141     private static ResourceBundle findBundle(String bun, String lang) {
    142         String key = bun + '-' + lang;
     148    /**
     149     *  Two-letter upper case or ""
     150     *  @return country in routerconsole.country property, else current locale
     151     *  @since 0.9.10
     152     */
     153    public static String getCountry(I2PAppContext ctx) {
     154        // property may be empty so we don't have a non-default
     155        // language and a default country
     156        return ctx.getProperty(PROP_COUNTRY, _localeCountry);
     157    }
     158
     159    /**
     160     * cache both found and not found for speed
     161     * @param lang non-null, if "" returns null
     162     * @param country non-null, may be ""
     163     * @return null if not found
     164     */
     165    private static ResourceBundle findBundle(String bun, String lang, String country) {
     166        String key = bun + '-' + lang + '-' + country;
    143167        ResourceBundle rv = _bundles.get(key);
    144168        if (rv == null && !_missing.contains(key)) {
     169            if ("".equals(lang)) {
     170                _missing.add(key);
     171                return null;
     172            }
    145173            try {
     174                Locale loc;
     175                if ("".equals(country))
     176                    loc = new Locale(lang);
     177                else
     178                    loc = new Locale(lang, country);
    146179                // We must specify the class loader so that a webapp can find the bundle in the .war
    147                 rv = ResourceBundle.getBundle(bun, new Locale(lang), Thread.currentThread().getContextClassLoader());
     180                rv = ResourceBundle.getBundle(bun, loc, Thread.currentThread().getContextClassLoader());
    148181                if (rv != null)
    149182                    _bundles.put(key, rv);
  • router/java/src/net/i2p/router/Router.java

    r822ec4a r88ea451  
    230230        // Check for other router but do not start a thread yet so the update doesn't cause
    231231        // a NCDFE
    232         if (!isOnlyRouterRunning()) {
    233             _eventLog.addEvent(EventLog.ABORTED, "Another router running");
    234             System.err.println("ERROR: There appears to be another router already running!");
    235             System.err.println("       Please make sure to shut down old instances before starting up");
    236             System.err.println("       a new one.  If you are positive that no other instance is running,");
    237             System.err.println("       please delete the file " + getPingFile().getAbsolutePath());
    238             System.exit(-1);
     232        for (int i = 0; i < 14; i++) {
     233            // Wrapper can start us up too quickly after a crash, the ping file
     234            // may still be less than LIVELINESS_DELAY (60s) old.
     235            // So wait at least 60s to be sure.
     236            if (isOnlyRouterRunning()) {
     237                if (i > 0)
     238                    System.err.println("INFO: No, there wasn't another router already running. Proceeding with startup.");
     239                break;
     240            }
     241            if (i < 13) {
     242                if (i == 0)
     243                    System.err.println("WARN: There may be another router already running. Waiting a while to be sure...");
     244                // yes this is ugly to sleep in the constructor.
     245                try { Thread.sleep(5000); } catch (InterruptedException ie) {}
     246            } else {
     247                _eventLog.addEvent(EventLog.ABORTED, "Another router running");
     248                System.err.println("ERROR: There appears to be another router already running!");
     249                System.err.println("       Please make sure to shut down old instances before starting up");
     250                System.err.println("       a new one.  If you are positive that no other instance is running,");
     251                System.err.println("       please delete the file " + getPingFile().getAbsolutePath());
     252                System.exit(-1);
     253            }
    239254        }
    240255
  • router/java/src/net/i2p/router/peermanager/PeerManager.java

    r822ec4a r88ea451  
    2626import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    2727import net.i2p.util.ConcurrentHashSet;
     28import net.i2p.util.I2PThread;
    2829import net.i2p.util.Log;
    2930import net.i2p.util.SimpleTimer2;
     
    9091        }
    9192        public void timeReached() {
     93            (new ReorgThread(this)).start();
     94        }
     95    }
     96
     97    /**
     98     *  This takes too long to run on the SimpleTimer2 queue
     99     *  @since 0.9.10
     100     */
     101    private class ReorgThread extends I2PThread {
     102        private SimpleTimer2.TimedEvent _event;
     103
     104        public ReorgThread(SimpleTimer2.TimedEvent event) {
     105            super("PeerManager Reorg");
     106            setDaemon(true);
     107            _event = event;
     108        }
     109
     110        public void run() {
    92111            long start = System.currentTimeMillis();
    93112            try {
     
    105124            else
    106125                delay = REORGANIZE_TIME;
    107             schedule(delay);
     126            _event.schedule(delay);
    108127        }
    109128    }
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    r822ec4a r88ea451  
    2727import net.i2p.router.util.EventLog;
    2828import net.i2p.util.Addresses;
     29import net.i2p.util.I2PThread;
    2930import net.i2p.util.Log;
    3031import net.i2p.util.SimpleTimer;
     
    224225    private static final int START_DELAY = 5*60*1000;
    225226    private static final int LOOKUP_TIME = 30*60*1000;
     227
    226228    private void startGeoIP() {
    227229        _context.simpleScheduler().addEvent(new QueueAll(), START_DELAY);
     
    249251    private class Lookup implements SimpleTimer.TimedEvent {
    250252        public void timeReached() {
     253            (new LookupThread()).start();
     254        }
     255    }
     256
     257    /**
     258     *  This takes too long to run on the SimpleTimer2 queue
     259     *  @since 0.9.10
     260     */
     261    private class LookupThread extends I2PThread {
     262
     263        public LookupThread() {
     264            super("GeoIP Lookup");
     265            setDaemon(true);
     266        }
     267
     268        public void run() {
     269            long start = System.currentTimeMillis();
    251270            _geoIP.blockingLookup();
     271            if (_log.shouldLog(Log.INFO))
     272                _log.info("GeoIP lookup took " + (System.currentTimeMillis() - start));
    252273        }
    253274    }
  • router/java/src/net/i2p/router/transport/ntcp/EventPumper.java

    r822ec4a r88ea451  
    212212
    213213                        // Increase allowed idle time if we are well under allowed connections, otherwise decrease
    214                         if (_transport.haveCapacity(60))
     214                        if (_transport.haveCapacity(45))
    215215                            _expireIdleWriteTime = Math.min(_expireIdleWriteTime + 1000, MAX_EXPIRE_IDLE_TIME);
    216216                        else
  • router/java/src/net/i2p/router/transport/udp/PeerState.java

    r822ec4a r88ea451  
    1212import java.util.Queue;
    1313import java.util.concurrent.LinkedBlockingQueue;
     14import java.util.concurrent.atomic.AtomicInteger;
    1415
    1516import net.i2p.data.Hash;
     
    120121    //private boolean _remoteWantsPreviousACKs;
    121122    /** how many bytes should we send to the peer in a second */
    122     private volatile int _sendWindowBytes;
     123    private int _sendWindowBytes;
    123124    /** how many bytes can we send to the peer in the current second */
    124     private volatile int _sendWindowBytesRemaining;
     125    private int _sendWindowBytesRemaining;
    125126    private long _lastSendRefill;
    126127    private int _sendBps;
     
    226227    private static final int MIN_CONCURRENT_MSGS = 8;
    227228    /** how many concurrent outbound messages do we allow throws OutboundMessageFragments to send */
    228     private volatile int _concurrentMessagesAllowed = MIN_CONCURRENT_MSGS;
     229    private int _concurrentMessagesAllowed = MIN_CONCURRENT_MSGS;
    229230    /**
    230231     * how many outbound messages are currently being transmitted.  Not thread safe, as we're not strict
    231232     */
    232     private volatile int _concurrentMessagesActive = 0;
     233    private int _concurrentMessagesActive;
    233234    /** how many concurrency rejections have we had in a row */
    234     private volatile int _consecutiveRejections = 0;
     235    private int _consecutiveRejections;
    235236    /** is it inbound? **/
    236237    private final boolean _isInbound;
     
    437438
    438439    /** how many bytes should we send to the peer in a second */
    439     public int getSendWindowBytes() { return _sendWindowBytes; }
     440    public int getSendWindowBytes() {
     441        synchronized(_outboundMessages) {
     442            return _sendWindowBytes;
     443        }
     444    }
     445
    440446    /** how many bytes can we send to the peer in the current second */
    441     public int getSendWindowBytesRemaining() { return _sendWindowBytesRemaining; }
     447    public int getSendWindowBytesRemaining() {
     448        synchronized(_outboundMessages) {
     449            return _sendWindowBytesRemaining;
     450        }
     451    }
     452
    442453    /** what IP is the peer sending and receiving packets on? */
    443454    public byte[] getRemoteIP() { return _remoteIP; }
     
    581592    public int getSendBps() { return _sendBps; }
    582593    public int getReceiveBps() { return _receiveBps; }
     594
    583595    public int incrementConsecutiveFailedSends() {
    584         _concurrentMessagesActive--;
    585         if (_concurrentMessagesActive < 0)
    586             _concurrentMessagesActive = 0;
    587        
    588         //long now = _context.clock().now()/(10*1000);
    589         //if (_lastFailedSendPeriod >= now) {
    590         //    // ignore... too fast
    591         //} else {
    592         //    _lastFailedSendPeriod = now;
    593             _consecutiveFailedSends++;
    594         //}
    595         return _consecutiveFailedSends;
    596     }
     596        synchronized(_outboundMessages) {
     597            _concurrentMessagesActive--;
     598            if (_concurrentMessagesActive < 0)
     599                _concurrentMessagesActive = 0;
     600           
     601            //long now = _context.clock().now()/(10*1000);
     602            //if (_lastFailedSendPeriod >= now) {
     603            //    // ignore... too fast
     604            //} else {
     605            //    _lastFailedSendPeriod = now;
     606                _consecutiveFailedSends++;
     607            //}
     608            return _consecutiveFailedSends;
     609        }
     610    }
     611
    597612    public long getInactivityTime() {
    598613        long now = _context.clock().now();
     
    621636     * cannot.  If it is not decremented, the window size remaining is
    622637     * not adjusted at all.
    623      */
    624     public boolean allocateSendingBytes(int size, int messagePushCount) { return allocateSendingBytes(size, false, messagePushCount); }
    625 
    626     public boolean allocateSendingBytes(int size, boolean isForACK) { return allocateSendingBytes(size, isForACK, -1); }
    627 
    628     /**
     638     *
    629639     *  Caller should synch
    630640     */
    631     public boolean allocateSendingBytes(int size, boolean isForACK, int messagePushCount) {
     641    private boolean allocateSendingBytes(int size, int messagePushCount) { return allocateSendingBytes(size, false, messagePushCount); }
     642
     643    //private boolean allocateSendingBytes(int size, boolean isForACK) { return allocateSendingBytes(size, isForACK, -1); }
     644
     645    /**
     646     *  Caller should synch
     647     */
     648    private boolean allocateSendingBytes(int size, boolean isForACK, int messagePushCount) {
    632649        long now = _context.clock().now();
    633650        long duration = now - _lastSendRefill;
     
    695712
    696713    public int getSlowStartThreshold() { return _slowStartThreshold; }
    697     public int getConcurrentSends() { return _concurrentMessagesActive; }
    698     public int getConcurrentSendWindow() { return _concurrentMessagesAllowed; }
    699     public int getConsecutiveSendRejections() { return _consecutiveRejections; }
     714
     715    public int getConcurrentSends() {
     716        synchronized(_outboundMessages) {
     717            return _concurrentMessagesActive;
     718        }
     719    }
     720
     721    public int getConcurrentSendWindow() {
     722        synchronized(_outboundMessages) {
     723            return _concurrentMessagesAllowed;
     724        }
     725    }
     726
     727    public int getConsecutiveSendRejections() {
     728        synchronized(_outboundMessages) {
     729            return _consecutiveRejections;
     730        }
     731    }
     732
    700733    public boolean isInbound() { return _isInbound; }
    701734
     
    16751708     *  Have 3 return values, because if allocateSendingBytes() returns false,
    16761709     *  then allocateSend() can stop iterating
     1710     *
     1711     *  Caller should synch
    16771712     */
    16781713    private ShouldSend locked_shouldSend(OutboundMessageState state) {
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r822ec4a r88ea451  
    28492849        public void timeReached() {
    28502850            // Increase allowed idle time if we are well under allowed connections, otherwise decrease
    2851             if (haveCapacity(60)) {
     2851            if (haveCapacity(45)) {
    28522852                long inc;
    28532853                // don't adjust too quickly if we are looping fast
Note: See TracChangeset for help on using the changeset viewer.