diff --git a/docs/manual.html b/docs/manual.html index 683998724..f0d33daa8 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -32,35 +32,38 @@
save_path() returns the path that was given to add_torrent() when this torrent was started.
+force_reannounce() will force this torrent to do another tracker request, to receive new +peers. If the torrent is invalid, queued or in checking mode, this functions will throw +invalid_handle.
+connect_peer() is a way to manually connect to peers that one believe is a part of the +torrent. If the peer does not respond, or is not a member of this torrent, it will simply +be disconnected. No harm can be done by using this other than an unnecessary connection +attempt is made. If the torrent is uninitialized or in queued or checking mode, this +will throw invalid_handle.
info_hash() returns the info hash for the torrent.
set_max_uploads() sets the maximum number of peers that's unchoked at the same time on this torrent. If you set this to -1, there will be no limit.
@@ -621,7 +634,8 @@ struct peer_info choked = 0x2, remote_interested = 0x4, remote_choked = 0x8, - supports_extensions = 0x10 + supports_extensions = 0x10, + local_connection = 0x20 }; unsigned int flags; address ip; @@ -643,12 +657,37 @@ struct peer_info };The flags attribute tells you in which state the peer is. It is set to -any combination of the four enums above. Where interesting means that we -are interested in pieces from this peer. choked means that we have -choked this peer. remote_interested and remote_choked means the -same thing but that the peer is interested in pieces from us and the peer has choked -us. support_extensions means that this peer supports the extension protocol -as described by nolar.
+any combination of the enums above. The following table describes each flag: +interesting | +we are interested in pieces from this peer. | +
choked | +we have choked this peer. | +
remote_interested +remote_choked | +means the same thing but that the peer is interested +in pieces from us and the peer has choked us. | +
support_extensions | +means that this peer supports the extension protocol +as described by nolar. | +
local_connection | +The connection was initiated by us, the peer has a +listen port open, and that port is the same is in the +address of this peer. If this flag is not set, this +peer connection was opened by this peer connecting to +us. | +
The ip field is the IP-address to this peer. Its type is a wrapper around the actual address and the port number. See address class.
up_speed and down_speed is the current upload and download speed @@ -658,7 +697,7 @@ from and uploaded to this peer. These numbers do not include the protocol chatte the payload data.
id is the peer's id as used in the bit torrent protocol. This id can be used to extract 'fingerprints' from the peer. Sometimes it can tell you which client the peer -is using.
+is using. See identify_clientpieces is a vector of booleans that has as many entries as there are pieces in the torrent. Each boolean tells you if the peer has that piece (if it's set to true) or if the peer miss that piece (set to false).
@@ -863,9 +902,19 @@ 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 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.
+There's a function, in the header libtorrent/identify_client.hpp, that can be used +to extract a string describing a client version from its peer-id. It has the following +declaration:
++std::string identify_client(const peer_id& id); ++
It will recognize most clients that have this kind of identification in the peer-id.
+The pop_alert() function on session is the interface for retrieving alerts, warnings, messages and errors from libtorrent. If there hasn't occured any errors (matching your severity level) pop_alert() will @@ -946,7 +995,7 @@ have a severity leve that can be used to sort them or present them to the user in different ways.
The specific alerts, that all derives from alert, are:
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.
@@ -961,7 +1010,7 @@ struct tracker_alert: alertThis 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.
@@ -981,7 +1030,7 @@ struct hash_failed_alert: alertThis 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.
@@ -996,7 +1045,7 @@ struct peer_error_alert: alertThis alert is generated when you receive a chat message from another peer. Chat messages are supported as an extension ("chat"). It is generated as severity level critical, even though it doesn't necessarily require any user intervention, it's high priority @@ -1018,16 +1067,16 @@ struct chat_message_alert: alert
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.
@@ -1038,7 +1087,7 @@ struct invalid_handle: std::exception
This is thrown by session::add_torrent() if the torrent already has been added to the session.
@@ -1049,7 +1098,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 @@ -1059,7 +1108,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.
@@ -1070,7 +1119,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.
@@ -1082,9 +1131,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:
@@ -1148,7 +1197,7 @@ int main(int argc, char* argv[])
This is a simple client. It doesn't have much output to keep it simple:
#include <iostream> @@ -1200,7 +1249,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 @@ -1214,18 +1263,18 @@ fast-resume data is corrupt or doesn't fit the storage for that torrent, then it not trust the fast-resume data and just do the checking.
These extensions all operates within the extension protocol. The name of the extension is the name used in the extension-list packets, and the payload is the data in the extended message (not counting the length-prefix, message-id nor extension-id).
These are the extensions that are currently implemented.
Extension name: "chat"
The payload in the packet is a bencoded dictionary with any combination of the following entries:
@@ -1252,7 +1301,7 @@ Any unrecognized strings should be ignored.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/manual.rst b/docs/manual.rst index 58a946b14..3633ea9dd 100755 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -646,7 +646,8 @@ fields:: choked = 0x2, remote_interested = 0x4, remote_choked = 0x8, - supports_extensions = 0x10 + supports_extensions = 0x10, + local_connection = 0x20 }; unsigned int flags; address ip; @@ -668,12 +669,25 @@ fields:: }; The ``flags`` attribute tells you in which state the peer is. It is set to -any combination of the four enums above. Where ``interesting`` means that we -are interested in pieces from this peer. ``choked`` means that **we** have -choked this peer. ``remote_interested`` and ``remote_choked`` means the -same thing but that the peer is interested in pieces from us and the peer has choked -**us**. ``support_extensions`` means that this peer supports the `extension protocol -as described by nolar`__. +any combination of the enums above. The following table describes each flag: + ++-------------------------+-------------------------------------------------------+ +| ``interesting`` | we are interested in pieces from this peer. | ++-------------------------+-------------------------------------------------------+ +| ``choked`` | **we** have choked this peer. | ++-------------------------+-------------------------------------------------------+ +| ``remote_interested`` | means the same thing but that the peer is interested | +| ``remote_choked`` | in pieces from us and the peer has choked **us**. | ++-------------------------+-------------------------------------------------------+ +| ``support_extensions`` | means that this peer supports the `extension protocol | +| | as described by nolar`__. | ++-------------------------+-------------------------------------------------------+ +| ``local_connection`` | The connection was initiated by us, the peer has a | +| | listen port open, and that port is the same is in the | +| | address_ of this peer. If this flag is not set, this | +| | peer connection was opened by this peer connecting to | +| | us. | ++-------------------------+-------------------------------------------------------+ __ http://nolar.com/azureus/extended.htm @@ -922,7 +936,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. identify_client -~~~~~~~~~~~~~~~ +--------------- There's a function, in the header ``libtorrent/identify_client.hpp``, that can be used to extract a string describing a client version from its peer-id. It has the following diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index fa23fd7c1..93c788c5b 100755 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -334,6 +334,9 @@ namespace libtorrent bool support_extensions() const { return m_supports_extensions; } + bool is_local() const + { return m_active; } + #ifndef NDEBUG boost::shared_ptr