merged RC_1_1 into master

This commit is contained in:
arvidn 2016-05-27 12:35:53 -07:00
commit 420b5f51e6
16 changed files with 138 additions and 17 deletions

View File

@ -19,6 +19,8 @@
1.1.1 release
* fixed parsing of IPv6 endpoint with invalid port character separator
* added limited support for new x.pe parameter from BEP 9
* fixed dht stats counters that weren't being updated
* make sure add_torrent_alert is always posted before other alerts for
the torrent

View File

@ -1492,7 +1492,7 @@ int main(int argc, char* argv[])
int tick = 0;
#ifndef WIN32
#ifndef _WIN32
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
#endif
@ -1536,7 +1536,7 @@ int main(int argc, char* argv[])
if (c == ESCAPE_SEQ)
{
// escape code, read another character
#ifdef WIN32
#ifdef _WIN32
c = _getch();
#else
c = getc(stdin);

View File

@ -199,9 +199,12 @@ namespace libtorrent
ret += int(e.preformatted().size());
break;
case entry::undefined_t:
// trying to encode a structure with uninitialized values!
// TORRENT_ASSERT_VAL(false, e.type());
// do nothing
// empty string
write_char(out, '0');
write_char(out, ':');
ret += 2;
break;
}
return ret;

View File

@ -246,7 +246,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_USE_PWRITEV 1
// ==== WINDOWS ===
#elif defined WIN32
#elif defined _WIN32
#define TORRENT_WINDOWS
#ifndef TORRENT_USE_GETIPFORWARDTABLE
# define TORRENT_USE_GETIPFORWARDTABLE 1

View File

@ -141,7 +141,7 @@ namespace libtorrent
struct type_of_service
{
#ifdef WIN32
#ifdef _WIN32
typedef DWORD tos_t;
#else
typedef int tos_t;

View File

@ -102,7 +102,7 @@ std::string demangle(char const* name)
free(unmangled);
return ret;
}
#elif defined WIN32
#elif defined _WIN32
#include "windows.h"
#include "dbghelp.h"
@ -144,7 +144,7 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth, void*)
free(symbols);
}
#elif defined WIN32
#elif defined _WIN32
#include "windows.h"
#include "libtorrent/utf8.hpp"

View File

