Changeset fa504ae8


Ignore:
Timestamp:
Aug 27, 2012 9:36:39 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ab213f4
Parents:
d305eb6
Message:
  • Fix cases where we weren't using the session for b32 lookup
Files:
7 edited

Legend:

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

    rd305eb6 rfa504ae8  
    339339                if (DataHelper.eq(hash, peer.getPeerID().getDestHash()))
    340340                    continue;
    341                 PeerID pID = new PeerID(hash);
     341                PeerID pID = new PeerID(hash, listener.getUtil());
    342342                peers.add(pID);
    343343            }
  • apps/i2psnark/java/src/org/klomp/snark/PeerCoordinator.java

    rd305eb6 rfa504ae8  
    14361436    return false;
    14371437  }
     1438
     1439  /**
     1440   *  Convenience
     1441   *  @since 0.9.2
     1442   */
     1443  public I2PSnarkUtil getUtil() {
     1444      return _util;
     1445  }
    14381446}
    14391447
  • apps/i2psnark/java/src/org/klomp/snark/PeerID.java

    rd305eb6 rfa504ae8  
    5353  private boolean triedDestLookup;
    5454  private final int hash;
     55  private final I2PSnarkUtil util;
    5556
    5657  public PeerID(byte[] id, Destination address)
     
    6162    this.destHash = address.calculateHash().getData();
    6263    hash = calculateHash();
     64    util = null;
    6365  }
    6466
     
    9496    this.destHash = address.calculateHash().getData();
    9597    hash = calculateHash();
     98    util = null;
    9699  }
    97100
    98101  /**
    99102   * Creates a PeerID from a destHash
     103   * @param util for eventual destination lookup
    100104   * @since 0.8.1
    101105   */
    102   public PeerID(byte[] dest_hash) throws InvalidBEncodingException
     106  public PeerID(byte[] dest_hash, I2PSnarkUtil util) throws InvalidBEncodingException
    103107  {
    104108    // id and address remain null
     
    108112    destHash = dest_hash;
    109113    hash = DataHelper.hashCode(dest_hash);
     114    this.util = util;
    110115  }
    111116
     
    132137    if (address == null && destHash != null && !triedDestLookup) {
    133138        String b32 = Base32.encode(destHash) + ".b32.i2p";
    134         address = I2PAppContext.getGlobalContext().namingService().lookup(b32);
     139        address = util.getDestination(b32);
    135140        triedDestLookup = true;
    136141    }
  • apps/i2psnark/java/src/org/klomp/snark/PeerListener.java

    rd305eb6 rfa504ae8  
    208208   */
    209209  void gotPeers(Peer peer, List<PeerID> pIDList);
     210
     211  /**
     212   *  Convenience
     213   *  @since 0.9.2
     214   */
     215  public I2PSnarkUtil getUtil();
    210216}
  • apps/i2psnark/java/src/org/klomp/snark/TrackerClient.java

    rd305eb6 rfa504ae8  
    488488                    List<Peer> peers = new ArrayList(hashes.size());
    489489                    for (Hash h : hashes) {
    490                         PeerID pID = new PeerID(h.getData());
     490                        PeerID pID = new PeerID(h.getData(), _util);
    491491                        peers.add(new Peer(pID, snark.getID(), snark.getInfoHash(), snark.getMetaInfo()));
    492492                    }
     
    652652
    653653        TrackerInfo info = new TrackerInfo(in, snark.getID(),
    654                                            snark.getInfoHash(), snark.getMetaInfo());
     654                                           snark.getInfoHash(), snark.getMetaInfo(), _util);
    655655        if (_log.shouldLog(Log.INFO))
    656656            _log.info("TrackerClient response: " + info);
  • apps/i2psnark/java/src/org/klomp/snark/TrackerInfo.java

    rd305eb6 rfa504ae8  
    4848
    4949  /** @param metainfo may be null */
    50   public TrackerInfo(InputStream in, byte[] my_id, byte[] infohash, MetaInfo metainfo)
    51     throws IOException
    52   {
    53     this(new BDecoder(in), my_id, infohash, metainfo);
    54   }
    55 
    56   private TrackerInfo(BDecoder be, byte[] my_id, byte[] infohash, MetaInfo metainfo)
    57     throws IOException
    58   {
    59     this(be.bdecodeMap().getMap(), my_id, infohash, metainfo);
    60   }
    61 
    62   private TrackerInfo(Map m, byte[] my_id, byte[] infohash, MetaInfo metainfo)
     50  public TrackerInfo(InputStream in, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
     51    throws IOException
     52  {
     53    this(new BDecoder(in), my_id, infohash, metainfo, util);
     54  }
     55
     56  private TrackerInfo(BDecoder be, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
     57    throws IOException
     58  {
     59    this(be.bdecodeMap().getMap(), my_id, infohash, metainfo, util);
     60  }
     61
     62  private TrackerInfo(Map m, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
    6363    throws IOException
    6464  {
     
    8686            try {
    8787              // One big string (the official compact format)
    88               p = getPeers(bePeers.getBytes(), my_id, infohash, metainfo);
     88              p = getPeers(bePeers.getBytes(), my_id, infohash, metainfo, util);
    8989            } catch (InvalidBEncodingException ibe) {
    9090              // List of Dictionaries or List of Strings
    91               p = getPeers(bePeers.getList(), my_id, infohash, metainfo);
     91              p = getPeers(bePeers.getList(), my_id, infohash, metainfo, util);
    9292            }
    9393            peers = p;
     
    125125
    126126  /** List of Dictionaries or List of Strings */
    127   private static Set<Peer> getPeers(List<BEValue> l, byte[] my_id, byte[] infohash, MetaInfo metainfo)
     127  private static Set<Peer> getPeers(List<BEValue> l, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
    128128    throws IOException
    129129  {
     
    139139                // Case 2 - compact - A list of 32-byte binary strings (hashes)
    140140                // This was just for testing and is not the official format
    141                 peerID = new PeerID(bev.getBytes());
     141                peerID = new PeerID(bev.getBytes(), util);
    142142            } catch (InvalidBEncodingException ibe2) {
    143143                // don't let one bad entry spoil the whole list
     
    158158   *  @since 0.8.1
    159159   */
    160   private static Set<Peer> getPeers(byte[] l, byte[] my_id, byte[] infohash, MetaInfo metainfo)
     160  private static Set<Peer> getPeers(byte[] l, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
    161161    throws IOException
    162162  {
     
    169169        System.arraycopy(l, i * HASH_LENGTH, hash, 0, HASH_LENGTH);
    170170        try {
    171             peerID = new PeerID(hash);
     171            peerID = new PeerID(hash, util);
    172172        } catch (InvalidBEncodingException ibe) {
    173173            // won't happen
  • history.txt

    rd305eb6 rfa504ae8  
    112012-08-27 zzz
    2  * i2psnark: Notify threads awaiting DHT replies at shutdown
     2 * i2psnark:
     3   - Notify threads awaiting DHT replies at shutdown
     4   - Fix cases where we weren't using the session for b32 lookup
    35 * Reseed: Remove forum.i2p2.de
    46 * Streaming: Limit amount of slow-start exponential growth
Note: See TracChangeset for help on using the changeset viewer.