Changeset 95aba0c


Ignore:
Timestamp:
Aug 26, 2009 10:15:32 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
bb14fa0
Parents:
df4143f
Message:
  • EepGet?, I2PSnark:
    • New I2PSocketEepGet fetches through existing tunnels rather than through the proxy
    • Use new eepget for i2psnark
    • Add a fake user agent for non-proxied fetches
    • Cleanups
Files:
1 added
8 edited

Legend:

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

    rdf4143f r95aba0c  
    1818import net.i2p.client.streaming.I2PServerSocket;
    1919import net.i2p.client.streaming.I2PSocket;
     20import net.i2p.client.streaming.I2PSocketEepGet;
    2021import net.i2p.client.streaming.I2PSocketManager;
    2122import net.i2p.client.streaming.I2PSocketManagerFactory;
     
    232233            fetchURL = rewriteAnnounce(url);
    233234        //_log.debug("Rewritten url [" + fetchURL + "]");
    234         EepGet get = new EepGet(_context, _shouldProxy, _proxyHost, _proxyPort, retries, out.getAbsolutePath(), fetchURL);
     235        //EepGet get = new EepGet(_context, _shouldProxy, _proxyHost, _proxyPort, retries, out.getAbsolutePath(), fetchURL);
     236        // Use our tunnel for announces and .torrent fetches too! Make sure we're connected first...
     237        if (!connected()) {
     238            if (!connect())
     239                return null;
     240        }
     241        EepGet get = new I2PSocketEepGet(_context, _manager, retries, out.getAbsolutePath(), fetchURL);
    235242        if (get.fetch()) {
    236243            _log.debug("Fetch successful [" + url + "]: size=" + out.length());
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    rdf4143f r95aba0c  
    752752
    753753        //out.write("\n");
    754         out.write("EepProxy host: <input type=\"text\" name=\"eepHost\" value=\""
    755                   + _manager.util().getEepProxyHost() + "\" size=\"15\" /> ");
    756         out.write("port: <input type=\"text\" name=\"eepPort\" value=\""
    757                   + _manager.util().getEepProxyPort() + "\" size=\"5\" maxlength=\"5\" /><br>\n");
     754        //out.write("EepProxy host: <input type=\"text\" name=\"eepHost\" value=\""
     755        //          + _manager.util().getEepProxyHost() + "\" size=\"15\" /> ");
     756        //out.write("port: <input type=\"text\" name=\"eepPort\" value=\""
     757        //          + _manager.util().getEepProxyPort() + "\" size=\"5\" maxlength=\"5\" /><br>\n");
    758758        out.write("I2CP host: <input type=\"text\" name=\"i2cpHost\" value=\""
    759759                  + _manager.util().getI2CPHost() + "\" size=\"15\" /> ");
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java

    rdf4143f r95aba0c  
    3838 *   $method $path $protocolVersion\nHost: $site
    3939 * or
    40  *   $method http://i2p/$site/$path $protocolVersion
     40 *   $method http://i2p/$b64key/$path $protocolVersion
    4141 * or
    4242 *   $method /$site/$path $protocolVersion
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionOptions.java

    rdf4143f r95aba0c  
    267267            setSlowStartGrowthRateFactor(getInt(opts, PROP_SLOW_START_GROWTH_RATE_FACTOR, 2));
    268268        if (opts.containsKey(PROP_CONNECT_TIMEOUT))
     269            // wow 5 minutes!!! FIXME!!
    269270            setConnectTimeout(getInt(opts, PROP_CONNECT_TIMEOUT, Connection.DISCONNECT_TIMEOUT));
    270271        if (opts.containsKey(PROP_ANSWER_PINGS))
  • core/java/src/net/i2p/util/EepGet.java

    rdf4143f r95aba0c  
    2828 */
    2929public class EepGet {
    30     private I2PAppContext _context;
     30    protected I2PAppContext _context;
    3131    protected Log _log;
    3232    protected boolean _shouldProxy;
     
    3636    private long _minSize; // minimum and maximum acceptable response size, -1 signifies unlimited,
    3737    private long _maxSize; // applied both against whole responses and chunks
    38     private String _outputFile;
    39     private OutputStream _outputStream;
     38    protected String _outputFile;
     39    protected OutputStream _outputStream;
    4040    /** url we were asked to fetch */
    4141    protected String _url;
     
    4848    private boolean _keepFetching;
    4949    private Socket _proxy;
    50     private OutputStream _proxyOut;
    51     private InputStream _proxyIn;
     50    protected OutputStream _proxyOut;
     51    protected InputStream _proxyIn;
    5252    protected OutputStream _out;
    53     private long _alreadyTransferred;
     53    protected long _alreadyTransferred;
    5454    private long _bytesTransferred;
    5555    protected long _bytesRemaining;
     
    6868    protected int _redirects;
    6969    protected String _redirectLocation;
     70    /** this will be replaced by the HTTP Proxy if we are using it */
     71    protected static final String USER_AGENT = "Wget/1.11.4";
     72    protected static final long CONNECT_TIMEOUT = 45*1000;
     73    protected static final long INACTIVITY_TIMEOUT = 60*1000;
    7074   
    7175    public EepGet(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String outputFile, String url) {
     
    119123        _headersRead = false;
    120124        _aborted = false;
    121         _fetchHeaderTimeout = 45*1000;
     125        _fetchHeaderTimeout = CONNECT_TIMEOUT;
    122126        _listeners = new ArrayList(1);
    123127        _etag = etag;
     
    135139        int markSize = 1024;
    136140        int lineLen = 40;
    137         int inactivityTimeout = 60*1000;
     141        long inactivityTimeout = INACTIVITY_TIMEOUT;
    138142        String etag = null;
    139143        String saveAs = null;
     
    184188        EepGet get = new EepGet(I2PAppContext.getGlobalContext(), true, proxyHost, proxyPort, numRetries, saveAs, url, true, etag);
    185189        get.addStatusListener(get.new CLIStatusListener(markSize, lineLen));
    186         get.fetch(45*1000, -1, inactivityTimeout);
     190        get.fetch(CONNECT_TIMEOUT, -1, inactivityTimeout);
    187191    }
    188192   
     
    217221    }
    218222   
    219     protected static void usage() {
     223    private static void usage() {
    220224        System.err.println("EepGet [-p 127.0.0.1:4444] [-n #retries] [-o outputFile] [-m markSize lineLen] [-t timeout] url");
    221225    }
     
    248252        public void attempting(String url);
    249253    }
    250     private class CLIStatusListener implements StatusListener {
     254    protected class CLIStatusListener implements StatusListener {
    251255        private int _markSize;
    252256        private int _lineSize;
     
    498502            timeout.setInactivityTimeout(_fetchInactivityTimeout);
    499503        else
    500             timeout.setInactivityTimeout(60*1000);
     504            timeout.setInactivityTimeout(INACTIVITY_TIMEOUT);
    501505       
    502506        if (_redirectLocation != null) {
     
    830834    }
    831835
    832     private void increment(byte[] lookahead, int cur) {
     836    private static void increment(byte[] lookahead, int cur) {
    833837        lookahead[0] = lookahead[1];
    834838        lookahead[1] = lookahead[2];
    835839        lookahead[2] = (byte)cur;
    836840    }
    837     private boolean isEndOfHeaders(byte lookahead[]) {
     841    private static boolean isEndOfHeaders(byte lookahead[]) {
    838842        byte first = lookahead[0];
    839843        byte second = lookahead[1];
     
    845849    /** we ignore any potential \r, since we trim it on write anyway */
    846850    private static final byte NL = '\n';
    847     private boolean isNL(byte b) { return (b == NL); }
     851    private static boolean isNL(byte b) { return (b == NL); }
    848852
    849853    protected void sendRequest(SocketTimeout timeout) throws IOException {
     
    896900   
    897901    protected String getRequest() throws IOException {
    898         StringBuilder buf = new StringBuilder(512);
     902        StringBuilder buf = new StringBuilder(2048);
    899903        boolean post = false;
    900904        if ( (_postData != null) && (_postData.length() > 0) )
     
    907911        String query = url.getQuery();
    908912        if (query != null)
    909             path = path + "?" + query;
     913            path = path + '?' + query;
    910914        if (!path.startsWith("/"))
    911915            path = "/" + path;
     
    924928            buf.append("-\r\n");
    925929        }
    926         buf.append("Accept-Encoding: \r\n");
    927930        if (_shouldProxy)
    928931            buf.append("X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n");
    929932        if (!_allowCaching) {
    930             buf.append("Cache-control: no-cache\r\n");
    931             buf.append("Pragma: no-cache\r\n");
     933            buf.append("Cache-control: no-cache\r\n" +
     934                       "Pragma: no-cache\r\n");
    932935        }
    933936        if ((_etag != null) && (_alreadyTransferred <= 0)) {
     
    943946        if (post)
    944947            buf.append("Content-length: ").append(_postData.length()).append("\r\n");
    945         buf.append("Connection: close\r\n\r\n");
     948        // This will be replaced if we are going through I2PTunnelHTTPClient
     949        buf.append("User-Agent: " + USER_AGENT + "\r\n" +
     950                   "Accept-Encoding: \r\n" +
     951                   "Connection: close\r\n\r\n");
    946952        if (post)
    947953            buf.append(_postData);
  • core/java/src/net/i2p/util/EepGetScheduler.java

    rdf4143f r95aba0c  
    88
    99/**
    10  *
     10 *  @deprecated unused a webapp version would be nice though
    1111 */
    1212public class EepGetScheduler implements EepGet.StatusListener {
  • core/java/src/net/i2p/util/EepHead.java

    rdf4143f r95aba0c  
    9494    }
    9595   
    96     protected static void usage() {
     96    private static void usage() {
    9797        System.err.println("EepHead [-p 127.0.0.1:4444] [-n #retries] [-t timeout] url");
    9898    }
     
    192192        if (_shouldProxy)
    193193            buf.append("X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n");
     194        // This will be replaced if we are going through I2PTunnelHTTPClient
     195        buf.append("User-Agent: " + USER_AGENT + "\r\n");
    194196        buf.append("Connection: close\r\n\r\n");
    195197        if (_log.shouldLog(Log.DEBUG))
  • core/java/src/net/i2p/util/SocketTimeout.java

    rdf4143f r95aba0c  
    66import java.util.Date;
    77
     8/**
     9 *  This should be deprecated.
     10 *  It is only used by EepGet, and it uses the inefficient SimpleTimer.
     11 *  The only advantage seems to be a total timeout period, which is the second
     12 *  argument to EepGet.fetch(headerTimeout, totalTimeout, inactivityTimeout),
     13 *  which is most likely always set to -1.
     14 *
     15 *  Use socket.setsotimeout instead?
     16 */
    817public class SocketTimeout implements SimpleTimer.TimedEvent {
    918    private Socket _targetSocket;
Note: See TracChangeset for help on using the changeset viewer.