fix uTP and SOCKS5 simulations and update libsimulator
This commit is contained in:
parent
8bb1cd2b46
commit
4523e05527
@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "libtorrent/error_code.hpp"
|
#include "libtorrent/error_code.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/time.hpp"
|
||||||
#include "libtorrent/close_reason.hpp"
|
#include "libtorrent/close_reason.hpp"
|
||||||
#include "libtorrent/broadcast_socket.hpp" // for is_v4
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@ -300,12 +299,6 @@ struct TORRENT_EXTRA_EXPORT utp_stream
|
|||||||
template <class Handler>
|
template <class Handler>
|
||||||
void async_connect(endpoint_type const& endpoint, Handler const& handler)
|
void async_connect(endpoint_type const& endpoint, Handler const& handler)
|
||||||
{
|
{
|
||||||
if (!is_v4(endpoint))
|
|
||||||
{
|
|
||||||
m_io_service.post(std::bind<void>(handler, boost::asio::error::operation_not_supported));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_impl == nullptr)
|
if (m_impl == nullptr)
|
||||||
{
|
{
|
||||||
m_io_service.post(std::bind<void>(handler, boost::asio::error::not_connected));
|
m_io_service.post(std::bind<void>(handler, boost::asio::error::not_connected));
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8905f8a0faec37ea0655fc2e7921fad40e904749
|
Subproject commit ffaccc122691d10131a95bbe085ab325f57a602b
|
@ -125,9 +125,9 @@ void run_test(
|
|||||||
ta->handle.connect_peer(lt::tcp::endpoint(peer1, 6881));
|
ta->handle.connect_peer(lt::tcp::endpoint(peer1, 6881));
|
||||||
}
|
}
|
||||||
on_alert(ses, a);
|
on_alert(ses, a);
|
||||||
});
|
}, 0);
|
||||||
|
|
||||||
print_alerts(*ses[1]);
|
print_alerts(*ses[1], [](lt::session&, lt::alert const*){}, 1);
|
||||||
|
|
||||||
// the first peer is a downloader, the second peer is a seed
|
// the first peer is a downloader, the second peer is a seed
|
||||||
lt::add_torrent_params params = create_torrent(1);
|
lt::add_torrent_params params = create_torrent(1);
|
||||||
@ -218,7 +218,8 @@ TORRENT_TEST(no_proxy_utp_ipv6)
|
|||||||
{
|
{
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
run_test(
|
run_test(
|
||||||
[](lt::session&, lt::session&) {},
|
[](lt::session& ses0, lt::session& ses1)
|
||||||
|
{ utp_only(ses0); utp_only(ses1); },
|
||||||
[](lt::session&, lt::alert const*) {},
|
[](lt::session&, lt::alert const*) {},
|
||||||
[](std::shared_ptr<lt::session> ses[2]) {
|
[](std::shared_ptr<lt::session> ses[2]) {
|
||||||
TEST_EQUAL(is_seed(*ses[0]), true);
|
TEST_EQUAL(is_seed(*ses[0]), true);
|
||||||
@ -263,31 +264,33 @@ TORRENT_TEST(no_proxy_utp)
|
|||||||
{
|
{
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
run_test(
|
run_test(
|
||||||
[](lt::session&, lt::session&) {},
|
[](lt::session& ses0, lt::session& ses1)
|
||||||
|
{ utp_only(ses0); utp_only(ses1); },
|
||||||
[](lt::session&, lt::alert const*) {},
|
[](lt::session&, lt::alert const*) {},
|
||||||
[](std::shared_ptr<lt::session> ses[2]) {
|
[](std::shared_ptr<lt::session> ses[2]) {
|
||||||
TEST_EQUAL(is_seed(*ses[0]), true);
|
TEST_EQUAL(is_seed(*ses[0]), true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// TOD: 3 figure out why this test is failing
|
|
||||||
TORRENT_TEST(encryption_utp)
|
TORRENT_TEST(encryption_utp)
|
||||||
{
|
{
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
run_test(
|
run_test(
|
||||||
[](lt::session& ses0, lt::session& ses1)
|
[](lt::session& ses0, lt::session& ses1)
|
||||||
{ enable_enc(ses0); enable_enc(ses1); utp_only(ses0); },
|
{
|
||||||
|
enable_enc(ses0);
|
||||||
|
enable_enc(ses1);
|
||||||
|
utp_only(ses0);
|
||||||
|
utp_only(ses1);
|
||||||
|
},
|
||||||
[](lt::session&, lt::alert const*) {},
|
[](lt::session&, lt::alert const*) {},
|
||||||
[](std::shared_ptr<lt::session> ses[2]) {
|
[](std::shared_ptr<lt::session> ses[2]) {
|
||||||
TEST_EQUAL(is_seed(*ses[0]), true);
|
TEST_EQUAL(is_seed(*ses[0]), true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// TODO: the socks server does not support UDP yet
|
|
||||||
|
|
||||||
/*
|
|
||||||
TORRENT_TEST(socks5_utp)
|
TORRENT_TEST(socks5_utp)
|
||||||
{
|
{
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
@ -297,6 +300,7 @@ TORRENT_TEST(socks5_utp)
|
|||||||
set_proxy(ses0, settings_pack::socks5);
|
set_proxy(ses0, settings_pack::socks5);
|
||||||
utp_only(ses0);
|
utp_only(ses0);
|
||||||
filter_ips(ses1);
|
filter_ips(ses1);
|
||||||
|
utp_only(ses1);
|
||||||
},
|
},
|
||||||
[](lt::session&, lt::alert const*) {},
|
[](lt::session&, lt::alert const*) {},
|
||||||
[](std::shared_ptr<lt::session> ses[2]) {
|
[](std::shared_ptr<lt::session> ses[2]) {
|
||||||
@ -304,7 +308,6 @@ TORRENT_TEST(socks5_utp)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// the purpose of these tests is to make sure that the sessions can't actually
|
// the purpose of these tests is to make sure that the sessions can't actually
|
||||||
// talk directly to each other. i.e. they are negative tests. If they can talk
|
// talk directly to each other. i.e. they are negative tests. If they can talk
|
||||||
@ -325,7 +328,8 @@ TORRENT_TEST(no_proxy_utp_banned)
|
|||||||
{
|
{
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
run_test(
|
run_test(
|
||||||
[](lt::session&, lt::session& ses1) { filter_ips(ses1); },
|
[](lt::session& ses0, lt::session& ses1)
|
||||||
|
{ utp_only(ses0); utp_only(ses1); filter_ips(ses1); },
|
||||||
[](lt::session&, lt::alert const*) {},
|
[](lt::session&, lt::alert const*) {},
|
||||||
[](std::shared_ptr<lt::session> ses[2]) {
|
[](std::shared_ptr<lt::session> ses[2]) {
|
||||||
TEST_EQUAL(is_seed(*ses[0]), false);
|
TEST_EQUAL(is_seed(*ses[0]), false);
|
||||||
|
@ -120,14 +120,15 @@ void set_proxy(lt::session& ses, int proxy_type, int flags, bool proxy_peer_conn
|
|||||||
}
|
}
|
||||||
|
|
||||||
void print_alerts(lt::session& ses
|
void print_alerts(lt::session& ses
|
||||||
, std::function<void(lt::session&, lt::alert const*)> on_alert)
|
, std::function<void(lt::session&, lt::alert const*)> on_alert
|
||||||
|
, int const idx)
|
||||||
{
|
{
|
||||||
lt::time_point start_time = lt::clock_type::now();
|
lt::time_point start_time = lt::clock_type::now();
|
||||||
|
|
||||||
static std::vector<lt::alert*> alerts;
|
static std::vector<lt::alert*> alerts;
|
||||||
|
|
||||||
ses.set_alert_notify([&ses,start_time,on_alert] {
|
ses.set_alert_notify([&ses,start_time,on_alert,idx] {
|
||||||
ses.get_io_service().post([&ses,start_time,on_alert] {
|
ses.get_io_service().post([&ses,start_time,on_alert,idx] {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
alerts.clear();
|
alerts.clear();
|
||||||
@ -135,8 +136,10 @@ void print_alerts(lt::session& ses
|
|||||||
|
|
||||||
for (lt::alert const* a : alerts)
|
for (lt::alert const* a : alerts)
|
||||||
{
|
{
|
||||||
std::printf("%-3d [0] %s\n", int(lt::duration_cast<lt::seconds>(a->timestamp()
|
std::printf("%-3d [%d] %s\n"
|
||||||
- start_time).count()), a->message().c_str());
|
, int(lt::duration_cast<lt::seconds>(a->timestamp() - start_time).count())
|
||||||
|
, idx
|
||||||
|
, a->message().c_str());
|
||||||
// call the user handler
|
// call the user handler
|
||||||
on_alert(ses, a);
|
on_alert(ses, a);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ void set_proxy(lt::session& ses, int proxy_type, int flags = 0
|
|||||||
|
|
||||||
void print_alerts(lt::session& ses
|
void print_alerts(lt::session& ses
|
||||||
, std::function<void(lt::session&, lt::alert const*)> on_alert
|
, std::function<void(lt::session&, lt::alert const*)> on_alert
|
||||||
= [](lt::session&, lt::alert const*) {});
|
= [](lt::session&, lt::alert const*) {}, int idx = 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user