|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.klomp.snark.MetaInfo
public class MetaInfo
Note: this class is buggy, as it doesn't propogate custom meta fields into the bencoded info data, and from there to the info_hash. At the moment, though, it seems to work with torrents created by I2P-BT, I2PRufus and Azureus.
| Constructor Summary | |
|---|---|
MetaInfo(InputStream in)
Creates a new MetaInfo from the given InputStream. |
|
MetaInfo(Map<String,BEValue> m)
Creates a new MetaInfo from a Map of BEValues and the SHA1 over the original bencoded info dictonary (this is a hack, we could reconstruct the bencoded stream and recalculate the hash). |
|
MetaInfo(String announce,
String name,
String name_utf8,
List<List<String>> files,
List<Long> lengths,
int piece_length,
byte[] piece_hashes,
long length,
boolean privateTorrent)
Called by Storage when creating a new torrent from local data |
|
| Method Summary | |
|---|---|
boolean |
checkPiece(int piece,
byte[] bs,
int off,
int length)
Checks that the given piece has the same SHA1 hash as the given byte array. |
(package private) boolean |
checkPiece(PartialPiece pp)
|
String |
getAnnounce()
Returns the string representing the URL of the tracker for this torrent. |
List<List<String>> |
getFiles()
Returns a list of lists of file name hierarchies or null if it is a single name. |
byte[] |
getInfoBytes()
|
byte[] |
getInfoHash()
Returns the original 20 byte SHA1 hash over the bencoded info map. |
List<Long> |
getLengths()
Returns a list of Longs indication the size of the individual files, or null if it is a single file. |
String |
getName()
Returns the requested name for the file or toplevel directory. |
static String |
getNameAndInfoHash(InputStream in,
byte[] infoHashOut)
Efficiently returns the name and the 20 byte SHA1 hash of the info dictionary in a torrent file Caller must close stream. |
(package private) byte[] |
getPieceHashes()
Returns the piece hashes. |
int |
getPieceLength(int piece)
Return the length of a piece. |
int |
getPieces()
Returns the number of pieces. |
byte[] |
getTorrentData()
Called by servlet to save a new torrent file generated from local data |
long |
getTotalLength()
Returns the total length of the torrent in bytes. |
boolean |
isPrivate()
Is it a private torrent? |
static void |
main(String[] args)
|
MetaInfo |
reannounce(String announce)
Creates a copy of this MetaInfo that shares everything except the announce URL. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
MetaInfo(String announce,
String name,
String name_utf8,
List<List<String>> files,
List<Long> lengths,
int piece_length,
byte[] piece_hashes,
long length,
boolean privateTorrent)
announce - may be nullfiles - null for single-file torrentlengths - null for single-file torrent
public MetaInfo(InputStream in)
throws IOException
IOException
public MetaInfo(Map<String,BEValue> m)
throws InvalidBEncodingException
InvalidBEncodingException| Method Detail |
|---|
public static String getNameAndInfoHash(InputStream in,
byte[] infoHashOut)
throws IOException
infoHashOut - 20-byte out parameter
IOExceptionpublic String getAnnounce()
public byte[] getInfoHash()
byte[] getPieceHashes()
public String getName()
public boolean isPrivate()
public List<List<String>> getFiles()
public List<Long> getLengths()
public int getPieces()
public int getPieceLength(int piece)
getPieces()-1).
IndexOutOfBoundsException - when piece is equal to or
greater then the number of pieces in the torrent.
public boolean checkPiece(int piece,
byte[] bs,
int off,
int length)
boolean checkPiece(PartialPiece pp)
public long getTotalLength()
public String toString()
toString in class Objectpublic MetaInfo reannounce(String announce)
public byte[] getTorrentData()
public byte[] getInfoBytes()
public static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||