@ -459,7 +459,7 @@ namespace libtorrent { namespace dht
if (ec == boost::asio::error::connection_refused
|| ec == boost::asio::error::connection_reset
|| ec == boost::asio::error::connection_aborted
#ifdef WIN32
#ifdef _WIN32
|| ec == error_code(ERROR_HOST_UNREACHABLE, system_category())
|| ec == error_code(ERROR_PORT_UNREACHABLE, system_category())
|| ec == error_code(ERROR_CONNECTION_REFUSED, system_category())

View File

@ -39,6 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/hex.hpp" // to_hex, from_hex
#include "libtorrent/socket_io.hpp"
#include <string>
namespace libtorrent
{
std::string make_magnet_uri(torrent_handle const& handle)

View File

@ -125,7 +125,8 @@ void natpmp::start()
}
ADD_OUTSTANDING_ASYNC("natpmp::on_reply");
m_socket.async_receive_from(boost::asio::buffer(&m_response_buffer, 16)
m_socket.async_receive_from(boost::asio::buffer(&m_response_buffer[0]
, sizeof(m_response_buffer))
, m_remote, std::bind(&natpmp::on_reply, self(), _1, _2));
send_get_ip_address_request();
@ -437,10 +438,11 @@ void natpmp::on_reply(error_code const& e
ADD_OUTSTANDING_ASYNC("natpmp::on_reply");
// make a copy of the response packet buffer
// to avoid overwriting it in the next receive call
char msg_buf[16];
char msg_buf[sizeof(m_response_buffer)];
memcpy(msg_buf, m_response_buffer, bytes_transferred);
m_socket.async_receive_from(boost::asio::buffer(&m_response_buffer, 16)
m_socket.async_receive_from(boost::asio::buffer(&m_response_buffer[0]
, sizeof(m_response_buffer))
, m_remote, std::bind(&natpmp::on_reply, self(), _1, _2));
if (m_remote != m_nat_endpoint)
@ -483,7 +485,7 @@ void natpmp::on_reply(error_code const& e
}
if (bytes_transferred < 16)
if (bytes_transferred != 16)
{
#ifndef TORRENT_DISABLE_LOGGING
log("received packet of invalid size: %d", int(bytes_transferred));

View File

@ -2408,7 +2408,7 @@ namespace aux {
&& err != boost::asio::error::operation_aborted
&& err != boost::asio::error::network_reset
&& err != boost::asio::error::network_unreachable
#ifdef WIN32
#ifdef _WIN32
// ERROR_MORE_DATA means the same thing as EMSGSIZE
&& err != error_code(ERROR_MORE_DATA, system_category())
&& err != error_code(ERROR_HOST_UNREACHABLE, system_category())

View File

@ -105,6 +105,11 @@ namespace libtorrent
}
*port_pos = '\0';
++port_pos;
if (port_pos == str.end() || *port_pos != ':')
{
ec = errors::invalid_port;
return ret;
}
#if TORRENT_USE_IPV6
ret.address(address_v6::from_string(&*start, ec));
#else
@ -125,12 +130,13 @@ namespace libtorrent
if (ec) return ret;
}
++port_pos;
if (port_pos == str.end())
{
ec = errors::invalid_port;
return ret;
}
++port_pos;
ret.port(std::atoi(&*port_pos));
return ret;
}

View File

@ -703,6 +703,11 @@ namespace libtorrent
set_limit_impl(p.upload_limit, peer_connection::upload_channel, false);
set_limit_impl(p.download_limit, peer_connection::download_channel, false);
for (auto const& peer : p.peers)
{
add_peer(peer, peer_info::resume_data);
}
#ifndef TORRENT_NO_DEPRECATE
if (!m_name && !m_url.empty()) m_name.reset(new std::string(m_url));
#endif
@ -10728,6 +10733,7 @@ namespace libtorrent
{
if (!m_apply_ip_filter) return;
if (!m_peer_list) return;
if (!m_ip_filter) return;
torrent_state st = get_peer_list_state();
std::vector<address> banned;

View File

@ -121,6 +121,19 @@ TORRENT_TEST(preformatted_node)
TEST_EQUAL(encode(e), "d4:infofoobare");
}
TORRENT_TEST(undefined_node)
{
entry e(entry::undefined_t);
TEST_EQUAL(encode(e), "0:");
}
TORRENT_TEST(undefined_node2)
{
entry e(entry::dictionary_t);
e["info"] = entry(entry::undefined_t);
TEST_EQUAL(encode(e), "d4:info0:e");
}
#ifndef TORRENT_NO_DEPRECATE
TORRENT_TEST(lazy_entry)
{

View File

@ -283,7 +283,7 @@ TORRENT_TEST(file)
{
error_code ec;
file f;
#if TORRENT_USE_UNC_PATHS || !defined WIN32
#if TORRENT_USE_UNC_PATHS || !defined _WIN32
TEST_CHECK(f.open("con", file::read_write, ec));
#else
TEST_CHECK(f.open("test_file", file::read_write, ec));

View File

@ -114,3 +114,58 @@ TORRENT_TEST(socket_io)
TEST_EQUAL(list[0], udp::endpoint(address_v4::from_string("16.5.128.1"), 1337));
}
TORRENT_TEST(parse_invalid_ipv4_endpoint)
{
error_code ec;
tcp::endpoint endp;
endp = parse_endpoint("127.0.0.1-4", ec);
TEST_CHECK(ec);
ec.clear();
endp = parse_endpoint("127.0.0.1", ec);
TEST_CHECK(ec);
ec.clear();
endp = parse_endpoint("127.0.0.1:", ec);
TEST_CHECK(ec);
ec.clear();
endp = parse_endpoint("127.0.0.1X", ec);
TEST_CHECK(ec);
ec.clear();
endp = parse_endpoint("127.0.0.1:4", ec);
TEST_CHECK(!ec);
TEST_EQUAL(endp, ep("127.0.0.1", 4));
ec.clear();
}
#if TORRENT_USE_IPV6
TORRENT_TEST(parse_invalid_ipv6_endpoint)
{
error_code ec;
tcp::endpoint endp;
endp = parse_endpoint("[::1]-4", ec);
TEST_CHECK(ec);
ec.clear();
endp = parse_endpoint("[::1]", ec);
TEST_CHECK(ec);
ec.clear();
endp = parse_endpoint("[::1]:", ec);
TEST_CHECK(ec);
ec.clear();
endp = parse_endpoint("[::1]X", ec);
TEST_CHECK(ec);
ec.clear();
endp = parse_endpoint("[::1]:4", ec);
TEST_CHECK(!ec);
TEST_EQUAL(endp, ep("::1", 4));
ec.clear();
}
#endif

View File

@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/create_torrent.hpp"
#include "libtorrent/alert_types.hpp"
#include "libtorrent/torrent.hpp"
#include "libtorrent/peer_info.hpp"
#include <boost/tuple/tuple.hpp>
#include <boost/make_shared.hpp>
#include <iostream>
@ -210,6 +212,36 @@ TORRENT_TEST(total_wanted)
TEST_EQUAL(st.total_wanted_done, 0);
}
TORRENT_TEST(added_peers)
{
file_storage fs;
fs.add_file("test_torrent_dir4/tmp1", 1024);
libtorrent::create_torrent t(fs, 1024);
std::vector<char> tmp;
bencode(std::back_inserter(tmp), t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(
&tmp[0], tmp.size(), boost::ref(ec)));
settings_pack pack;
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48130");
pack.set_int(settings_pack::max_retry_port_bind, 10);
lt::session ses(pack);
add_torrent_params p;
p.ti = info;
p.save_path = ".";
p.url = "magnet:?xt=urn:btih:abababababababababababababababababababab&x.pe=127.0.0.1:48081&x.pe=127.0.0.2:48082";
torrent_handle h = ses.add_torrent(p);
std::vector<peer_list_entry> v;
h.get_full_peer_list(v);
TEST_EQUAL(v.size(), 2);
}
TORRENT_TEST(torrent)
{
/* {