diff --git a/docs/manual.rst b/docs/manual.rst index 7e6804388..e4cacfa2e 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -468,21 +468,22 @@ The file format is a bencoded dictionary containing the following fields: | | especially useful when moving torrents with move_storage() | | | since this will be updated. | +--------------------------+--------------------------------------------------------------+ -| ``peers`` | list of dictionaries. Each dictionary has the following | -| | layout: | -| | | -| | +----------+-----------------------------------------------+ | -| | | ``ip`` | string, the ip address of the peer. This is | | -| | | | not a binary representation of the ip | | -| | | | address, but the string representation. It | | -| | | | may be an IPv6 string or an IPv4 string. | | -| | +----------+-----------------------------------------------+ | -| | | ``port`` | integer, the listen port of the peer | | -| | +----------+-----------------------------------------------+ | -| | | -| | These are the local peers we were connected to when this | -| | fast-resume data was saved. | -| | | +| ``peers`` | string. This string contains IPv4 and port pairs of peers we | +| | were connected to last session. The endpoints are in compact | +| | representation. 4 bytes IPv4 address followed by 2 bytes | +| | port. Hence, the length of this string should be divisible | +| | by 6. | ++--------------------------+--------------------------------------------------------------+ +| ``banned_peers`` | string. This string has the same format as ``peers`` but | +| | instead represent IPv4 peers that we have banned. | ++--------------------------+--------------------------------------------------------------+ +| ``peers6`` | string. This string contains IPv6 and port pairs of peers we | +| | were connected to last session. The endpoints are in compact | +| | representation. 16 bytes IPv6 address followed by 2 bytes | +| | port. The length of this string should be divisible by 18. | ++--------------------------+--------------------------------------------------------------+ +| ``banned_peers6`` | string. This string has the same format as ``peers6`` but | +| | instead represent IPv6 peers that we have banned. | +--------------------------+--------------------------------------------------------------+ | ``unfinished`` | list of dictionaries. Each dictionary represents an | | | piece, and has the following layout: | diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index d84e18c14..f233d185b 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -2009,14 +2009,14 @@ namespace libtorrent // the sequence number of this item boost::uint64_t seq; - // the salf, if any, used to lookup and store this item. If no + // the salt, if any, used to lookup and store this item. If no // salt was used, this is an empty string std::string salt; // the data for this item entry item; - // the last response for mutable date is authoritative. + // the last response for mutable data is authoritative. bool authoritative; }; diff --git a/include/libtorrent/kademlia/dht_storage.hpp b/include/libtorrent/kademlia/dht_storage.hpp index 8bffb9bcb..7e57522d2 100644 --- a/include/libtorrent/kademlia/dht_storage.hpp +++ b/include/libtorrent/kademlia/dht_storage.hpp @@ -115,6 +115,7 @@ namespace dht virtual bool get_peers(sha1_hash const& info_hash , bool noseed, bool scrape , entry& peers) const = 0; + // This function is named announce_peer for consistency with the // upper layers, but has nothing to do with networking. Its only // responsibility is store the peer in such a way that it's returned @@ -139,6 +140,7 @@ namespace dht // virtual bool get_immutable_item(sha1_hash const& target , entry& item) const = 0; + // Store the item's data. This layer is only for storage. // The authentication of the item is performed by the upper layer. // @@ -158,6 +160,7 @@ namespace dht // virtual bool get_mutable_item_seq(sha1_hash const& target , boost::int64_t& seq) const = 0; + // This function retrieves the mutable stored in the DHT. // // For implementers: @@ -166,7 +169,7 @@ namespace dht // the following keys should be filled // item["v"] - with the value no encoded. // item["sig"] - with a string representation of the signature. - // item["k"] - with a string represnetation of the public key. + // item["k"] - with a string representation of the public key. // // returns true if the item is found and the data is returned // inside the (entry) out parameter item. @@ -174,6 +177,7 @@ namespace dht virtual bool get_mutable_item(sha1_hash const& target , boost::int64_t seq, bool force_fill , entry& item) const = 0; + // Store the item's data. This layer is only for storage. // The authentication of the item is performed by the upper layer. // diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 3fee69802..7f0f85264 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -263,7 +263,7 @@ namespace libtorrent // it to finish. The timeout can be set with apply_settings(). ~session(); - // In case you want to destruct the session asynchrounously, you can + // In case you want to destruct the session asynchronously, you can // request a session destruction proxy. If you don't do this, the // destructor of the session object will block while the trackers are // contacted. If you keep one ``session_proxy`` to the session when diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index a23a4fd69..32374ebc0 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -178,10 +178,10 @@ namespace libtorrent // to allow accepting uTP connections as well as TCP. If using the DHT, // this will also make the DHT use the same UDP ports. // - // Note:: - // The current support for opening arbitrary UDP sockets is limited. - // In this version of libtorrent, there will only ever be two UDP - // sockets, one for IPv4 and one for IPv6. + // .. note:: + // The current support for opening arbitrary UDP sockets is limited. + // In this version of libtorrent, there will only ever be two UDP + // sockets, one for IPv4 and one for IPv6. listen_interfaces, // when using a poxy, this is the hostname where the proxy is running diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index ab749cc43..c04dfaadb 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -984,7 +984,7 @@ namespace libtorrent // string containing one or more, comma separated, ip-address (either an // IPv4 or IPv6 address). When specifying multiple interfaces, the // torrent will round-robin which interface to use for each outgoing - // conneciton. This is useful for clients that are multi-homed. + // connection. This is useful for clients that are multi-homed. void use_interface(const char* net_interface) const; // Fills the specified ``std::vector`` with the availability for @@ -993,17 +993,17 @@ namespace libtorrent // for all pieces is reported as 0. // // The piece availability is the number of peers that we are connected - // that has advertized having a particular piece. This is the information + // that has advertised having a particular piece. This is the information // that libtorrent uses in order to prefer picking rare pieces. void piece_availability(std::vector& avail) const; - // These functions are used to set and get the prioritiy of individual + // These functions are used to set and get the priority of individual // pieces. By default all pieces have priority 4. That means that the // random rarest first algorithm is effectively active for all pieces. // You may however change the priority of individual pieces. There are 8 // priority levels. 0 means not to download the piece at all. Otherwise, // lower priority values means less likely to be picked. Piece priority - // takes presedence over piece availability. Every priority-7 piece will + // takes precedence over piece availability. Every priority-7 piece will // be attempted to be picked before a priority 6 piece and so on. // // Piece priorities can not be changed for torrents that have not diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 9a8de81cc..0bcc80b71 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -288,8 +288,8 @@ namespace libtorrent // ``set_web_seeds()`` replaces all web seeds with the ones specified in // the ``seeds`` vector. // - // The ``extern_auth`` argument can be used for other athorization - // schemese than basic HTTP authorization. If set, it will override any + // The ``extern_auth`` argument can be used for other authorization + // schemes than basic HTTP authorization. If set, it will override any // username and password found in the URL itself. The string will be sent // as the HTTP authorization header's value (without specifying "Basic"). // diff --git a/src/enum_net.cpp b/src/enum_net.cpp index 6a50e5bb1..01bf12341 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -278,7 +278,9 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl ifreq req; memset(&req, 0, sizeof(req)); if_indextoname(rtm->rtm_index, req.ifr_name); - if (ioctl(s, siocgifmtu, &req) < 0) return false; + + // ignore errors here. This is best-effort + ioctl(s, siocgifmtu, &req); rt_info->mtu = req.ifr_mtu; return true; @@ -465,10 +467,9 @@ namespace libtorrent memset(&req, 0, sizeof(req)); // -1 to leave a null terminator strncpy(req.ifr_name, iface.name, IF_NAMESIZE - 1); - if (ioctl(s, siocgifmtu, &req) < 0) - { - continue; - } + + // ignore errors here. This is best-effort + ioctl(s, siocgifmtu, &req); iface.mtu = req.ifr_mtu; ret.push_back(iface); } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 4ab2158e7..ec0efe551 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1928,6 +1928,11 @@ retry: if (!ec && s.sock) { + // update the listen_interface member with the + // actual port we ended up listening on, so that the other + // sockets can be bound to the same one + m_listen_interface.port(s.external_port); + TORRENT_ASSERT(!m_abort); m_listen_sockets.push_back(s); diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index 7dd7d7261..83073433d 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -209,6 +209,9 @@ void test_ssl(int test_idx, bool use_utp) ses2.status(); } + wait_for_alert(ses1, torrent_finished_alert::alert_type, "ses1"); + wait_for_downloading(ses2, "ses2"); + // connect the peers after setting the certificates int port = 0; if (test.use_ssl_ports) @@ -219,7 +222,7 @@ void test_ssl(int test_idx, bool use_utp) else port = ses2.listen_port(); - fprintf(stderr, "%s: ses1: connecting peer port: %d\n" + fprintf(stderr, "\n\n%s: ses1: connecting peer port: %d\n\n\n" , time_now_string(), port); tor1.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec) , port)); @@ -263,7 +266,7 @@ void test_ssl(int test_idx, bool use_utp) if (st2.state != torrent_status::downloading) { - static char const* state_str[] = + static char const* state_str[] = {"checking (q)", "checking", "dl metadata" , "downloading", "finished", "seeding", "allocating", "checking (r)"}; std::cerr << "st2 state: " << state_str[st2.state] << std::endl;