merged implied_port from RC_0_16
This commit is contained in:
parent
be6afa74f3
commit
8bc8c1abe8
|
@ -19,6 +19,7 @@
|
||||||
* fix uTP edge case where udp socket buffer fills up
|
* fix uTP edge case where udp socket buffer fills up
|
||||||
* fix nagle implementation in uTP
|
* fix nagle implementation in uTP
|
||||||
|
|
||||||
|
* support 'implied_port' in DHT announce_peer
|
||||||
* don't use pool allocator for disk blocks (cache may now return pages to the kernel)
|
* don't use pool allocator for disk blocks (cache may now return pages to the kernel)
|
||||||
|
|
||||||
0.16.9 release
|
0.16.9 release
|
||||||
|
|
|
@ -46,55 +46,6 @@ namespace libtorrent {
|
||||||
namespace dht {
|
namespace dht {
|
||||||
|
|
||||||
typedef std::vector<char> packet_t;
|
typedef std::vector<char> packet_t;
|
||||||
/*
|
|
||||||
namespace messages
|
|
||||||
{
|
|
||||||
enum { ping = 0, find_node = 1, get_peers = 2, announce_peer = 3, error = 4 };
|
|
||||||
char const* const ids[] = { "ping", "find_node", "get_peers", "announce_peer", "error" };
|
|
||||||
} // namespace messages
|
|
||||||
|
|
||||||
struct msg
|
|
||||||
{
|
|
||||||
msg()
|
|
||||||
: reply(false)
|
|
||||||
, message_id(-1)
|
|
||||||
, port(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// true if this message is a reply
|
|
||||||
bool reply;
|
|
||||||
// the kind if message
|
|
||||||
int message_id;
|
|
||||||
// if this is a reply, a copy of the transaction id
|
|
||||||
// from the request. If it's a request, a transaction
|
|
||||||
// id that should be sent back in the reply
|
|
||||||
std::string transaction_id;
|
|
||||||
// the node id of the process sending the message
|
|
||||||
node_id id;
|
|
||||||
// the address of the process sending or receiving
|
|
||||||
// the message.
|
|
||||||
udp::endpoint addr;
|
|
||||||
// if this is a nodes response, these are the nodes
|
|
||||||
nodes_t nodes;
|
|
||||||
|
|
||||||
peers_t peers;
|
|
||||||
|
|
||||||
// similar to transaction_id but for write operations.
|
|
||||||
std::string write_token;
|
|
||||||
|
|
||||||
// the info has for peer_requests, announce_peer
|
|
||||||
// and responses
|
|
||||||
node_id info_hash;
|
|
||||||
|
|
||||||
// port for announce_peer messages
|
|
||||||
int port;
|
|
||||||
|
|
||||||
// ERROR MESSAGES
|
|
||||||
int error_code;
|
|
||||||
std::string error_msg;
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef std::vector<node_entry> nodes_t;
|
typedef std::vector<node_entry> nodes_t;
|
||||||
typedef std::vector<tcp::endpoint> peers_t;
|
typedef std::vector<tcp::endpoint> peers_t;
|
||||||
|
|
||||||
|
|
|
@ -703,10 +703,11 @@ void node_impl::incoming_request(msg const& m, entry& e)
|
||||||
{"token", lazy_entry::string_t, 0, 0},
|
{"token", lazy_entry::string_t, 0, 0},
|
||||||
{"n", lazy_entry::string_t, 0, key_desc_t::optional},
|
{"n", lazy_entry::string_t, 0, key_desc_t::optional},
|
||||||
{"seed", lazy_entry::int_t, 0, key_desc_t::optional},
|
{"seed", lazy_entry::int_t, 0, key_desc_t::optional},
|
||||||
|
{"implied_port", lazy_entry::int_t, 0, key_desc_t::optional},
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_entry const* msg_keys[5];
|
lazy_entry const* msg_keys[6];
|
||||||
if (!verify_message(arg_ent, msg_desc, msg_keys, 5, error_string, sizeof(error_string)))
|
if (!verify_message(arg_ent, msg_desc, msg_keys, 6, error_string, sizeof(error_string)))
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
++g_failed_announces;
|
++g_failed_announces;
|
||||||
|
@ -716,6 +717,12 @@ void node_impl::incoming_request(msg const& m, entry& e)
|
||||||
}
|
}
|
||||||
|
|
||||||
int port = int(msg_keys[1]->int_value());
|
int port = int(msg_keys[1]->int_value());
|
||||||
|
|
||||||
|
// is the announcer asking to ignore the explicit
|
||||||
|
// listen port and instead use the source port of the packet?
|
||||||
|
if (msg_keys[5] && msg_keys[5]->int_value() != 0)
|
||||||
|
port = m.addr.port();
|
||||||
|
|
||||||
if (port < 0 || port >= 65536)
|
if (port < 0 || port >= 65536)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
|
|
Loading…
Reference in New Issue