Changeset 54fdfd8


Ignore:
Timestamp:
Feb 8, 2011 3:29:18 AM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ad3342a
Parents:
ba9c701
Message:
Files:
7 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • build.xml

    rba9c701 r54fdfd8  
    240240            doctitle="I2P Javadocs for Release ${release.number} Build ${build.number}"
    241241            windowtitle="I2P Anonymous Network - Java Documentation - Version ${release.number}">
    242             <group title="Core SDK (i2p.jar)" packages="net.i2p:net.i2p.*:net.i2p.client:net.i2p.client.*:net.i2p.internal:net.i2p.internal.*:freenet.support.CPUInformation:org.bouncycastle.crypto:org.bouncycastle.crypto.*:gnu.crypto.*:gnu.gettext:org.xlattice.crypto.filters:com.nettgryppa.security" />
     242            <group title="Core SDK (i2p.jar)" packages="net.i2p:net.i2p.*:net.i2p.client:net.i2p.client.*:net.i2p.internal:net.i2p.internal.*:freenet.support.CPUInformation:org.bouncycastle.crypto:org.bouncycastle.crypto.*:gnu.crypto.*:gnu.gettext:org.xlattice.crypto.filters:com.nettgryppa.security:net.metanotion.*" />
    243243            <group title="Streaming Library" packages="net.i2p.client.streaming" />
    244244            <group title="Router" packages="net.i2p.router:net.i2p.router.*:net.i2p.data.i2np:org.cybergarage.*:org.freenetproject" />
  • core/java/src/net/i2p/I2PAppContext.java

    rba9c701 r54fdfd8  
    88
    99import net.i2p.client.naming.NamingService;
    10 import net.i2p.client.naming.PetNameDB;
    1110import net.i2p.crypto.AESEngine;
    1211import net.i2p.crypto.CryptixAESEngine;
     
    7372    private SessionKeyManager _sessionKeyManager;
    7473    private NamingService _namingService;
    75     private PetNameDB _petnameDb;
    7674    private ElGamalEngine _elGamalEngine;
    7775    private ElGamalAESEngine _elGamalAESEngine;
     
    9088    private volatile boolean _sessionKeyManagerInitialized;
    9189    private volatile boolean _namingServiceInitialized;
    92     private volatile boolean _petnameDbInitialized;
    9390    private volatile boolean _elGamalEngineInitialized;
    9491    private volatile boolean _elGamalAESEngineInitialized;
     
    178175        _sessionKeyManager = null;
    179176        _namingService = null;
    180         _petnameDb = null;
    181177        _elGamalEngine = null;
    182178        _elGamalAESEngine = null;
     
    581577    }
    582578   
    583     /** @deprecated unused */
    584     public PetNameDB petnameDb() {
    585         if (!_petnameDbInitialized)
    586             initializePetnameDb();
    587         return _petnameDb;
    588     }
    589 
    590     /** @deprecated unused */
    591     private void initializePetnameDb() {
    592         synchronized (this) {
    593             if (_petnameDb == null) {
    594                 _petnameDb = new PetNameDB();
    595             }
    596             _petnameDbInitialized = true;
    597         }
    598     }
    599    
    600579    /**
    601580     * This is the ElGamal engine used within this context.  While it doesn't
  • core/java/src/net/i2p/client/naming/BlockfileNamingService.java

    rba9c701 r54fdfd8  
    6666 *
    6767 */
    68 public class BlockfileNamingService extends NamingService {
     68public class BlockfileNamingService extends DummyNamingService {
    6969
    7070    private final Log _log;
     
    7878    private static final Serializer _destSerializer = new DestEntrySerializer();
    7979
    80     private static final int BASE32_HASH_LENGTH = 52;   // 1 + Hash.HASH_LENGTH * 8 / 5
    8180    private static final String HOSTS_DB = "hostsdb.blockfile";
    8281    private static final String PROP_HOSTS_FILE = "i2p.hostsfilelist";
     
    179178                            continue;
    180179                        String key = line.substring(0, split).toLowerCase();
    181                         if (line.indexOf('#') > 0)  // trim off any end of line comment
     180                        if (line.indexOf('#') > 0)  { // trim off any end of line comment
    182181                            line = line.substring(0, line.indexOf('#')).trim();
     182                            if (line.length() < split + 1)
     183                                continue;
     184                        }
    183185                        String b64 = line.substring(split+1);   //.trim() ??????????????
    184186                        Destination d = lookupBase64(b64);
     
    194196                }
    195197                total += count;
    196                 _log.error("Added " + count + " hosts from " + file);
     198                _log.logAlways(Log.INFO, "Added " + count + " hosts from " + file);
    197199                _lists.add(hostsfile);
    198200            }
     
    343345    @Override
    344346    public Destination lookup(String hostname) {
    345         Destination d = getCache(hostname);
     347        Destination d = super.lookup(hostname);
    346348        if (d != null)
    347349            return d;
    348 
    349         // If it's long, assume it's a key.
    350         if (hostname.length() >= 516) {
    351             d = lookupBase64(hostname);
    352             // What the heck, cache these too
    353             putCache(hostname, d);
    354             return d;
    355         }
    356 
    357         // Try Base32 decoding
    358         if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.endsWith(".b32.i2p") &&
    359             Boolean.valueOf(_context.getProperty(PROP_B32, "true")).booleanValue()) {
    360             d = LookupDest.lookupBase32Hash(_context, hostname.substring(0, BASE32_HASH_LENGTH));
    361             if (d != null) {
    362                 putCache(hostname, d);
    363                 return d;
    364             }
    365         }
    366350
    367351        String key = hostname.toLowerCase();
     
    505489    public static void main(String[] args) {
    506490        BlockfileNamingService bns = new BlockfileNamingService(I2PAppContext.getGlobalContext());
    507         //System.out.println("zzz.i2p: " + bns._lists.get(2).get("zzz.i2p"));
    508491        System.out.println("zzz.i2p: " + bns.lookup("zzz.i2p"));
    509492        List<String> names = null;
     
    532515        System.out.println("BFNS took " + DataHelper.formatDuration(System.currentTimeMillis() - start));
    533516        System.out.println("found " + found + " notfound " + notfound);
    534 synchronized(bns) {
    535 try { bns.wait(); } catch (InterruptedException ie) {}
    536 }
    537517        bns.close();
    538518
  • core/java/src/net/i2p/client/naming/DummyNamingService.java

    rba9c701 r54fdfd8  
    1212
    1313/**
    14  * A Dummy naming service that can only handle base64 destinations.
     14 * A Dummy naming service that can only handle base64 and b32 destinations.
    1515 */
    1616class DummyNamingService extends NamingService {
     17    private static final int BASE32_HASH_LENGTH = 52;   // 1 + Hash.HASH_LENGTH * 8 / 5
     18    public final static String PROP_B32 = "i2p.naming.hostsTxt.useB32";
     19
    1720    /**
    1821     * The naming service should only be constructed and accessed through the
     
    2629    @Override
    2730    public Destination lookup(String hostname) {
    28         return lookupBase64(hostname);
     31        Destination d = getCache(hostname);
     32        if (d != null)
     33            return d;
     34
     35        // If it's long, assume it's a key.
     36        if (hostname.length() >= 516) {
     37            d = lookupBase64(hostname);
     38            // What the heck, cache these too
     39            putCache(hostname, d);
     40            return d;
     41        }
     42
     43        // Try Base32 decoding
     44        if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.endsWith(".b32.i2p") &&
     45            _context.getBooleanPropertyDefaultTrue(PROP_B32)) {
     46            d = LookupDest.lookupBase32Hash(_context, hostname.substring(0, BASE32_HASH_LENGTH));
     47            if (d != null) {
     48                putCache(hostname, d);
     49                return d;
     50            }
     51        }
     52
     53        return null;
    2954    }
    3055}
  • core/java/src/net/i2p/client/naming/HostsTxtNamingService.java

    rba9c701 r54fdfd8  
    3030 * A naming service based on the "hosts.txt" file.
    3131 */
    32 public class HostsTxtNamingService extends NamingService {
     32public class HostsTxtNamingService extends DummyNamingService {
    3333
    3434    /**
     
    4646     */
    4747    public final static String PROP_HOSTS_FILE = "i2p.hostsfilelist";
    48     public final static String PROP_B32 = "i2p.naming.hostsTxt.useB32";
    4948
    5049    /** default hosts.txt filename */
     
    6362    }
    6463   
    65     private static final int BASE32_HASH_LENGTH = 52;   // 1 + Hash.HASH_LENGTH * 8 / 5
    66 
    6764    @Override
    6865    public Destination lookup(String hostname) {
    69         Destination d = getCache(hostname);
     66        Destination d = super.lookup(hostname);
    7067        if (d != null)
    7168            return d;
    72 
    73         // If it's long, assume it's a key.
    74         if (hostname.length() >= 516) {
    75             d = lookupBase64(hostname);
    76             // What the heck, cache these too
    77             putCache(hostname, d);
    78             return d;
    79         }
    80 
    81         // Try Base32 decoding
    82         if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.endsWith(".b32.i2p") &&
    83             Boolean.valueOf(_context.getProperty(PROP_B32, "true")).booleanValue()) {
    84             d = LookupDest.lookupBase32Hash(_context, hostname.substring(0, BASE32_HASH_LENGTH));
    85             if (d != null) {
    86                 putCache(hostname, d);
    87                 return d;
    88             }
    89         }
    9069
    9170        List filenames = getFilenames();
  • core/java/src/net/i2p/client/naming/NamingService.java

    rba9c701 r54fdfd8  
    9797            instance = (NamingService)con.newInstance(new Object[] { context });
    9898        } catch (Exception ex) {
    99             _log.error("Cannot loadNaming service implementation", ex);
     99            _log.error("Cannot load naming service " + impl, ex);
    100100            instance = new DummyNamingService(context); // fallback
    101101        }
Note: See TracChangeset for help on using the changeset viewer.