diff --git a/docs/index.html b/docs/index.html index 1c4c81743..5d73fd2aa 100755 --- a/docs/index.html +++ b/docs/index.html @@ -27,45 +27,50 @@
TODO: describe the type dispatching mechanism
-The currently available alert types are:
----
-- tracker_alert
-- hash_failed_alert
-
You can try a dynamic_cast to these types to get more message-pecific information. Here -are their definitions:
+You can do a dynamic_cast to a specific alert type to get more message-specific information. +These are the different alert types.
+This alert is generated on tracker time outs, premature disconnects, invalid response or +a HTTP response other than "200 OK". From the alert you can get the handle to the torrent +the tracker belongs to. This alert is generated as severity level warning.
struct tracker_alert: alert { @@ -293,7 +296,14 @@ struct tracker_alert: alert torrent_handle handle; }; - ++
This alert is generated when a finished piece fails its hash check. You can get the handle +to the torrent which got the failed piece and the index of the piece itself from the alert. +This alert is generated as severity level info.
+struct hash_failed_alert: alert { hash_failed_alert( @@ -308,8 +318,24 @@ struct hash_failed_alert: alert };
This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer +will be disconnected, but you get its peer-id from the alert. This alert is generated +as severity level debug.
++struct peer_error_alert: alert +{ + peer_error_alert(const peer_id& pid, const std::string& msg); + virtual std::auto_ptr<alert> clone() const; + + peer_id id; +}; ++
The torrent files are bencoded. There are two functions in libtorrent that can encode and decode bencoded data. They are:
@@ -348,7 +374,7 @@ entry e = bdecode(buf, buf + data_size); it will throw invalid_encoding.
The entry class represents one node in a bencoded hierarchy. It works as a variant type, it can be either a list, a dictionary (std::map), an integer or a string. This is its synopsis:
@@ -418,7 +444,7 @@ if (i != dict.end()) exists.The torrent_info has the following synopsis:
class torrent_info @@ -505,7 +531,7 @@ object, representing the time when this torrent file was created. If there's no in the torrent file, this will return a date of january 1:st 1970.
You will usually have to store your torrent handles somewhere, since it's the object through which you retrieve infromation about the torrent and aborts the torrent. Its declaration looks like this:
@@ -544,7 +570,7 @@ torrent. If you set this to -1, there will be no limit.write_resume_data() takes a non-const reference to a char-vector, that vector will be filled with the fast-resume data. For more information about how fast-resume works, see fast resume.
status() will return a structure with information about the status of this torrent. If the torrent_handle is invalid, it will throw invalid_handle exception. It contains the following fields:
@@ -626,7 +652,7 @@ all peers. The rates are given as the number of bytes per second.total_done is the total number of bytes of the file(s) that we have.
get_download_queue() takes a non-const reference to a vector which it will fill information about pieces that are partially downloaded or not downloaded at all but partially requested. The entry in the vector (partial_piece_info) looks like this:
@@ -658,7 +684,7 @@ When a piece fails a hash verification, single blocks may be redownloaded to see may pass then.get_peer_info() takes a reference to a vector that will be cleared and filled with one entry for each peer connected to this torrent, given the handle is valid. If the torrent_handle is invalid, it will throw invalid_handle exception. Each entry in @@ -735,19 +761,19 @@ of bytes of this block we have received from the peer, and < the total number of bytes in this block.
Returns a const reference to the torrent_info object associated with this torrent. This reference is valid as long as the torrent_handle is valid, no longer. If the torrent_handle is invalid, invalid_handle exception will be thrown.
Returns true if this handle refers to a valid torrent and false if it hasn't been initialized or if the torrent it refers to has been aborted.
The address class represents a name of a network endpoint (usually referred to as IP-address) and a port number. This is the same thing as a sockaddr_in would contain. Its declaration looks like this:
@@ -780,7 +806,7 @@ while it does the DNS lookup, it returns a string that points to the address repip() will return the 32-bit ip-address as an integer. port() returns the port number.
You have some control over tracker requests through the http_settings object. You create it and fill it with your settings and the use session::set_http_settings() to apply them. You have control over proxy and authorization settings and also the user-agent @@ -820,7 +846,7 @@ uncompressed (given your limit is lower than 2 megs). Default limit is 1 megabyte.
Both the peer_id and sha1_hash types are typedefs of the class big_number. It represents 20 bytes of data. Its synopsis follows:
@@ -841,7 +867,7 @@ public:The iterators gives you access to individual bytes.
This class creates sha1-hashes. Its declaration looks like this:
class hasher @@ -865,7 +891,7 @@ call reset() to reinitialize i For more info, see src/sha1.c.
The fingerprint class represents information about a client and its version. It is used to encode this information into the client's peer id.
This is the class declaration:
@@ -907,6 +933,9 @@ sure not to clash with anybody else. Here are some taken id's:The major, minor, revision and tag parameters are used to identify the @@ -914,7 +943,7 @@ version of your client. All these numbers must be within the range [0, 9].
to_string() will generate the actual string put in the peer-id, and return it.
The alert class is used to pass messages of events from the libtorrent code to the user. It is a base class that specific messages are derived from. This is its synopsis:
@@ -937,11 +966,11 @@ public:There are a number of exceptions that can be thrown from different places in libtorrent, here's a complete list with description.
This exception is thrown when querying information from a torrent_handle that hasn't been initialized or that has become invalid.
@@ -952,7 +981,7 @@ struct invalid_handle: std::exception
This is thrown by session::add_torrent() if the torrent already has been added to the session.
@@ -963,7 +992,7 @@ struct duplicate_torrent: std::exception
This is thrown by bdecode() if the input data is not a valid bencoding.
struct invalid_encoding: std::exception @@ -973,7 +1002,7 @@ struct invalid_encoding: std::exception
This is thrown from the accessors of entry if the data type of the entry doesn't match the type you want to extract from it.
@@ -984,7 +1013,7 @@ struct type_error: std::runtime_error
This exception is thrown from the constructor of torrent_info if the given bencoded information doesn't meet the requirements on what information has to be present in a torrent file.
@@ -996,9 +1025,9 @@ struct invalid_torrent_file: std::exception
This is an example of a program that will take a torrent-file as a parameter and print information about it to std out:
@@ -1062,7 +1091,7 @@ int main(int argc, char* argv[])
This is a simple client. It doesn't have much output to keep it simple:
#include <iostream> @@ -1114,7 +1143,7 @@ int main(int argc, char* argv[])
The fast resume mechanism is a way to remember which pieces are downloaded and where they are put between sessions. You can generate fast resume data by calling torrent_handle::write_resume_data() on torrent_handle. You can then save this data @@ -1127,7 +1156,7 @@ will skip the time consuming checks. It may have to do the checking anyway, if t fast-resume data is corrupt or doesn't fit the storage for that torrent, then it will not trust the fast-resume data and just do the checking.
The format of the fast-resume data is as follows, given that all 4-byte integers are stored as big-endian:
@@ -1150,12 +1179,12 @@ for each unfinished piece
There's a mailing list.
You can usually find me as hydri in #btports @ irc.freenode.net.
Written by Arvid Norberg and Daniel Wallin. Copyright (c) 2003
Contributions by Magnus Jonsson
Thanks to Reimond Retz for bugfixes, suggestions and testing
diff --git a/docs/index.rst b/docs/index.rst index be471e82f..4b8de3458 100755 --- a/docs/index.rst +++ b/docs/index.rst @@ -983,6 +983,9 @@ sure not to clash with anybody else. Here are some taken id's: +----------+-----------------------+ | 'BX' | BittorrentX | +----------+-----------------------+ +| 'MT' | Moonlight Torrent | ++----------+-----------------------+ + The ``major``, ``minor``, ``revision`` and ``tag`` parameters are used to identify the version of your client. All these numbers must be within the range [0, 9]. diff --git a/src/identify_client.cpp b/src/identify_client.cpp index f10824798..49a0e6f5e 100755 --- a/src/identify_client.cpp +++ b/src/identify_client.cpp @@ -157,6 +157,10 @@ namespace libtorrent else if (std::equal(f->id, f->id+2, "LT")) identity << "libtorrent "; + // Moonlight Torrent + else if (std::equal(f->id, f->id+2, "MT")) + identity << "Moonlight Torrent "; + // unknown client else identity << std::string(f->id, f->id+2) << " ";