Changeset 5414d41


Ignore:
Timestamp:
Mar 25, 2009 11:19:37 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e692e18d
Parents:
5eda7c30
Message:

I2PSnark: Use new BW Limits message, remove router.jar dependencies

Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/build.xml

    r5eda7c30 r5414d41  
    1919            <classpath>
    2020                <pathelement location="../../../core/java/build/obj" />
    21                 <pathelement location="../../../router/java/build/obj" />
    2221                <pathelement location="../../ministreaming/java/build/obj" />
    2322                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
     
    3332            debug="true" deprecation="on" source="1.5" target="1.5"
    3433            destdir="./build/obj"
    35             classpath="../../../core/java/build/i2p.jar:../../../router/java/build/router.jar:../../jetty/jettylib/org.mortbay.jetty.jar:../../jetty/jettylib/javax.servlet.jar:../../ministreaming/java/build/mstreaming.jar" />
     34            classpath="../../../core/java/build/i2p.jar:../../jetty/jettylib/org.mortbay.jetty.jar:../../jetty/jettylib/javax.servlet.jar:../../ministreaming/java/build/mstreaming.jar" />
    3635    </target>
    3736    <target name="jar" depends="builddep, compile">
  • apps/i2psnark/java/src/org/klomp/snark/Snark.java

    r5eda7c30 r5414d41  
    3737
    3838import net.i2p.I2PAppContext;
    39 import net.i2p.router.client.ClientManagerFacadeImpl;
    4039import net.i2p.client.streaming.I2PServerSocket;
    4140import net.i2p.data.Destination;
     
    262261               StorageListener slistener, boolean start, String rootDir) {
    263262    this(new I2PSnarkUtil(ctx), torrent, null, -1, slistener, null, null, null, null, false, rootDir);
    264     String host = opts.getProperty(ClientManagerFacadeImpl.PROP_CLIENT_HOST);
     263    String host = opts.getProperty("i2cp.hostname");
    265264    int port = 0;
    266     String s = opts.getProperty(ClientManagerFacadeImpl.PROP_CLIENT_PORT);
     265    String s = opts.getProperty("i2cp.port");
    267266    if (s != null) {
    268267        try {
  • apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java

    r5eda7c30 r5414d41  
    1919import net.i2p.data.Base64;
    2020import net.i2p.data.DataHelper;
    21 import net.i2p.router.RouterContext;
    2221import net.i2p.util.I2PAppThread;
    2322import net.i2p.util.Log;
     
    148147        if (!_config.containsKey(PROP_UPLOADERS_TOTAL))
    149148            _config.setProperty(PROP_UPLOADERS_TOTAL, "" + Snark.MAX_TOTAL_UPLOADERS);
    150         if (!_config.containsKey(PROP_UPBW_MAX)) {
    151             try {
    152                 if (_context instanceof RouterContext)
    153                     _config.setProperty(PROP_UPBW_MAX, "" + (((RouterContext)_context).bandwidthLimiter().getOutboundKBytesPerSecond() / 2));
    154                 else
    155                     _config.setProperty(PROP_UPBW_MAX, "" + DEFAULT_MAX_UP_BW);
    156             } catch (NoClassDefFoundError ncdfe) {
    157                 _config.setProperty(PROP_UPBW_MAX, "" + DEFAULT_MAX_UP_BW);
    158             }
    159         }
    160149        if (!_config.containsKey(PROP_DIR))
    161150            _config.setProperty(PROP_DIR, "i2psnark");
     
    163152            _config.setProperty(PROP_AUTO_START, DEFAULT_AUTO_START);
    164153        updateConfig();
     154    }
     155
     156    /** call from DirMonitor since loadConfig() is called before router I2CP is up */
     157    private void getBWLimit() {
     158        if (!_config.containsKey(PROP_UPBW_MAX)) {
     159            int[] limits = BWLimits.getBWLimits(_util.getI2CPHost(), _util.getI2CPPort());
     160            if (limits != null && limits[1] > 0)
     161                _util.setMaxUpBW(limits[1]);
     162        }
    165163    }
    166164   
     
    620618            }
    621619
     620            // here because we need to delay until I2CP is up
     621            // although the user will see the default until then
     622            getBWLimit();
    622623            while (true) {
    623624                File dir = getDataDir();
  • core/java/src/net/i2p/client/I2PSession.java

    r5eda7c30 r5414d41  
    144144    public Destination lookupDest(Hash h) throws I2PSessionException;
    145145
     146    /**
     147     * Get the current bandwidth limits
     148     */
     149    public int[] bandwidthLimits() throws I2PSessionException;
     150
    146151    /** See I2PSessionMuxedImpl for details */
    147152    public void addSessionListener(I2PSessionListener lsnr, int proto, int port);
  • core/java/src/net/i2p/client/I2PSessionImpl.java

    r5eda7c30 r5414d41  
    657657    }
    658658
     659    public int[] bandwidthLimits() throws I2PSessionException {
     660        return null;
     661    }
     662
    659663    protected void updateActivity() {
    660664        _lastActivity = _context.clock().now();
  • core/java/src/net/i2p/client/I2PSimpleSession.java

    r5eda7c30 r5414d41  
    131131        _bwReceivedLock = new Object();
    132132        sendMessage(new GetBandwidthLimitsMessage());
    133         for (int i = 0; i < 5 && !_destReceived; i++) {
     133        for (int i = 0; i < 5 && !_bwReceived; i++) {
    134134            try {
    135135                synchronized (_bwReceivedLock) {
  • router/java/src/net/i2p/router/client/ClientMessageEventListener.java

    r5eda7c30 r5414d41  
    281281
    282282    /**
    283      * Divide router limit by 2 for overhead.
     283     * Divide router limit by 1.75 for overhead.
    284284     * This could someday give a different answer to each client.
    285285     * But it's not enforced anywhere.
     
    288288        if (_log.shouldLog(Log.INFO))
    289289            _log.info("Got BW Limits request");
    290         int in = _context.bandwidthLimiter().getInboundKBytesPerSecond() / 2;
    291         int out = _context.bandwidthLimiter().getOutboundKBytesPerSecond() / 2;
     290        int in = _context.bandwidthLimiter().getInboundKBytesPerSecond() * 4 / 7;
     291        int out = _context.bandwidthLimiter().getOutboundKBytesPerSecond() * 4 / 7;
    292292        BandwidthLimitsMessage msg = new BandwidthLimitsMessage(in, out);
    293293        try {
Note: See TracChangeset for help on using the changeset viewer.