remove some old cruft and defines (#785)
remove some old cruft and defines
This commit is contained in:
parent
8c8f5bb03b
commit
fa8232cd13
|
@ -87,11 +87,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#elif defined __SUNPRO_CC
|
||||
|
||||
// SunPRO seems to have an overly-strict
|
||||
// definition of POD types and doesn't
|
||||
// seem to allow std::array in unions
|
||||
#define TORRENT_BROKEN_UNIONS 1
|
||||
|
||||
#define TORRENT_COMPLETE_TYPES_REQUIRED 1
|
||||
|
||||
// ======= MSVC =========
|
||||
|
@ -104,10 +99,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
// class X needs to have dll-interface to be used by clients of class Y
|
||||
#pragma warning(disable:4251)
|
||||
|
||||
#if (defined(_MSC_VER) && _MSC_VER < 1310)
|
||||
#define TORRENT_COMPLETE_TYPES_REQUIRED 1
|
||||
#endif
|
||||
|
||||
// deprecation markup is only enabled when libtorrent
|
||||
// headers are included by clients, not while building
|
||||
// libtorrent itself
|
||||
|
@ -386,10 +377,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_USE_LOCALE 0
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_BROKEN_UNIONS
|
||||
#define TORRENT_BROKEN_UNIONS 0
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_USE_WSTRING
|
||||
#if !defined BOOST_NO_STD_WSTRING
|
||||
#define TORRENT_USE_WSTRING 1
|
||||
|
@ -488,25 +475,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER <= 1200
|
||||
// this is here to provide a standard-conforming for
|
||||
// keyword for old versions of msvc. The pragmas are
|
||||
// there to silence the warning it produces by using
|
||||
// a constant as conditional
|
||||
#define for \
|
||||
__pragma( warning(push) ) \
|
||||
__pragma( warning(disable:4127) ) \
|
||||
if (false) {} else \
|
||||
__pragma( warning(pop) )
|
||||
for
|
||||
#endif
|
||||
|
||||
#if TORRENT_BROKEN_UNIONS
|
||||
#define TORRENT_UNION struct
|
||||
#else
|
||||
#define TORRENT_UNION union
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__
|
||||
#define TORRENT_FUNCTION __PRETTY_FUNCTION__
|
||||
#else
|
||||
|
|
|
@ -146,7 +146,7 @@ private:
|
|||
|
||||
node_id m_id;
|
||||
|
||||
TORRENT_UNION addr_t
|
||||
union addr_t
|
||||
{
|
||||
#if TORRENT_USE_IPV6
|
||||
address_v6::bytes_type v6;
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace libtorrent
|
|||
};
|
||||
|
||||
private:
|
||||
TORRENT_UNION addr_t
|
||||
union addr_t
|
||||
{
|
||||
address_v4::bytes_type v4;
|
||||
#if TORRENT_USE_IPV6
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
TORRENT_UNION addr_t
|
||||
union addr_t
|
||||
{
|
||||
address_v4::bytes_type v4;
|
||||
#if TORRENT_USE_IPV6
|
||||
|
|
|
@ -52,8 +52,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
#define CCONTROL_TARGET 100
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
#ifndef TORRENT_UTP_LOG_ENABLE
|
||||
|
|
|
@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "settings.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "simulator/utils.hpp"
|
||||
#include "setup_transfer.hpp" // for addr()
|
||||
|
||||
#include "libtorrent/alert.hpp"
|
||||
#include "libtorrent/alert_types.hpp"
|
||||
|
|
|
@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "simulator/http_server.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "create_torrent.hpp"
|
||||
#include "setup_transfer.hpp" // for addr()
|
||||
#include "simulator/simulator.hpp"
|
||||
#include "setup_swarm.hpp"
|
||||
#include "utils.hpp"
|
||||
|
|
|
@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "simulator/utils.hpp"
|
||||
#include "setup_swarm.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "setup_transfer.hpp" // for addr()
|
||||
|
||||
using namespace sim;
|
||||
|
||||
|
|
|
@ -117,11 +117,6 @@ void set_proxy(lt::session& ses, int proxy_type, int flags, bool proxy_peer_conn
|
|||
ses.apply_settings(p);
|
||||
}
|
||||
|
||||
lt::address addr(char const* str)
|
||||
{
|
||||
return lt::address::from_string(str);
|
||||
}
|
||||
|
||||
void print_alerts(lt::session& ses
|
||||
, std::function<void(lt::session&, lt::alert const*)> on_alert)
|
||||
{
|
||||
|
|
|
@ -42,9 +42,6 @@ namespace libtorrent
|
|||
|
||||
namespace lt = libtorrent;
|
||||
|
||||
// construct an address from string
|
||||
lt::address addr(char const* str);
|
||||
|
||||
void utp_only(lt::session& ses);
|
||||
void enable_enc(lt::session& ses);
|
||||
void filter_ips(lt::session& ses);
|
||||
|
|
|
@ -53,8 +53,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
using namespace std::placeholders;
|
||||
|
||||
#define MAX_SYMLINK_PATH 200
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
|
@ -96,6 +94,8 @@ namespace libtorrent
|
|||
#ifndef TORRENT_WINDOWS
|
||||
std::string get_symlink_path_impl(char const* path)
|
||||
{
|
||||
constexpr int MAX_SYMLINK_PATH = 200;
|
||||
|
||||
char buf[MAX_SYMLINK_PATH];
|
||||
std::string f = convert_to_native(path);
|
||||
int char_read = readlink(f.c_str(),buf,MAX_SYMLINK_PATH);
|
||||
|
|
|
@ -941,11 +941,11 @@ namespace libtorrent
|
|||
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
#define TORRENT_SEPARATOR_CHAR '\\'
|
||||
bool need_sep = branch[branch.size()-1] != '\\'
|
||||
bool const need_sep = branch[branch.size()-1] != '\\'
|
||||
&& branch[branch.size()-1] != '/';
|
||||
#else
|
||||
#define TORRENT_SEPARATOR_CHAR '/'
|
||||
bool need_sep = branch[branch.size()-1] != '/';
|
||||
bool const need_sep = branch[branch.size()-1] != '/';
|
||||
#endif
|
||||
|
||||
if (need_sep) branch += TORRENT_SEPARATOR_CHAR;
|
||||
|
@ -960,10 +960,10 @@ namespace libtorrent
|
|||
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
#define TORRENT_SEPARATOR "\\"
|
||||
bool need_sep = lhs[lhs.size()-1] != '\\' && lhs[lhs.size()-1] != '/';
|
||||
bool const need_sep = lhs[lhs.size()-1] != '\\' && lhs[lhs.size()-1] != '/';
|
||||
#else
|
||||
#define TORRENT_SEPARATOR "/"
|
||||
bool need_sep = lhs[lhs.size()-1] != '/';
|
||||
bool const need_sep = lhs[lhs.size()-1] != '/';
|
||||
#endif
|
||||
std::string ret;
|
||||
int target_size = int(lhs.size() + rhs.size() + 2);
|
||||
|
|
|
@ -531,10 +531,6 @@ void http_connection::on_resolve(error_code const& e
|
|||
|
||||
std::random_shuffle(m_endpoints.begin(), m_endpoints.end(), randint);
|
||||
|
||||
// The following statement causes msvc to crash (ICE). Since it's not
|
||||
// necessary in the vast majority of cases, just ignore the endpoint
|
||||
// order for windows
|
||||
#if !defined _MSC_VER || _MSC_VER > 1310
|
||||
// sort the endpoints so that the ones with the same IP version as our
|
||||
// bound listen socket are first. So that when contacting a tracker,
|
||||
// we'll talk to it from the same IP that we're listening on
|
||||
|
@ -542,7 +538,6 @@ void http_connection::on_resolve(error_code const& e
|
|||
std::partition(m_endpoints.begin(), m_endpoints.end()
|
||||
, [this] (tcp::endpoint const& ep)
|
||||
{ return ep.address().is_v4() == m_bind_addr.is_v4(); });
|
||||
#endif
|
||||
|
||||
connect();
|
||||
}
|
||||
|
|
|
@ -934,3 +934,30 @@ tcp::endpoint ep(char const* ip, int port)
|
|||
TEST_CHECK(!ec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
libtorrent::address addr(char const* ip)
|
||||
{
|
||||
lt::error_code ec;
|
||||
auto ret = lt::address::from_string(ip, ec);
|
||||
TEST_CHECK(!ec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
libtorrent::address_v4 addr4(char const* ip)
|
||||
{
|
||||
lt::error_code ec;
|
||||
auto ret = lt::address_v4::from_string(ip, ec);
|
||||
TEST_CHECK(!ec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
libtorrent::address_v6 addr6(char const* ip)
|
||||
{
|
||||
lt::error_code ec;
|
||||
auto ret = lt::address_v6::from_string(ip, ec);
|
||||
TEST_CHECK(!ec);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -107,6 +107,11 @@ EXPORT void stop_proxy(int port);
|
|||
EXPORT void stop_all_proxies();
|
||||
|
||||
EXPORT libtorrent::tcp::endpoint ep(char const* ip, int port);
|
||||
EXPORT libtorrent::address addr(char const* ip);
|
||||
EXPORT libtorrent::address_v4 addr4(char const* ip);
|
||||
#if TORRENT_USE_IPV6
|
||||
EXPORT libtorrent::address_v6 addr6(char const* ip);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include "libtorrent/ip_filter.hpp"
|
||||
#include "setup_transfer.hpp" // for addr()
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
#include "test.hpp"
|
||||
|
@ -57,10 +58,6 @@ bool compare(ip_range<Addr> const& lhs
|
|||
&& lhs.flags == rhs.flags;
|
||||
}
|
||||
|
||||
#define IP(x) address::from_string(x, ec)
|
||||
#define IP4(x) address_v4::from_string(x, ec)
|
||||
#define IP6(x) address_v6::from_string(x, ec)
|
||||
|
||||
template <class T>
|
||||
void test_rules_invariant(std::vector<ip_range<T> > const& r, ip_filter const& f)
|
||||
{
|
||||
|
@ -71,13 +68,13 @@ void test_rules_invariant(std::vector<ip_range<T> > const& r, ip_filter const& f
|
|||
error_code ec;
|
||||
if (sizeof(r.front().first) == sizeof(address_v4))
|
||||
{
|
||||
TEST_CHECK(r.front().first == IP("0.0.0.0"));
|
||||
TEST_CHECK(r.back().last == IP("255.255.255.255"));
|
||||
TEST_CHECK(r.front().first == addr("0.0.0.0"));
|
||||
TEST_CHECK(r.back().last == addr("255.255.255.255"));
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_CHECK(r.front().first == IP("::0"));
|
||||
TEST_CHECK(r.back().last == IP("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
|
||||
TEST_CHECK(r.front().first == addr("::0"));
|
||||
TEST_CHECK(r.back().last == addr("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
|
||||
}
|
||||
|
||||
for (iterator i(r.begin()), j(boost::next(r.begin()))
|
||||
|
@ -99,15 +96,15 @@ TORRENT_TEST(ip_filter)
|
|||
// **** test joining of ranges at the end ****
|
||||
ip_range<address_v4> expected1[] =
|
||||
{
|
||||
{IP4("0.0.0.0"), IP4("0.255.255.255"), 0}
|
||||
, {IP4("1.0.0.0"), IP4("3.0.0.0"), ip_filter::blocked}
|
||||
, {IP4("3.0.0.1"), IP4("255.255.255.255"), 0}
|
||||
{addr4("0.0.0.0"), addr4("0.255.255.255"), 0}
|
||||
, {addr4("1.0.0.0"), addr4("3.0.0.0"), ip_filter::blocked}
|
||||
, {addr4("3.0.0.1"), addr4("255.255.255.255"), 0}
|
||||
};
|
||||
|
||||
{
|
||||
ip_filter f;
|
||||
f.add_rule(IP("1.0.0.0"), IP("2.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("2.0.0.1"), IP("3.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("1.0.0.0"), addr("2.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("2.0.0.1"), addr("3.0.0.0"), ip_filter::blocked);
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
range = boost::get<0>(f.export_filter());
|
||||
|
@ -125,8 +122,8 @@ TORRENT_TEST(ip_filter)
|
|||
|
||||
{
|
||||
ip_filter f;
|
||||
f.add_rule(IP("2.0.0.1"), IP("3.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("1.0.0.0"), IP("2.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("2.0.0.1"), addr("3.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("1.0.0.0"), addr("2.0.0.0"), ip_filter::blocked);
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
range = boost::get<0>(f.export_filter());
|
||||
|
@ -145,8 +142,8 @@ TORRENT_TEST(ip_filter)
|
|||
|
||||
{
|
||||
ip_filter f;
|
||||
f.add_rule(IP("2.0.0.1"), IP("3.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("1.0.0.0"), IP("2.4.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("2.0.0.1"), addr("3.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("1.0.0.0"), addr("2.4.0.0"), ip_filter::blocked);
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
range = boost::get<0>(f.export_filter());
|
||||
|
@ -165,8 +162,8 @@ TORRENT_TEST(ip_filter)
|
|||
|
||||
{
|
||||
ip_filter f;
|
||||
f.add_rule(IP("1.0.0.0"), IP("2.4.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("2.0.0.1"), IP("3.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("1.0.0.0"), addr("2.4.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("2.0.0.1"), addr("3.0.0.0"), ip_filter::blocked);
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
range = boost::get<0>(f.export_filter());
|
||||
|
@ -185,12 +182,12 @@ TORRENT_TEST(ip_filter)
|
|||
|
||||
{
|
||||
ip_filter f;
|
||||
f.add_rule(IP("1.0.0.0"), IP("2.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("3.0.0.0"), IP("4.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("5.0.0.0"), IP("6.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("7.0.0.0"), IP("8.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("1.0.0.0"), addr("2.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("3.0.0.0"), addr("4.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("5.0.0.0"), addr("6.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("7.0.0.0"), addr("8.0.0.0"), ip_filter::blocked);
|
||||
|
||||
f.add_rule(IP("1.0.1.0"), IP("9.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("1.0.1.0"), addr("9.0.0.0"), ip_filter::blocked);
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
range = boost::get<0>(f.export_filter());
|
||||
|
@ -202,9 +199,9 @@ TORRENT_TEST(ip_filter)
|
|||
TEST_CHECK(range.size() == 3);
|
||||
ip_range<address_v4> expected[] =
|
||||
{
|
||||
{IP4("0.0.0.0"), IP4("0.255.255.255"), 0}
|
||||
, {IP4("1.0.0.0"), IP4("9.0.0.0"), ip_filter::blocked}
|
||||
, {IP4("9.0.0.1"), IP4("255.255.255.255"), 0}
|
||||
{addr4("0.0.0.0"), addr4("0.255.255.255"), 0}
|
||||
, {addr4("1.0.0.0"), addr4("9.0.0.0"), ip_filter::blocked}
|
||||
, {addr4("9.0.0.1"), addr4("255.255.255.255"), 0}
|
||||
};
|
||||
|
||||
TEST_CHECK(std::equal(range.begin(), range.end(), expected, &compare<address_v4>));
|
||||
|
@ -215,12 +212,12 @@ TORRENT_TEST(ip_filter)
|
|||
|
||||
{
|
||||
ip_filter f;
|
||||
f.add_rule(IP("1.0.0.0"), IP("2.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("3.0.0.0"), IP("4.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("5.0.0.0"), IP("6.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(IP("7.0.0.0"), IP("8.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("1.0.0.0"), addr("2.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("3.0.0.0"), addr("4.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("5.0.0.0"), addr("6.0.0.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("7.0.0.0"), addr("8.0.0.0"), ip_filter::blocked);
|
||||
|
||||
f.add_rule(IP("0.0.1.0"), IP("7.0.4.0"), ip_filter::blocked);
|
||||
f.add_rule(addr("0.0.1.0"), addr("7.0.4.0"), ip_filter::blocked);
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
range = boost::get<0>(f.export_filter());
|
||||
|
@ -232,9 +229,9 @@ TORRENT_TEST(ip_filter)
|
|||
TEST_CHECK(range.size() == 3);
|
||||
ip_range<address_v4> expected[] =
|
||||
{
|
||||
{IP4("0.0.0.0"), IP4("0.0.0.255"), 0}
|
||||
, {IP4("0.0.1.0"), IP4("8.0.0.0"), ip_filter::blocked}
|
||||
, {IP4("8.0.0.1"), IP4("255.255.255.255"), 0}
|
||||
{addr4("0.0.0.0"), addr4("0.0.0.255"), 0}
|
||||
, {addr4("0.0.1.0"), addr4("8.0.0.0"), ip_filter::blocked}
|
||||
, {addr4("8.0.0.1"), addr4("255.255.255.255"), 0}
|
||||
};
|
||||
|
||||
TEST_CHECK(std::equal(range.begin(), range.end(), expected, &compare<address_v4>));
|
||||
|
@ -247,15 +244,15 @@ TORRENT_TEST(ip_filter)
|
|||
|
||||
ip_range<address_v6> expected2[] =
|
||||
{
|
||||
{IP6("::0"), IP6("0:ffff:ffff:ffff:ffff:ffff:ffff:ffff"), 0}
|
||||
, {IP6("1::"), IP6("3::"), ip_filter::blocked}
|
||||
, {IP6("3::1"), IP6("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"), 0}
|
||||
{addr6("::0"), addr6("0:ffff:ffff:ffff:ffff:ffff:ffff:ffff"), 0}
|
||||
, {addr6("1::"), addr6("3::"), ip_filter::blocked}
|
||||
, {addr6("3::1"), addr6("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"), 0}
|
||||
};
|
||||
|
||||
{
|
||||
ip_filter f;
|
||||
f.add_rule(IP("2::1"), IP("3::"), ip_filter::blocked);
|
||||
f.add_rule(IP("1::"), IP("2::"), ip_filter::blocked);
|
||||
f.add_rule(addr("2::1"), addr("3::"), ip_filter::blocked);
|
||||
f.add_rule(addr("1::"), addr("2::"), ip_filter::blocked);
|
||||
|
||||
std::vector<ip_range<address_v6> > range;
|
||||
range = boost::get<1>(f.export_filter());
|
||||
|
|
Loading…
Reference in New Issue