Changeset cf46310


Ignore:
Timestamp:
Feb 18, 2012 3:22:40 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c957577
Parents:
88cf742
Message:

stub out private mode

Location:
apps/i2psnark/java/src/org/klomp/snark
Files:
3 edited

Legend:

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

    r88cf742 rcf46310  
    6262  private final byte[] piece_hashes;
    6363  private final long length;
     64  private final boolean privateTorrent;
    6465  private Map<String, BEValue> infoMap;
    6566
     
    7273   */
    7374  MetaInfo(String announce, String name, String name_utf8, List<List<String>> files, List<Long> lengths,
    74            int piece_length, byte[] piece_hashes, long length)
     75           int piece_length, byte[] piece_hashes, long length, boolean privateTorrent)
    7576  {
    7677    this.announce = announce;
     
    8384    this.piece_hashes = piece_hashes;
    8485    this.length = length;
     86    this.privateTorrent = privateTorrent;
    8587
    8688    // TODO if we add a parameter for other keys
     
    160162    else
    161163        name_utf8 = null;
     164
     165    // BEP 27
     166    val = info.get("private");
     167    privateTorrent = val != null && val.getString().equals("1");
    162168
    163169    val = info.get("piece length");
     
    320326
    321327  /**
     328   * Is it a private torrent?
     329   * @since 0.9
     330   */
     331  public boolean isPrivate() {
     332    return privateTorrent;
     333  }
     334
     335  /**
    322336   * Returns a list of lists of file name hierarchies or null if it is
    323337   * a single name. It has the same size as the list returned by
     
    440454    return new MetaInfo(announce, name, name_utf8, files,
    441455                        lengths, piece_length,
    442                         piece_hashes, length);
     456                        piece_hashes, length, privateTorrent);
    443457  }
    444458
     
    476490    if (name_utf8 != null)
    477491        info.put("name.utf-8", name_utf8);
     492    // BEP 27
     493    if (privateTorrent)
     494        info.put("private", "1");
     495
    478496    info.put("piece length", Integer.valueOf(piece_length));
    479497    info.put("pieces", piece_hashes);
  • apps/i2psnark/java/src/org/klomp/snark/Storage.java

    r88cf742 rcf46310  
    102102   * @param listener may be null
    103103   */
    104   public Storage(I2PSnarkUtil util, File baseFile, String announce, StorageListener listener)
     104  public Storage(I2PSnarkUtil util, File baseFile, String announce,
     105                 boolean privateTorrent, StorageListener listener)
    105106    throws IOException
    106107  {
     
    158159    byte[] piece_hashes = fast_digestCreate();
    159160    metainfo = new MetaInfo(announce, baseFile.getName(), null, files,
    160                             lengthsList, piece_size, piece_hashes, total);
     161                            lengthsList, piece_size, piece_hashes, total, privateTorrent);
    161162
    162163  }
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r88cf742 rcf46310  
    669669                        // This may take a long time to check the storage, but since it already exists,
    670670                        // it shouldn't be THAT bad, so keep it in this thread.
    671                         Storage s = new Storage(_manager.util(), baseFile, announceURL, null);
     671                        Storage s = new Storage(_manager.util(), baseFile, announceURL, req.getParameter("private") != null, null);
    672672                        s.close(); // close the files... maybe need a way to pass this Storage to addTorrent rather than starting over
    673673                        MetaInfo info = s.getMetaInfo();
Note: See TracChangeset for help on using the changeset viewer.