diff options
author | Allen Zhong | 2018-06-08 21:52:50 +0800 |
---|---|---|
committer | Allen Zhong | 2018-06-08 21:52:50 +0800 |
commit | 82c95538aa75f69d6b689355a39a522ef46ad162 (patch) | |
tree | b4e4506a7e7235e7abbf8e16a0fc2054a7d7e8fa | |
parent | c1081d9648e538b8960a243301b5eb629ab205f7 (diff) | |
download | aur-82c95538aa75f69d6b689355a39a522ef46ad162.tar.gz |
upgpkg: libtorrent-ipv6 0.13.7-1
-rw-r--r-- | .SRCINFO | 10 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | PKGBUILD | 17 | ||||
-rw-r--r-- | libtorrent-feature-bind-to-0.13.7.patch | 426 |
4 files changed, 443 insertions, 12 deletions
@@ -1,9 +1,9 @@ # Generated by mksrcinfo v8 -# Tue Feb 6 08:19:24 UTC 2018 +# Fri Jun 8 13:42:30 UTC 2018 pkgbase = libtorrent-ipv6 pkgdesc = BitTorrent library with a focus on high performance and good code, with ipv6 support - pkgver = 0.13.6 - pkgrel = 4 + pkgver = 0.13.7 + pkgrel = 1 url = http://rakshasa.github.io/rtorrent/ arch = x86_64 license = GPL @@ -11,8 +11,10 @@ pkgbase = libtorrent-ipv6 depends = openssl provides = libtorrent conflicts = libtorrent - source = libtorrent-0.13.6::git+https://github.com/rakshasa/libtorrent.git#commit=9eb9ba21720e544af3550f59900318a9b4d4a532 + source = libtorrent::git+https://github.com/rakshasa/libtorrent.git#commit=9f15199ce2312350735b1d87e6db033414b41db0 + source = libtorrent-feature-bind-to-0.13.7.patch sha256sums = SKIP + sha256sums = ef0b0ce4378647ac0246dd88f68dc5fbf01336cac13de60e1f4600dd329629f3 pkgname = libtorrent-ipv6 diff --git a/.gitignore b/.gitignore index 1c375f8d2d93..7e9650beff95 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,4 @@ cookies *.o *.log -libtorrent-0.13.6/ +libtorrent/ @@ -8,8 +8,8 @@ _pkgname=libtorrent pkgname=libtorrent-ipv6 -pkgver=0.13.6 -pkgrel=4 +pkgver=0.13.7 +pkgrel=1 pkgdesc='BitTorrent library with a focus on high performance and good code, with ipv6 support' url='http://rakshasa.github.io/rtorrent/' arch=('x86_64') @@ -18,16 +18,19 @@ depends=('openssl') makedepends=('git') conflicts=("${_pkgname}") provides=("${_pkgname}") -source=("$_pkgname-$pkgver::git+https://github.com/rakshasa/libtorrent.git#commit=9eb9ba21720e544af3550f59900318a9b4d4a532") -sha256sums=('SKIP') +source=("$_pkgname::git+https://github.com/rakshasa/libtorrent.git#commit=9f15199ce2312350735b1d87e6db033414b41db0" + 'libtorrent-feature-bind-to-0.13.7.patch') +sha256sums=('SKIP' + 'ef0b0ce4378647ac0246dd88f68dc5fbf01336cac13de60e1f4600dd329629f3') prepare() { - cd "${srcdir}/${_pkgname}-${pkgver}" + cd "${srcdir}/${_pkgname}" + patch -Np1 -i ../libtorrent-feature-bind-to-0.13.7.patch sed '/AM_PATH_CPPUNIT/d' -i configure.ac } build() { - cd "${srcdir}/${_pkgname}-${pkgver}" + cd "${srcdir}/${_pkgname}" ./autogen.sh export CXXFLAGS="${CXXFLAGS} -std=c++11 -fno-strict-aliasing" @@ -39,6 +42,6 @@ build() { } package() { - cd "${srcdir}/${_pkgname}-${pkgver}" + cd "${srcdir}/${_pkgname}" make DESTDIR="${pkgdir}" install } diff --git a/libtorrent-feature-bind-to-0.13.7.patch b/libtorrent-feature-bind-to-0.13.7.patch new file mode 100644 index 000000000000..20327623c464 --- /dev/null +++ b/libtorrent-feature-bind-to-0.13.7.patch @@ -0,0 +1,426 @@ +diff --git a/configure.ac b/configure.ac +index 581b1bb6..da476f5d 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1,12 +1,12 @@ +-AC_INIT(libtorrent, 0.13.6, sundell.software@gmail.com) ++AC_INIT(libtorrent, 0.13.7, sundell.software@gmail.com) + + LT_INIT([disable-static]) + + dnl Find a better way to do this +-AC_DEFINE(PEER_NAME, "-lt0D60-", Identifier that is part of the default peer id) +-AC_DEFINE(PEER_VERSION, "lt\x0D\x60", 4 byte client and version identifier for DHT) ++AC_DEFINE(PEER_NAME, "-lt0D70-", Identifier that is part of the default peer id) ++AC_DEFINE(PEER_VERSION, "lt\x0D\x70", 4 byte client and version identifier for DHT) + +-LIBTORRENT_CURRENT=19 ++LIBTORRENT_CURRENT=20 + LIBTORRENT_REVISION=0 + LIBTORRENT_AGE=0 + +diff --git a/src/torrent/peer/peer_list.cc b/src/torrent/peer/peer_list.cc +index b3d482a6..080a7f13 100644 +--- a/src/torrent/peer/peer_list.cc ++++ b/src/torrent/peer/peer_list.cc +@@ -146,7 +146,11 @@ PeerList::insert_address(const sockaddr* sa, int flags) { + + PeerInfo* peerInfo = new PeerInfo(sa); + peerInfo->set_listen_port(address->port()); +- peerInfo->set_flags(m_ipv4_table.at(address->sa_inet()->address_h()) & PeerInfo::mask_ip_table); ++ uint32_t host_byte_order_ipv4_addr = address->sa_inet()->address_h(); ++ ++ // IPv4 addresses stored in host byte order in ipv4_table so they are comparable. ntohl has been called ++ if(m_ipv4_table.defined(host_byte_order_ipv4_addr)) ++ peerInfo->set_flags(m_ipv4_table.at(host_byte_order_ipv4_addr) & PeerInfo::mask_ip_table); + + manager->client_list()->retrieve_unknown(&peerInfo->mutable_client_info()); + +@@ -267,12 +271,25 @@ PeerList::connected(const sockaddr* sa, int flags) { + !socket_address_key::is_comparable_sockaddr(sa)) + return NULL; + +- int filter_value = m_ipv4_table.at(address->sa_inet()->address_h()); ++ uint32_t host_byte_order_ipv4_addr = address->sa_inet()->address_h(); ++ int filter_value = 0; ++ ++ // IPv4 addresses stored in host byte order in ipv4_table so they are comparable. ntohl has been called ++ if(m_ipv4_table.defined(host_byte_order_ipv4_addr)) ++ filter_value = m_ipv4_table.at(host_byte_order_ipv4_addr); + + // We should also remove any PeerInfo objects already for this + // address. +- if ((filter_value & PeerInfo::flag_unwanted)) ++ if ((filter_value & PeerInfo::flag_unwanted)) { ++ char ipv4_str[INET_ADDRSTRLEN]; ++ uint32_t net_order_addr = htonl(host_byte_order_ipv4_addr); ++ ++ inet_ntop(AF_INET, &net_order_addr, ipv4_str, INET_ADDRSTRLEN); ++ ++ lt_log_print(LOG_PEER_INFO, "Peer %s is unwanted: preventing connection", ipv4_str); ++ + return NULL; ++ } + + PeerInfo* peerInfo; + range_type range = base_type::equal_range(sock_key); +diff --git a/src/torrent/peer/peer_list.h b/src/torrent/peer/peer_list.h +index a3b409cb..4c2f707d 100644 +--- a/src/torrent/peer/peer_list.h ++++ b/src/torrent/peer/peer_list.h +@@ -46,7 +46,7 @@ namespace torrent { + + class DownloadInfo; + +-typedef extents<uint32_t, int, 32, 256, 8> ipv4_table; ++typedef extents<uint32_t, int> ipv4_table; + + class LIBTORRENT_EXPORT PeerList : private std::multimap<socket_address_key, PeerInfo*> { + public: +diff --git a/src/torrent/utils/extents.h b/src/torrent/utils/extents.h +index 8ec1e600..c2b887b1 100644 +--- a/src/torrent/utils/extents.h ++++ b/src/torrent/utils/extents.h +@@ -37,191 +37,150 @@ + #ifndef LIBTORRENT_UTILS_EXTENTS_H + #define LIBTORRENT_UTILS_EXTENTS_H + +-#include lt_tr1_array + +-#include <algorithm> ++#include <map> ++#include <stdexcept> + + namespace torrent { + +-template <typename Key, typename Tp, unsigned int TableSize, unsigned int TableBits> +-struct extents_base { +- typedef Key key_type; +- typedef std::pair<Key, Key> range_type; +- typedef std::pair<extents_base*, Tp> mapped_type; +- typedef Tp mapped_value_type; +- +- typedef std::array<mapped_type, TableSize> table_type; +- +- extents_base(key_type pos, unsigned int mb, mapped_value_type val); +- extents_base(extents_base* parent, typename table_type::const_iterator itr); +- ~extents_base(); +- +- bool is_divisible(key_type key) const { return key % mask_bits == 0; } +- bool is_leaf_branch() const { return mask_bits == 0; } +- bool is_equal_range(key_type first, key_type last, const mapped_value_type& val) const; +- +- unsigned int sizeof_data() const; +- +- typename table_type::iterator partition_at(key_type key) { return table.begin() + ((key >> mask_bits) & (TableSize - 1)); } +- typename table_type::const_iterator partition_at(key_type key) const { return table.begin() + ((key >> mask_bits) & (TableSize - 1)); } +- +- unsigned int mask_distance(unsigned int mb) { return (~(~key_type() << mb) >> mask_bits); } +- +- key_type partition_pos(typename table_type::const_iterator part) const { return position + (std::distance(table.begin(), part) << mask_bits); } +- +- void insert(key_type pos, unsigned int mb, const mapped_value_type& val); +- +- const mapped_value_type& at(key_type key) const; +- +- unsigned int mask_bits; +- key_type position; +- table_type table; +-}; +- +-template <typename Key, typename Tp, unsigned int MaskBits, unsigned int TableSize, unsigned int TableBits> +-class extents : private extents_base<Key, Tp, TableSize, TableBits> { ++template <class Address, class Value, class Compare=std::less<Address> > ++class extents { + public: +- typedef extents_base<Key, Tp, TableSize, TableBits> base_type; +- +- typedef typename base_type::key_type key_type; +- typedef base_type value_type; +- typedef typename base_type::range_type range_type; +- typedef typename base_type::mapped_type mapped_type; +- typedef typename base_type::mapped_value_type mapped_value_type; +- typedef typename base_type::table_type table_type; +- +- static const key_type mask_bits = MaskBits; +- static const key_type table_bits = TableBits; +- static const key_type table_size = TableSize; +- +- using base_type::at; +- using base_type::sizeof_data; ++ typedef Address key_type; // start address ++ typedef Value mapped_value_type; // The value mapped to the ip range ++ typedef std::pair<Address, Value> mapped_type; // End address, value mapped to ip range ++ typedef std::map<key_type, mapped_type, Compare> range_map_type; // The map itself + + extents(); ++ ~extents(); + +- bool is_equal_range(key_type first, key_type last, const mapped_value_type& val) const; +- +- void insert(key_type pos, unsigned int mb, const mapped_value_type& val); ++ void insert(key_type address_start, key_type address_end, mapped_value_type value); ++ bool defined(key_type address_start, key_type address_end); ++ bool defined(key_type address); ++ key_type get_matching_key(key_type address_start, key_type address_end); // throws error on not defined. test with defined() ++ mapped_value_type at(key_type address_start, key_type address_end); // throws error on not defined. test with defined() ++ mapped_value_type at(key_type address); // throws error on not defined. test with defined() ++ unsigned int sizeof_data() const; + +- base_type* data() { return this; } ++ range_map_type range_map; + }; + +-template <typename Key, typename Tp, unsigned int TableSize, unsigned int TableBits> +-extents_base<Key, Tp, TableSize, TableBits>::extents_base(key_type pos, unsigned int mb, mapped_value_type val) : +- mask_bits(mb), position(pos) { +- std::fill(table.begin(), table.end(), mapped_type(NULL, mapped_value_type())); ++/////////////////////////////////////// ++// CONSTRUCTOR [PLACEHOLDER] ++/////////////////////////////////////// ++template <class Address, class Value, class Compare > ++extents<Address, Value, Compare>::extents() { ++ //nothing to do ++ return; + } + +-template <typename Key, typename Tp, unsigned int TableSize, unsigned int TableBits> +-extents_base<Key, Tp, TableSize, TableBits>::extents_base(extents_base* parent, typename table_type::const_iterator itr) : +- mask_bits(parent->mask_bits - TableBits), position(parent->partition_pos(itr)) { +- std::fill(table.begin(), table.end(), mapped_type(NULL, itr->second)); ++/////////////////////////////////////// ++// DESTRUCTOR [PLACEHOLDER] ++/////////////////////////////////////// ++template <class Address, class Value, class Compare > ++extents<Address, Value, Compare>::~extents() { ++ //nothing to do. map destructor can handle cleanup. ++ return; + } + +-template <typename Key, typename Tp, unsigned int MaskBits, unsigned int TableSize, unsigned int TableBits> +-extents<Key, Tp, MaskBits, TableSize, TableBits>::extents() : +- base_type(key_type(), mask_bits - table_bits, mapped_value_type()) +-{ +-} ++////////////////////////////////////////////////////////////////////////////////// ++// INSERT O(log N) assuming no overlapping ranges ++///////////////////////////////////////////////////////////////////////////////// ++template <class Address, class Value, class Compare > ++void extents<Address, Value, Compare>::insert(key_type address_start, key_type address_end, mapped_value_type value) { ++ //we allow overlap ranges though not 100% overlap but only if mapped values are the same. first remove any overlap range that has a different value. ++ typename range_map_type::iterator iter = range_map.upper_bound(address_start); ++ if( iter != range_map.begin() ) { iter--; } ++ bool ignore_due_to_total_overlap = false; ++ while( iter->first <= address_end && iter != range_map.end() ) { ++ key_type delete_key = iter->first; ++ bool do_delete_due_to_overlap = iter->first <= address_end && (iter->second).first >= address_start && (iter->second).second != value; ++ bool do_delete_due_to_total_overlap = address_start <= iter->first && address_end >= (iter->second).first; ++ iter++; ++ if(do_delete_due_to_overlap || do_delete_due_to_total_overlap) { ++ range_map.erase (delete_key); ++ } ++ else { ++ ignore_due_to_total_overlap = ignore_due_to_total_overlap || ( iter->first <= address_start && (iter->second).first >= address_end ); ++ } ++ } + +-template <typename Key, typename Tp, unsigned int TableSize, unsigned int TableBits> +-extents_base<Key, Tp, TableSize, TableBits>::~extents_base() { +- for (typename table_type::const_iterator itr = table.begin(), last = table.end(); itr != last; itr++) +- delete itr->first; ++ if(!ignore_due_to_total_overlap) { ++ mapped_type entry; ++ entry.first = address_end; ++ entry.second = value; ++ range_map.insert( std::pair<key_type,mapped_type>(address_start, entry) ); ++ } + } + +-template <typename Key, typename Tp, unsigned int TableSize, unsigned int TableBits> +-unsigned int +-extents_base<Key, Tp, TableSize, TableBits>::sizeof_data() const { +- unsigned int sum = sizeof(*this); +- +- for (typename table_type::const_iterator itr = table.begin(), last = table.end(); itr != last; itr++) +- if (itr->first != NULL) +- sum += itr->first->sizeof_data(); +- +- return sum; ++////////////////////////////////////////////////////////////////////// ++// DEFINED O(log N) assuming no overlapping ranges ++////////////////////////////////////////////////////////////////////// ++template <class Address, class Value, class Compare > ++bool extents<Address, Value, Compare>::defined(key_type address_start, key_type address_end) { ++ bool defined = false; ++ typename range_map_type::iterator iter = range_map.upper_bound(address_start); ++ if( iter != range_map.begin() ) { iter--; } ++ while( iter->first <= address_end && !defined && iter != range_map.end() ) { ++ defined = iter->first <= address_end && (iter->second).first >= address_start; ++ iter++; ++ } ++ return defined; + } +- +-template <typename Key, typename Tp, unsigned int MaskBits, unsigned int TableSize, unsigned int TableBits> +-void +-extents<Key, Tp, MaskBits, TableSize, TableBits>::insert(key_type pos, unsigned int mb, const mapped_value_type& val) { +- key_type mask = ~key_type() << mb; +- +- base_type::insert(pos & mask, mb, val); ++template <class Address, class Value, class Compare > ++bool extents<Address, Value, Compare>::defined(key_type address) { ++ return defined(address, address); + } + +-template <typename Key, typename Tp, unsigned int TableSize, unsigned int TableBits> +-void +-extents_base<Key, Tp, TableSize, TableBits>::insert(key_type pos, unsigned int mb, const mapped_value_type& val) { +- // RESTRICTED +- typename table_type::iterator first = partition_at(pos); +- typename table_type::iterator last = partition_at(pos) + mask_distance(mb) + 1; +- +- if (mb < mask_bits) { +- if (first->first == NULL) +- first->first = new extents_base(this, first); ++////////////////////////////////////////////////////////////////////// ++// GET_MATCHING_KEY O(log N) assuming no overlapping ranges ++////////////////////////////////////////////////////////////////////// ++template <class Address, class Value, class Compare > ++typename extents<Address, Value, Compare>::key_type extents<Address, Value, Compare>::get_matching_key(key_type address_start, key_type address_end) { ++ key_type key; ++ bool defined = false; ++ typename range_map_type::iterator iter = range_map.upper_bound(address_start); ++ if( iter != range_map.begin() ) { iter--; } ++ while( iter->first <= address_end && !defined && iter != range_map.end() ) { ++ defined = iter->first <= address_end && (iter->second).first >= address_start; ++ if(defined) ++ key = iter->first; + +- first->first->insert(pos, mb, val); +- return; ++ iter++; + } +- +- while (first != last) { +- if (first->first != NULL) { +- delete first->first; +- first->first = NULL; +- } +- +- (first++)->second = val; ++ // this will cause exception to be thrown ++ if(!defined) { ++ std::out_of_range e("nothing defined for specified key"); ++ throw e; + } ++ return key; + } + +-template <typename Key, typename Tp, unsigned int MaskBits, unsigned int TableSize, unsigned int TableBits> +-bool +-extents<Key, Tp, MaskBits, TableSize, TableBits>::is_equal_range(key_type first, key_type last, const mapped_value_type& val) const { +- // RESTRICTED +- first = std::max(first, key_type()); +- last = std::min(last, key_type() + (~key_type() >> (sizeof(key_type) * 8 - MaskBits))); +- +- if (first <= last) +- return base_type::is_equal_range(first, last, val); +- else +- return true; ++////////////////////////////////////////////////////////////////////// ++// AT O(log N) assuming no overlapping ranges ++////////////////////////////////////////////////////////////////////// ++template <class Address, class Value, class Compare > ++typename extents<Address, Value, Compare>::mapped_value_type extents<Address, Value, Compare>::at(key_type address_start, key_type address_end) { ++ key_type key = get_matching_key(address_start, address_end); ++ mapped_type entry = range_map.at(key); ++ return entry.second; + } +- +-template <typename Key, typename Tp, unsigned int TableSize, unsigned int TableBits> +-bool +-extents_base<Key, Tp, TableSize, TableBits>::is_equal_range(key_type key_first, key_type key_last, const mapped_value_type& val) const { +- // RESTRICTED +- typename table_type::const_iterator first = partition_at(key_first); +- typename table_type::const_iterator last = partition_at(key_last) + 1; +- +- do { +- // std::cout << "shift_amount " << key_first << ' ' << key_last << std::endl; +- +- if (first->first == NULL && val != first->second) +- return false; +- +- if (first->first != NULL && !first->first->is_equal_range(std::max(key_first, partition_pos(first)), +- std::min(key_last, partition_pos(first + 1) - 1), val)) +- return false; +- +- } while (++first != last); +- +- return true; ++template <class Address, class Value, class Compare > ++typename extents<Address, Value, Compare>::mapped_value_type extents<Address, Value, Compare>::at(key_type address) { ++ return at(address, address); + } + +-// Assumes 'key' is within the range of the range. +-template <typename Key, typename Tp, unsigned int TableSize, unsigned int TableBits> +-const typename extents_base<Key, Tp, TableSize, TableBits>::mapped_value_type& +-extents_base<Key, Tp, TableSize, TableBits>::at(key_type key) const { +- typename table_type::const_iterator itr = partition_at(key); +- +- while (itr->first != NULL) +- itr = itr->first->partition_at(key); +- +- return itr->second; ++////////////////////////////////////////////////////////////////////// ++// SIZEOF_DATA O(1) ++////////////////////////////////////////////////////////////////////// ++template <class Address, class Value, class Compare > ++unsigned int extents<Address, Value, Compare>::sizeof_data() const { ++ // we don't know overhead on map, so this won't be accurate. just estimate. ++ unsigned int entry_size = sizeof(key_type) + sizeof(mapped_type); ++ return entry_size * range_map.size(); + } + ++ + } + + #endif +diff --git a/test/torrent/utils/test_extents.cc b/test/torrent/utils/test_extents.cc +index 0ce87388..87424d62 100644 +--- a/test/torrent/utils/test_extents.cc ++++ b/test/torrent/utils/test_extents.cc +@@ -16,10 +16,11 @@ void + ExtentsTest::tearDown() { + } + +-typedef torrent::extents<uint32_t, int, 8, 16, 4> extent_type_1; ++//typedef torrent::extents<uint32_t, int, 8, 16, 4> extent_type_1; ++typedef torrent::extents<uint32_t, int> extent_type_1; + + // typedef torrent::extents<uint32_t, int, 0, 256, 16> extent_type_3; +- ++/* + template <typename Extent> + bool + verify_extent_data(Extent& extent, const uint32_t* idx, const int* val) { +@@ -46,11 +47,11 @@ static const int val_basic_1[] = {1, 0, 1}; + + // static const uint32_t idx_basic_2[] = {0, 1, 16, 255, 256, 256}; + // static const int val_basic_2[] = {1, 0, 2, 1}; +- ++*/ + void + ExtentsTest::test_basic() { + extent_type_1 extent_1; +- ++/* + // Test empty. + CPPUNIT_ASSERT(verify_extent_data(extent_1, idx_empty, val_empty)); + +@@ -68,4 +69,5 @@ ExtentsTest::test_basic() { + // extent_1.insert(38, 3, 2); + + // CPPUNIT_ASSERT(verify_extent_data(extent_1, idx_basic_2, val_basic_2)); ++*/ + } |