Changeset 5041d819


Ignore:
Timestamp:
Aug 21, 2014 11:27:34 PM (6 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
a1cb00b
Parents:
a12f898 (diff), 02ab6ea (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 b026fe071e77884ef6d104635c793ef16357ec71)

to branch 'i2p.i2p.str4d.eddsa' (head 0d928736c4a34d8a337e1f55e095fe90564ea1fb)

Files:
1 added
21 edited

Legend:

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

    ra12f898 r5041d819  
    7575  private static final int DEFAULT_PIECE_SIZE = 256*1024;
    7676  /** bigger than this will be rejected */
    77   public static final int MAX_PIECE_SIZE = 4*1024*1024;
     77  public static final int MAX_PIECE_SIZE = 8*1024*1024;
    7878  /** The maximum number of pieces in a torrent. */
    7979  public static final int MAX_PIECES = 10*1024;
     
    602602   * Just does an existence check but no length check or data reverification
    603603   *
    604    * @param rootDir ignored
    605604   * @throws IOE on fail
    606605   */
  • apps/i2psnark/java/src/org/klomp/snark/web/URIUtil.java

    ra12f898 r5041d819  
    5757       
    5858    /** Encode a URI path.
     59     *
     60     *  Somewhat oddly, this encodes all chars >= 0x80 if buf is null, (strict RFC 2396)
     61     *  but only the control, space, and special chars if buf is non-null.
     62     *
    5963     * @param path The path the encode
    6064     * @param buf StringBuilder to encode path into (or null)
     
    8488                        break loop;
    8589                    default:
    86                         if (c>127)
     90                        if (c >= 0x7f || c <= 0x1f)
    8791                        {
    8892                            bytes = DataHelper.getUTF8(path);
     
    133137                          buf.append("%20");
    134138                          continue;
     139                      case 0x7f:
     140                          buf.append("%7F");
     141                          continue;
    135142                      default:
    136                           if (c<0)
    137                           {
    138                               buf.append('%');
     143                          if (c <= 0x1f) // includes negative
    139144                              toHex(c,buf);
    140                           }
    141145                          else
    142146                              buf.append((char)c);
     
    181185                            continue;
    182186                        default:
    183                             buf.append(c);
     187                            if (c <= 0x1f || (c >= 0x7f && c <= 0x9f) || Character.isSpaceChar(c))
     188                                toHex(c,buf);
     189                            else
     190                              buf.append(c);
    184191                            continue;
    185192                    }
     
    196203    private static void toHex(byte b, StringBuilder buf)
    197204    {
     205            buf.append('%');
    198206            int d=0xf&((0xF0&b)>>4);
    199207            buf.append((char)((d>9?('A'-10):'0')+d));
     
    201209            buf.append((char)((d>9?('A'-10):'0')+d));
    202210    }
     211   
     212    /**
     213     *  UTF-8
     214     */
     215    private static void toHex(char c, StringBuilder buf)
     216    {
     217            if (c > 0x7f) {
     218                byte[] b = DataHelper.getUTF8(Character.toString(c));
     219                for (int i = 0; i < b.length; i++) {
     220                    toHex(b[i], buf);
     221                }
     222            } else {
     223                toHex((byte) c, buf);
     224            }
     225    }
    203226}
    204227
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java

    ra12f898 r5041d819  
    2525import java.util.concurrent.atomic.AtomicLong;
    2626
     27import javax.net.ssl.SSLServerSocketFactory;
     28
    2729import net.i2p.I2PAppContext;
    2830import net.i2p.I2PException;
     
    8688    private static int _executorThreadCount;
    8789    private static final Object _executorLock = new Object();
     90
     91    public static final String PROP_USE_SSL = I2PTunnelServer.PROP_USE_SSL;
    8892
    8993    /**
     
    600604                return;
    601605            }
    602             ss = new ServerSocket(localPort, 0, addr);
     606            Properties opts = getTunnel().getClientOptions();
     607            boolean useSSL = Boolean.parseBoolean(opts.getProperty(PROP_USE_SSL));
     608            if (useSSL) {
     609                // was already done in web/IndexBean.java when saving the config
     610                boolean wasCreated = SSLClientUtil.verifyKeyStore(opts);
     611                if (wasCreated) {
     612                    // From here, we can't save the config.
     613                    // We shouldn't get here, as SSL isn't the default, so it would
     614                    // be enabled via the GUI only.
     615                    // If it was done manually, the keys will be regenerated at every startup,
     616                    // which is bad.
     617                    _log.logAlways(Log.WARN, "Created new i2ptunnel SSL keys but can't save the config, disable and enable via i2ptunnel GUI");
     618                }
     619                SSLServerSocketFactory fact = SSLClientUtil.initializeFactory(opts);
     620                ss = fact.createServerSocket(localPort, 0, addr);
     621            } else {
     622                ss = new ServerSocket(localPort, 0, addr);
     623            }
    603624
    604625            // If a free port was requested, find out what we got
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java

    ra12f898 r5041d819  
    22
    33import net.i2p.i2ptunnel.udp.*;
     4import net.i2p.util.I2PAppThread;
    45
    56/**
     
    1011
    1112    public Pinger() {
    12         this.thread = new Thread(this);
     13        this.thread = new I2PAppThread(this);
    1314    }
    1415
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSource.java

    ra12f898 r5041d819  
    77import net.i2p.client.I2PSessionListener;
    88import net.i2p.client.datagram.I2PDatagramDissector;
     9import net.i2p.util.I2PAppThread;
    910
    1011/**
     
    3435       
    3536        // create thread
    36         this.thread = new Thread(this);
     37        this.thread = new I2PAppThread(this);
    3738    }
    3839   
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/UDPSource.java

    ra12f898 r5041d819  
    33import java.net.DatagramSocket;
    44import java.net.DatagramPacket;
     5
     6import net.i2p.util.I2PAppThread;
    57
    68/**
     
    2022       
    2123        // create thread
    22         this.thread = new Thread(this);
     24        this.thread = new I2PAppThread(this);
    2325    }
    2426
     
    2628    public UDPSource(DatagramSocket sock) {
    2729        this.sock = sock;
    28         this.thread = new Thread(this);
     30        this.thread = new I2PAppThread(this);
    2931    }
    3032   
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java

    ra12f898 r5041d819  
    2727import net.i2p.client.I2PClient;
    2828import net.i2p.data.Certificate;
     29import net.i2p.data.DataHelper;
    2930import net.i2p.data.Destination;
    3031import net.i2p.data.PrivateKeyFile;
    3132import net.i2p.data.SessionKey;
     33import net.i2p.i2ptunnel.I2PTunnelClientBase;
    3234import net.i2p.i2ptunnel.I2PTunnelConnectClient;
    3335import net.i2p.i2ptunnel.I2PTunnelHTTPClient;
     
    3638import net.i2p.i2ptunnel.I2PTunnelIRCClient;
    3739import net.i2p.i2ptunnel.I2PTunnelServer;
     40import net.i2p.i2ptunnel.SSLClientUtil;
    3841import net.i2p.i2ptunnel.TunnelController;
    3942import net.i2p.i2ptunnel.TunnelControllerGroup;
     
    256259        try { Thread.sleep(1000); } catch (InterruptedException ie) {}
    257260        // and give them something to look at in any case
    258         return _("Starting tunnel") + ' ' + getTunnelName(_tunnel) + "&hellip;";
     261        return _("Starting tunnel") + ' ' + getTunnelName(_tunnel) + "...";
    259262    }
    260263   
     
    269272        try { Thread.sleep(1000); } catch (InterruptedException ie) {}
    270273        // and give them something to look at in any case
    271         return _("Stopping tunnel") + ' ' + getTunnelName(_tunnel) + "&hellip;";
     274        return _("Stopping tunnel") + ' ' + getTunnelName(_tunnel) + "...";
    272275    }
    273276   
     
    277280       
    278281        Properties config = getConfig();
    279        
     282
     283        String ksMsg = null;
     284        String type = config.getProperty(TunnelController.PROP_TYPE);
     285        if (TunnelController.TYPE_STD_CLIENT.equals(type) || TunnelController.TYPE_IRC_CLIENT.equals(type)) {
     286            //
     287            // If we switch to SSL, create the keystore here, so we can store the new properties.
     288            // Down in I2PTunnelClientBase it's very hard to save the config.
     289            //
     290            if (Boolean.parseBoolean(config.getProperty(OPT + I2PTunnelClientBase.PROP_USE_SSL))) {
     291                try {
     292                    boolean created = SSLClientUtil.verifyKeyStore(config, OPT);
     293                    if (created) {
     294                        // config now contains new keystore props
     295                        ksMsg = "Created new self-signed certificate for tunnel " + getTunnelName(_tunnel);
     296                    }       
     297                } catch (IOException ioe) {       
     298                    ksMsg = "Failed to create new self-signed certificate for tunnel " +
     299                            getTunnelName(_tunnel) + ", check logs: " + ioe;
     300                }       
     301            }       
     302        }       
    280303        if (cur == null) {
    281304            // creating new
     
    328351       
    329352        List<String> msgs = doSave();
     353        if (ksMsg != null)
     354            msgs.add(ksMsg);
    330355        return getMessages(msgs);
    331356    }
     
    398423     * messages.
    399424     *
     425     * @return HTML escaped
    400426     */
    401427    public String getMessages() {
     
    406432        if (_action != null) {
    407433            try {
    408                 buf.append(processAction()).append("\n");
     434                buf.append(processAction()).append('\n');
    409435            } catch (Exception e) {
    410436                _log.log(Log.CRIT, "Error processing " + _action, e);
     437                buf.append("Error: ").append(e.toString()).append('\n');
    411438            }
    412439        }
    413440        getMessages(_group.clearAllMessages(), buf);
    414         return buf.toString();
     441        return DataHelper.escapeHTML(buf.toString());
    415442    }
    416443   
     
    12941321        };
    12951322    private static final String _booleanClientOpts[] = {
    1296         "i2cp.reduceOnIdle", "i2cp.closeOnIdle", "i2cp.newDestOnResume", "persistentClientKey", "i2cp.delayOpen"
     1323        "i2cp.reduceOnIdle", "i2cp.closeOnIdle", "i2cp.newDestOnResume", "persistentClientKey", "i2cp.delayOpen",
     1324        I2PTunnelClientBase.PROP_USE_SSL,
    12971325        };
    12981326    private static final String _booleanProxyOpts[] = {
  • apps/i2ptunnel/jsp/editClient.jsp

    ra12f898 r5041d819  
    141141         <% } /* streamrclient */ %>
    142142            </div>
     143         <% if ("client".equals(tunnelType) || "ircclient".equals(tunnelType)) {
     144          %><div id="portField" class="rowItem">
     145                <label>
     146                    <%=intl._("Use SSL?")%>
     147                </label>
     148                <input value="1" type="checkbox" id="startOnLoad" name="useSSL" title="Clients use SSL to connect" <%=(editBean.isSSLEnabled(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />               
     149            </div>
     150         <% } /* tunnel types */ %>
    143151
    144152            <div class="subdivider">
  • apps/i2ptunnel/jsp/index.jsp

    ra12f898 r5041d819  
    245245               String cPort= indexBean.getClientPort2(curClient);
    246246               out.write(cPort);
     247               if (indexBean.isSSLEnabled(curClient))
     248                   out.write(" SSL");
    247249          %>
    248250            </span>
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java

    ra12f898 r5041d819  
    2626public class I2PSocketManagerFactory {
    2727
     28    /**
     29     *  Ignored since 0.9.12, cannot be changed via properties.
     30     *  @deprecated
     31     */
    2832    public static final String PROP_MANAGER = "i2p.streaming.manager";
     33
     34    /**
     35     *  The one and only manager.
     36     */
    2937    public static final String DEFAULT_MANAGER = "net.i2p.client.streaming.impl.I2PSocketManagerFull";
    3038
  • core/java/src/net/i2p/data/DataHelper.java

    ra12f898 r5041d819  
    16301630    }
    16311631
    1632     private static final String escapeChars[] = {"&", "\"", "<", ">", "\"", "'"};
    1633     private static final String escapeCodes[] = {"&amp;", "&quot;", "&lt;", "&gt;", "&quot;", "&apos;"};
     1632    private static final String escapeChars[] = {"&", "\"", "<", ">", "'"};
     1633    private static final String escapeCodes[] = {"&amp;", "&quot;", "&lt;", "&gt;", "&apos;"};
    16341634
    16351635    /**
  • core/java/src/net/i2p/util/Clock.java

    ra12f898 r5041d819  
    9898           
    9999            if (!_statCreated) {
    100                 _context.statManager().createRequiredRateStat("clock.skew", "Clock step adjustment (ms)", "Clock", new long[] { 10*60*1000, 3*60*60*1000, 24*60*60*60 });
     100                _context.statManager().createRequiredRateStat("clock.skew", "Clock step adjustment (ms)", "Clock", new long[] { 10*60*1000, 3*60*60*1000, 24*60*60*1000 });
    101101                _statCreated = true;
    102102            }
  • history.txt

    ra12f898 r5041d819  
     12014-08-21 zzz
     2 * i2psnark:
     3   - Escape control chars in encodePath()
     4   - Increase max piece size to 8 MB (ticket #1347)
     5 * i2ptunnel: Add local SSL support for std. and IRC client tunnels (ticket #1107)
     6
    172014-08-19 zzz
    28 * i2psnark:
  • router/java/src/net/i2p/router/RouterClock.java

    ra12f898 r5041d819  
    162162           
    163163            if (!_statCreated) {
    164                 _context.statManager().createRequiredRateStat("clock.skew", "Clock step adjustment (ms)", "Clock", new long[] { 10*60*1000, 3*60*60*1000, 24*60*60*60 });
     164                _context.statManager().createRequiredRateStat("clock.skew", "Clock step adjustment (ms)", "Clock", new long[] { 10*60*1000, 3*60*60*1000, 24*60*60*1000 });
    165165                _statCreated = true;
    166166            }
  • router/java/src/net/i2p/router/RouterVersion.java

    ra12f898 r5041d819  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 7;
     21    public final static long BUILD = 8;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/tunnel/BatchedPreprocessor.java

    ra12f898 r5041d819  
    4949    private final String _name;
    5050   
     51    private static final boolean DEBUG = false;
     52
    5153    public BatchedPreprocessor(RouterContext ctx, String name) {
    5254        super(ctx);
     
    176178                        if (timingBuf != null)
    177179                            timingBuf.append(" sent " + cur);
    178                         notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed allocated");
     180                        if (DEBUG)
     181                            notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed allocated");
    179182                        _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1);
    180183                        _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length);
     
    185188                        if (timingBuf != null)
    186189                            timingBuf.append(" sent perfect fit " + cur).append(".");
    187                         notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), msg.getData().length, msg.getMessageIds(), "flushed tail, remaining: " + pending);
     190                        if (DEBUG)
     191                            notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), msg.getData().length, msg.getMessageIds(), "flushed tail, remaining: " + pending);
    188192                        _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1);
    189193                        _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length);
     
    235239                            break;
    236240                        pending.remove(0);
    237                         notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed remaining");
     241                        if (DEBUG)
     242                            notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed remaining");
    238243                        _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1);
    239244                        _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length);
     
    384389
    385390        long msgId = sender.sendPreprocessed(preprocessed, rec);
    386         for (int i = 0; i < pending.size(); i++) {
    387             PendingGatewayMessage cur = pending.get(i);
    388             cur.addMessageId(msgId);
     391        if (DEBUG) {
     392            // creates a list in PGM
     393            for (int i = 0; i < pending.size(); i++) {
     394                PendingGatewayMessage cur = pending.get(i);
     395                cur.addMessageId(msgId);
     396            }
    389397        }
    390398        if (_log.shouldLog(Log.DEBUG))
  • router/java/src/net/i2p/router/tunnel/BatchedRouterPreprocessor.java

    ra12f898 r5041d819  
    1212 */
    1313class BatchedRouterPreprocessor extends BatchedPreprocessor {
    14     private TunnelCreatorConfig _config;
    15     protected HopConfig _hopConfig;
     14    private final TunnelCreatorConfig _config;
     15    protected final HopConfig _hopConfig;
    1616    private final long _sendDelay;
    1717   
     
    3535        super(ctx, getName(cfg));
    3636        _config = cfg;
     37        _hopConfig = null;
    3738        _sendDelay = initialSendDelay();
    3839    }
     
    4142    public BatchedRouterPreprocessor(RouterContext ctx, HopConfig cfg) {
    4243        super(ctx, getName(cfg));
     44        _config = null;
    4345        _hopConfig = cfg;
    4446        _sendDelay = initialSendDelay();
  • router/java/src/net/i2p/router/tunnel/OutboundSender.java

    ra12f898 r5041d819  
    1111 */
    1212class OutboundSender implements TunnelGateway.Sender {
    13     private final I2PAppContext _context;
    14     private final Log _log;
     13    //private final I2PAppContext _context;
     14    //private final Log _log;
    1515    private final TunnelCreatorConfig _config;
    1616    private final OutboundGatewayProcessor _processor;
     
    1919   
    2020    public OutboundSender(I2PAppContext ctx, TunnelCreatorConfig config) {
    21         _context = ctx;
    22         _log = ctx.logManager().getLog(OutboundSender.class);
     21        //_context = ctx;
     22        //_log = ctx.logManager().getLog(OutboundSender.class);
    2323        _config = config;
    24         _processor = new OutboundGatewayProcessor(_context, config);
     24        _processor = new OutboundGatewayProcessor(ctx, config);
    2525    }
    2626   
    2727    public long sendPreprocessed(byte[] preprocessed, TunnelGateway.Receiver receiver) {
    28         if (_log.shouldLog(Log.DEBUG))
    29             _log.debug("preprocessed data going out " + _config + ": " + Base64.encode(preprocessed));
     28        //if (_log.shouldLog(Log.DEBUG))
     29        //    _log.debug("preprocessed data going out " + _config + ": " + Base64.encode(preprocessed));
    3030        //if (USE_ENCRYPTION)
    3131            _processor.process(preprocessed, 0, preprocessed.length);
    32         if (_log.shouldLog(Log.DEBUG))
    33             _log.debug("after wrapping up the preprocessed data on " + _config);
     32        //if (_log.shouldLog(Log.DEBUG))
     33        //    _log.debug("after wrapping up the preprocessed data on " + _config);
    3434        long rv = receiver.receiveEncrypted(preprocessed);
    35         if (_log.shouldLog(Log.DEBUG))
    36             _log.debug("after receiving on " + _config + ": receiver = " + receiver);
     35        //if (_log.shouldLog(Log.DEBUG))
     36        //    _log.debug("after receiving on " + _config + ": receiver = " + receiver);
    3737        return rv;
    3838    }
  • router/java/src/net/i2p/router/tunnel/TrivialPreprocessor.java

    ra12f898 r5041d819  
    1818 *
    1919 * See FragmentHandler Javadoc for tunnel message fragment format
     20 *
     21 * Not instantiated directly except in unit tests; see BatchedPreprocessor
     22 *
    2023 */
    2124class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor {
     
    4952     */
    5053    public boolean preprocessQueue(List<PendingGatewayMessage> pending, TunnelGateway.Sender sender, TunnelGateway.Receiver rec) {
    51         throw new IllegalArgumentException("unused, right?");
     54        throw new UnsupportedOperationException("unused, right?");
    5255    }
    5356   
     
    266269     *  call getInstructionAugmentationSize() for that.
    267270     */
    268     protected int getInstructionsSize(PendingGatewayMessage msg) {
     271    protected static int getInstructionsSize(PendingGatewayMessage msg) {
    269272        if (msg.getFragmentNumber() > 0)
    270273            return 7;
     
    284287   
    285288    /** @return 0 or 4 */
    286     protected int getInstructionAugmentationSize(PendingGatewayMessage msg, int offset, int instructionsSize) {
     289    protected static int getInstructionAugmentationSize(PendingGatewayMessage msg, int offset, int instructionsSize) {
    287290        int payloadLength = msg.getData().length - msg.getOffset();
    288291        if (offset + payloadLength + instructionsSize + IV_SIZE + 1 + 4 > PREPROCESSED_SIZE) {
  • router/java/src/net/i2p/router/tunnel/TunnelGateway.java

    ra12f898 r5041d819  
    3434 * Unused directly - see PumpedTunnelGateway, ThrottledPumpedTunnelGateway, and TunnelGatewayZeroHop overrides.
    3535 */
    36 class TunnelGateway {
     36abstract class TunnelGateway {
    3737    protected final RouterContext _context;
    3838    protected final Log _log;
  • router/java/test/junit/net/i2p/router/tunnel/FragmentTest.java

    ra12f898 r5041d819  
    6767        try {
    6868            pre.preprocessQueue(messages, new SenderImpl(), receiver);
    69             fail("should have thrown IAE");
    70         } catch (IllegalArgumentException expected){}
     69            fail("should have thrown UOE");
     70        } catch (UnsupportedOperationException expected){}
    7171    }
    7272   
     
    9090        try {
    9191            pre.preprocessQueue(messages, new SenderImpl(), receiver);
    92             fail("should have thrown IAE");
    93         } catch (IllegalArgumentException expected){}
     92            fail("should have thrown UOE");
     93        } catch (UnsupportedOperationException expected){}
    9494    }
    9595   
Note: See TracChangeset for help on using the changeset viewer.