mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2025-12-15 23:05:34 +01:00
Revert "libtorrent: upgrade 0.13.8 -> 1"
This reverts commit 3259bc75f5.
AUH incorrectly identified the tag "pre-merge-1" as version "1".
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
parent
f747ee50b2
commit
89e86cd407
|
|
@ -1,44 +0,0 @@
|
|||
From c2b119de0e66fb047bb20e445ac8e25824448858 Mon Sep 17 00:00:00 2001
|
||||
From: chros <chros@chrosGX620>
|
||||
Date: Sun, 30 Jul 2017 20:34:47 +0100
|
||||
Subject: [PATCH] Fix compilation issue with gcc v6.x and empty CXXFLAGS (See
|
||||
#10)
|
||||
|
||||
---
|
||||
configure.ac | 1 +
|
||||
scripts/rak_compiler.m4 | 13 +++++++++++++
|
||||
2 files changed, 14 insertions(+)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 65e34872..2f29e3f9 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -28,6 +28,7 @@ AC_C_BIGENDIAN(
|
||||
AC_MSG_ERROR([Could not determine endianness])
|
||||
)
|
||||
|
||||
+RAK_CHECK_CXXFLAGS
|
||||
RAK_ENABLE_DEBUG
|
||||
RAK_ENABLE_EXTRA_DEBUG
|
||||
RAK_ENABLE_WERROR
|
||||
diff --git a/scripts/rak_compiler.m4 b/scripts/rak_compiler.m4
|
||||
index 39bd19a7..87871abf 100644
|
||||
--- a/scripts/rak_compiler.m4
|
||||
+++ b/scripts/rak_compiler.m4
|
||||
@@ -1,3 +1,16 @@
|
||||
+AC_DEFUN([RAK_CHECK_CXXFLAGS], [
|
||||
+
|
||||
+ AC_MSG_CHECKING([for user-defined CXXFLAGS])
|
||||
+
|
||||
+ if test -n "$CXXFLAGS"; then
|
||||
+ AC_MSG_RESULT([user-defined "$CXXFLAGS"])
|
||||
+ else
|
||||
+ CXXFLAGS="-O2"
|
||||
+ AC_MSG_RESULT([default "$CXXFLAGS"])
|
||||
+ fi
|
||||
+])
|
||||
+
|
||||
+
|
||||
AC_DEFUN([RAK_ENABLE_DEBUG], [
|
||||
AC_ARG_ENABLE(debug,
|
||||
AC_HELP_STRING([--enable-debug], [enable debug information [[default=yes]]]),
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
From 8229218dff1105e9fb2bb2c7510910a0db98f3ef Mon Sep 17 00:00:00 2001
|
||||
From: chros <chros@chrosGX620>
|
||||
Date: Wed, 2 Aug 2017 12:48:27 +0100
|
||||
Subject: [PATCH] Modfiy gcc v6.x fix for empty CXXFLAGS (See #10)
|
||||
|
||||
---
|
||||
configure.ac | 1 +
|
||||
scripts/rak_compiler.m4 | 21 +++++++++++++++++----
|
||||
2 files changed, 18 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 2f29e3f9..a6df6b80 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -28,6 +28,7 @@ AC_C_BIGENDIAN(
|
||||
AC_MSG_ERROR([Could not determine endianness])
|
||||
)
|
||||
|
||||
+RAK_CHECK_CFLAGS
|
||||
RAK_CHECK_CXXFLAGS
|
||||
RAK_ENABLE_DEBUG
|
||||
RAK_ENABLE_EXTRA_DEBUG
|
||||
diff --git a/scripts/rak_compiler.m4 b/scripts/rak_compiler.m4
|
||||
index 87871abf..9a361bed 100644
|
||||
--- a/scripts/rak_compiler.m4
|
||||
+++ b/scripts/rak_compiler.m4
|
||||
@@ -1,12 +1,25 @@
|
||||
+AC_DEFUN([RAK_CHECK_CFLAGS], [
|
||||
+
|
||||
+ AC_MSG_CHECKING([for user-defined CFLAGS])
|
||||
+
|
||||
+ if test "$CFLAGS" = ""; then
|
||||
+ unset CFLAGS
|
||||
+ AC_MSG_RESULT([undefined])
|
||||
+ else
|
||||
+ AC_MSG_RESULT([user-defined "$CFLAGS"])
|
||||
+ fi
|
||||
+])
|
||||
+
|
||||
+
|
||||
AC_DEFUN([RAK_CHECK_CXXFLAGS], [
|
||||
|
||||
AC_MSG_CHECKING([for user-defined CXXFLAGS])
|
||||
|
||||
- if test -n "$CXXFLAGS"; then
|
||||
- AC_MSG_RESULT([user-defined "$CXXFLAGS"])
|
||||
+ if test "$CXXFLAGS" = ""; then
|
||||
+ unset CXXFLAGS
|
||||
+ AC_MSG_RESULT([undefined])
|
||||
else
|
||||
- CXXFLAGS="-O2"
|
||||
- AC_MSG_RESULT([default "$CXXFLAGS"])
|
||||
+ AC_MSG_RESULT([user-defined "$CXXFLAGS"])
|
||||
fi
|
||||
])
|
||||
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From 48635a0fdb06b8572809dc54c630109db1e6e85c Mon Sep 17 00:00:00 2001
|
||||
From: Matt Traudt <sirmatt@ksu.edu>
|
||||
Date: Mon, 20 Nov 2017 15:22:51 -0500
|
||||
Subject: [PATCH] Add space to fmt str in log_gz_file_write
|
||||
|
||||
Without this space, the log level identifier ('D', 'I', etc.)
|
||||
would be right next to actual content.
|
||||
|
||||
Before: <timestamp> Depoll->pcb(17): Open event.
|
||||
After: <timestamp> D epoll->pcb(17): Open event.
|
||||
---
|
||||
src/torrent/utils/log.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/torrent/utils/log.cc b/src/torrent/utils/log.cc
|
||||
index 646d36e3..58b563a6 100644
|
||||
--- a/src/torrent/utils/log.cc
|
||||
+++ b/src/torrent/utils/log.cc
|
||||
@@ -381,7 +381,7 @@ log_gz_file_write(std::shared_ptr<log_gz_output>& outfile, const char* data, siz
|
||||
|
||||
// Normal groups are nul-terminated strings.
|
||||
if (group >= 0) {
|
||||
- const char* fmt = (group >= LOG_NON_CASCADING) ? ("%" PRIi32 " ") : ("%" PRIi32 " %c");
|
||||
+ const char* fmt = (group >= LOG_NON_CASCADING) ? ("%" PRIi32 " ") : ("%" PRIi32 " %c ");
|
||||
|
||||
int buffer_length = snprintf(buffer, 64, fmt,
|
||||
cachedTime.seconds(),
|
||||
|
|
@ -1,379 +0,0 @@
|
|||
From facd1b78071e315a2e5ee4992d3545dae4290e07 Mon Sep 17 00:00:00 2001
|
||||
From: chros <chros@chrosGX620>
|
||||
Date: Sun, 10 Dec 2017 18:51:32 +0000
|
||||
Subject: [PATCH] IPv4 filter enhancement #11IPv4 filter enhancement (Closes
|
||||
#11)
|
||||
|
||||
---
|
||||
src/torrent/peer/peer_list.cc | 23 ++-
|
||||
src/torrent/peer/peer_list.h | 2 +-
|
||||
src/torrent/utils/extents.h | 267 ++++++++++++++--------------------
|
||||
3 files changed, 134 insertions(+), 158 deletions(-)
|
||||
|
||||
diff --git a/src/torrent/peer/peer_list.cc b/src/torrent/peer/peer_list.cc
|
||||
index 23ca651a..aa60939a 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());
|
||||
|
||||
@@ -264,12 +268,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
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
From 4a5ed3897e772c75929b376b08985d844898b619 Mon Sep 17 00:00:00 2001
|
||||
From: chros <chros@chrosGX620>
|
||||
Date: Tue, 12 Dec 2017 15:19:51 +0000
|
||||
Subject: [PATCH] Disable extents test to pass TravisCI (See #11)
|
||||
|
||||
---
|
||||
test/torrent/utils/test_extents.cc | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/test/torrent/utils/test_extents.cc b/test/torrent/utils/test_extents.cc
|
||||
index 6ac5a57d..d6b8d11d 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));
|
||||
+*/
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
From da7db7db29a8488e29d3b0f02906c5db379d4b6d Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Thu, 7 Jun 2018 13:18:03 +0900
|
||||
Subject: [PATCH] Bumped version to 0.13.7.
|
||||
|
||||
---
|
||||
configure.ac | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index a6df6b80..5b1ea237 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
|
||||
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
From dbf6abfd6f905b9218465d15eebec7eedaaed6b0 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Tue, 20 Dec 2016 19:51:02 +0900
|
||||
Subject: [PATCH] Added support for openssl 1.1.
|
||||
|
||||
---
|
||||
configure.ac | 4 ++++
|
||||
src/utils/diffie_hellman.cc | 36 ++++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 38 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 5b1ea237..b885714d 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -71,12 +71,15 @@ AC_ARG_ENABLE(openssl,
|
||||
[ --disable-openssl Don't use OpenSSL's SHA1 implementation.],
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
+dnl move to scripts.
|
||||
PKG_CHECK_MODULES(OPENSSL, libcrypto,
|
||||
CXXFLAGS="$CXXFLAGS $OPENSSL_CFLAGS";
|
||||
LIBS="$LIBS $OPENSSL_LIBS")
|
||||
|
||||
AC_DEFINE(USE_OPENSSL, 1, Using OpenSSL.)
|
||||
AC_DEFINE(USE_OPENSSL_SHA, 1, Using OpenSSL's SHA1 implementation.)
|
||||
+ AC_CHECK_LIB([crypto], [DH_set0_pqg], [AC_DEFINE(USE_OPENSSL_1_1, 1, Using OpenSSL 1.1.)])
|
||||
+
|
||||
else
|
||||
AC_DEFINE(USE_NSS_SHA, 1, Using Mozilla's SHA1 implementation.)
|
||||
fi
|
||||
@@ -87,6 +90,7 @@ AC_ARG_ENABLE(openssl,
|
||||
|
||||
AC_DEFINE(USE_OPENSSL, 1, Using OpenSSL.)
|
||||
AC_DEFINE(USE_OPENSSL_SHA, 1, Using OpenSSL's SHA1 implementation.)
|
||||
+ AC_CHECK_LIB([crypto], [DH_set0_pqg], [AC_DEFINE(USE_OPENSSL_1_1, 1, Using OpenSSL 1.1.)])
|
||||
]
|
||||
)
|
||||
|
||||
diff --git a/src/utils/diffie_hellman.cc b/src/utils/diffie_hellman.cc
|
||||
index aa653d45..7ec13165 100644
|
||||
--- a/src/utils/diffie_hellman.cc
|
||||
+++ b/src/utils/diffie_hellman.cc
|
||||
@@ -54,11 +54,23 @@ DiffieHellman::DiffieHellman(const unsigned char *prime, int primeLength,
|
||||
m_secret(NULL), m_size(0) {
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
+
|
||||
m_dh = DH_new();
|
||||
+
|
||||
+#ifdef USE_OPENSSL_1_1
|
||||
+ BIGNUM * const dh_p = BN_bin2bn(prime, primeLength, NULL);
|
||||
+ BIGNUM * const dh_g = BN_bin2bn(generator, generatorLength, NULL);
|
||||
+
|
||||
+ if (dh_p == NULL || dh_g == NULL ||
|
||||
+ !DH_set0_pqg(m_dh, dh_p, NULL, dh_g))
|
||||
+ throw internal_error("Could not generate Diffie-Hellman parameters");
|
||||
+#else
|
||||
m_dh->p = BN_bin2bn(prime, primeLength, NULL);
|
||||
m_dh->g = BN_bin2bn(generator, generatorLength, NULL);
|
||||
+#endif
|
||||
|
||||
DH_generate_key(m_dh);
|
||||
+
|
||||
#else
|
||||
throw internal_error("Compiled without encryption support.");
|
||||
#endif
|
||||
@@ -74,7 +86,19 @@ DiffieHellman::~DiffieHellman() {
|
||||
bool
|
||||
DiffieHellman::is_valid() const {
|
||||
#ifdef USE_OPENSSL
|
||||
+ if (m_dh == NULL)
|
||||
+ return false;
|
||||
+
|
||||
+#ifdef USE_OPENSSL_1_1
|
||||
+ const BIGNUM *pub_key;
|
||||
+
|
||||
+ DH_get0_key(m_dh, &pub_key, NULL);
|
||||
+
|
||||
+ return pub_key != NULL;
|
||||
+#else
|
||||
return m_dh != NULL && m_dh->pub_key != NULL;
|
||||
+#endif
|
||||
+
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@@ -103,8 +127,16 @@ DiffieHellman::store_pub_key(unsigned char* dest, unsigned int length) {
|
||||
#ifdef USE_OPENSSL
|
||||
std::memset(dest, 0, length);
|
||||
|
||||
- if ((int)length >= BN_num_bytes(m_dh->pub_key))
|
||||
- BN_bn2bin(m_dh->pub_key, dest + length - BN_num_bytes(m_dh->pub_key));
|
||||
+ const BIGNUM *pub_key;
|
||||
+
|
||||
+#ifdef USE_OPENSSL_1_1
|
||||
+ DH_get0_key(m_dh, &pub_key, NULL);
|
||||
+#else
|
||||
+ pub_key = m_dh->pub_key;
|
||||
+#endif
|
||||
+
|
||||
+ if ((int)length >= BN_num_bytes(pub_key))
|
||||
+ BN_bn2bin(pub_key, dest + length - BN_num_bytes(pub_key));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
From c2ec5e0fb8ce7a0df513b5f4086e23d92049ef0e Mon Sep 17 00:00:00 2001
|
||||
From: Stephen Shkardoon <ss23@ss23.geek.nz>
|
||||
Date: Mon, 25 Jun 2018 20:05:18 +1200
|
||||
Subject: [PATCH] Use AC_COMPILE instead of AC_RUN to check for execinfo.h
|
||||
|
||||
This way enables cross compiling, since we don't need to run anything
|
||||
during the configure script.
|
||||
---
|
||||
scripts/common.m4 | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/scripts/common.m4 b/scripts/common.m4
|
||||
index ff023928..b6d051f5 100644
|
||||
--- a/scripts/common.m4
|
||||
+++ b/scripts/common.m4
|
||||
@@ -153,7 +153,7 @@ dnl Need to fix this so that it uses the stuff defined by the system.
|
||||
AC_DEFUN([TORRENT_CHECK_EXECINFO], [
|
||||
AC_MSG_CHECKING(for execinfo.h)
|
||||
|
||||
- AC_RUN_IFELSE([AC_LANG_SOURCE([
|
||||
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
#include <execinfo.h>
|
||||
int main() { backtrace((void**)0, 0); backtrace_symbols((char**)0, 0); return 0;}
|
||||
])],
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
From b0fb874a8921fa4ba2ea0923d779fae8f70c82b1 Mon Sep 17 00:00:00 2001
|
||||
From: Stephen Shkardoon <ss23@ss23.geek.nz>
|
||||
Date: Thu, 21 Jun 2018 14:38:30 +1200
|
||||
Subject: [PATCH] Modify configure to prevent unnecessary kqueue checks
|
||||
|
||||
By only running the TORRENT_CHECK_KQUEUE_SOCKET_ONLY check if kqueue support
|
||||
is already detected, we increase the number of platforms that we can
|
||||
cross compile on.
|
||||
Otherwise, the cross compilation fails due to TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
using AC_RUN_IFELSE, which fails during cross compilation.
|
||||
---
|
||||
scripts/checks.m4 | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
diff --git a/scripts/checks.m4 b/scripts/checks.m4
|
||||
index 8d77fc5e..c9333561 100644
|
||||
--- a/scripts/checks.m4
|
||||
+++ b/scripts/checks.m4
|
||||
@@ -88,6 +88,7 @@ AC_DEFUN([TORRENT_CHECK_KQUEUE], [
|
||||
[
|
||||
AC_DEFINE(USE_KQUEUE, 1, Use kqueue.)
|
||||
AC_MSG_RESULT(yes)
|
||||
+ TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
@@ -137,7 +138,6 @@ AC_DEFUN([TORRENT_WITH_KQUEUE], [
|
||||
[
|
||||
if test "$withval" = "yes"; then
|
||||
TORRENT_CHECK_KQUEUE
|
||||
- TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
fi
|
||||
])
|
||||
])
|
||||
@@ -149,11 +149,9 @@ AC_DEFUN([TORRENT_WITHOUT_KQUEUE], [
|
||||
[
|
||||
if test "$withval" = "yes"; then
|
||||
TORRENT_CHECK_KQUEUE
|
||||
- TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
fi
|
||||
], [
|
||||
TORRENT_CHECK_KQUEUE
|
||||
- TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
])
|
||||
])
|
||||
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
From 4ff83fc53b2c7462b02f804ee20414d85944e3c9 Mon Sep 17 00:00:00 2001
|
||||
From: chros <chros@chrosGX620>
|
||||
Date: Sun, 14 May 2017 19:36:09 +0100
|
||||
Subject: [PATCH] Display info on failed tracker bencode parsing (See #9)
|
||||
|
||||
---
|
||||
rak/string_manip.h | 20 ++++++++++++++++++++
|
||||
src/tracker/tracker_http.cc | 6 ++++--
|
||||
2 files changed, 24 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/rak/string_manip.h b/rak/string_manip.h
|
||||
index f8d3f590..68614d2a 100644
|
||||
--- a/rak/string_manip.h
|
||||
+++ b/rak/string_manip.h
|
||||
@@ -371,6 +371,26 @@ is_all_name(const Sequence& src) {
|
||||
return is_all_name(src.begin(), src.end());
|
||||
}
|
||||
|
||||
+template <typename Iterator>
|
||||
+std::string
|
||||
+sanitize(Iterator first, Iterator last) {
|
||||
+ std::string dest;
|
||||
+ for (; first != last; ++first) {
|
||||
+ if (std::isprint(*first) && *first != '\r' && *first != '\n' && *first != '\t')
|
||||
+ dest += *first;
|
||||
+ else
|
||||
+ dest += " ";
|
||||
+ }
|
||||
+
|
||||
+ return dest;
|
||||
+}
|
||||
+
|
||||
+template <typename Sequence>
|
||||
+std::string
|
||||
+sanitize(const Sequence& src) {
|
||||
+ return trim(sanitize(src.begin(), src.end()));
|
||||
+}
|
||||
+
|
||||
}
|
||||
|
||||
#endif
|
||||
diff --git a/src/tracker/tracker_http.cc b/src/tracker/tracker_http.cc
|
||||
index 553f922c..b6d9e0ac 100644
|
||||
--- a/src/tracker/tracker_http.cc
|
||||
+++ b/src/tracker/tracker_http.cc
|
||||
@@ -288,8 +288,10 @@ TrackerHttp::receive_done() {
|
||||
Object b;
|
||||
*m_data >> b;
|
||||
|
||||
- if (m_data->fail())
|
||||
- return receive_failed("Could not parse bencoded data");
|
||||
+ if (m_data->fail()) {
|
||||
+ std::string dump = m_data->str();
|
||||
+ return receive_failed("Could not parse bencoded data: " + rak::sanitize(dump).substr(0,99));
|
||||
+ }
|
||||
|
||||
if (!b.is_map())
|
||||
return receive_failed("Root not a bencoded map");
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
From 2f197be69057f793d29272b90300f74d0b588d51 Mon Sep 17 00:00:00 2001
|
||||
From: chros <chros@chrosGX620>
|
||||
Date: Mon, 15 May 2017 19:24:33 +0100
|
||||
Subject: [PATCH] Strip tags also when displaying info on failed tracker
|
||||
bencode parsing (See #9)
|
||||
|
||||
---
|
||||
rak/string_manip.h | 25 +++++++++++++++++++++++++
|
||||
src/tracker/tracker_http.cc | 2 +-
|
||||
2 files changed, 26 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/rak/string_manip.h b/rak/string_manip.h
|
||||
index 68614d2a..ae867c98 100644
|
||||
--- a/rak/string_manip.h
|
||||
+++ b/rak/string_manip.h
|
||||
@@ -391,6 +391,31 @@ sanitize(const Sequence& src) {
|
||||
return trim(sanitize(src.begin(), src.end()));
|
||||
}
|
||||
|
||||
+template <typename Iterator>
|
||||
+std::string striptags(Iterator first, Iterator last) {
|
||||
+ bool copychar = true;
|
||||
+ std::string dest;
|
||||
+
|
||||
+ for (; first != last; ++first) {
|
||||
+ if (std::isprint(*first) && *first == '<') {
|
||||
+ copychar = false;
|
||||
+ } else if (std::isprint(*first) && *first == '>') {
|
||||
+ copychar = true;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (copychar)
|
||||
+ dest += *first;
|
||||
+ }
|
||||
+
|
||||
+ return dest;
|
||||
+}
|
||||
+
|
||||
+template <typename Sequence>
|
||||
+std::string striptags(const Sequence& src) {
|
||||
+ return striptags(src.begin(), src.end());
|
||||
+}
|
||||
+
|
||||
}
|
||||
|
||||
#endif
|
||||
diff --git a/src/tracker/tracker_http.cc b/src/tracker/tracker_http.cc
|
||||
index b6d9e0ac..eefe5a17 100644
|
||||
--- a/src/tracker/tracker_http.cc
|
||||
+++ b/src/tracker/tracker_http.cc
|
||||
@@ -290,7 +290,7 @@ TrackerHttp::receive_done() {
|
||||
|
||||
if (m_data->fail()) {
|
||||
std::string dump = m_data->str();
|
||||
- return receive_failed("Could not parse bencoded data: " + rak::sanitize(dump).substr(0,99));
|
||||
+ return receive_failed("Could not parse bencoded data: " + rak::sanitize(rak::striptags(dump)).substr(0,99));
|
||||
}
|
||||
|
||||
if (!b.is_map())
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
From 0e86289a8bb5672781e508683bb28aebf9995127 Mon Sep 17 00:00:00 2001
|
||||
From: lps-rocks <admin@lps.rocks>
|
||||
Date: Mon, 4 Mar 2019 05:03:47 -0500
|
||||
Subject: [PATCH] Switch to C++11 MRT RNG for random bytes
|
||||
|
||||
Switching to a better RNG for generating strings will prevent the common peerID collisions the rTorrent client has been seeing for YEARS in #440 and #318.
|
||||
---
|
||||
rak/string_manip.h | 12 +++++++++---
|
||||
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/rak/string_manip.h b/rak/string_manip.h
|
||||
index ae867c98..1a09c377 100644
|
||||
--- a/rak/string_manip.h
|
||||
+++ b/rak/string_manip.h
|
||||
@@ -39,9 +39,13 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
+#include <climits>
|
||||
#include <cstdlib>
|
||||
+#include <functional>
|
||||
#include <iterator>
|
||||
#include <locale>
|
||||
+#include <random>
|
||||
+
|
||||
|
||||
namespace rak {
|
||||
|
||||
@@ -312,11 +316,13 @@ transform_hex_str(const Sequence& seq) {
|
||||
template <typename Sequence>
|
||||
Sequence
|
||||
generate_random(size_t length) {
|
||||
+ std::random_device rd;
|
||||
+ std::mt19937 mt(rd());
|
||||
+ using bytes_randomizer = std::independent_bits_engine<std::mt19937, CHAR_BIT, uint8_t>;
|
||||
+ bytes_randomizer bytes(mt);
|
||||
Sequence s;
|
||||
s.reserve(length);
|
||||
-
|
||||
- std::generate_n(std::back_inserter(s), length, &::random);
|
||||
-
|
||||
+ std::generate_n(std::back_inserter(s), length, std::ref(bytes));
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
From bf35c5f3d4e458a671fdc3c382f4fa06ecaeb119 Mon Sep 17 00:00:00 2001
|
||||
From: Vladyslav Movchan <vladislav.movchan@gmail.com>
|
||||
Date: Sat, 3 Nov 2018 19:52:56 +0200
|
||||
Subject: [PATCH] Prevent loss of 'm_ipv6_socket' attribute which led to
|
||||
execution of setsockopt(..., IPPROTO_IP, IP_TOS, ...) on IPv6 socket
|
||||
|
||||
---
|
||||
src/net/socket_fd.cc | 4 ++--
|
||||
src/net/socket_fd.h | 1 +
|
||||
2 files changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/net/socket_fd.cc b/src/net/socket_fd.cc
|
||||
index 54cb6ded..f04059f6 100644
|
||||
--- a/src/net/socket_fd.cc
|
||||
+++ b/src/net/socket_fd.cc
|
||||
@@ -251,7 +251,7 @@ SocketFd::accept(rak::socket_address* sa) {
|
||||
socklen_t len = sizeof(rak::socket_address);
|
||||
|
||||
if (sa == NULL) {
|
||||
- return SocketFd(::accept(m_fd, NULL, &len));
|
||||
+ return SocketFd(::accept(m_fd, NULL, &len), m_ipv6_socket);
|
||||
}
|
||||
|
||||
int fd = ::accept(m_fd, sa->c_sockaddr(), &len);
|
||||
@@ -260,7 +260,7 @@ SocketFd::accept(rak::socket_address* sa) {
|
||||
*sa = sa->sa_inet6()->normalize_address();
|
||||
}
|
||||
|
||||
- return SocketFd(fd);
|
||||
+ return SocketFd(fd, m_ipv6_socket);
|
||||
}
|
||||
|
||||
// unsigned int
|
||||
diff --git a/src/net/socket_fd.h b/src/net/socket_fd.h
|
||||
index ca765e88..2329b4e9 100644
|
||||
--- a/src/net/socket_fd.h
|
||||
+++ b/src/net/socket_fd.h
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
|
||||
SocketFd() : m_fd(-1) {}
|
||||
explicit SocketFd(int fd) : m_fd(fd) {}
|
||||
+ SocketFd(int fd, bool ipv6_socket) : m_fd(fd), m_ipv6_socket(ipv6_socket) {}
|
||||
|
||||
bool is_valid() const { return m_fd >= 0; }
|
||||
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From 1890bde5c051d932d1b2940e815d0c82964c474c Mon Sep 17 00:00:00 2001
|
||||
From: Gleb Smirnoff <glebius@FreeBSD.org>
|
||||
Date: Tue, 2 Oct 2018 18:57:43 -0700
|
||||
Subject: [PATCH] If during socket creation AF_INET6 failes initialize sockaddr
|
||||
as AF_INET. Otherwise any bind(2) would fail due to sockaddr address family
|
||||
not matching socket address family.
|
||||
|
||||
---
|
||||
src/net/listen.cc | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/net/listen.cc b/src/net/listen.cc
|
||||
index da1c2e84..d424e94c 100644
|
||||
--- a/src/net/listen.cc
|
||||
+++ b/src/net/listen.cc
|
||||
@@ -75,7 +75,10 @@ Listen::open(uint16_t first, uint16_t last, int backlog, const rak::socket_addre
|
||||
|
||||
// TODO: Temporary until we refactor:
|
||||
if (bindAddress->family() == 0) {
|
||||
- sa.sa_inet6()->clear();
|
||||
+ if (m_ipv6_socket)
|
||||
+ sa.sa_inet6()->clear();
|
||||
+ else
|
||||
+ sa.sa_inet()->clear();
|
||||
} else {
|
||||
sa.copy(*bindAddress, bindAddress->length());
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
From cbd946b6cad8c93b3d39ab4f338b3640f684cbfc Mon Sep 17 00:00:00 2001
|
||||
From: Adam Fontenot <adam.m.fontenot@gmail.com>
|
||||
Date: Sat, 7 Jul 2018 16:52:07 -0700
|
||||
Subject: [PATCH] Fixes https://github.com/rakshasa/rtorrent/issues/731
|
||||
|
||||
---
|
||||
src/tracker/tracker_http.cc | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/tracker/tracker_http.cc b/src/tracker/tracker_http.cc
|
||||
index eefe5a17..1bf94107 100644
|
||||
--- a/src/tracker/tracker_http.cc
|
||||
+++ b/src/tracker/tracker_http.cc
|
||||
@@ -145,13 +145,13 @@ TrackerHttp::send_state(int state) {
|
||||
if (!localAddress->is_address_any())
|
||||
s << "&ip=" << localAddress->address_str();
|
||||
|
||||
- if (localAddress->is_address_any() || localAddress->family() != rak::socket_address::pf_inet6) {
|
||||
+ if (localAddress->is_address_any() && localAddress->family() == rak::socket_address::pf_inet) {
|
||||
rak::socket_address local_v6;
|
||||
if (get_local_address(rak::socket_address::af_inet6, &local_v6))
|
||||
s << "&ipv6=" << rak::copy_escape_html(local_v6.address_str());
|
||||
}
|
||||
|
||||
- if (localAddress->is_address_any() || localAddress->family() != rak::socket_address::pf_inet) {
|
||||
+ if (localAddress->is_address_any() && localAddress->family() == rak::socket_address::pf_inet6) {
|
||||
rak::socket_address local_v4;
|
||||
if (get_local_address(rak::socket_address::af_inet, &local_v4))
|
||||
s << "&ipv4=" << local_v4.address_str();
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
From d49316117401cff4045b1d1194cec60909e45555 Mon Sep 17 00:00:00 2001
|
||||
From: chros <chros@chrosGX620>
|
||||
Date: Sun, 13 May 2018 11:34:33 +0100
|
||||
Subject: [PATCH] Fix honoring throttle.min_peers* settings in rtorrent (See
|
||||
#13)
|
||||
|
||||
---
|
||||
src/download/download_main.cc | 17 ++++++-----------
|
||||
1 file changed, 6 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/download/download_main.cc b/src/download/download_main.cc
|
||||
index 48222c38..efe91d66 100644
|
||||
--- a/src/download/download_main.cc
|
||||
+++ b/src/download/download_main.cc
|
||||
@@ -355,19 +355,14 @@ DownloadMain::receive_tracker_success() {
|
||||
|
||||
void
|
||||
DownloadMain::receive_tracker_request() {
|
||||
- bool should_stop = false;
|
||||
- bool should_start = false;
|
||||
+ if (info()->is_pex_enabled() && info()->size_pex() > 0
|
||||
+ || connection_list()->size() + peer_list()->available_list()->size() / 2 >= connection_list()->min_size()) {
|
||||
|
||||
- if (info()->is_pex_enabled() && info()->size_pex() > 0)
|
||||
- should_stop = true;
|
||||
-
|
||||
- if (connection_list()->size() + peer_list()->available_list()->size() / 2 < connection_list()->min_size())
|
||||
- should_start = true;
|
||||
-
|
||||
- if (should_stop)
|
||||
m_tracker_controller->stop_requesting();
|
||||
- else if (should_start)
|
||||
- m_tracker_controller->start_requesting();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ m_tracker_controller->start_requesting();
|
||||
}
|
||||
|
||||
struct SocketAddressCompact_less {
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
From 9fd2f35f86397b9259e0c9b7c54444c0ec3c8965 Mon Sep 17 00:00:00 2001
|
||||
From: adam <adam@shinka.sh>
|
||||
Date: Mon, 26 Feb 2018 16:04:34 +0200
|
||||
Subject: [PATCH] increase piece length max
|
||||
|
||||
---
|
||||
src/download/download_constructor.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/download/download_constructor.cc b/src/download/download_constructor.cc
|
||||
index 1bb261bd..67ef4276 100644
|
||||
--- a/src/download/download_constructor.cc
|
||||
+++ b/src/download/download_constructor.cc
|
||||
@@ -157,7 +157,7 @@ DownloadConstructor::parse_info(const Object& b) {
|
||||
} else {
|
||||
chunkSize = b.get_key_value("piece length");
|
||||
|
||||
- if (chunkSize <= (1 << 10) || chunkSize > (128 << 20))
|
||||
+ if (chunkSize <= (1 << 10) || chunkSize > (128 << 22))
|
||||
throw input_error("Torrent has an invalid \"piece length\".");
|
||||
}
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
From b263b347f14b9d0ca54d04ca92367a98d791dc17 Mon Sep 17 00:00:00 2001
|
||||
From: Jari Sundell <sundell.software@gmail.com>
|
||||
Date: Sun, 9 Jun 2019 14:53:32 +0900
|
||||
Subject: [PATCH] Set max piece size 512mb.
|
||||
|
||||
---
|
||||
src/download/download_constructor.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/download/download_constructor.cc b/src/download/download_constructor.cc
|
||||
index 67ef4276..1bf362fa 100644
|
||||
--- a/src/download/download_constructor.cc
|
||||
+++ b/src/download/download_constructor.cc
|
||||
@@ -157,7 +157,7 @@ DownloadConstructor::parse_info(const Object& b) {
|
||||
} else {
|
||||
chunkSize = b.get_key_value("piece length");
|
||||
|
||||
- if (chunkSize <= (1 << 10) || chunkSize > (128 << 22))
|
||||
+ if (chunkSize <= (1 << 10) || chunkSize > (512 << 20))
|
||||
throw input_error("Torrent has an invalid \"piece length\".");
|
||||
}
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
From cdfb4381bedb278dabb8ca75c10858d16b895355 Mon Sep 17 00:00:00 2001
|
||||
From: Jari Sundell <sundell.software@gmail.com>
|
||||
Date: Sun, 9 Jun 2019 14:55:44 +0900
|
||||
Subject: [PATCH] Fixed compiler warning.
|
||||
|
||||
---
|
||||
src/download/download_main.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/download/download_main.cc b/src/download/download_main.cc
|
||||
index efe91d66..9a3f9df2 100644
|
||||
--- a/src/download/download_main.cc
|
||||
+++ b/src/download/download_main.cc
|
||||
@@ -355,7 +355,7 @@ DownloadMain::receive_tracker_success() {
|
||||
|
||||
void
|
||||
DownloadMain::receive_tracker_request() {
|
||||
- if (info()->is_pex_enabled() && info()->size_pex() > 0
|
||||
+ if ((info()->is_pex_enabled() && info()->size_pex()) > 0
|
||||
|| connection_list()->size() + peer_list()->available_list()->size() / 2 >= connection_list()->min_size()) {
|
||||
|
||||
m_tracker_controller->stop_requesting();
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
From 8934703edb5982661483eb8a29d76e6a726b5fe2 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Mon, 8 Jul 2019 19:37:06 +0200
|
||||
Subject: [PATCH] Added _GNU_SOURCE to fallocate test. (neheb)
|
||||
|
||||
---
|
||||
scripts/checks.m4 | 10 ++++++----
|
||||
src/data/socket_file.cc | 1 +
|
||||
2 files changed, 7 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/scripts/checks.m4 b/scripts/checks.m4
|
||||
index c9333561..83be8461 100644
|
||||
--- a/scripts/checks.m4
|
||||
+++ b/scripts/checks.m4
|
||||
@@ -88,7 +88,6 @@ AC_DEFUN([TORRENT_CHECK_KQUEUE], [
|
||||
[
|
||||
AC_DEFINE(USE_KQUEUE, 1, Use kqueue.)
|
||||
AC_MSG_RESULT(yes)
|
||||
- TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
@@ -97,7 +96,7 @@ AC_DEFUN([TORRENT_CHECK_KQUEUE], [
|
||||
AC_DEFUN([TORRENT_CHECK_KQUEUE_SOCKET_ONLY], [
|
||||
AC_MSG_CHECKING(whether kqueue supports pipes and ptys)
|
||||
|
||||
- AC_RUN_IFELSE([AC_LANG_SOURCE([
|
||||
+ AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@@ -138,6 +137,7 @@ AC_DEFUN([TORRENT_WITH_KQUEUE], [
|
||||
[
|
||||
if test "$withval" = "yes"; then
|
||||
TORRENT_CHECK_KQUEUE
|
||||
+ TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
fi
|
||||
])
|
||||
])
|
||||
@@ -149,9 +149,11 @@ AC_DEFUN([TORRENT_WITHOUT_KQUEUE], [
|
||||
[
|
||||
if test "$withval" = "yes"; then
|
||||
TORRENT_CHECK_KQUEUE
|
||||
+ TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
fi
|
||||
], [
|
||||
TORRENT_CHECK_KQUEUE
|
||||
+ TORRENT_CHECK_KQUEUE_SOCKET_ONLY
|
||||
])
|
||||
])
|
||||
|
||||
@@ -172,8 +174,8 @@ AC_DEFUN([TORRENT_WITHOUT_VARIABLE_FDSET], [
|
||||
AC_DEFUN([TORRENT_CHECK_FALLOCATE], [
|
||||
AC_MSG_CHECKING(for fallocate)
|
||||
|
||||
- AC_TRY_LINK([#include <fcntl.h>
|
||||
- #include <linux/falloc.h>
|
||||
+ AC_TRY_LINK([#define _GNU_SOURCE
|
||||
+ #include <fcntl.h>
|
||||
],[ fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 0); return 0;
|
||||
],
|
||||
[
|
||||
diff --git a/src/data/socket_file.cc b/src/data/socket_file.cc
|
||||
index 4b4519ed..b359ef8e 100644
|
||||
--- a/src/data/socket_file.cc
|
||||
+++ b/src/data/socket_file.cc
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_FALLOCATE
|
||||
+#define _GNU_SOURCE
|
||||
#include <linux/falloc.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -1,293 +0,0 @@
|
|||
From 856d42e2ca3c9810bf84a8bce219000e822540fa Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Fri, 12 Jul 2019 00:29:35 +0200
|
||||
Subject: [PATCH] Fixed diffie hellman implementation.
|
||||
|
||||
---
|
||||
src/utils/diffie_hellman.cc | 137 ++++++++++++------------------------
|
||||
src/utils/diffie_hellman.h | 67 ++++--------------
|
||||
2 files changed, 59 insertions(+), 145 deletions(-)
|
||||
|
||||
diff --git a/src/utils/diffie_hellman.cc b/src/utils/diffie_hellman.cc
|
||||
index 7ec13165..d53a857b 100644
|
||||
--- a/src/utils/diffie_hellman.cc
|
||||
+++ b/src/utils/diffie_hellman.cc
|
||||
@@ -1,118 +1,79 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
+#include "diffie_hellman.h"
|
||||
+
|
||||
+#include "torrent/exceptions.h"
|
||||
+
|
||||
#include <cstring>
|
||||
-#include <string>
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
+#include <openssl/dh.h>
|
||||
#include <openssl/bn.h>
|
||||
#endif
|
||||
|
||||
-#include "diffie_hellman.h"
|
||||
-#include "torrent/exceptions.h"
|
||||
-
|
||||
namespace torrent {
|
||||
|
||||
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
-DiffieHellman::DiffieHellman(const unsigned char *prime, int primeLength,
|
||||
- const unsigned char *generator, int generatorLength) :
|
||||
- m_secret(NULL), m_size(0) {
|
||||
-
|
||||
#ifdef USE_OPENSSL
|
||||
|
||||
- m_dh = DH_new();
|
||||
-
|
||||
-#ifdef USE_OPENSSL_1_1
|
||||
- BIGNUM * const dh_p = BN_bin2bn(prime, primeLength, NULL);
|
||||
- BIGNUM * const dh_g = BN_bin2bn(generator, generatorLength, NULL);
|
||||
+static void dh_free(void* dh) { DH_free(reinterpret_cast<DH*>(dh)); }
|
||||
+static DiffieHellman::dh_ptr dh_new() { return DiffieHellman::dh_ptr(reinterpret_cast<void*>(DH_new()), &dh_free); }
|
||||
+static DH* dh_get(DiffieHellman::dh_ptr& dh) { return reinterpret_cast<DH*>(dh.get()); }
|
||||
|
||||
- if (dh_p == NULL || dh_g == NULL ||
|
||||
- !DH_set0_pqg(m_dh, dh_p, NULL, dh_g))
|
||||
- throw internal_error("Could not generate Diffie-Hellman parameters");
|
||||
+static bool
|
||||
+dh_set_pg(DiffieHellman::dh_ptr& dh, BIGNUM* dh_p, BIGNUM* dh_g) {
|
||||
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
+ return DH_set0_pqg(reinterpret_cast<DH*>(dh.get()), dh_p, nullptr, dh_g);
|
||||
#else
|
||||
- m_dh->p = BN_bin2bn(prime, primeLength, NULL);
|
||||
- m_dh->g = BN_bin2bn(generator, generatorLength, NULL);
|
||||
+ reinterpret_cast<DH*>(dh.get())->p = dh_p;
|
||||
+ reinterpret_cast<DH*>(dh.get())->g = dh_g;
|
||||
+ return true;
|
||||
#endif
|
||||
+}
|
||||
|
||||
- DH_generate_key(m_dh);
|
||||
-
|
||||
+static const BIGNUM* dh_get_pub_key(const DiffieHellman::dh_ptr& dh) {
|
||||
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
+ const BIGNUM *pub_key;
|
||||
+ DH_get0_key(reinterpret_cast<DH*>(dh.get()), &pub_key, nullptr);
|
||||
+ return pub_key;
|
||||
#else
|
||||
- throw internal_error("Compiled without encryption support.");
|
||||
+ return dh != nullptr ? reinterpret_cast<DH*>(dh.get())->pub_key : nullptr;
|
||||
#endif
|
||||
-};
|
||||
+}
|
||||
|
||||
-DiffieHellman::~DiffieHellman() {
|
||||
- delete [] m_secret;
|
||||
-#ifdef USE_OPENSSL
|
||||
- DH_free(m_dh);
|
||||
+#else
|
||||
+static DiffieHellman::dh_ptr dh_new() { throw internal_error("Compiled without encryption support."); }
|
||||
+static void dh_free(void* dh) {}
|
||||
+static void* dh_get_pub_key(const DiffieHellman::dh_ptr& dh) { return nullptr; }
|
||||
#endif
|
||||
-};
|
||||
|
||||
-bool
|
||||
-DiffieHellman::is_valid() const {
|
||||
-#ifdef USE_OPENSSL
|
||||
- if (m_dh == NULL)
|
||||
- return false;
|
||||
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
+DiffieHellman::DiffieHellman(const unsigned char *prime, int primeLength,
|
||||
+ const unsigned char *generator, int generatorLength) :
|
||||
+ m_dh(dh_new()), m_size(0) {
|
||||
|
||||
-#ifdef USE_OPENSSL_1_1
|
||||
- const BIGNUM *pub_key;
|
||||
+#ifdef USE_OPENSSL
|
||||
+ BIGNUM* dh_p = BN_bin2bn(prime, primeLength, nullptr);
|
||||
+ BIGNUM* dh_g = BN_bin2bn(generator, generatorLength, nullptr);
|
||||
|
||||
- DH_get0_key(m_dh, &pub_key, NULL);
|
||||
+ if (dh_p == nullptr || dh_g == nullptr || !dh_set_pg(m_dh, dh_p, dh_g))
|
||||
+ throw internal_error("Could not generate Diffie-Hellman parameters");
|
||||
|
||||
- return pub_key != NULL;
|
||||
-#else
|
||||
- return m_dh != NULL && m_dh->pub_key != NULL;
|
||||
+ DH_generate_key(dh_get(m_dh));
|
||||
#endif
|
||||
+};
|
||||
|
||||
-#else
|
||||
- return false;
|
||||
-#endif
|
||||
+bool
|
||||
+DiffieHellman::is_valid() const {
|
||||
+ return dh_get_pub_key(m_dh) != nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
DiffieHellman::compute_secret(const unsigned char *pubkey, unsigned int length) {
|
||||
#ifdef USE_OPENSSL
|
||||
- BIGNUM* k = BN_bin2bn(pubkey, length, NULL);
|
||||
+ BIGNUM* k = BN_bin2bn(pubkey, length, nullptr);
|
||||
|
||||
- delete [] m_secret;
|
||||
- m_secret = new char[DH_size(m_dh)];
|
||||
-
|
||||
- m_size = DH_compute_key((unsigned char*)m_secret, k, m_dh);
|
||||
+ m_secret.reset(new char[DH_size(dh_get(m_dh))]);
|
||||
+ m_size = DH_compute_key(reinterpret_cast<unsigned char*>(m_secret.get()), k, dh_get(m_dh));
|
||||
|
||||
BN_free(k);
|
||||
|
||||
@@ -124,16 +85,10 @@ DiffieHellman::compute_secret(const unsigned char *pubkey, unsigned int length)
|
||||
|
||||
void
|
||||
DiffieHellman::store_pub_key(unsigned char* dest, unsigned int length) {
|
||||
-#ifdef USE_OPENSSL
|
||||
std::memset(dest, 0, length);
|
||||
|
||||
- const BIGNUM *pub_key;
|
||||
-
|
||||
-#ifdef USE_OPENSSL_1_1
|
||||
- DH_get0_key(m_dh, &pub_key, NULL);
|
||||
-#else
|
||||
- pub_key = m_dh->pub_key;
|
||||
-#endif
|
||||
+#ifdef USE_OPENSSL
|
||||
+ const BIGNUM *pub_key = dh_get_pub_key(m_dh);
|
||||
|
||||
if ((int)length >= BN_num_bytes(pub_key))
|
||||
BN_bn2bin(pub_key, dest + length - BN_num_bytes(pub_key));
|
||||
diff --git a/src/utils/diffie_hellman.h b/src/utils/diffie_hellman.h
|
||||
index 432542be..2cec5bee 100644
|
||||
--- a/src/utils/diffie_hellman.h
|
||||
+++ b/src/utils/diffie_hellman.h
|
||||
@@ -1,79 +1,38 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#ifndef LIBTORRENT_DIFFIE_HELLMAN_H
|
||||
#define LIBTORRENT_DIFFIE_HELLMAN_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
+#include <memory>
|
||||
#include <string>
|
||||
|
||||
-#ifdef USE_OPENSSL
|
||||
-#include <openssl/dh.h>
|
||||
-#endif
|
||||
-
|
||||
namespace torrent {
|
||||
|
||||
class DiffieHellman {
|
||||
public:
|
||||
+ typedef std::unique_ptr<char[]> secret_ptr;
|
||||
+ typedef std::unique_ptr<void, void (*)(void*)> dh_ptr;
|
||||
+
|
||||
DiffieHellman(const unsigned char prime[], int primeLength,
|
||||
const unsigned char generator[], int generatorLength);
|
||||
- ~DiffieHellman();
|
||||
|
||||
- bool compute_secret(const unsigned char pubkey[], unsigned int length);
|
||||
- void store_pub_key(unsigned char* dest, unsigned int length);
|
||||
+ bool is_valid() const;
|
||||
|
||||
- bool is_valid() const;
|
||||
+ bool compute_secret(const unsigned char pubkey[], unsigned int length);
|
||||
+ void store_pub_key(unsigned char* dest, unsigned int length);
|
||||
|
||||
- unsigned int size() const { return m_size; }
|
||||
+ unsigned int size() const { return m_size; }
|
||||
|
||||
- const char* c_str() const { return m_secret; }
|
||||
- std::string secret_str() const { return std::string(m_secret, m_size); }
|
||||
+ const char* c_str() const { return m_secret.get(); }
|
||||
+ std::string secret_str() const { return std::string(m_secret.get(), m_size); }
|
||||
|
||||
private:
|
||||
DiffieHellman(const DiffieHellman& dh);
|
||||
DiffieHellman& operator = (const DiffieHellman& dh);
|
||||
|
||||
-#ifdef USE_OPENSSL
|
||||
- DH* m_dh;
|
||||
-#else
|
||||
- void* m_void;
|
||||
-#endif
|
||||
- char* m_secret;
|
||||
- unsigned int m_size;
|
||||
+ dh_ptr m_dh;
|
||||
+ secret_ptr m_secret;
|
||||
+ int m_size;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
From 660bbc17e32c518c2727607ee5b73039c7109207 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Sat, 13 Jul 2019 00:07:43 +0200
|
||||
Subject: [PATCH] Increased max timeout for tracker requests.
|
||||
|
||||
---
|
||||
src/torrent/tracker.h | 40 ++--------------------------------------
|
||||
1 file changed, 2 insertions(+), 38 deletions(-)
|
||||
|
||||
diff --git a/src/torrent/tracker.h b/src/torrent/tracker.h
|
||||
index 2b00ad47..a528ef6a 100644
|
||||
--- a/src/torrent/tracker.h
|
||||
+++ b/src/torrent/tracker.h
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#ifndef LIBTORRENT_TRACKER_H
|
||||
#define LIBTORRENT_TRACKER_H
|
||||
|
||||
@@ -148,8 +112,8 @@ protected:
|
||||
|
||||
void set_group(uint32_t v) { m_group = v; }
|
||||
|
||||
- void set_normal_interval(int v) { m_normal_interval = std::min(std::max(600, v), 3600); }
|
||||
- void set_min_interval(int v) { m_min_interval = std::min(std::max(300, v), 1800); }
|
||||
+ void set_normal_interval(int v) { m_normal_interval = std::min(std::max(600, v), 8 * 3600); }
|
||||
+ void set_min_interval(int v) { m_min_interval = std::min(std::max(300, v), 4 * 3600); }
|
||||
|
||||
int m_flags;
|
||||
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
From efc75948253c1a8db482daabf45d9eabaaf4b099 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Wed, 17 Jul 2019 19:41:04 +0200
|
||||
Subject: [PATCH] Close log files when reusing a name.
|
||||
|
||||
---
|
||||
src/torrent/utils/log.cc | 20 ++++++++++++++++----
|
||||
src/torrent/utils/log.h | 7 +++++++
|
||||
test/torrent/tracker_timeout_test.cc | 8 ++++----
|
||||
test/torrent/utils/log_test.cc | 12 ++++++------
|
||||
4 files changed, 33 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/src/torrent/utils/log.cc b/src/torrent/utils/log.cc
|
||||
index 58b563a6..5169a730 100644
|
||||
--- a/src/torrent/utils/log.cc
|
||||
+++ b/src/torrent/utils/log.cc
|
||||
@@ -294,12 +294,16 @@ log_open_output(const char* name, log_slot slot) {
|
||||
throw input_error("Cannot open more than 64 log output handlers.");
|
||||
}
|
||||
|
||||
- if (log_find_output_name(name) != log_outputs.end()) {
|
||||
- pthread_mutex_unlock(&log_mutex);
|
||||
- throw input_error("Log name already used.");
|
||||
+ log_output_list::iterator itr = log_find_output_name(name);
|
||||
+
|
||||
+ if (itr == log_outputs.end()) {
|
||||
+ log_outputs.push_back(std::make_pair(name, slot));
|
||||
+ } else {
|
||||
+ // by replacing the "write" slot binding, the old file gets closed
|
||||
+ // (handles are shared pointers)
|
||||
+ itr->second = slot;
|
||||
}
|
||||
|
||||
- log_outputs.push_back(std::make_pair(name, slot));
|
||||
log_rebuild_cache();
|
||||
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
@@ -307,6 +311,14 @@ log_open_output(const char* name, log_slot slot) {
|
||||
|
||||
void
|
||||
log_close_output(const char* name) {
|
||||
+ pthread_mutex_lock(&log_mutex);
|
||||
+
|
||||
+ log_output_list::iterator itr = log_find_output_name(name);
|
||||
+
|
||||
+ if (itr != log_outputs.end())
|
||||
+ log_outputs.erase(itr);
|
||||
+
|
||||
+ pthread_mutex_unlock(&log_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
diff --git a/src/torrent/utils/log.h b/src/torrent/utils/log.h
|
||||
index a053d6ec..430bda5e 100644
|
||||
--- a/src/torrent/utils/log.h
|
||||
+++ b/src/torrent/utils/log.h
|
||||
@@ -229,6 +229,7 @@ void log_cleanup() LIBTORRENT_EXPORT;
|
||||
|
||||
void log_open_output(const char* name, log_slot slot) LIBTORRENT_EXPORT;
|
||||
void log_close_output(const char* name) LIBTORRENT_EXPORT;
|
||||
+void log_close_output_str(const std::string name) LIBTORRENT_EXPORT;
|
||||
|
||||
void log_add_group_output(int group, const char* name) LIBTORRENT_EXPORT;
|
||||
void log_remove_group_output(int group, const char* name) LIBTORRENT_EXPORT;
|
||||
@@ -240,6 +241,12 @@ void log_open_file_output(const char* name, const char* filename) LIBTORR
|
||||
void log_open_gz_file_output(const char* name, const char* filename) LIBTORRENT_EXPORT;
|
||||
log_buffer* log_open_log_buffer(const char* name) LIBTORRENT_EXPORT;
|
||||
|
||||
+//
|
||||
+// Implementation:
|
||||
+//
|
||||
+
|
||||
+inline void log_close_output_str(const std::string name) { log_close_output(name.c_str()); }
|
||||
+
|
||||
}
|
||||
|
||||
#endif
|
||||
diff --git a/test/torrent/tracker_timeout_test.cc b/test/torrent/tracker_timeout_test.cc
|
||||
index 081b9301..cd060006 100644
|
||||
--- a/test/torrent/tracker_timeout_test.cc
|
||||
+++ b/test/torrent/tracker_timeout_test.cc
|
||||
@@ -29,13 +29,13 @@ tracker_timeout_test::test_set_timeout() {
|
||||
|
||||
tracker.set_new_normal_interval(100);
|
||||
CPPUNIT_ASSERT(tracker.normal_interval() == 600);
|
||||
- tracker.set_new_normal_interval(4000);
|
||||
- CPPUNIT_ASSERT(tracker.normal_interval() == 3600);
|
||||
+ tracker.set_new_normal_interval(8 * 4000);
|
||||
+ CPPUNIT_ASSERT(tracker.normal_interval() == 8 * 3600);
|
||||
|
||||
tracker.set_new_min_interval(100);
|
||||
CPPUNIT_ASSERT(tracker.min_interval() == 300);
|
||||
- tracker.set_new_min_interval(4000);
|
||||
- CPPUNIT_ASSERT(tracker.min_interval() == 1800);
|
||||
+ tracker.set_new_min_interval(4 * 4000);
|
||||
+ CPPUNIT_ASSERT(tracker.min_interval() == 4 * 3600);
|
||||
}
|
||||
|
||||
void
|
||||
diff --git a/test/torrent/utils/log_test.cc b/test/torrent/utils/log_test.cc
|
||||
index 9b99c245..24c22b59 100644
|
||||
--- a/test/torrent/utils/log_test.cc
|
||||
+++ b/test/torrent/utils/log_test.cc
|
||||
@@ -75,13 +75,13 @@ utils_log_test::test_output_open() {
|
||||
// Test inserting duplicate names, should catch.
|
||||
// CPPUNIT_ASSERT_THROW(torrent::log_open_output("test_output_1", torrent::log_slot());, torrent::input_error);
|
||||
|
||||
- try {
|
||||
- torrent::log_open_output("test_output_1", torrent::log_slot());
|
||||
- } catch (torrent::input_error& e) {
|
||||
- return;
|
||||
- }
|
||||
+ // try {
|
||||
+ // torrent::log_open_output("test_output_1", torrent::log_slot());
|
||||
+ // } catch (torrent::input_error& e) {
|
||||
+ // return;
|
||||
+ // }
|
||||
|
||||
- CPPUNIT_ASSERT(false);
|
||||
+ // CPPUNIT_ASSERT(false);
|
||||
|
||||
// Test more than 64 entries.
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
From 7faa9c58ce098bbdeff83b6add72f3075b47881d Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Fri, 19 Jul 2019 13:38:12 +0200
|
||||
Subject: [PATCH] Bumped to version 0.13.8.
|
||||
|
||||
---
|
||||
configure.ac | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index b885714d..4ed08124 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -1,12 +1,12 @@
|
||||
-AC_INIT(libtorrent, 0.13.7, sundell.software@gmail.com)
|
||||
+AC_INIT(libtorrent, 0.13.8, sundell.software@gmail.com)
|
||||
|
||||
LT_INIT([disable-static])
|
||||
|
||||
dnl Find a better way to do this
|
||||
-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)
|
||||
+AC_DEFINE(PEER_NAME, "-lt0D80-", Identifier that is part of the default peer id)
|
||||
+AC_DEFINE(PEER_VERSION, "lt\x0D\x80", 4 byte client and version identifier for DHT)
|
||||
|
||||
-LIBTORRENT_CURRENT=20
|
||||
+LIBTORRENT_CURRENT=21
|
||||
LIBTORRENT_REVISION=0
|
||||
LIBTORRENT_AGE=0
|
||||
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
From 7667094274879fe158e718bf2765d35f82d924bd Mon Sep 17 00:00:00 2001
|
||||
From: nicholi <nschell@gmail.com>
|
||||
Date: Tue, 23 Jul 2019 23:59:16 -0700
|
||||
Subject: [PATCH] Allow logs to be appended rather than overwritten.
|
||||
|
||||
---
|
||||
src/torrent/utils/log.cc | 13 +++++++++++++
|
||||
src/torrent/utils/log.h | 1 +
|
||||
test/torrent/utils/log_test.cc | 35 ++++++++++++++++++++++++++++++++++
|
||||
test/torrent/utils/log_test.h | 2 ++
|
||||
4 files changed, 51 insertions(+)
|
||||
|
||||
diff --git a/src/torrent/utils/log.cc b/src/torrent/utils/log.cc
|
||||
index 5169a730..a900c109 100644
|
||||
--- a/src/torrent/utils/log.cc
|
||||
+++ b/src/torrent/utils/log.cc
|
||||
@@ -428,6 +428,19 @@ log_open_file_output(const char* name, const char* filename) {
|
||||
std::placeholders::_3));
|
||||
}
|
||||
|
||||
+void
|
||||
+log_open_file_output_append(const char* name, const char* filename) {
|
||||
+ std::shared_ptr<std::ofstream> outfile(new std::ofstream(filename, std::ofstream::out | std::ofstream::app));
|
||||
+
|
||||
+ if (!outfile->good())
|
||||
+ throw input_error("Could not open log file '" + std::string(filename) + "'.");
|
||||
+
|
||||
+ log_open_output(name, std::bind(&log_file_write, outfile,
|
||||
+ std::placeholders::_1,
|
||||
+ std::placeholders::_2,
|
||||
+ std::placeholders::_3));
|
||||
+}
|
||||
+
|
||||
void
|
||||
log_open_gz_file_output(const char* name, const char* filename) {
|
||||
std::shared_ptr<log_gz_output> outfile(new log_gz_output(filename));
|
||||
diff --git a/src/torrent/utils/log.h b/src/torrent/utils/log.h
|
||||
index 430bda5e..531c8565 100644
|
||||
--- a/src/torrent/utils/log.h
|
||||
+++ b/src/torrent/utils/log.h
|
||||
@@ -238,6 +238,7 @@ void log_add_child(int group, int child) LIBTORRENT_EXPORT;
|
||||
void log_remove_child(int group, int child) LIBTORRENT_EXPORT;
|
||||
|
||||
void log_open_file_output(const char* name, const char* filename) LIBTORRENT_EXPORT;
|
||||
+void log_open_file_output_append(const char* name, const char* filename) LIBTORRENT_EXPORT;
|
||||
void log_open_gz_file_output(const char* name, const char* filename) LIBTORRENT_EXPORT;
|
||||
log_buffer* log_open_log_buffer(const char* name) LIBTORRENT_EXPORT;
|
||||
|
||||
diff --git a/test/torrent/utils/log_test.cc b/test/torrent/utils/log_test.cc
|
||||
index 24c22b59..aa13fff8 100644
|
||||
--- a/test/torrent/utils/log_test.cc
|
||||
+++ b/test/torrent/utils/log_test.cc
|
||||
@@ -155,3 +155,38 @@ utils_log_test::test_file_output() {
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(buffer, std::string(buffer).find("test_file") != std::string::npos);
|
||||
}
|
||||
+
|
||||
+void
|
||||
+utils_log_test::test_file_output_append() {
|
||||
+ std::string filename = "utils_log_test.XXXXXX";
|
||||
+
|
||||
+ mktemp(&*filename.begin());
|
||||
+
|
||||
+ torrent::log_open_file_output_append("test_file", filename.c_str());
|
||||
+ torrent::log_add_group_output(GROUP_PARENT_1, "test_file");
|
||||
+
|
||||
+ lt_log_print(GROUP_PARENT_1, "test_line_1");
|
||||
+
|
||||
+ torrent::log_cleanup(); // To ensure we flush the buffers.
|
||||
+
|
||||
+ // re-open and write 2nd line
|
||||
+ torrent::log_open_file_output_append("test_file", filename.c_str());
|
||||
+ torrent::log_add_group_output(GROUP_PARENT_1, "test_file");
|
||||
+
|
||||
+ lt_log_print(GROUP_PARENT_1, "test_line_2");
|
||||
+
|
||||
+ torrent::log_cleanup(); // To ensure we flush the buffers.
|
||||
+
|
||||
+ std::ifstream temp_file(filename.c_str());
|
||||
+
|
||||
+ CPPUNIT_ASSERT(temp_file.good());
|
||||
+
|
||||
+ char buffer_line1[256];
|
||||
+ temp_file.getline(buffer_line1, 256);
|
||||
+
|
||||
+ char buffer_line2[256];
|
||||
+ temp_file.getline(buffer_line2, 256);
|
||||
+
|
||||
+ CPPUNIT_ASSERT_MESSAGE(buffer_line1, std::string(buffer_line1).find("test_line_1") != std::string::npos);
|
||||
+ CPPUNIT_ASSERT_MESSAGE(buffer_line2, std::string(buffer_line2).find("test_line_2") != std::string::npos);
|
||||
+}
|
||||
diff --git a/test/torrent/utils/log_test.h b/test/torrent/utils/log_test.h
|
||||
index 3a66cc24..d4cb3bc6 100644
|
||||
--- a/test/torrent/utils/log_test.h
|
||||
+++ b/test/torrent/utils/log_test.h
|
||||
@@ -10,6 +10,7 @@ class utils_log_test : public CppUnit::TestFixture {
|
||||
CPPUNIT_TEST(test_print);
|
||||
CPPUNIT_TEST(test_children);
|
||||
CPPUNIT_TEST(test_file_output);
|
||||
+ CPPUNIT_TEST(test_file_output_append);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@@ -22,4 +23,5 @@ public:
|
||||
void test_print();
|
||||
void test_children();
|
||||
void test_file_output();
|
||||
+ void test_file_output_append();
|
||||
};
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
From df54913c34c8b584d6d2072a65ad1590766780c5 Mon Sep 17 00:00:00 2001
|
||||
From: nicholi <nschell@gmail.com>
|
||||
Date: Fri, 26 Jul 2019 00:50:52 -0700
|
||||
Subject: [PATCH] Removed log append function. Added append parameter with
|
||||
default value (false) to log_open_file functions.
|
||||
|
||||
---
|
||||
src/torrent/utils/log.cc | 26 ++++++++------------------
|
||||
src/torrent/utils/log.h | 5 ++---
|
||||
test/torrent/utils/log_test.cc | 4 ++--
|
||||
3 files changed, 12 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/src/torrent/utils/log.cc b/src/torrent/utils/log.cc
|
||||
index a900c109..6c605474 100644
|
||||
--- a/src/torrent/utils/log.cc
|
||||
+++ b/src/torrent/utils/log.cc
|
||||
@@ -73,7 +73,7 @@ struct log_cache_entry {
|
||||
};
|
||||
|
||||
struct log_gz_output {
|
||||
- log_gz_output(const char* filename) { gz_file = gzopen(filename, "w"); }
|
||||
+ log_gz_output(const char* filename, bool append) { gz_file = gzopen(filename, append ? "a" : "w"); }
|
||||
~log_gz_output() { if (gz_file != NULL) gzclose(gz_file); }
|
||||
|
||||
bool is_valid() { return gz_file != Z_NULL; }
|
||||
@@ -416,8 +416,11 @@ log_gz_file_write(std::shared_ptr<log_gz_output>& outfile, const char* data, siz
|
||||
}
|
||||
|
||||
void
|
||||
-log_open_file_output(const char* name, const char* filename) {
|
||||
- std::shared_ptr<std::ofstream> outfile(new std::ofstream(filename));
|
||||
+log_open_file_output(const char* name, const char* filename, bool append) {
|
||||
+ std::ios_base::openmode mode = std::ofstream::out;
|
||||
+ if (append)
|
||||
+ mode |= std::ofstream::app;
|
||||
+ std::shared_ptr<std::ofstream> outfile(new std::ofstream(filename, mode));
|
||||
|
||||
if (!outfile->good())
|
||||
throw input_error("Could not open log file '" + std::string(filename) + "'.");
|
||||
@@ -429,21 +432,8 @@ log_open_file_output(const char* name, const char* filename) {
|
||||
}
|
||||
|
||||
void
|
||||
-log_open_file_output_append(const char* name, const char* filename) {
|
||||
- std::shared_ptr<std::ofstream> outfile(new std::ofstream(filename, std::ofstream::out | std::ofstream::app));
|
||||
-
|
||||
- if (!outfile->good())
|
||||
- throw input_error("Could not open log file '" + std::string(filename) + "'.");
|
||||
-
|
||||
- log_open_output(name, std::bind(&log_file_write, outfile,
|
||||
- std::placeholders::_1,
|
||||
- std::placeholders::_2,
|
||||
- std::placeholders::_3));
|
||||
-}
|
||||
-
|
||||
-void
|
||||
-log_open_gz_file_output(const char* name, const char* filename) {
|
||||
- std::shared_ptr<log_gz_output> outfile(new log_gz_output(filename));
|
||||
+log_open_gz_file_output(const char* name, const char* filename, bool append) {
|
||||
+ std::shared_ptr<log_gz_output> outfile(new log_gz_output(filename, append));
|
||||
|
||||
if (!outfile->is_valid())
|
||||
throw input_error("Could not open log gzip file '" + std::string(filename) + "'.");
|
||||
diff --git a/src/torrent/utils/log.h b/src/torrent/utils/log.h
|
||||
index 531c8565..0dfdc86b 100644
|
||||
--- a/src/torrent/utils/log.h
|
||||
+++ b/src/torrent/utils/log.h
|
||||
@@ -237,9 +237,8 @@ void log_remove_group_output(int group, const char* name) LIBTORRENT_EXPORT;
|
||||
void log_add_child(int group, int child) LIBTORRENT_EXPORT;
|
||||
void log_remove_child(int group, int child) LIBTORRENT_EXPORT;
|
||||
|
||||
-void log_open_file_output(const char* name, const char* filename) LIBTORRENT_EXPORT;
|
||||
-void log_open_file_output_append(const char* name, const char* filename) LIBTORRENT_EXPORT;
|
||||
-void log_open_gz_file_output(const char* name, const char* filename) LIBTORRENT_EXPORT;
|
||||
+void log_open_file_output(const char* name, const char* filename, bool append = false) LIBTORRENT_EXPORT;
|
||||
+void log_open_gz_file_output(const char* name, const char* filename, bool append = false) LIBTORRENT_EXPORT;
|
||||
log_buffer* log_open_log_buffer(const char* name) LIBTORRENT_EXPORT;
|
||||
|
||||
//
|
||||
diff --git a/test/torrent/utils/log_test.cc b/test/torrent/utils/log_test.cc
|
||||
index aa13fff8..9f975636 100644
|
||||
--- a/test/torrent/utils/log_test.cc
|
||||
+++ b/test/torrent/utils/log_test.cc
|
||||
@@ -162,7 +162,7 @@ utils_log_test::test_file_output_append() {
|
||||
|
||||
mktemp(&*filename.begin());
|
||||
|
||||
- torrent::log_open_file_output_append("test_file", filename.c_str());
|
||||
+ torrent::log_open_file_output("test_file", filename.c_str(), false);
|
||||
torrent::log_add_group_output(GROUP_PARENT_1, "test_file");
|
||||
|
||||
lt_log_print(GROUP_PARENT_1, "test_line_1");
|
||||
@@ -170,7 +170,7 @@ utils_log_test::test_file_output_append() {
|
||||
torrent::log_cleanup(); // To ensure we flush the buffers.
|
||||
|
||||
// re-open and write 2nd line
|
||||
- torrent::log_open_file_output_append("test_file", filename.c_str());
|
||||
+ torrent::log_open_file_output("test_file", filename.c_str(), true);
|
||||
torrent::log_add_group_output(GROUP_PARENT_1, "test_file");
|
||||
|
||||
lt_log_print(GROUP_PARENT_1, "test_line_2");
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,26 +0,0 @@
|
|||
From b656a77864bd322d69522f1f9d922404066e5a7c Mon Sep 17 00:00:00 2001
|
||||
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
||||
Date: Mon, 21 Oct 2019 09:32:15 +0200
|
||||
Subject: [PATCH] libtorrent.pc.in: add Libs.Private (#202)
|
||||
|
||||
Add Libs.Private: -lz so applications that want to link statically with
|
||||
libtorrent (such as rtorrent) will know that they must link with -lz
|
||||
|
||||
Fixes:
|
||||
- http://autobuild.buildroot.org/results/075598e1699c2ac20a4dfbcb5695bbb7343f9a86
|
||||
|
||||
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
||||
---
|
||||
libtorrent.pc.in | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/libtorrent.pc.in b/libtorrent.pc.in
|
||||
index cf6612bc..6108f7e9 100644
|
||||
--- a/libtorrent.pc.in
|
||||
+++ b/libtorrent.pc.in
|
||||
@@ -7,4 +7,5 @@ Name: libtorrent
|
||||
Description: A BitTorrent library
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -ltorrent
|
||||
+Libs.Private: -lz
|
||||
Cflags: -I${includedir}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From 7c80dc3e3a47dd996ca0554fce4f69d16761a9c9 Mon Sep 17 00:00:00 2001
|
||||
From: Tadej Obrstar <tadej.obrstar@gmail.com>
|
||||
Date: Sun, 1 Dec 2019 06:59:25 +0100
|
||||
Subject: [PATCH] Fix for inotify missing quickly renamed files (#203)
|
||||
|
||||
---
|
||||
src/torrent/utils/directory_events.cc | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/torrent/utils/directory_events.cc b/src/torrent/utils/directory_events.cc
|
||||
index 5d789f4e..8dcc2a61 100644
|
||||
--- a/src/torrent/utils/directory_events.cc
|
||||
+++ b/src/torrent/utils/directory_events.cc
|
||||
@@ -154,8 +154,11 @@ directory_events::event_read() {
|
||||
wd_list::const_iterator itr = std::find_if(m_wd_list.begin(), m_wd_list.end(),
|
||||
std::bind(&watch_descriptor::compare_desc, std::placeholders::_1, event->wd));
|
||||
|
||||
- if (itr != m_wd_list.end())
|
||||
- itr->slot(itr->path + event->name);
|
||||
+ if (itr != m_wd_list.end()) {
|
||||
+ std::string sname(event->name);
|
||||
+ if((sname.substr(sname.find_last_of(".") ) == ".torrent"))
|
||||
+ itr->slot(itr->path + event->name);
|
||||
+ }
|
||||
|
||||
event = (struct inotify_event*)(next_event);
|
||||
}
|
||||
|
|
@ -1,470 +0,0 @@
|
|||
From 81897862edea81e9620493c473f488d1820bcf93 Mon Sep 17 00:00:00 2001
|
||||
From: Jari Sundell <sundell.software@gmail.com>
|
||||
Date: Tue, 3 Dec 2019 21:53:48 +0900
|
||||
Subject: [PATCH] Fix compiler warnings. (#204)
|
||||
|
||||
---
|
||||
configure.ac | 6 ++-
|
||||
scripts/ax_execinfo.m4 | 67 +++++++++++++++++++++++++++++++
|
||||
scripts/common.m4 | 15 -------
|
||||
scripts/rak_execinfo.m4 | 11 +++++
|
||||
src/torrent/exceptions.cc | 4 +-
|
||||
test/Makefile.am | 15 ++-----
|
||||
test/helpers/expect_fd.h | 8 ++--
|
||||
test/helpers/mock_compare.h | 6 +--
|
||||
test/helpers/progress_listener.cc | 3 +-
|
||||
test/main.cc | 4 +-
|
||||
test/net/Makefile.am | 40 ++++++++++++++++++
|
||||
test/torrent/net/Makefile.am | 44 ++++++++++++++++++++
|
||||
test/torrent/net/test_fd.cc | 48 +++++++++++-----------
|
||||
13 files changed, 207 insertions(+), 64 deletions(-)
|
||||
create mode 100644 scripts/ax_execinfo.m4
|
||||
create mode 100644 scripts/rak_execinfo.m4
|
||||
create mode 100644 test/net/Makefile.am
|
||||
create mode 100644 test/torrent/net/Makefile.am
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 620ca552..b6708366 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -33,6 +33,7 @@ RAK_CHECK_CXXFLAGS
|
||||
RAK_ENABLE_DEBUG
|
||||
RAK_ENABLE_EXTRA_DEBUG
|
||||
RAK_ENABLE_WERROR
|
||||
+RAK_DISABLE_BACKTRACE
|
||||
|
||||
RAK_CHECK_CXX11
|
||||
|
||||
@@ -57,8 +58,8 @@ TORRENT_WITH_INOTIFY
|
||||
|
||||
CC_ATTRIBUTE_VISIBILITY
|
||||
|
||||
-AX_PTHREAD
|
||||
AX_CHECK_ZLIB
|
||||
+AX_PTHREAD
|
||||
|
||||
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
||||
|
||||
@@ -74,7 +75,6 @@ AC_CHECK_FUNCS(posix_memalign)
|
||||
TORRENT_CHECK_MADVISE()
|
||||
TORRENT_CHECK_CACHELINE()
|
||||
TORRENT_CHECK_POPCOUNT()
|
||||
-TORRENT_CHECK_EXECINFO()
|
||||
TORRENT_CHECK_PTHREAD_SETNAME_NP()
|
||||
TORRENT_MINCORE()
|
||||
|
||||
@@ -111,4 +111,6 @@ AC_OUTPUT([
|
||||
src/tracker/Makefile
|
||||
src/utils/Makefile
|
||||
test/Makefile
|
||||
+ test/torrent/net/Makefile
|
||||
+ test/net/Makefile
|
||||
])
|
||||
diff --git a/scripts/ax_execinfo.m4 b/scripts/ax_execinfo.m4
|
||||
new file mode 100644
|
||||
index 00000000..0ff5fc0e
|
||||
--- /dev/null
|
||||
+++ b/scripts/ax_execinfo.m4
|
||||
@@ -0,0 +1,67 @@
|
||||
+# ===========================================================================
|
||||
+# https://www.gnu.org/software/autoconf-archive/ax_execinfo.html
|
||||
+# ===========================================================================
|
||||
+#
|
||||
+# SYNOPSIS
|
||||
+#
|
||||
+# AX_EXECINFO([ACTION-IF-EXECINFO-H-IS-FOUND], [ACTION-IF-EXECINFO-H-IS-NOT-FOUND], [ADDITIONAL-TYPES-LIST])
|
||||
+#
|
||||
+# DESCRIPTION
|
||||
+#
|
||||
+# Checks for execinfo.h header and if the len parameter/return type can be
|
||||
+# found from a list, also define backtrace_size_t to that type.
|
||||
+#
|
||||
+# By default the list of types to try contains int and size_t, but should
|
||||
+# some yet undiscovered system use e.g. unsigned, the 3rd argument can be
|
||||
+# used for extensions. I'd like to hear of further suggestions.
|
||||
+#
|
||||
+# Executes ACTION-IF-EXECINFO-H-IS-FOUND when present and the execinfo.h
|
||||
+# header is found or ACTION-IF-EXECINFO-H-IS-NOT-FOUND in case the header
|
||||
+# seems unavailable.
|
||||
+#
|
||||
+# Also adds -lexecinfo to LIBS on BSD if needed.
|
||||
+#
|
||||
+# LICENSE
|
||||
+#
|
||||
+# Copyright (c) 2014 Thomas Jahns <jahns@dkrz.de>
|
||||
+#
|
||||
+# Copying and distribution of this file, with or without modification, are
|
||||
+# permitted in any medium without royalty provided the copyright notice
|
||||
+# and this notice are preserved. This file is offered as-is, without any
|
||||
+# warranty.
|
||||
+
|
||||
+#serial 2
|
||||
+
|
||||
+AC_DEFUN([AX_EXECINFO],
|
||||
+ [AC_CHECK_HEADERS([execinfo.h])
|
||||
+ AS_IF([test x"$ac_cv_header_execinfo_h" = xyes],
|
||||
+ [AC_CACHE_CHECK([size parameter type for backtrace()],
|
||||
+ [ax_cv_proto_backtrace_type],
|
||||
+ [AC_LANG_PUSH([C])
|
||||
+ for ax_cv_proto_backtrace_type in size_t int m4_ifnblank([$3],[$3 ])none; do
|
||||
+ AS_IF([test "${ax_cv_proto_backtrace_type}" = none],
|
||||
+ [ax_cv_proto_backtrace_type= ; break])
|
||||
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
|
||||
+#include <execinfo.h>
|
||||
+extern
|
||||
+${ax_cv_proto_backtrace_type} backtrace(void **addrlist, ${ax_cv_proto_backtrace_type} len);
|
||||
+char **backtrace_symbols(void *const *buffer, ${ax_cv_proto_backtrace_type} size);
|
||||
+])],
|
||||
+ [break])
|
||||
+ done
|
||||
+ AC_LANG_POP([C])])])
|
||||
+ AS_IF([test x${ax_cv_proto_backtrace_type} != x],
|
||||
+ [AC_DEFINE_UNQUOTED([backtrace_size_t], [$ax_cv_proto_backtrace_type],
|
||||
+ [Defined to return type of backtrace().])])
|
||||
+ AC_SEARCH_LIBS([backtrace],[execinfo])
|
||||
+ AS_IF([test x"${ax_cv_proto_backtrace_type}" != x -a x"$ac_cv_header_execinfo_h" = xyes -a x"$ac_cv_search_backtrace" != xno],
|
||||
+ [AC_DEFINE([HAVE_BACKTRACE],[1],
|
||||
+ [Defined if backtrace() could be fully identified.])
|
||||
+ ]m4_ifnblank([$1],[$1
|
||||
+]),m4_ifnblank([$2],[$2
|
||||
+]))])
|
||||
+dnl
|
||||
+dnl Local Variables:
|
||||
+dnl mode: autoconf
|
||||
+dnl End:
|
||||
+dnl
|
||||
diff --git a/scripts/common.m4 b/scripts/common.m4
|
||||
index b6d051f5..55e8d66e 100644
|
||||
--- a/scripts/common.m4
|
||||
+++ b/scripts/common.m4
|
||||
@@ -150,21 +150,6 @@ dnl Need to fix this so that it uses the stuff defined by the system.
|
||||
])
|
||||
])
|
||||
|
||||
-AC_DEFUN([TORRENT_CHECK_EXECINFO], [
|
||||
- AC_MSG_CHECKING(for execinfo.h)
|
||||
-
|
||||
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
- #include <execinfo.h>
|
||||
- int main() { backtrace((void**)0, 0); backtrace_symbols((char**)0, 0); return 0;}
|
||||
- ])],
|
||||
- [
|
||||
- AC_MSG_RESULT(yes)
|
||||
- AC_DEFINE(USE_EXECINFO, 1, Use execinfo.h)
|
||||
- ], [
|
||||
- AC_MSG_RESULT(no)
|
||||
- ])
|
||||
-])
|
||||
-
|
||||
AC_DEFUN([TORRENT_CHECK_ALIGNED], [
|
||||
AC_MSG_CHECKING(the byte alignment)
|
||||
|
||||
diff --git a/scripts/rak_execinfo.m4 b/scripts/rak_execinfo.m4
|
||||
new file mode 100644
|
||||
index 00000000..c1d9b2f8
|
||||
--- /dev/null
|
||||
+++ b/scripts/rak_execinfo.m4
|
||||
@@ -0,0 +1,11 @@
|
||||
+AC_DEFUN([RAK_DISABLE_BACKTRACE], [
|
||||
+ AC_ARG_ENABLE(backtrace,
|
||||
+ AC_HELP_STRING([--disable-backtrace], [disable backtrace information [[default=no]]]),
|
||||
+ [
|
||||
+ if test "$enableval" = "yes"; then
|
||||
+ AX_EXECINFO
|
||||
+ fi
|
||||
+ ],[
|
||||
+ AX_EXECINFO
|
||||
+ ])
|
||||
+])
|
||||
diff --git a/src/torrent/exceptions.cc b/src/torrent/exceptions.cc
|
||||
index 2aeca1d7..f834f9fa 100644
|
||||
--- a/src/torrent/exceptions.cc
|
||||
+++ b/src/torrent/exceptions.cc
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
-#ifdef USE_EXECINFO
|
||||
+#ifdef HAVE_BACKTRACE
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
@@ -75,7 +75,7 @@ internal_error::initialize(const std::string& msg) {
|
||||
|
||||
std::stringstream output;
|
||||
|
||||
-#ifdef USE_EXECINFO
|
||||
+#ifdef HAVE_BACKTRACE
|
||||
void* stackPtrs[20];
|
||||
|
||||
// Print the stack and exit.
|
||||
diff --git a/test/Makefile.am b/test/Makefile.am
|
||||
index b60a86a6..23b260e4 100644
|
||||
--- a/test/Makefile.am
|
||||
+++ b/test/Makefile.am
|
||||
@@ -1,3 +1,5 @@
|
||||
+SUBDIRS = torrent/net net
|
||||
+
|
||||
TESTS = LibTorrentTest
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
|
||||
@@ -43,19 +45,9 @@ LibTorrentTest_SOURCES = \
|
||||
data/hash_queue_test.cc \
|
||||
data/hash_queue_test.h \
|
||||
\
|
||||
- net/test_socket_listen.cc \
|
||||
- net/test_socket_listen.h \
|
||||
- \
|
||||
protocol/test_request_list.cc \
|
||||
protocol/test_request_list.h \
|
||||
\
|
||||
- torrent/net/test_address_info.cc \
|
||||
- torrent/net/test_address_info.h \
|
||||
- torrent/net/test_fd.cc \
|
||||
- torrent/net/test_fd.h \
|
||||
- torrent/net/test_socket_address.cc \
|
||||
- torrent/net/test_socket_address.h \
|
||||
- \
|
||||
torrent/utils/log_test.cc \
|
||||
torrent/utils/log_test.h \
|
||||
torrent/utils/option_strings_test.cc \
|
||||
@@ -97,9 +89,10 @@ LibTorrentTest_SOURCES = \
|
||||
torrent/tracker_timeout_test.h \
|
||||
tracker/tracker_http_test.cc \
|
||||
tracker/tracker_http_test.h \
|
||||
+ \
|
||||
main.cc
|
||||
|
||||
LibTorrentTest_CXXFLAGS = $(CPPUNIT_CFLAGS)
|
||||
-LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS) -ldl
|
||||
+LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS) -ldl
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/src
|
||||
diff --git a/test/helpers/expect_fd.h b/test/helpers/expect_fd.h
|
||||
index 178cbabc..cc77c34a 100644
|
||||
--- a/test/helpers/expect_fd.h
|
||||
+++ b/test/helpers/expect_fd.h
|
||||
@@ -18,15 +18,15 @@ sap_cache_copy_addr_c_ptr(sap_cache_type& sap_cache, const torrent::c_sa_unique_
|
||||
|
||||
inline void
|
||||
expect_event_open_re(int idx) {
|
||||
- mock_expect(&torrent::poll_event_open, mock_compare_map<torrent::Event>::begin_pointer + idx);
|
||||
- mock_expect(&torrent::poll_event_insert_read, mock_compare_map<torrent::Event>::begin_pointer + idx);
|
||||
- mock_expect(&torrent::poll_event_insert_error, mock_compare_map<torrent::Event>::begin_pointer + idx);
|
||||
+ mock_expect(&torrent::poll_event_open, mock_compare_map<torrent::Event>::begin_pointer() + idx);
|
||||
+ mock_expect(&torrent::poll_event_insert_read, mock_compare_map<torrent::Event>::begin_pointer() + idx);
|
||||
+ mock_expect(&torrent::poll_event_insert_error, mock_compare_map<torrent::Event>::begin_pointer() + idx);
|
||||
}
|
||||
|
||||
inline void
|
||||
expect_event_closed_fd(int idx, int fd) {
|
||||
mock_expect(&torrent::fd__close, 0, fd);
|
||||
- mock_expect(&torrent::poll_event_closed, mock_compare_map<torrent::Event>::begin_pointer + idx);
|
||||
+ mock_expect(&torrent::poll_event_closed, mock_compare_map<torrent::Event>::begin_pointer() + idx);
|
||||
}
|
||||
|
||||
inline void
|
||||
diff --git a/test/helpers/mock_compare.h b/test/helpers/mock_compare.h
|
||||
index 3ea90305..3cc8d075 100644
|
||||
--- a/test/helpers/mock_compare.h
|
||||
+++ b/test/helpers/mock_compare.h
|
||||
@@ -34,11 +34,11 @@ template <typename T>
|
||||
struct mock_compare_map {
|
||||
typedef std::map<const T*, const T*> values_type;
|
||||
|
||||
- constexpr static T* begin_pointer = reinterpret_cast<T*>(0x1000);
|
||||
- constexpr static T* end_pointer = reinterpret_cast<T*>(0x2000);
|
||||
+ static T* begin_pointer() { return reinterpret_cast<T*>(0x1000); }
|
||||
+ static T* end_pointer() { return reinterpret_cast<T*>(0x2000); }
|
||||
|
||||
static bool is_key(const T* k) {
|
||||
- return k >= begin_pointer && k < end_pointer;
|
||||
+ return k >= begin_pointer() && k < end_pointer();
|
||||
}
|
||||
|
||||
static bool has_key(const T* k) {
|
||||
diff --git a/test/helpers/progress_listener.cc b/test/helpers/progress_listener.cc
|
||||
index 02803ffc..c2b60bcd 100644
|
||||
--- a/test/helpers/progress_listener.cc
|
||||
+++ b/test/helpers/progress_listener.cc
|
||||
@@ -54,7 +54,8 @@ void
|
||||
progress_listener::startSuite(CppUnit::Test *suite) {
|
||||
m_test_path.push_back(suite);
|
||||
|
||||
- std::cout << std::endl << get_test_path(m_test_path) << suite->getName() << ":" << std::endl;
|
||||
+ if (suite->countTestCases() > 0)
|
||||
+ std::cout << std::endl << get_test_path(m_test_path) << suite->getName() << ":" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
diff --git a/test/main.cc b/test/main.cc
|
||||
index da93fead..e8a00e1f 100644
|
||||
--- a/test/main.cc
|
||||
+++ b/test/main.cc
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
-#ifdef USE_EXECINFO
|
||||
+#ifdef HAVE_BACKTRACE
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@ do_test_panic(int signum) {
|
||||
|
||||
std::cout << std::endl << std::endl << "Caught " << strsignal(signum) << ", dumping stack:" << std::endl << std::endl;
|
||||
|
||||
-#ifdef USE_EXECINFO
|
||||
+#ifdef HAVE_BACKTRACE
|
||||
void* stackPtrs[20];
|
||||
|
||||
// Print the stack and exit.
|
||||
diff --git a/test/net/Makefile.am b/test/net/Makefile.am
|
||||
new file mode 100644
|
||||
index 00000000..bb951814
|
||||
--- /dev/null
|
||||
+++ b/test/net/Makefile.am
|
||||
@@ -0,0 +1,40 @@
|
||||
+TESTS = LibTorrentTestNet
|
||||
+AUTOMAKE_OPTIONS = subdir-objects
|
||||
+
|
||||
+check_PROGRAMS = $(TESTS)
|
||||
+LibTorrentTestNet_LDADD = \
|
||||
+ ../../src/libtorrent.la \
|
||||
+ ../../src/torrent/libsub_torrent.la \
|
||||
+ ../../src/torrent/data/libsub_torrentdata.la \
|
||||
+ ../../src/torrent/download/libsub_torrentdownload.la \
|
||||
+ ../../src/torrent/peer/libsub_torrentpeer.la \
|
||||
+ ../../src/data/libsub_data.la \
|
||||
+ ../../src/dht/libsub_dht.la \
|
||||
+ ../../src/net/libsub_net.la \
|
||||
+ ../../src/protocol/libsub_protocol.la \
|
||||
+ ../../src/download/libsub_download.la \
|
||||
+ ../../src/tracker/libsub_tracker.la \
|
||||
+ ../../src/utils/libsub_utils.la \
|
||||
+ ../../src/torrent/utils/libsub_torrentutils.la
|
||||
+
|
||||
+LibTorrentTestNet_SOURCES = \
|
||||
+ ../helpers/expect_fd.h \
|
||||
+ ../helpers/expect_utils.h \
|
||||
+ ../helpers/mock_compare.h \
|
||||
+ ../helpers/mock_function.cc \
|
||||
+ ../helpers/mock_function.h \
|
||||
+ ../helpers/network.h \
|
||||
+ ../helpers/progress_listener.cc \
|
||||
+ ../helpers/progress_listener.h \
|
||||
+ ../helpers/test_fixture.cc \
|
||||
+ ../helpers/test_fixture.h \
|
||||
+ \
|
||||
+ test_socket_listen.cc \
|
||||
+ test_socket_listen.h \
|
||||
+ \
|
||||
+ ../main.cc
|
||||
+
|
||||
+LibTorrentTestNet_CXXFLAGS = $(CPPUNIT_CFLAGS)
|
||||
+LibTorrentTestNet_LDFLAGS = $(CPPUNIT_LIBS) -ldl
|
||||
+
|
||||
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/test
|
||||
diff --git a/test/torrent/net/Makefile.am b/test/torrent/net/Makefile.am
|
||||
new file mode 100644
|
||||
index 00000000..8a531cc1
|
||||
--- /dev/null
|
||||
+++ b/test/torrent/net/Makefile.am
|
||||
@@ -0,0 +1,44 @@
|
||||
+TESTS = LibTorrentTestTorrentNet
|
||||
+AUTOMAKE_OPTIONS = subdir-objects
|
||||
+
|
||||
+check_PROGRAMS = $(TESTS)
|
||||
+LibTorrentTestTorrentNet_LDADD = \
|
||||
+ ../../../src/libtorrent.la \
|
||||
+ ../../../src/torrent/libsub_torrent.la \
|
||||
+ ../../../src/torrent/data/libsub_torrentdata.la \
|
||||
+ ../../../src/torrent/download/libsub_torrentdownload.la \
|
||||
+ ../../../src/torrent/peer/libsub_torrentpeer.la \
|
||||
+ ../../../src/data/libsub_data.la \
|
||||
+ ../../../src/dht/libsub_dht.la \
|
||||
+ ../../../src/net/libsub_net.la \
|
||||
+ ../../../src/protocol/libsub_protocol.la \
|
||||
+ ../../../src/download/libsub_download.la \
|
||||
+ ../../../src/tracker/libsub_tracker.la \
|
||||
+ ../../../src/utils/libsub_utils.la \
|
||||
+ ../../../src/torrent/utils/libsub_torrentutils.la
|
||||
+
|
||||
+LibTorrentTestTorrentNet_SOURCES = \
|
||||
+ ../../helpers/expect_fd.h \
|
||||
+ ../../helpers/expect_utils.h \
|
||||
+ ../../helpers/mock_compare.h \
|
||||
+ ../../helpers/mock_function.cc \
|
||||
+ ../../helpers/mock_function.h \
|
||||
+ ../../helpers/network.h \
|
||||
+ ../../helpers/progress_listener.cc \
|
||||
+ ../../helpers/progress_listener.h \
|
||||
+ ../../helpers/test_fixture.cc \
|
||||
+ ../../helpers/test_fixture.h \
|
||||
+ \
|
||||
+ test_address_info.cc \
|
||||
+ test_address_info.h \
|
||||
+ test_fd.cc \
|
||||
+ test_fd.h \
|
||||
+ test_socket_address.cc \
|
||||
+ test_socket_address.h \
|
||||
+ \
|
||||
+ ../../main.cc
|
||||
+
|
||||
+LibTorrentTestTorrentNet_CXXFLAGS = $(CPPUNIT_CFLAGS)
|
||||
+LibTorrentTestTorrentNet_LDFLAGS = $(CPPUNIT_LIBS) -ldl
|
||||
+
|
||||
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/test
|
||||
diff --git a/test/torrent/net/test_fd.cc b/test/torrent/net/test_fd.cc
|
||||
index 3cab0c5e..5e56f0f3 100644
|
||||
--- a/test/torrent/net/test_fd.cc
|
||||
+++ b/test/torrent/net/test_fd.cc
|
||||
@@ -1,24 +1,24 @@
|
||||
-#include "config.h"
|
||||
-
|
||||
-#include "test_fd.h"
|
||||
-
|
||||
-#include <torrent/net/fd.h>
|
||||
-
|
||||
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_fd, "torrent/net");
|
||||
-
|
||||
-void
|
||||
-test_fd::test_valid_flags() {
|
||||
- CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream));
|
||||
- CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_nonblock));
|
||||
- CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_reuse_address));
|
||||
- CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v4only));
|
||||
- CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v6only));
|
||||
-
|
||||
- CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flag_v4only | torrent::fd_flag_v6only));
|
||||
- CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v4only | torrent::fd_flag_v6only));
|
||||
-
|
||||
- CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags()));
|
||||
- CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags(~torrent::fd_flag_all)));
|
||||
- CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags(torrent::fd_flag_stream | ~torrent::fd_flag_all)));
|
||||
- CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags(0x3245132)));
|
||||
-}
|
||||
+#include "config.h"
|
||||
+
|
||||
+#include "test_fd.h"
|
||||
+
|
||||
+#include <torrent/net/fd.h>
|
||||
+
|
||||
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_fd, "torrent/net");
|
||||
+
|
||||
+void
|
||||
+test_fd::test_valid_flags() {
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream));
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_nonblock));
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_reuse_address));
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v4only));
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v6only));
|
||||
+
|
||||
+ CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flag_v4only | torrent::fd_flag_v6only));
|
||||
+ CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v4only | torrent::fd_flag_v6only));
|
||||
+
|
||||
+ CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags()));
|
||||
+ CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags(~torrent::fd_flag_all)));
|
||||
+ CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags(torrent::fd_flag_stream | ~torrent::fd_flag_all)));
|
||||
+ CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags(0x3245132)));
|
||||
+}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
From e813c344b1e4aa89288febb2f59109972083f1bb Mon Sep 17 00:00:00 2001
|
||||
From: Rosen Penev <rosenp@gmail.com>
|
||||
Date: Thu, 5 Dec 2019 01:55:53 -0800
|
||||
Subject: [PATCH] Fix log format so GCC can check it. (#205)
|
||||
|
||||
---
|
||||
src/torrent/utils/log.cc | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/torrent/utils/log.cc b/src/torrent/utils/log.cc
|
||||
index b855a2c6..24932996 100644
|
||||
--- a/src/torrent/utils/log.cc
|
||||
+++ b/src/torrent/utils/log.cc
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
+#define GROUPFMT (group >= LOG_NON_CASCADING) ? ("%" PRIi32 " ") : ("%" PRIi32 " %c ")
|
||||
+
|
||||
namespace torrent {
|
||||
|
||||
struct log_cache_entry {
|
||||
@@ -356,9 +358,7 @@ log_gz_file_write(std::shared_ptr<log_gz_output>& outfile, const char* data, siz
|
||||
|
||||
// Normal groups are nul-terminated strings.
|
||||
if (group >= 0) {
|
||||
- const char* fmt = (group >= LOG_NON_CASCADING) ? ("%" PRIi32 " ") : ("%" PRIi32 " %c ");
|
||||
-
|
||||
- int buffer_length = snprintf(buffer, 64, fmt,
|
||||
+ int buffer_length = snprintf(buffer, 64, GROUPFMT,
|
||||
cachedTime.seconds(),
|
||||
log_level_char[group % 6]);
|
||||
|
||||
|
|
@ -1,843 +0,0 @@
|
|||
From 7b85e112ac2f59a39afa344148a946553c776142 Mon Sep 17 00:00:00 2001
|
||||
From: Jari Sundell <sundell.software@gmail.com>
|
||||
Date: Fri, 6 Dec 2019 00:35:21 +0900
|
||||
Subject: [PATCH] Consolidate make script to optimize build. (#206)
|
||||
|
||||
---
|
||||
configure.ac | 14 +--
|
||||
src/Makefile.am | 147 ++++++++++++++++++++++++-----
|
||||
src/data/Makefile.am | 28 ------
|
||||
src/dht/Makefile.am | 18 ----
|
||||
src/download/Makefile.am | 19 ----
|
||||
src/net/Makefile.am | 30 ------
|
||||
src/protocol/Makefile.am | 28 ------
|
||||
src/torrent/Makefile.am | 154 ++++++++++++++++++++++++++++---
|
||||
src/torrent/download/Makefile.am | 22 -----
|
||||
src/torrent/net/Makefile.am | 25 -----
|
||||
src/torrent/peer/Makefile.am | 28 ------
|
||||
src/torrent/utils/Makefile.am | 41 --------
|
||||
src/tracker/Makefile.am | 11 ---
|
||||
src/utils/Makefile.am | 14 ---
|
||||
test/Makefile.am | 92 +++++++++++++-----
|
||||
15 files changed, 338 insertions(+), 333 deletions(-)
|
||||
delete mode 100644 src/data/Makefile.am
|
||||
delete mode 100644 src/dht/Makefile.am
|
||||
delete mode 100644 src/download/Makefile.am
|
||||
delete mode 100644 src/net/Makefile.am
|
||||
delete mode 100644 src/protocol/Makefile.am
|
||||
delete mode 100644 src/torrent/download/Makefile.am
|
||||
delete mode 100644 src/torrent/net/Makefile.am
|
||||
delete mode 100644 src/torrent/peer/Makefile.am
|
||||
delete mode 100644 src/torrent/utils/Makefile.am
|
||||
delete mode 100644 src/tracker/Makefile.am
|
||||
delete mode 100644 src/utils/Makefile.am
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index b6708366..e83710cc 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -17,7 +17,7 @@ AC_SUBST(LIBTORRENT_CURRENT)
|
||||
AC_SUBST(LIBTORRENT_INTERFACE_VERSION_INFO)
|
||||
AC_SUBST(LIBTORRENT_INTERFACE_VERSION_NO)
|
||||
|
||||
-AM_INIT_AUTOMAKE([serial-tests])
|
||||
+AM_INIT_AUTOMAKE([serial-tests subdir-objects])
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
AC_PROG_CXX
|
||||
@@ -98,18 +98,6 @@ AC_OUTPUT([
|
||||
Makefile
|
||||
src/Makefile
|
||||
src/torrent/Makefile
|
||||
- src/torrent/data/Makefile
|
||||
- src/torrent/download/Makefile
|
||||
- src/torrent/net/Makefile
|
||||
- src/torrent/peer/Makefile
|
||||
- src/torrent/utils/Makefile
|
||||
- src/data/Makefile
|
||||
- src/dht/Makefile
|
||||
- src/download/Makefile
|
||||
- src/net/Makefile
|
||||
- src/protocol/Makefile
|
||||
- src/tracker/Makefile
|
||||
- src/utils/Makefile
|
||||
test/Makefile
|
||||
test/torrent/net/Makefile
|
||||
test/net/Makefile
|
||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||
index 99aaace0..e96bd74b 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -1,30 +1,12 @@
|
||||
-SUBDIRS = \
|
||||
- torrent \
|
||||
- data \
|
||||
- dht \
|
||||
- download \
|
||||
- net \
|
||||
- protocol \
|
||||
- tracker \
|
||||
- utils
|
||||
+SUBDIRS = torrent
|
||||
|
||||
lib_LTLIBRARIES = libtorrent.la
|
||||
+noinst_LTLIBRARIES = libtorrent_other.la
|
||||
|
||||
libtorrent_la_LDFLAGS = -version-info $(LIBTORRENT_INTERFACE_VERSION_INFO)
|
||||
libtorrent_la_LIBADD = \
|
||||
- torrent/libsub_torrent.la \
|
||||
- torrent/data/libsub_torrentdata.la \
|
||||
- torrent/download/libsub_torrentdownload.la \
|
||||
- torrent/net/libsub_torrentnet.la \
|
||||
- torrent/peer/libsub_torrentpeer.la \
|
||||
- torrent/utils/libsub_torrentutils.la \
|
||||
- data/libsub_data.la \
|
||||
- dht/libsub_dht.la \
|
||||
- download/libsub_download.la \
|
||||
- net/libsub_net.la \
|
||||
- protocol/libsub_protocol.la \
|
||||
- tracker/libsub_tracker.la \
|
||||
- utils/libsub_utils.la
|
||||
+ torrent/libtorrent_torrent.la \
|
||||
+ libtorrent_other.la
|
||||
|
||||
libtorrent_la_SOURCES = \
|
||||
globals.cc \
|
||||
@@ -36,4 +18,125 @@ libtorrent_la_SOURCES = \
|
||||
thread_main.cc \
|
||||
thread_main.h
|
||||
|
||||
+libtorrent_other_la_SOURCES = \
|
||||
+ data/chunk.cc \
|
||||
+ data/chunk.h \
|
||||
+ data/chunk_handle.h \
|
||||
+ data/chunk_iterator.h \
|
||||
+ data/chunk_list.cc \
|
||||
+ data/chunk_list.h \
|
||||
+ data/chunk_list_node.h \
|
||||
+ data/chunk_part.cc \
|
||||
+ data/chunk_part.h \
|
||||
+ data/hash_check_queue.cc \
|
||||
+ data/hash_check_queue.h \
|
||||
+ data/hash_chunk.cc \
|
||||
+ data/hash_chunk.h \
|
||||
+ data/hash_queue.cc \
|
||||
+ data/hash_queue.h \
|
||||
+ data/hash_queue_node.cc \
|
||||
+ data/hash_queue_node.h \
|
||||
+ data/hash_torrent.cc \
|
||||
+ data/hash_torrent.h \
|
||||
+ data/memory_chunk.cc \
|
||||
+ data/memory_chunk.h \
|
||||
+ data/socket_file.cc \
|
||||
+ data/socket_file.h \
|
||||
+ \
|
||||
+ dht/dht_bucket.cc \
|
||||
+ dht/dht_bucket.h \
|
||||
+ dht/dht_hash_map.h \
|
||||
+ dht/dht_node.cc \
|
||||
+ dht/dht_node.h \
|
||||
+ dht/dht_router.cc \
|
||||
+ dht/dht_router.h \
|
||||
+ dht/dht_server.cc \
|
||||
+ dht/dht_server.h \
|
||||
+ dht/dht_tracker.cc \
|
||||
+ dht/dht_tracker.h \
|
||||
+ dht/dht_transaction.cc \
|
||||
+ dht/dht_transaction.h \
|
||||
+ \
|
||||
+ download/available_list.cc \
|
||||
+ download/available_list.h \
|
||||
+ download/chunk_selector.cc \
|
||||
+ download/chunk_selector.h \
|
||||
+ download/chunk_statistics.cc \
|
||||
+ download/chunk_statistics.h \
|
||||
+ download/delegator.cc \
|
||||
+ download/delegator.h \
|
||||
+ download/download_constructor.cc \
|
||||
+ download/download_constructor.h \
|
||||
+ download/download_main.cc \
|
||||
+ download/download_main.h \
|
||||
+ download/download_wrapper.cc \
|
||||
+ download/download_wrapper.h \
|
||||
+ \
|
||||
+ net/address_list.cc \
|
||||
+ net/address_list.h \
|
||||
+ net/data_buffer.h \
|
||||
+ net/local_addr.cc \
|
||||
+ net/local_addr.h \
|
||||
+ net/listen.cc \
|
||||
+ net/listen.h \
|
||||
+ net/protocol_buffer.h \
|
||||
+ net/socket_base.cc \
|
||||
+ net/socket_base.h \
|
||||
+ net/socket_datagram.cc \
|
||||
+ net/socket_datagram.h \
|
||||
+ net/socket_fd.cc \
|
||||
+ net/socket_fd.h \
|
||||
+ net/socket_listen.cc \
|
||||
+ net/socket_listen.h \
|
||||
+ net/socket_set.cc \
|
||||
+ net/socket_set.h \
|
||||
+ net/socket_stream.cc \
|
||||
+ net/socket_stream.h \
|
||||
+ net/throttle_internal.cc \
|
||||
+ net/throttle_internal.h \
|
||||
+ net/throttle_list.cc \
|
||||
+ net/throttle_list.h \
|
||||
+ net/throttle_node.h \
|
||||
+ \
|
||||
+ protocol/encryption_info.h \
|
||||
+ protocol/extensions.cc \
|
||||
+ protocol/extensions.h \
|
||||
+ protocol/handshake.cc \
|
||||
+ protocol/handshake.h \
|
||||
+ protocol/handshake_encryption.cc \
|
||||
+ protocol/handshake_encryption.h \
|
||||
+ protocol/handshake_manager.cc \
|
||||
+ protocol/handshake_manager.h \
|
||||
+ protocol/initial_seed.cc \
|
||||
+ protocol/initial_seed.h \
|
||||
+ protocol/peer_chunks.h \
|
||||
+ protocol/peer_connection_base.cc \
|
||||
+ protocol/peer_connection_base.h \
|
||||
+ protocol/peer_connection_leech.cc \
|
||||
+ protocol/peer_connection_leech.h \
|
||||
+ protocol/peer_connection_metadata.cc \
|
||||
+ protocol/peer_connection_metadata.h \
|
||||
+ protocol/peer_factory.cc \
|
||||
+ protocol/peer_factory.h \
|
||||
+ protocol/protocol_base.h \
|
||||
+ protocol/request_list.cc \
|
||||
+ protocol/request_list.h \
|
||||
+ \
|
||||
+ tracker/tracker_dht.cc \
|
||||
+ tracker/tracker_dht.h \
|
||||
+ tracker/tracker_http.cc \
|
||||
+ tracker/tracker_http.h \
|
||||
+ tracker/tracker_udp.cc \
|
||||
+ tracker/tracker_udp.h \
|
||||
+ \
|
||||
+ utils/diffie_hellman.cc \
|
||||
+ utils/diffie_hellman.h \
|
||||
+ utils/instrumentation.cc \
|
||||
+ utils/instrumentation.h \
|
||||
+ utils/rc4.h \
|
||||
+ utils/sha1.h \
|
||||
+ utils/sha_fast.cc \
|
||||
+ utils/sha_fast.h \
|
||||
+ utils/queue_buckets.h
|
||||
+
|
||||
AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir)
|
||||
diff --git a/src/data/Makefile.am b/src/data/Makefile.am
|
||||
deleted file mode 100644
|
||||
index ef41c9bd..00000000
|
||||
--- a/src/data/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,28 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_data.la
|
||||
-
|
||||
-libsub_data_la_SOURCES = \
|
||||
- chunk.cc \
|
||||
- chunk.h \
|
||||
- chunk_handle.h \
|
||||
- chunk_iterator.h \
|
||||
- chunk_list.cc \
|
||||
- chunk_list.h \
|
||||
- chunk_list_node.h \
|
||||
- chunk_part.cc \
|
||||
- chunk_part.h \
|
||||
- hash_check_queue.cc \
|
||||
- hash_check_queue.h \
|
||||
- hash_chunk.cc \
|
||||
- hash_chunk.h \
|
||||
- hash_queue.cc \
|
||||
- hash_queue.h \
|
||||
- hash_queue_node.cc \
|
||||
- hash_queue_node.h \
|
||||
- hash_torrent.cc \
|
||||
- hash_torrent.h \
|
||||
- memory_chunk.cc \
|
||||
- memory_chunk.h \
|
||||
- socket_file.cc \
|
||||
- socket_file.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am
|
||||
deleted file mode 100644
|
||||
index a87c57bc..00000000
|
||||
--- a/src/dht/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,18 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_dht.la
|
||||
-
|
||||
-libsub_dht_la_SOURCES = \
|
||||
- dht_bucket.cc \
|
||||
- dht_bucket.h \
|
||||
- dht_hash_map.h \
|
||||
- dht_node.cc \
|
||||
- dht_node.h \
|
||||
- dht_router.cc \
|
||||
- dht_router.h \
|
||||
- dht_server.cc \
|
||||
- dht_server.h \
|
||||
- dht_tracker.cc \
|
||||
- dht_tracker.h \
|
||||
- dht_transaction.cc \
|
||||
- dht_transaction.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
diff --git a/src/download/Makefile.am b/src/download/Makefile.am
|
||||
deleted file mode 100644
|
||||
index 65ceaf97..00000000
|
||||
--- a/src/download/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,19 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_download.la
|
||||
-
|
||||
-libsub_download_la_SOURCES = \
|
||||
- available_list.cc \
|
||||
- available_list.h \
|
||||
- chunk_selector.cc \
|
||||
- chunk_selector.h \
|
||||
- chunk_statistics.cc \
|
||||
- chunk_statistics.h \
|
||||
- delegator.cc \
|
||||
- delegator.h \
|
||||
- download_constructor.cc \
|
||||
- download_constructor.h \
|
||||
- download_main.cc \
|
||||
- download_main.h \
|
||||
- download_wrapper.cc \
|
||||
- download_wrapper.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
diff --git a/src/net/Makefile.am b/src/net/Makefile.am
|
||||
deleted file mode 100644
|
||||
index e3a8c7e1..00000000
|
||||
--- a/src/net/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,30 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_net.la
|
||||
-
|
||||
-libsub_net_la_SOURCES = \
|
||||
- address_list.cc \
|
||||
- address_list.h \
|
||||
- data_buffer.h \
|
||||
- local_addr.cc \
|
||||
- local_addr.h \
|
||||
- listen.cc \
|
||||
- listen.h \
|
||||
- protocol_buffer.h \
|
||||
- socket_base.cc \
|
||||
- socket_base.h \
|
||||
- socket_datagram.cc \
|
||||
- socket_datagram.h \
|
||||
- socket_fd.cc \
|
||||
- socket_fd.h \
|
||||
- socket_listen.cc \
|
||||
- socket_listen.h \
|
||||
- socket_set.cc \
|
||||
- socket_set.h \
|
||||
- socket_stream.cc \
|
||||
- socket_stream.h \
|
||||
- throttle_internal.cc \
|
||||
- throttle_internal.h \
|
||||
- throttle_list.cc \
|
||||
- throttle_list.h \
|
||||
- throttle_node.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
diff --git a/src/protocol/Makefile.am b/src/protocol/Makefile.am
|
||||
deleted file mode 100644
|
||||
index 2e9aba7a..00000000
|
||||
--- a/src/protocol/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,28 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_protocol.la
|
||||
-
|
||||
-libsub_protocol_la_SOURCES = \
|
||||
- encryption_info.h \
|
||||
- extensions.cc \
|
||||
- extensions.h \
|
||||
- handshake.cc \
|
||||
- handshake.h \
|
||||
- handshake_encryption.cc \
|
||||
- handshake_encryption.h \
|
||||
- handshake_manager.cc \
|
||||
- handshake_manager.h \
|
||||
- initial_seed.cc \
|
||||
- initial_seed.h \
|
||||
- peer_chunks.h \
|
||||
- peer_connection_base.cc \
|
||||
- peer_connection_base.h \
|
||||
- peer_connection_leech.cc \
|
||||
- peer_connection_leech.h \
|
||||
- peer_connection_metadata.cc \
|
||||
- peer_connection_metadata.h \
|
||||
- peer_factory.cc \
|
||||
- peer_factory.h \
|
||||
- protocol_base.h \
|
||||
- request_list.cc \
|
||||
- request_list.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
diff --git a/src/torrent/Makefile.am b/src/torrent/Makefile.am
|
||||
index 8cd26ce7..30157b95 100644
|
||||
--- a/src/torrent/Makefile.am
|
||||
+++ b/src/torrent/Makefile.am
|
||||
@@ -1,13 +1,89 @@
|
||||
-SUBDIRS = \
|
||||
- data \
|
||||
- download \
|
||||
- net \
|
||||
- peer \
|
||||
- utils
|
||||
+noinst_LTLIBRARIES = libtorrent_torrent.la
|
||||
|
||||
-noinst_LTLIBRARIES = libsub_torrent.la
|
||||
-
|
||||
-libsub_torrent_la_SOURCES = \
|
||||
+libtorrent_torrent_la_SOURCES = \
|
||||
+ data/block.cc \
|
||||
+ data/block.h \
|
||||
+ data/block_failed.h \
|
||||
+ data/block_list.cc \
|
||||
+ data/block_list.h \
|
||||
+ data/block_transfer.h \
|
||||
+ data/chunk_utils.cc \
|
||||
+ data/chunk_utils.h \
|
||||
+ data/download_data.cc \
|
||||
+ data/download_data.h \
|
||||
+ data/file.cc \
|
||||
+ data/file.h \
|
||||
+ data/file_list.cc \
|
||||
+ data/file_list.h \
|
||||
+ data/file_list_iterator.cc \
|
||||
+ data/file_list_iterator.h \
|
||||
+ data/file_manager.cc \
|
||||
+ data/file_manager.h \
|
||||
+ data/file_utils.cc \
|
||||
+ data/file_utils.h \
|
||||
+ data/piece.h \
|
||||
+ data/transfer_list.cc \
|
||||
+ data/transfer_list.h \
|
||||
+\
|
||||
+ download/choke_group.cc \
|
||||
+ download/choke_group.h \
|
||||
+ download/choke_queue.cc \
|
||||
+ download/choke_queue.h \
|
||||
+ download/download_manager.cc \
|
||||
+ download/download_manager.h \
|
||||
+ download/group_entry.h \
|
||||
+ download/resource_manager.cc \
|
||||
+ download/resource_manager.h \
|
||||
+\
|
||||
+ net/address_info.cc \
|
||||
+ net/address_info.h \
|
||||
+ net/fd.cc \
|
||||
+ net/fd.h \
|
||||
+ net/socket_address.cc \
|
||||
+ net/socket_address.h \
|
||||
+ net/socket_address_key.cc \
|
||||
+ net/socket_address_key.h \
|
||||
+ net/socket_event.cc \
|
||||
+ net/socket_event.h \
|
||||
+ net/types.h \
|
||||
+\
|
||||
+ peer/choke_status.h \
|
||||
+ peer/client_info.cc \
|
||||
+ peer/client_info.h \
|
||||
+ peer/client_list.cc \
|
||||
+ peer/client_list.h \
|
||||
+ peer/connection_list.cc \
|
||||
+ peer/connection_list.h \
|
||||
+ peer/peer.cc \
|
||||
+ peer/peer.h \
|
||||
+ peer/peer_info.cc \
|
||||
+ peer/peer_info.h \
|
||||
+ peer/peer_list.cc \
|
||||
+ peer/peer_list.h \
|
||||
+\
|
||||
+ utils/directory_events.cc \
|
||||
+ utils/directory_events.h \
|
||||
+ utils/extents.h \
|
||||
+ utils/log.cc \
|
||||
+ utils/log.h \
|
||||
+ utils/log_buffer.cc \
|
||||
+ utils/log_buffer.h \
|
||||
+ utils/option_strings.cc \
|
||||
+ utils/option_strings.h \
|
||||
+ utils/random.cc \
|
||||
+ utils/random.h \
|
||||
+ utils/ranges.h \
|
||||
+ utils/resume.cc \
|
||||
+ utils/resume.h \
|
||||
+ utils/signal_bitfield.cc \
|
||||
+ utils/signal_bitfield.h \
|
||||
+ utils/thread_base.cc \
|
||||
+ utils/thread_base.h \
|
||||
+ utils/thread_interrupt.cc \
|
||||
+ utils/thread_interrupt.h \
|
||||
+ utils/uri_parser.cc \
|
||||
+ utils/uri_parser.h \
|
||||
+\
|
||||
bitfield.cc \
|
||||
bitfield.h \
|
||||
chunk_manager.cc \
|
||||
@@ -61,8 +137,64 @@ libsub_torrent_la_SOURCES = \
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
|
||||
-libtorrentincludedir = $(includedir)/torrent
|
||||
-libtorrentinclude_HEADERS = \
|
||||
+libtorrent_torrent_data_includedir = $(includedir)/torrent/data
|
||||
+libtorrent_torrent_data_include_HEADERS = \
|
||||
+ data/block.h \
|
||||
+ data/block_list.h \
|
||||
+ data/block_transfer.h \
|
||||
+ data/chunk_utils.h \
|
||||
+ data/download_data.h \
|
||||
+ data/file.h \
|
||||
+ data/file_list.h \
|
||||
+ data/file_list_iterator.h \
|
||||
+ data/file_manager.h \
|
||||
+ data/file_utils.h \
|
||||
+ data/piece.h \
|
||||
+ data/transfer_list.h
|
||||
+
|
||||
+libtorrent_torrent_download_includedir = $(includedir)/torrent/download
|
||||
+libtorrent_torrent_download_include_HEADERS = \
|
||||
+ download/choke_group.h \
|
||||
+ download/choke_queue.h \
|
||||
+ download/download_manager.h \
|
||||
+ download/group_entry.h \
|
||||
+ download/resource_manager.h
|
||||
+
|
||||
+libtorrent_torrent_net_includedir = $(includedir)/torrent/net
|
||||
+libtorrent_torrent_net_include_HEADERS = \
|
||||
+ net/address_info.h \
|
||||
+ net/fd.h \
|
||||
+ net/socket_address.h \
|
||||
+ net/socket_address_key.h \
|
||||
+ net/socket_event.h \
|
||||
+ net/types.h
|
||||
+
|
||||
+libtorrent_torrent_peer_includedir = $(includedir)/torrent/peer
|
||||
+libtorrent_torrent_peer_include_HEADERS = \
|
||||
+ peer/choke_status.h \
|
||||
+ peer/client_info.h \
|
||||
+ peer/client_list.h \
|
||||
+ peer/connection_list.h \
|
||||
+ peer/peer.h \
|
||||
+ peer/peer_info.h \
|
||||
+ peer/peer_list.h
|
||||
+
|
||||
+libtorrent_torrent_utils_includedir = $(includedir)/torrent/utils
|
||||
+libtorrent_torrent_utils_include_HEADERS = \
|
||||
+ utils/directory_events.h \
|
||||
+ utils/extents.h \
|
||||
+ utils/log.h \
|
||||
+ utils/log_buffer.h \
|
||||
+ utils/option_strings.h \
|
||||
+ utils/ranges.h \
|
||||
+ utils/resume.h \
|
||||
+ utils/signal_bitfield.h \
|
||||
+ utils/thread_base.h \
|
||||
+ utils/thread_interrupt.h \
|
||||
+ utils/uri_parser.h
|
||||
+
|
||||
+libtorrent_torrent_includedir = $(includedir)/torrent
|
||||
+libtorrent_torrent_include_HEADERS = \
|
||||
bitfield.h \
|
||||
chunk_manager.h \
|
||||
common.h \
|
||||
diff --git a/src/torrent/download/Makefile.am b/src/torrent/download/Makefile.am
|
||||
deleted file mode 100644
|
||||
index f92c7aa4..00000000
|
||||
--- a/src/torrent/download/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,22 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_torrentdownload.la
|
||||
-
|
||||
-libsub_torrentdownload_la_SOURCES = \
|
||||
- choke_group.cc \
|
||||
- choke_group.h \
|
||||
- choke_queue.cc \
|
||||
- choke_queue.h \
|
||||
- download_manager.cc \
|
||||
- download_manager.h \
|
||||
- group_entry.h \
|
||||
- resource_manager.cc \
|
||||
- resource_manager.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir)
|
||||
-
|
||||
-libtorrentincludedir = $(includedir)/torrent/download
|
||||
-libtorrentinclude_HEADERS = \
|
||||
- choke_group.h \
|
||||
- choke_queue.h \
|
||||
- download_manager.h \
|
||||
- group_entry.h \
|
||||
- resource_manager.h
|
||||
diff --git a/src/torrent/net/Makefile.am b/src/torrent/net/Makefile.am
|
||||
deleted file mode 100644
|
||||
index 35dd4774..00000000
|
||||
--- a/src/torrent/net/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,25 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_torrentnet.la
|
||||
-
|
||||
-libsub_torrentnet_la_SOURCES = \
|
||||
- address_info.cc \
|
||||
- address_info.h \
|
||||
- fd.cc \
|
||||
- fd.h \
|
||||
- socket_address.cc \
|
||||
- socket_address.h \
|
||||
- socket_address_key.cc \
|
||||
- socket_address_key.h \
|
||||
- socket_event.cc \
|
||||
- socket_event.h \
|
||||
- types.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir)
|
||||
-
|
||||
-libtorrentincludedir = $(includedir)/torrent/net
|
||||
-libtorrentinclude_HEADERS = \
|
||||
- address_info.h \
|
||||
- fd.h \
|
||||
- socket_address.h \
|
||||
- socket_address_key.h \
|
||||
- socket_event.h \
|
||||
- types.h
|
||||
diff --git a/src/torrent/peer/Makefile.am b/src/torrent/peer/Makefile.am
|
||||
deleted file mode 100644
|
||||
index 1324e88a..00000000
|
||||
--- a/src/torrent/peer/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,28 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_torrentpeer.la
|
||||
-
|
||||
-libsub_torrentpeer_la_SOURCES = \
|
||||
- choke_status.h \
|
||||
- client_info.cc \
|
||||
- client_info.h \
|
||||
- client_list.cc \
|
||||
- client_list.h \
|
||||
- connection_list.cc \
|
||||
- connection_list.h \
|
||||
- peer.cc \
|
||||
- peer.h \
|
||||
- peer_info.cc \
|
||||
- peer_info.h \
|
||||
- peer_list.cc \
|
||||
- peer_list.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir)
|
||||
-
|
||||
-libtorrentincludedir = $(includedir)/torrent/peer
|
||||
-libtorrentinclude_HEADERS = \
|
||||
- choke_status.h \
|
||||
- client_info.h \
|
||||
- client_list.h \
|
||||
- connection_list.h \
|
||||
- peer.h \
|
||||
- peer_info.h \
|
||||
- peer_list.h
|
||||
diff --git a/src/torrent/utils/Makefile.am b/src/torrent/utils/Makefile.am
|
||||
deleted file mode 100644
|
||||
index a48786c6..00000000
|
||||
--- a/src/torrent/utils/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,41 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_torrentutils.la
|
||||
-
|
||||
-libsub_torrentutils_la_SOURCES = \
|
||||
- directory_events.cc \
|
||||
- directory_events.h \
|
||||
- extents.h \
|
||||
- log.cc \
|
||||
- log.h \
|
||||
- log_buffer.cc \
|
||||
- log_buffer.h \
|
||||
- option_strings.cc \
|
||||
- option_strings.h \
|
||||
- random.cc \
|
||||
- random.h \
|
||||
- ranges.h \
|
||||
- resume.cc \
|
||||
- resume.h \
|
||||
- signal_bitfield.cc \
|
||||
- signal_bitfield.h \
|
||||
- thread_base.cc \
|
||||
- thread_base.h \
|
||||
- thread_interrupt.cc \
|
||||
- thread_interrupt.h \
|
||||
- uri_parser.cc \
|
||||
- uri_parser.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. -I$(top_srcdir)
|
||||
-
|
||||
-libtorrentincludedir = $(includedir)/torrent/utils
|
||||
-libtorrentinclude_HEADERS = \
|
||||
- directory_events.h \
|
||||
- extents.h \
|
||||
- log.h \
|
||||
- log_buffer.h \
|
||||
- option_strings.h \
|
||||
- ranges.h \
|
||||
- resume.h \
|
||||
- signal_bitfield.h \
|
||||
- thread_base.h \
|
||||
- thread_interrupt.h \
|
||||
- uri_parser.h
|
||||
diff --git a/src/tracker/Makefile.am b/src/tracker/Makefile.am
|
||||
deleted file mode 100644
|
||||
index 2f1ae5cf..00000000
|
||||
--- a/src/tracker/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,11 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_tracker.la
|
||||
-
|
||||
-libsub_tracker_la_SOURCES = \
|
||||
- tracker_dht.cc \
|
||||
- tracker_dht.h \
|
||||
- tracker_http.cc \
|
||||
- tracker_http.h \
|
||||
- tracker_udp.cc \
|
||||
- tracker_udp.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
|
||||
deleted file mode 100644
|
||||
index 27ce359b..00000000
|
||||
--- a/src/utils/Makefile.am
|
||||
+++ /dev/null
|
||||
@@ -1,14 +0,0 @@
|
||||
-noinst_LTLIBRARIES = libsub_utils.la
|
||||
-
|
||||
-libsub_utils_la_SOURCES = \
|
||||
- diffie_hellman.cc \
|
||||
- diffie_hellman.h \
|
||||
- instrumentation.cc \
|
||||
- instrumentation.h \
|
||||
- rc4.h \
|
||||
- sha1.h \
|
||||
- sha_fast.cc \
|
||||
- sha_fast.h \
|
||||
- queue_buckets.h
|
||||
-
|
||||
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
diff --git a/test/Makefile.am b/test/Makefile.am
|
||||
index 23b260e4..8b0291bb 100644
|
||||
--- a/test/Makefile.am
|
||||
+++ b/test/Makefile.am
|
||||
@@ -1,25 +1,68 @@
|
||||
-SUBDIRS = torrent/net net
|
||||
-
|
||||
-TESTS = LibTorrentTest
|
||||
-AUTOMAKE_OPTIONS = subdir-objects
|
||||
+TESTS = \
|
||||
+ LibTorrent_Test_Torrent_Net \
|
||||
+ LibTorrent_Test_Net \
|
||||
+ LibTorrent_Test
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
-LibTorrentTest_LDADD = \
|
||||
+
|
||||
+LibTorrent_Test_LDADD = \
|
||||
../src/libtorrent.la \
|
||||
- ../src/torrent/libsub_torrent.la \
|
||||
- ../src/torrent/data/libsub_torrentdata.la \
|
||||
- ../src/torrent/download/libsub_torrentdownload.la \
|
||||
- ../src/torrent/peer/libsub_torrentpeer.la \
|
||||
- ../src/data/libsub_data.la \
|
||||
- ../src/dht/libsub_dht.la \
|
||||
- ../src/net/libsub_net.la \
|
||||
- ../src/protocol/libsub_protocol.la \
|
||||
- ../src/download/libsub_download.la \
|
||||
- ../src/tracker/libsub_tracker.la \
|
||||
- ../src/utils/libsub_utils.la \
|
||||
- ../src/torrent/utils/libsub_torrentutils.la
|
||||
+ ../src/libtorrent_other.la \
|
||||
+ ../src/torrent/libtorrent_torrent.la
|
||||
+
|
||||
+LibTorrent_Test_Net_LDADD = $(LibTorrent_Test_LDADD)
|
||||
+LibTorrent_Test_Torrent_Net_LDADD = $(LibTorrent_Test_LDADD)
|
||||
+
|
||||
+# LibTorrent_Test_SOURCES = \
|
||||
+# helpers/expect_fd.h \
|
||||
+# helpers/expect_utils.h \
|
||||
+# helpers/mock_compare.h \
|
||||
+# helpers/mock_function.cc \
|
||||
+# helpers/mock_function.h \
|
||||
+# helpers/network.h \
|
||||
+# helpers/progress_listener.cc \
|
||||
+# helpers/progress_listener.h \
|
||||
+# helpers/test_fixture.cc \
|
||||
+# helpers/test_fixture.h
|
||||
+
|
||||
+LibTorrent_Test_Torrent_Net_SOURCES = \
|
||||
+ main.cc \
|
||||
+ helpers/expect_fd.h \
|
||||
+ helpers/expect_utils.h \
|
||||
+ helpers/mock_compare.h \
|
||||
+ helpers/mock_function.cc \
|
||||
+ helpers/mock_function.h \
|
||||
+ helpers/network.h \
|
||||
+ helpers/progress_listener.cc \
|
||||
+ helpers/progress_listener.h \
|
||||
+ helpers/test_fixture.cc \
|
||||
+ helpers/test_fixture.h \
|
||||
+ \
|
||||
+ torrent/net/test_address_info.cc \
|
||||
+ torrent/net/test_address_info.h \
|
||||
+ torrent/net/test_fd.cc \
|
||||
+ torrent/net/test_fd.h \
|
||||
+ torrent/net/test_socket_address.cc \
|
||||
+ torrent/net/test_socket_address.h
|
||||
|
||||
-LibTorrentTest_SOURCES = \
|
||||
+LibTorrent_Test_Net_SOURCES = \
|
||||
+ main.cc \
|
||||
+ helpers/expect_fd.h \
|
||||
+ helpers/expect_utils.h \
|
||||
+ helpers/mock_compare.h \
|
||||
+ helpers/mock_function.cc \
|
||||
+ helpers/mock_function.h \
|
||||
+ helpers/network.h \
|
||||
+ helpers/progress_listener.cc \
|
||||
+ helpers/progress_listener.h \
|
||||
+ helpers/test_fixture.cc \
|
||||
+ helpers/test_fixture.h \
|
||||
+ \
|
||||
+ net/test_socket_listen.cc \
|
||||
+ net/test_socket_listen.h
|
||||
+
|
||||
+LibTorrent_Test_SOURCES = \
|
||||
+ main.cc \
|
||||
helpers/expect_fd.h \
|
||||
helpers/expect_utils.h \
|
||||
helpers/mock_compare.h \
|
||||
@@ -87,12 +130,15 @@ LibTorrentTest_SOURCES = \
|
||||
torrent/tracker_list_features_test.h \
|
||||
torrent/tracker_timeout_test.cc \
|
||||
torrent/tracker_timeout_test.h \
|
||||
- tracker/tracker_http_test.cc \
|
||||
- tracker/tracker_http_test.h \
|
||||
\
|
||||
- main.cc
|
||||
+ tracker/tracker_http_test.cc \
|
||||
+ tracker/tracker_http_test.h
|
||||
|
||||
-LibTorrentTest_CXXFLAGS = $(CPPUNIT_CFLAGS)
|
||||
-LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS) -ldl
|
||||
+LibTorrent_Test_Torrent_Net_CXXFLAGS = $(CPPUNIT_CFLAGS)
|
||||
+LibTorrent_Test_Torrent_Net_LDFLAGS = $(CPPUNIT_LIBS) -ldl
|
||||
+LibTorrent_Test_Net_CXXFLAGS = $(CPPUNIT_CFLAGS)
|
||||
+LibTorrent_Test_Net_LDFLAGS = $(CPPUNIT_LIBS) -ldl
|
||||
+LibTorrent_Test_CXXFLAGS = $(CPPUNIT_CFLAGS)
|
||||
+LibTorrent_Test_LDFLAGS = $(CPPUNIT_LIBS) -ldl
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/src
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,22 +0,0 @@
|
|||
From 03e1c95987917bf98534e50fdd718a948540ffb2 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Thu, 25 Feb 2021 00:03:27 +0900
|
||||
Subject: [PATCH] Changes automake required files.
|
||||
|
||||
---
|
||||
autogen.sh | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/autogen.sh b/autogen.sh
|
||||
index 79afab8e..6def96dd 100755
|
||||
--- a/autogen.sh
|
||||
+++ b/autogen.sh
|
||||
@@ -36,7 +36,7 @@ echo automake...
|
||||
exit 1
|
||||
}
|
||||
|
||||
-automake --add-missing --copy --gnu || exit 1
|
||||
+automake --add-missing --copy --foreign || exit 1
|
||||
|
||||
echo autoconf...
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
From b4a3888bd891d804a83ae1cee623592725975895 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Sat, 27 Feb 2021 22:11:55 +0900
|
||||
Subject: [PATCH] Replaced custom execinfo autoconf test.
|
||||
|
||||
---
|
||||
configure.ac | 2 +-
|
||||
scripts/rak_execinfo.m4 | 11 -----------
|
||||
2 files changed, 1 insertion(+), 12 deletions(-)
|
||||
delete mode 100644 scripts/rak_execinfo.m4
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 88a46edd..197bbc94 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -34,7 +34,6 @@ RAK_CHECK_CXXFLAGS
|
||||
RAK_ENABLE_DEBUG
|
||||
RAK_ENABLE_EXTRA_DEBUG
|
||||
RAK_ENABLE_WERROR
|
||||
-RAK_DISABLE_BACKTRACE
|
||||
|
||||
RAK_CHECK_CXX11
|
||||
|
||||
@@ -58,6 +57,7 @@ TORRENT_WITH_INOTIFY
|
||||
CC_ATTRIBUTE_VISIBILITY
|
||||
|
||||
AX_CHECK_ZLIB
|
||||
+AX_EXECINFO
|
||||
AX_PTHREAD
|
||||
|
||||
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
||||
diff --git a/scripts/rak_execinfo.m4 b/scripts/rak_execinfo.m4
|
||||
deleted file mode 100644
|
||||
index c1d9b2f8..00000000
|
||||
--- a/scripts/rak_execinfo.m4
|
||||
+++ /dev/null
|
||||
@@ -1,11 +0,0 @@
|
||||
-AC_DEFUN([RAK_DISABLE_BACKTRACE], [
|
||||
- AC_ARG_ENABLE(backtrace,
|
||||
- AC_HELP_STRING([--disable-backtrace], [disable backtrace information [[default=no]]]),
|
||||
- [
|
||||
- if test "$enableval" = "yes"; then
|
||||
- AX_EXECINFO
|
||||
- fi
|
||||
- ],[
|
||||
- AX_EXECINFO
|
||||
- ])
|
||||
-])
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
From e5ed6301e0d07adeaab10e9924a8c9a2e327cdc5 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Thu, 29 Apr 2021 19:33:04 +0900
|
||||
Subject: [PATCH] Added option to disable pthread_setname_np.
|
||||
|
||||
---
|
||||
configure.ac | 30 +++++++++++++++++++-----------
|
||||
scripts/checks.m4 | 18 ++++++++++++++++++
|
||||
src/torrent/utils/thread_base.cc | 16 ++++++++++++++--
|
||||
3 files changed, 51 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 197bbc94..73caf712 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -24,9 +24,9 @@ AC_PROG_CXX
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
AC_C_BIGENDIAN(
|
||||
- AC_DEFINE(IS_BIG_ENDIAN, 1, Big endian),
|
||||
- AC_DEFINE(IS_LITTLE_ENDIAN, 1, Little endian),
|
||||
- AC_MSG_ERROR([Could not determine endianness])
|
||||
+ AC_DEFINE(IS_BIG_ENDIAN, 1, Big endian),
|
||||
+ AC_DEFINE(IS_LITTLE_ENDIAN, 1, Little endian),
|
||||
+ AC_MSG_ERROR([Could not determine endianness])
|
||||
)
|
||||
|
||||
RAK_CHECK_CFLAGS
|
||||
@@ -54,7 +54,15 @@ TORRENT_WITHOUT_STATVFS
|
||||
TORRENT_WITHOUT_STATFS
|
||||
TORRENT_WITH_INOTIFY
|
||||
|
||||
-CC_ATTRIBUTE_VISIBILITY
|
||||
+AC_ARG_ENABLE(attribute-visibility,
|
||||
+ AC_HELP_STRING([--disable-attribute-visibility], [disable symbol visibility attribute [[default=enable]]]),
|
||||
+ [
|
||||
+ if test "$enableval" = "yes"; then
|
||||
+ CC_ATTRIBUTE_VISIBILITY
|
||||
+ fi
|
||||
+ ],[
|
||||
+ CC_ATTRIBUTE_VISIBILITY
|
||||
+ ])
|
||||
|
||||
AX_CHECK_ZLIB
|
||||
AX_EXECINFO
|
||||
@@ -71,11 +79,11 @@ TORRENT_ARG_CYRUS_RC4
|
||||
|
||||
AC_CHECK_FUNCS(posix_memalign)
|
||||
|
||||
-TORRENT_CHECK_MADVISE()
|
||||
-TORRENT_CHECK_CACHELINE()
|
||||
-TORRENT_CHECK_POPCOUNT()
|
||||
-TORRENT_CHECK_PTHREAD_SETNAME_NP()
|
||||
-TORRENT_MINCORE()
|
||||
+TORRENT_CHECK_MADVISE
|
||||
+TORRENT_CHECK_CACHELINE
|
||||
+TORRENT_CHECK_POPCOUNT
|
||||
+TORRENT_DISABLE_PTHREAD_SETNAME_NP
|
||||
+TORRENT_MINCORE
|
||||
|
||||
TORRENT_DISABLE_INSTRUMENTATION
|
||||
|
||||
@@ -88,8 +96,8 @@ AC_SUBST(LIBTORRENT_CFLAGS)
|
||||
AC_DEFINE(HAVE_CONFIG_H, 1, true if config.h was included)
|
||||
|
||||
CC_ATTRIBUTE_UNUSED(
|
||||
- AC_DEFINE([__UNUSED], [__attribute__((unused))], [Wrapper around unused attribute]),
|
||||
- AC_DEFINE([__UNUSED], [], [Null-wrapper if unused attribute is unsupported])
|
||||
+ AC_DEFINE([__UNUSED], [__attribute__((unused))], [Wrapper around unused attribute]),
|
||||
+ AC_DEFINE([__UNUSED], [], [Null-wrapper if unused attribute is unsupported])
|
||||
)
|
||||
|
||||
AC_OUTPUT([
|
||||
diff --git a/scripts/checks.m4 b/scripts/checks.m4
|
||||
index 98ef17f8..915a5011 100644
|
||||
--- a/scripts/checks.m4
|
||||
+++ b/scripts/checks.m4
|
||||
@@ -490,3 +490,21 @@ AC_DEFUN([TORRENT_CHECK_PTHREAD_SETNAME_NP], [
|
||||
])
|
||||
])
|
||||
])
|
||||
+
|
||||
+AC_DEFUN([TORRENT_DISABLE_PTHREAD_SETNAME_NP], [
|
||||
+ AC_MSG_CHECKING([for pthread_setname_no])
|
||||
+
|
||||
+ AC_ARG_ENABLE(pthread-setname-np,
|
||||
+ AC_HELP_STRING([--disable-pthread-setname-np], [disable pthread_setname_np]),
|
||||
+ [
|
||||
+ if test "$enableval" = "no"; then
|
||||
+ AC_MSG_RESULT(disabled)
|
||||
+ else
|
||||
+ AC_MSG_RESULT(checking)
|
||||
+ TORRENT_CHECK_PTHREAD_SETNAME_NP
|
||||
+ fi
|
||||
+ ], [
|
||||
+ TORRENT_CHECK_PTHREAD_SETNAME_NP
|
||||
+ ]
|
||||
+ )
|
||||
+])
|
||||
diff --git a/src/torrent/utils/thread_base.cc b/src/torrent/utils/thread_base.cc
|
||||
index 99d6355d..ec0619f3 100644
|
||||
--- a/src/torrent/utils/thread_base.cc
|
||||
+++ b/src/torrent/utils/thread_base.cc
|
||||
@@ -41,10 +41,16 @@ thread_base::~thread_base() {
|
||||
|
||||
void
|
||||
thread_base::start_thread() {
|
||||
- if (m_poll == NULL)
|
||||
+ if (this == nullptr)
|
||||
+ throw internal_error("Called thread_base::start_thread on a nullptr.");
|
||||
+
|
||||
+ if (m_poll == nullptr)
|
||||
throw internal_error("No poll object for thread defined.");
|
||||
|
||||
- if (!is_initialized() || pthread_create(&m_thread, NULL, (pthread_func)&thread_base::event_loop, this))
|
||||
+ if (!is_initialized())
|
||||
+ throw internal_error("Called thread_base::start_thread on an uninitialized object.");
|
||||
+
|
||||
+ if (pthread_create(&m_thread, NULL, (pthread_func)&thread_base::event_loop, this))
|
||||
throw internal_error("Failed to create thread.");
|
||||
}
|
||||
|
||||
@@ -82,6 +88,12 @@ thread_base::should_handle_sigusr1() {
|
||||
|
||||
void*
|
||||
thread_base::event_loop(thread_base* thread) {
|
||||
+ if (thread == nullptr)
|
||||
+ throw internal_error("thread_base::event_loop called with a null pointer thread");
|
||||
+
|
||||
+ if (!thread->is_initialized())
|
||||
+ throw internal_error("thread_base::event_loop call on an uninitialized object");
|
||||
+
|
||||
__sync_lock_test_and_set(&thread->m_state, STATE_ACTIVE);
|
||||
|
||||
#if defined(HAS_PTHREAD_SETNAME_NP_DARWIN)
|
||||
|
|
@ -1,594 +0,0 @@
|
|||
From f978e68f9d907e25207d0a7d247d2b10935e5d76 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Thu, 29 Apr 2021 19:34:35 +0900
|
||||
Subject: [PATCH] Improved backtrace error checking.
|
||||
|
||||
---
|
||||
src/download/download_main.cc | 36 -------------
|
||||
src/download/download_main.h | 36 -------------
|
||||
src/download/download_wrapper.cc | 43 ++--------------
|
||||
src/torrent/data/download_data.h | 36 -------------
|
||||
src/torrent/download/choke_queue.cc | 50 +++++-------------
|
||||
src/torrent/download/resource_manager.cc | 53 +++++--------------
|
||||
src/torrent/exceptions.cc | 65 +++++++-----------------
|
||||
src/torrent/torrent.cc | 1 +
|
||||
src/torrent/utils/extents.h | 36 -------------
|
||||
src/torrent/utils/signal_bitfield.cc | 36 -------------
|
||||
10 files changed, 48 insertions(+), 344 deletions(-)
|
||||
|
||||
diff --git a/src/download/download_main.cc b/src/download/download_main.cc
|
||||
index 9a3f9df2..e075038a 100644
|
||||
--- a/src/download/download_main.cc
|
||||
+++ b/src/download/download_main.cc
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
#include <cstring>
|
||||
diff --git a/src/download/download_main.h b/src/download/download_main.h
|
||||
index da3cf182..4783e863 100644
|
||||
--- a/src/download/download_main.h
|
||||
+++ b/src/download/download_main.h
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#ifndef LIBTORRENT_DOWNLOAD_MAIN_H
|
||||
#define LIBTORRENT_DOWNLOAD_MAIN_H
|
||||
|
||||
diff --git a/src/download/download_wrapper.cc b/src/download/download_wrapper.cc
|
||||
index 59e81781..304bddce 100644
|
||||
--- a/src/download/download_wrapper.cc
|
||||
+++ b/src/download/download_wrapper.cc
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
#include <iterator>
|
||||
@@ -62,6 +26,8 @@
|
||||
|
||||
#include "download_wrapper.h"
|
||||
|
||||
+#define LT_LOG_THIS(log_fmt, ...) \
|
||||
+ lt_log_print_info(LOG_TORRENT_INFO, this->info(), "download", log_fmt, __VA_ARGS__);
|
||||
#define LT_LOG_STORAGE_ERRORS(log_fmt, ...) \
|
||||
lt_log_print_info(LOG_PROTOCOL_STORAGE_ERRORS, this->info(), "storage_errors", log_fmt, __VA_ARGS__);
|
||||
|
||||
@@ -325,8 +291,8 @@ DownloadWrapper::receive_tick(uint32_t ticks) {
|
||||
|
||||
void
|
||||
DownloadWrapper::receive_update_priorities() {
|
||||
- if (m_main->chunk_selector()->empty())
|
||||
- return;
|
||||
+ LT_LOG_THIS("update priorities: chunks_selected:%" PRIu32 " wanted_chunks:%" PRIu32,
|
||||
+ m_main->chunk_selector()->size(), data()->wanted_chunks());
|
||||
|
||||
data()->mutable_high_priority()->clear();
|
||||
data()->mutable_normal_priority()->clear();
|
||||
@@ -359,7 +325,6 @@ DownloadWrapper::receive_update_priorities() {
|
||||
}
|
||||
|
||||
bool was_partial = data()->wanted_chunks() != 0;
|
||||
-
|
||||
data()->update_wanted_chunks();
|
||||
|
||||
m_main->chunk_selector()->update_priorities();
|
||||
diff --git a/src/torrent/data/download_data.h b/src/torrent/data/download_data.h
|
||||
index fc212047..c701cb2f 100644
|
||||
--- a/src/torrent/data/download_data.h
|
||||
+++ b/src/torrent/data/download_data.h
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#ifndef LIBTORRENT_DATA_DOWNLOAD_DATA_H
|
||||
#define LIBTORRENT_DATA_DOWNLOAD_DATA_H
|
||||
|
||||
diff --git a/src/torrent/download/choke_queue.cc b/src/torrent/download/choke_queue.cc
|
||||
index 7c00b686..edf47795 100644
|
||||
--- a/src/torrent/download/choke_queue.cc
|
||||
+++ b/src/torrent/download/choke_queue.cc
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -50,6 +14,10 @@
|
||||
|
||||
#include "choke_queue.h"
|
||||
|
||||
+// TODO: Add a different logging category.
|
||||
+#define LT_LOG_THIS(log_fmt, ...) \
|
||||
+ lt_log_print_subsystem(LOG_TORRENT_INFO, "choke_queue", log_fmt, __VA_ARGS__);
|
||||
+
|
||||
namespace torrent {
|
||||
|
||||
struct choke_manager_less {
|
||||
@@ -193,6 +161,9 @@ choke_queue::rebuild_containers(container_type* queued, container_type* unchoked
|
||||
|
||||
void
|
||||
choke_queue::balance() {
|
||||
+ LT_LOG_THIS("balancing queue: heuristics:%i currently_unchoked:%" PRIu32 " max_unchoked:%" PRIu32,
|
||||
+ m_heuristics, m_currently_unchoked, m_maxUnchoked)
|
||||
+
|
||||
// Return if no balancing is needed. Don't return if is_unlimited()
|
||||
// as we might have just changed the value and have interested that
|
||||
// can be unchoked.
|
||||
@@ -216,6 +187,9 @@ choke_queue::balance() {
|
||||
|
||||
// If we have more unchoked than max global slots allow for,
|
||||
// 'can_unchoke' will be negative.
|
||||
+ //
|
||||
+ // Throws std::bad_function_call if 'set_slot_can_unchoke' is not
|
||||
+ // set.
|
||||
int can_unchoke = m_slotCanUnchoke();
|
||||
int max_unchoked = std::min(m_maxUnchoked, (uint32_t)(1 << 20));
|
||||
|
||||
@@ -240,8 +214,8 @@ choke_queue::balance() {
|
||||
if (result != 0)
|
||||
m_slotUnchoke(result);
|
||||
|
||||
- lt_log_print(LOG_PEER_DEBUG, "Called balance; adjust:%i can_unchoke:%i queued:%u unchoked:%u result:%i.",
|
||||
- adjust, can_unchoke, (unsigned)queued.size(), (unsigned)unchoked.size(), result);
|
||||
+ LT_LOG_THIS("balanced queue: adjust:%i can_unchoke:%i queued:%" PRIu32 " unchoked:%" PRIu32 " result:%i",
|
||||
+ adjust, can_unchoke, queued.size(), unchoked.size(), result);
|
||||
}
|
||||
|
||||
void
|
||||
diff --git a/src/torrent/download/resource_manager.cc b/src/torrent/download/resource_manager.cc
|
||||
index 51434c91..8ca7b02e 100644
|
||||
--- a/src/torrent/download/resource_manager.cc
|
||||
+++ b/src/torrent/download/resource_manager.cc
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -51,6 +15,11 @@
|
||||
#include "choke_queue.h"
|
||||
#include "resource_manager.h"
|
||||
|
||||
+#define LT_LOG_THIS(log_fmt, ...) \
|
||||
+ lt_log_print_subsystem(LOG_TORRENT_INFO, "resource_manager", log_fmt, __VA_ARGS__);
|
||||
+#define LT_LOG_ITR(log_fmt, ...) \
|
||||
+ lt_log_print_info(LOG_TORRENT_INFO, itr->download()->info(), "resource_manager", log_fmt, __VA_ARGS__);
|
||||
+
|
||||
namespace torrent {
|
||||
|
||||
const Rate* resource_manager_entry::up_rate() const { return m_download->info()->up_rate(); }
|
||||
@@ -226,6 +195,8 @@ ResourceManager::group_index_of(const std::string& name) {
|
||||
|
||||
void
|
||||
ResourceManager::set_priority(iterator itr, uint16_t pri) {
|
||||
+ LT_LOG_ITR("set priority: %" PRIu16, 0)
|
||||
+
|
||||
itr->set_priority(pri);
|
||||
}
|
||||
|
||||
@@ -283,7 +254,7 @@ ResourceManager::set_max_download_unchoked(unsigned int m) {
|
||||
// possibly multiple calls of this function.
|
||||
void
|
||||
ResourceManager::receive_upload_unchoke(int num) {
|
||||
- lt_log_print(LOG_PEER_INFO, "Upload unchoked slots adjust; currently:%u adjust:%i", m_currentlyUploadUnchoked, num);
|
||||
+ LT_LOG_THIS("adjusting upload unchoked slots; current:%u adjusted:%i", m_currentlyUploadUnchoked, num);
|
||||
|
||||
if ((int)m_currentlyUploadUnchoked + num < 0)
|
||||
throw internal_error("ResourceManager::receive_upload_unchoke(...) received an invalid value.");
|
||||
@@ -293,7 +264,7 @@ ResourceManager::receive_upload_unchoke(int num) {
|
||||
|
||||
void
|
||||
ResourceManager::receive_download_unchoke(int num) {
|
||||
- lt_log_print(LOG_PEER_INFO, "Download unchoked slots adjust; currently:%u adjust:%i", m_currentlyDownloadUnchoked, num);
|
||||
+ LT_LOG_THIS("adjusting download unchoked slots; current:%u adjusted:%i", m_currentlyDownloadUnchoked, num);
|
||||
|
||||
if ((int)m_currentlyDownloadUnchoked + num < 0)
|
||||
throw internal_error("ResourceManager::receive_download_unchoke(...) received an invalid value.");
|
||||
@@ -387,12 +358,14 @@ ResourceManager::balance_unchoked(unsigned int weight, unsigned int max_unchoked
|
||||
std::sort(group_first, group_last, std::bind(std::less<uint32_t>(),
|
||||
std::bind(&choke_group::up_requested, std::placeholders::_1),
|
||||
std::bind(&choke_group::up_requested, std::placeholders::_2)));
|
||||
- lt_log_print(LOG_PEER_DEBUG, "Upload unchoked slots cycle; currently:%u adjusted:%i max_unchoked:%u", m_currentlyUploadUnchoked, change, max_unchoked);
|
||||
+
|
||||
+ LT_LOG_THIS("balancing upload unchoked slots; current_unchoked:%u change:%i max_unchoked:%u", m_currentlyUploadUnchoked, change, max_unchoked);
|
||||
} else {
|
||||
std::sort(group_first, group_last, std::bind(std::less<uint32_t>(),
|
||||
std::bind(&choke_group::down_requested, std::placeholders::_1),
|
||||
std::bind(&choke_group::down_requested, std::placeholders::_2)));
|
||||
- lt_log_print(LOG_PEER_DEBUG, "Download unchoked slots cycle; currently:%u adjusted:%i max_unchoked:%u", m_currentlyDownloadUnchoked, change, max_unchoked);
|
||||
+
|
||||
+ LT_LOG_THIS("balancing download unchoked slots; current_unchoked:%u change:%i max_unchoked:%u", m_currentlyDownloadUnchoked, change, max_unchoked);
|
||||
}
|
||||
|
||||
while (group_first != group_last) {
|
||||
diff --git a/src/torrent/exceptions.cc b/src/torrent/exceptions.cc
|
||||
index f834f9fa..7375ed8e 100644
|
||||
--- a/src/torrent/exceptions.cc
|
||||
+++ b/src/torrent/exceptions.cc
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
#include <cerrno>
|
||||
@@ -73,23 +37,30 @@ void
|
||||
internal_error::initialize(const std::string& msg) {
|
||||
m_msg = msg;
|
||||
|
||||
- std::stringstream output;
|
||||
-
|
||||
#ifdef HAVE_BACKTRACE
|
||||
- void* stackPtrs[20];
|
||||
+ void* stack_ptrs[20];
|
||||
+ int stack_size = ::backtrace(stack_ptrs, 20);
|
||||
+ char** stack_symbol_names = ::backtrace_symbols(stack_ptrs, stack_size);
|
||||
|
||||
- // Print the stack and exit.
|
||||
- int stackSize = ::backtrace(stackPtrs, 20);
|
||||
- char** stackStrings = backtrace_symbols(stackPtrs, stackSize);
|
||||
+ if (stack_symbol_names == nullptr) {
|
||||
+ m_backtrace = "backtrace_symbols failed";
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- for (int i = 0; i < stackSize; ++i)
|
||||
- output << stackStrings[i] << std::endl;
|
||||
+ std::stringstream output;
|
||||
|
||||
-#else
|
||||
- output << "Stack dump not enabled." << std::endl;
|
||||
-#endif
|
||||
+ for (int i = 0; i < stack_size; ++i) {
|
||||
+ if (stack_symbol_names[i] != nullptr && stack_symbol_names[i] > (void*)0x1000)
|
||||
+ output << stack_symbol_names[i] << std::endl;
|
||||
+ else
|
||||
+ output << "stack_symbol: nullptr" << std::endl;
|
||||
+ }
|
||||
|
||||
m_backtrace = output.str();
|
||||
+
|
||||
+#else
|
||||
+ m_backtrace = "stack dump not enabled";
|
||||
+#endif
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/torrent/torrent.cc b/src/torrent/torrent.cc
|
||||
index fb70d247..67de4387 100644
|
||||
--- a/src/torrent/torrent.cc
|
||||
+++ b/src/torrent/torrent.cc
|
||||
@@ -203,6 +203,7 @@ download_priority(Download d) {
|
||||
return itr->priority();
|
||||
}
|
||||
|
||||
+// TODO: Remove this.
|
||||
void
|
||||
download_set_priority(Download d, uint32_t pri) {
|
||||
ResourceManager::iterator itr = manager->resource_manager()->find(d.ptr()->main());
|
||||
diff --git a/src/torrent/utils/extents.h b/src/torrent/utils/extents.h
|
||||
index c2b887b1..64605d4a 100644
|
||||
--- a/src/torrent/utils/extents.h
|
||||
+++ b/src/torrent/utils/extents.h
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#ifndef LIBTORRENT_UTILS_EXTENTS_H
|
||||
#define LIBTORRENT_UTILS_EXTENTS_H
|
||||
|
||||
diff --git a/src/torrent/utils/signal_bitfield.cc b/src/torrent/utils/signal_bitfield.cc
|
||||
index 82f81e7c..dfc3d1fe 100644
|
||||
--- a/src/torrent/utils/signal_bitfield.cc
|
||||
+++ b/src/torrent/utils/signal_bitfield.cc
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
#include "torrent/exceptions.h"
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
From cabc557fdf6f12fee7029081de2cf5de88464c21 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Thu, 29 Apr 2021 21:27:50 +0900
|
||||
Subject: [PATCH] Fixed issue with multiple connections from NAT not working.
|
||||
|
||||
---
|
||||
src/protocol/handshake.cc | 36 -------------------
|
||||
src/torrent/peer/peer_list.cc | 68 +++++++++++------------------------
|
||||
src/torrent/peer/peer_list.h | 36 -------------------
|
||||
3 files changed, 20 insertions(+), 120 deletions(-)
|
||||
|
||||
diff --git a/src/protocol/handshake.cc b/src/protocol/handshake.cc
|
||||
index 1b877c7a..d6f48e59 100644
|
||||
--- a/src/protocol/handshake.cc
|
||||
+++ b/src/protocol/handshake.cc
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
diff --git a/src/torrent/peer/peer_list.cc b/src/torrent/peer/peer_list.cc
|
||||
index 080a7f13..6ce630f7 100644
|
||||
--- a/src/torrent/peer/peer_list.cc
|
||||
+++ b/src/torrent/peer/peer_list.cc
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -262,8 +226,11 @@ PeerList::available_list_size() const {
|
||||
return m_available_list->size();
|
||||
}
|
||||
|
||||
+// TODO: Rename connecting:
|
||||
PeerInfo*
|
||||
PeerList::connected(const sockaddr* sa, int flags) {
|
||||
+ // TODO: Rewrite to use new socket address api after fixing bug.
|
||||
+
|
||||
const rak::socket_address* address = rak::socket_address::cast_from(sa);
|
||||
socket_address_key sock_key = socket_address_key::from_sockaddr(sa);
|
||||
|
||||
@@ -281,13 +248,7 @@ PeerList::connected(const sockaddr* sa, int flags) {
|
||||
// We should also remove any PeerInfo objects already for this
|
||||
// address.
|
||||
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);
|
||||
-
|
||||
+ LT_LOG_EVENTS("connecting peer rejected, flagged as unwanted: " LT_LOG_SA_FMT, address->address_str().c_str(), address->port());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -313,12 +274,23 @@ PeerList::connected(const sockaddr* sa, int flags) {
|
||||
//
|
||||
// This also ensure we can connect to peers running on the same
|
||||
// host as the tracker.
|
||||
- if (flags & connect_keep_handshakes &&
|
||||
- range.first->second->is_handshake() &&
|
||||
- rak::socket_address::cast_from(range.first->second->socket_address())->port() != address->port())
|
||||
- m_available_list->buffer()->push_back(*address);
|
||||
+ // if (flags & connect_keep_handshakes &&
|
||||
+ // range.first->second->is_handshake() &&
|
||||
+ // rak::socket_address::cast_from(range.first->second->socket_address())->port() != address->port())
|
||||
+ // m_available_list->buffer()->push_back(*address);
|
||||
|
||||
- return NULL;
|
||||
+ LT_LOG_EVENTS("connecting peer rejected, already connected (buggy, fixme): " LT_LOG_SA_FMT, address->address_str().c_str(), address->port());
|
||||
+
|
||||
+ // TODO: Verify this works properly, possibly add a check/flag
|
||||
+ // that allows the handshake manager to notify peer list if the
|
||||
+ // incoming connection was a duplicate peer hash.
|
||||
+
|
||||
+ //return NULL;
|
||||
+
|
||||
+ peerInfo = new PeerInfo(sa);
|
||||
+ peerInfo->set_flags(filter_value & PeerInfo::mask_ip_table);
|
||||
+
|
||||
+ base_type::insert(range.second, value_type(sock_key, peerInfo));
|
||||
}
|
||||
|
||||
if (flags & connect_filter_recent &&
|
||||
diff --git a/src/torrent/peer/peer_list.h b/src/torrent/peer/peer_list.h
|
||||
index 4c2f707d..a9d31a54 100644
|
||||
--- a/src/torrent/peer/peer_list.h
|
||||
+++ b/src/torrent/peer/peer_list.h
|
||||
@@ -1,39 +1,3 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
#ifndef LIBTORRENT_PEER_LIST_H
|
||||
#define LIBTORRENT_PEER_LIST_H
|
||||
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
From 532d3e54b3f012dc81530ebb80ded8b26434fdd9 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Wed, 16 Jun 2021 23:28:28 +0900
|
||||
Subject: [PATCH] Added '--disable-execinfo' option to configure.
|
||||
|
||||
---
|
||||
configure.ac | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 73caf712..a4f051e4 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -64,8 +64,17 @@ AC_ARG_ENABLE(attribute-visibility,
|
||||
CC_ATTRIBUTE_VISIBILITY
|
||||
])
|
||||
|
||||
+AC_ARG_ENABLE(execinfo,
|
||||
+ AC_HELP_STRING([--disable-execinfo], [disable libexecinfo [[default=enable]]]),
|
||||
+ [
|
||||
+ if test "$enableval" = "yes"; then
|
||||
+ AX_EXECINFO
|
||||
+ fi
|
||||
+ ],[
|
||||
+ AX_EXECINFO
|
||||
+ ])
|
||||
+
|
||||
AX_CHECK_ZLIB
|
||||
-AX_EXECINFO
|
||||
AX_PTHREAD
|
||||
|
||||
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
||||
|
|
@ -1,457 +0,0 @@
|
|||
From 92781533fc4afab67447e8e6d47a649383179c44 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Sun, 20 Jun 2021 18:10:52 +0900
|
||||
Subject: [PATCH] Detect ip address.
|
||||
|
||||
---
|
||||
src/net/local_addr.cc | 6 +-
|
||||
src/torrent/Makefile.am | 5 +-
|
||||
src/torrent/net/fd.cc | 3 +
|
||||
src/torrent/net/fd.h | 14 ++--
|
||||
src/torrent/net/socket_address.cc | 2 +-
|
||||
src/torrent/net/socket_address.h | 2 +-
|
||||
src/torrent/net/utils.cc | 104 ++++++++++++++++++++++++
|
||||
src/torrent/net/utils.h | 9 ++
|
||||
src/tracker/tracker_http.cc | 104 ++++++++----------------
|
||||
test/helpers/network.h | 2 +
|
||||
test/torrent/net/test_fd.cc | 9 ++
|
||||
test/torrent/net/test_socket_address.cc | 2 +-
|
||||
12 files changed, 181 insertions(+), 81 deletions(-)
|
||||
create mode 100755 src/torrent/net/utils.cc
|
||||
create mode 100755 src/torrent/net/utils.h
|
||||
|
||||
diff --git a/src/net/local_addr.cc b/src/net/local_addr.cc
|
||||
index 24413265..0c7116cb 100644
|
||||
--- a/src/net/local_addr.cc
|
||||
+++ b/src/net/local_addr.cc
|
||||
@@ -34,6 +34,8 @@
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
+// TODO: Remove.
|
||||
+
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -241,7 +243,7 @@ bool get_local_address(sa_family_t family, rak::socket_address *address) {
|
||||
int plen = IFA_PAYLOAD(nlmsg);
|
||||
for (const rtattr *rta = IFA_RTA(ifa);
|
||||
RTA_OK(rta, plen);
|
||||
- rta = RTA_NEXT(rta, plen)) {
|
||||
+ rta = RTA_NEXT(rta, plen)) {
|
||||
if (rta->rta_type != IFA_LOCAL &&
|
||||
rta->rta_type != IFA_ADDRESS) {
|
||||
continue;
|
||||
@@ -303,7 +305,7 @@ get_local_address(sa_family_t family, rak::socket_address *address) {
|
||||
dummy_dest.set_address_c_str("4.0.0.0");
|
||||
break;
|
||||
case rak::socket_address::af_inet6:
|
||||
- dummy_dest.set_address_c_str("2001:700::");
|
||||
+ dummy_dest.set_address_c_str("2001:1::");
|
||||
break;
|
||||
default:
|
||||
throw internal_error("Unknown address family");
|
||||
diff --git a/src/torrent/Makefile.am b/src/torrent/Makefile.am
|
||||
index 30157b95..5de7e8ae 100644
|
||||
--- a/src/torrent/Makefile.am
|
||||
+++ b/src/torrent/Makefile.am
|
||||
@@ -46,6 +46,8 @@ libtorrent_torrent_la_SOURCES = \
|
||||
net/socket_event.cc \
|
||||
net/socket_event.h \
|
||||
net/types.h \
|
||||
+ net/utils.cc \
|
||||
+ net/utils.h \
|
||||
\
|
||||
peer/choke_status.h \
|
||||
peer/client_info.cc \
|
||||
@@ -167,7 +169,8 @@ libtorrent_torrent_net_include_HEADERS = \
|
||||
net/socket_address.h \
|
||||
net/socket_address_key.h \
|
||||
net/socket_event.h \
|
||||
- net/types.h
|
||||
+ net/types.h \
|
||||
+ net/utils.h
|
||||
|
||||
libtorrent_torrent_peer_includedir = $(includedir)/torrent/peer
|
||||
libtorrent_torrent_peer_include_HEADERS = \
|
||||
diff --git a/src/torrent/net/fd.cc b/src/torrent/net/fd.cc
|
||||
index 07c91779..6d228181 100644
|
||||
--- a/src/torrent/net/fd.cc
|
||||
+++ b/src/torrent/net/fd.cc
|
||||
@@ -64,6 +64,9 @@ fd_open(fd_flags flags) {
|
||||
if ((flags & fd_flag_stream)) {
|
||||
domain = SOCK_STREAM;
|
||||
protocol = IPPROTO_TCP;
|
||||
+ } else if ((flags & fd_flag_datagram)) {
|
||||
+ domain = SOCK_DGRAM;
|
||||
+ protocol = IPPROTO_UDP;
|
||||
} else {
|
||||
LT_LOG_FLAG("fd_open missing socket type");
|
||||
errno = EINVAL;
|
||||
diff --git a/src/torrent/net/fd.h b/src/torrent/net/fd.h
|
||||
index a7094646..6ab3302d 100644
|
||||
--- a/src/torrent/net/fd.h
|
||||
+++ b/src/torrent/net/fd.h
|
||||
@@ -9,11 +9,12 @@ namespace torrent {
|
||||
|
||||
enum fd_flags : int {
|
||||
fd_flag_stream = 0x1,
|
||||
- fd_flag_nonblock = 0x10,
|
||||
- fd_flag_reuse_address = 0x20,
|
||||
- fd_flag_v4only = 0x40,
|
||||
- fd_flag_v6only = 0x80,
|
||||
- fd_flag_all = 0xff,
|
||||
+ fd_flag_datagram = 0x10,
|
||||
+ fd_flag_nonblock = 0x20,
|
||||
+ fd_flag_reuse_address = 0x40,
|
||||
+ fd_flag_v4only = 0x80,
|
||||
+ fd_flag_v6only = 0x100,
|
||||
+ fd_flag_all = 0x1ff,
|
||||
};
|
||||
|
||||
constexpr bool fd_valid_flags(fd_flags flags);
|
||||
@@ -53,7 +54,8 @@ operator |=(fd_flags& lhs, fd_flags rhs) {
|
||||
constexpr bool
|
||||
fd_valid_flags(fd_flags flags) {
|
||||
return
|
||||
- (flags & fd_flag_stream) &&
|
||||
+ ((flags & fd_flag_stream) || (flags & fd_flag_datagram)) &&
|
||||
+ !((flags & fd_flag_stream) && (flags & fd_flag_datagram)) &&
|
||||
!((flags & fd_flag_v4only) && (flags & fd_flag_v6only)) &&
|
||||
!(flags & ~(fd_flag_all));
|
||||
}
|
||||
diff --git a/src/torrent/net/socket_address.cc b/src/torrent/net/socket_address.cc
|
||||
index c36ba0ae..078bee25 100644
|
||||
--- a/src/torrent/net/socket_address.cc
|
||||
+++ b/src/torrent/net/socket_address.cc
|
||||
@@ -135,7 +135,7 @@ sa_unique_ptr
|
||||
sa_make_unspec() {
|
||||
sa_unique_ptr sa(new sockaddr);
|
||||
|
||||
- std::memset(sa.get(), 0, sizeof(sa));
|
||||
+ std::memset(sa.get(), 0, sizeof(sockaddr));
|
||||
sa.get()->sa_family = AF_UNSPEC;
|
||||
|
||||
return sa;
|
||||
diff --git a/src/torrent/net/socket_address.h b/src/torrent/net/socket_address.h
|
||||
index f64aee68..b9586ca1 100644
|
||||
--- a/src/torrent/net/socket_address.h
|
||||
+++ b/src/torrent/net/socket_address.h
|
||||
@@ -102,8 +102,8 @@ bool fd_sap_equal(const fd_sap_tuple& lhs, const fd_sap_tuple& rhs) LIBTORRENT_E
|
||||
|
||||
inline bool sap_is_unspec(const sa_unique_ptr& sap) { return sa_is_unspec(sap.get()); }
|
||||
inline bool sap_is_unspec(const c_sa_unique_ptr& sap) { return sa_is_unspec(sap.get()); }
|
||||
-inline bool sap_is_inet(const c_sa_unique_ptr& sap) { return sa_is_inet(sap.get()); }
|
||||
inline bool sap_is_inet(const sa_unique_ptr& sap) { return sa_is_inet(sap.get()); }
|
||||
+inline bool sap_is_inet(const c_sa_unique_ptr& sap) { return sa_is_inet(sap.get()); }
|
||||
inline bool sap_is_inet6(const sa_unique_ptr& sap) { return sa_is_inet6(sap.get()); }
|
||||
inline bool sap_is_inet6(const c_sa_unique_ptr& sap) { return sa_is_inet6(sap.get()); }
|
||||
inline bool sap_is_inet_inet6(const sa_unique_ptr& sap) { return sa_is_inet_inet6(sap.get()); }
|
||||
diff --git a/src/torrent/net/utils.cc b/src/torrent/net/utils.cc
|
||||
new file mode 100755
|
||||
index 00000000..4cb85924
|
||||
--- /dev/null
|
||||
+++ b/src/torrent/net/utils.cc
|
||||
@@ -0,0 +1,104 @@
|
||||
+#import <torrent/net/utils.h>
|
||||
+
|
||||
+#import <cerrno>
|
||||
+#import <cstring>
|
||||
+#import <torrent/net/fd.h>
|
||||
+#import <torrent/net/socket_address.h>
|
||||
+#import <torrent/utils/log.h>
|
||||
+
|
||||
+#define LT_LOG_ERROR(log_fmt) \
|
||||
+ lt_log_print(LOG_CONNECTION_FD, "fd: " log_fmt " (errno:%i message:'%s')", \
|
||||
+ errno, std::strerror(errno));
|
||||
+#define LT_LOG_FD(log_fmt) \
|
||||
+ lt_log_print(LOG_CONNECTION_FD, "fd->%i: " log_fmt, fd);
|
||||
+#define LT_LOG_FD_ERROR(log_fmt) \
|
||||
+ lt_log_print(LOG_CONNECTION_FD, "fd->%i: " log_fmt " (errno:%i message:'%s')", \
|
||||
+ fd, errno, std::strerror(errno));
|
||||
+#define LT_LOG_FD_SIN(log_fmt) \
|
||||
+ lt_log_print(LOG_CONNECTION_FD, "fd->%i: " log_fmt " (address:%s)", \
|
||||
+ fd, sin_pretty_str(sa.get()).c_str());
|
||||
+#define LT_LOG_FD_SIN6(log_fmt) \
|
||||
+ lt_log_print(LOG_CONNECTION_FD, "fd->%i: " log_fmt " (address:%s)", \
|
||||
+ fd, sin6_pretty_str(sa.get()).c_str());
|
||||
+
|
||||
+namespace torrent {
|
||||
+
|
||||
+auto detect_local_sin_addr() -> sin_unique_ptr {
|
||||
+ int fd = fd_open(fd_flag_v4only | fd_flag_datagram);
|
||||
+ if (fd == -1) {
|
||||
+ LT_LOG_ERROR("detect_local_sin_addr: open failed");
|
||||
+ return sin_unique_ptr();
|
||||
+ }
|
||||
+
|
||||
+ // TODO: Check if unique_ptr works.
|
||||
+ std::shared_ptr<void> _fd(nullptr, [fd](...){ fd_close(fd); });
|
||||
+
|
||||
+ auto connectAddress = sin_make();
|
||||
+ connectAddress.get()->sin_addr.s_addr = htonl(0x04000001);
|
||||
+ connectAddress.get()->sin_port = 80;
|
||||
+
|
||||
+ if (!fd_connect(fd, reinterpret_cast<sockaddr*>(connectAddress.get())) && errno != EINPROGRESS) {
|
||||
+ LT_LOG_FD_ERROR("detect_local_sin_addr: connect failed");
|
||||
+ return sin_unique_ptr();
|
||||
+ }
|
||||
+
|
||||
+ // TODO: Make sa function.
|
||||
+ socklen_t socklen = sizeof(sockaddr_in);
|
||||
+
|
||||
+ auto sa = sin_make();
|
||||
+
|
||||
+ if (::getsockname(fd, reinterpret_cast<sockaddr*>(sa.get()), &socklen) != 0) {
|
||||
+ LT_LOG_FD_ERROR("detect_local_sin_addr: getsockname failed");
|
||||
+ return sin_unique_ptr();
|
||||
+ }
|
||||
+ if (socklen != sizeof(sockaddr_in)) {
|
||||
+ LT_LOG_FD("detect_local_sin_addr: getsockname failed, invalid socklen");
|
||||
+ return sin_unique_ptr();
|
||||
+ }
|
||||
+
|
||||
+ LT_LOG_FD_SIN("detect_local_sin_addr: success");
|
||||
+
|
||||
+ return sa;
|
||||
+}
|
||||
+
|
||||
+auto detect_local_sin6_addr() -> sin6_unique_ptr {
|
||||
+ int fd = fd_open(fd_flag_v6only | fd_flag_datagram);
|
||||
+ if (fd == -1) {
|
||||
+ LT_LOG_ERROR("detect_local_sin6_addr: open failed");
|
||||
+ return sin6_unique_ptr();
|
||||
+ }
|
||||
+
|
||||
+ // TODO: Check if unique_ptr works.
|
||||
+ std::shared_ptr<void> _fd(nullptr, [fd](...){ fd_close(fd); });
|
||||
+
|
||||
+ auto connectAddress = sin6_make();
|
||||
+ connectAddress.get()->sin6_addr.s6_addr[0] = 0x20;
|
||||
+ connectAddress.get()->sin6_addr.s6_addr[1] = 0x01;
|
||||
+ connectAddress.get()->sin6_addr.s6_addr[15] = 0x01;
|
||||
+ connectAddress.get()->sin6_port = 80;
|
||||
+
|
||||
+ if (!fd_connect(fd, reinterpret_cast<sockaddr*>(connectAddress.get())) && errno != EINPROGRESS) {
|
||||
+ LT_LOG_FD_ERROR("detect_local_sin6_addr: connect failed");
|
||||
+ return sin6_unique_ptr();
|
||||
+ }
|
||||
+
|
||||
+ // TODO: Make sa function.
|
||||
+ socklen_t socklen = sizeof(sockaddr_in6);
|
||||
+
|
||||
+ auto sa = sin6_make();
|
||||
+
|
||||
+ if (::getsockname(fd, reinterpret_cast<sockaddr*>(sa.get()), &socklen) != 0) {
|
||||
+ LT_LOG_FD_ERROR("detect_local_sin6_addr: getsockname failed");
|
||||
+ return sin6_unique_ptr();
|
||||
+ }
|
||||
+ if (socklen != sizeof(sockaddr_in6)) {
|
||||
+ LT_LOG_FD("detect_local_sin6_addr: getsockname failed, invalid socklen");
|
||||
+ return sin6_unique_ptr();
|
||||
+ }
|
||||
+
|
||||
+ LT_LOG_FD_SIN6("detect_local_sin6_addr: success");
|
||||
+
|
||||
+ return sa;
|
||||
+}
|
||||
+
|
||||
+}
|
||||
diff --git a/src/torrent/net/utils.h b/src/torrent/net/utils.h
|
||||
new file mode 100755
|
||||
index 00000000..1d550c51
|
||||
--- /dev/null
|
||||
+++ b/src/torrent/net/utils.h
|
||||
@@ -0,0 +1,9 @@
|
||||
+#import <torrent/common.h>
|
||||
+#import <torrent/net/socket_address.h>
|
||||
+
|
||||
+namespace torrent {
|
||||
+
|
||||
+auto detect_local_sin_addr() -> sin_unique_ptr;
|
||||
+auto detect_local_sin6_addr() -> sin6_unique_ptr;
|
||||
+
|
||||
+}
|
||||
diff --git a/src/tracker/tracker_http.cc b/src/tracker/tracker_http.cc
|
||||
index 1bf94107..de3a39ab 100644
|
||||
--- a/src/tracker/tracker_http.cc
|
||||
+++ b/src/tracker/tracker_http.cc
|
||||
@@ -1,63 +1,29 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2011, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
-#include "config.h"
|
||||
+#import "config.h"
|
||||
|
||||
#define __STDC_FORMAT_MACROS
|
||||
|
||||
-#include <iomanip>
|
||||
-#include <sstream>
|
||||
-#include <rak/functional.h>
|
||||
-#include <rak/string_manip.h>
|
||||
-
|
||||
-#include "net/address_list.h"
|
||||
-#include "net/local_addr.h"
|
||||
-#include "torrent/connection_manager.h"
|
||||
-#include "torrent/download_info.h"
|
||||
-#include "torrent/exceptions.h"
|
||||
-#include "torrent/http.h"
|
||||
-#include "torrent/object_stream.h"
|
||||
-#include "torrent/tracker_list.h"
|
||||
-#include "torrent/utils/log.h"
|
||||
-#include "torrent/utils/option_strings.h"
|
||||
-
|
||||
-#include "tracker_http.h"
|
||||
-
|
||||
-#include "globals.h"
|
||||
-#include "manager.h"
|
||||
+#import <iomanip>
|
||||
+#import <sstream>
|
||||
+#import <rak/functional.h>
|
||||
+#import <rak/string_manip.h>
|
||||
+
|
||||
+#import "net/address_list.h"
|
||||
+#import "net/local_addr.h"
|
||||
+#import "torrent/connection_manager.h"
|
||||
+#import "torrent/download_info.h"
|
||||
+#import "torrent/exceptions.h"
|
||||
+#import "torrent/http.h"
|
||||
+#import "torrent/net/utils.h"
|
||||
+#import "torrent/net/socket_address.h"
|
||||
+#import "torrent/object_stream.h"
|
||||
+#import "torrent/tracker_list.h"
|
||||
+#import "torrent/utils/log.h"
|
||||
+#import "torrent/utils/option_strings.h"
|
||||
+
|
||||
+#import "tracker_http.h"
|
||||
+
|
||||
+#import "globals.h"
|
||||
+#import "manager.h"
|
||||
|
||||
#define LT_LOG_TRACKER(log_level, log_fmt, ...) \
|
||||
lt_log_print_info(LOG_TRACKER_##log_level, m_parent->info(), "tracker", "[%u] " log_fmt, group(), __VA_ARGS__);
|
||||
@@ -142,19 +108,19 @@ TrackerHttp::send_state(int state) {
|
||||
|
||||
const rak::socket_address* localAddress = rak::socket_address::cast_from(manager->connection_manager()->local_address());
|
||||
|
||||
- if (!localAddress->is_address_any())
|
||||
- s << "&ip=" << localAddress->address_str();
|
||||
-
|
||||
- if (localAddress->is_address_any() && localAddress->family() == rak::socket_address::pf_inet) {
|
||||
- rak::socket_address local_v6;
|
||||
- if (get_local_address(rak::socket_address::af_inet6, &local_v6))
|
||||
- s << "&ipv6=" << rak::copy_escape_html(local_v6.address_str());
|
||||
- }
|
||||
+ if (localAddress->is_address_any()) {
|
||||
+ auto ipv4_address = detect_local_sin_addr();
|
||||
+ auto ipv6_address = detect_local_sin6_addr();
|
||||
|
||||
- if (localAddress->is_address_any() && localAddress->family() == rak::socket_address::pf_inet6) {
|
||||
- rak::socket_address local_v4;
|
||||
- if (get_local_address(rak::socket_address::af_inet, &local_v4))
|
||||
- s << "&ipv4=" << local_v4.address_str();
|
||||
+ if (ipv4_address != nullptr) {
|
||||
+ s << "&ipv4=" << sin_addr_str(ipv4_address.get());
|
||||
+ }
|
||||
+ if (ipv6_address != nullptr) {
|
||||
+ s << "&ipv6=" << sin6_addr_str(ipv6_address.get());
|
||||
+ }
|
||||
+
|
||||
+ } else {
|
||||
+ s << "&ip=" << localAddress->address_str();
|
||||
}
|
||||
|
||||
if (info->is_compact())
|
||||
diff --git a/test/helpers/network.h b/test/helpers/network.h
|
||||
index 6cf2f870..eb188426 100644
|
||||
--- a/test/helpers/network.h
|
||||
+++ b/test/helpers/network.h
|
||||
@@ -112,6 +112,7 @@ wrap_ai_get_first_sa(const char* nodename, const char* servname = nullptr, const
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(("wrap_ai_get_first_sa: nodename:'" + std::string(nodename) + "'").c_str(),
|
||||
sa != nullptr);
|
||||
+
|
||||
return sa;
|
||||
}
|
||||
|
||||
@@ -121,6 +122,7 @@ wrap_ai_get_first_c_sa(const char* nodename, const char* servname = nullptr, con
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(("wrap_ai_get_first_sa: nodename:'" + std::string(nodename) + "'").c_str(),
|
||||
sa != nullptr);
|
||||
+
|
||||
return torrent::c_sa_unique_ptr(sa.release());
|
||||
}
|
||||
|
||||
diff --git a/test/torrent/net/test_fd.cc b/test/torrent/net/test_fd.cc
|
||||
index 5e56f0f3..0a00ccd4 100644
|
||||
--- a/test/torrent/net/test_fd.cc
|
||||
+++ b/test/torrent/net/test_fd.cc
|
||||
@@ -9,13 +9,22 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_fd, "torrent/net");
|
||||
void
|
||||
test_fd::test_valid_flags() {
|
||||
CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream));
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_datagram));
|
||||
+ CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_datagram));
|
||||
+
|
||||
CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_nonblock));
|
||||
CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_reuse_address));
|
||||
CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v4only));
|
||||
CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v6only));
|
||||
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_datagram | torrent::fd_flag_nonblock));
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_datagram | torrent::fd_flag_reuse_address));
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_datagram | torrent::fd_flag_v4only));
|
||||
+ CPPUNIT_ASSERT(torrent::fd_valid_flags(torrent::fd_flag_datagram | torrent::fd_flag_v6only));
|
||||
+
|
||||
CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flag_v4only | torrent::fd_flag_v6only));
|
||||
CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flag_stream | torrent::fd_flag_v4only | torrent::fd_flag_v6only));
|
||||
+ CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flag_datagram | torrent::fd_flag_v4only | torrent::fd_flag_v6only));
|
||||
|
||||
CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags()));
|
||||
CPPUNIT_ASSERT(!torrent::fd_valid_flags(torrent::fd_flags(~torrent::fd_flag_all)));
|
||||
diff --git a/test/torrent/net/test_socket_address.cc b/test/torrent/net/test_socket_address.cc
|
||||
index 8a1b0c8a..a27b38bc 100644
|
||||
--- a/test/torrent/net/test_socket_address.cc
|
||||
+++ b/test/torrent/net/test_socket_address.cc
|
||||
@@ -83,7 +83,7 @@ test_socket_address::test_make() {
|
||||
CPPUNIT_ASSERT(sin6_inet6->sin6_family == AF_INET6);
|
||||
CPPUNIT_ASSERT(sin6_inet6->sin6_port == 0);
|
||||
CPPUNIT_ASSERT(sin6_inet6->sin6_flowinfo == 0);
|
||||
- CPPUNIT_ASSERT(compare_sin6_addr(sin6_inet6->sin6_addr, in6_addr{0}));
|
||||
+ CPPUNIT_ASSERT(compare_sin6_addr(sin6_inet6->sin6_addr, (in6_addr{0})));
|
||||
CPPUNIT_ASSERT(sin6_inet6->sin6_scope_id == 0);
|
||||
|
||||
torrent::sa_unique_ptr sa_unix = torrent::sa_make_unix("");
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
From e646ed5427b690b75208510d328457af66b208e8 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Mon, 21 Jun 2021 21:12:56 +0900
|
||||
Subject: [PATCH] Added ipv6 options.
|
||||
|
||||
---
|
||||
src/torrent/connection_manager.cc | 6 +++++-
|
||||
src/torrent/connection_manager.h | 13 +++++++++++++
|
||||
src/tracker/tracker_http.cc | 13 +++++--------
|
||||
3 files changed, 23 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/torrent/connection_manager.cc b/src/torrent/connection_manager.cc
|
||||
index 972dcbfc..ea5efc58 100644
|
||||
--- a/src/torrent/connection_manager.cc
|
||||
+++ b/src/torrent/connection_manager.cc
|
||||
@@ -89,7 +89,11 @@ ConnectionManager::ConnectionManager() :
|
||||
|
||||
m_listen(new Listen),
|
||||
m_listen_port(0),
|
||||
- m_listen_backlog(SOMAXCONN) {
|
||||
+ m_listen_backlog(SOMAXCONN),
|
||||
+
|
||||
+ m_block_ipv4(false),
|
||||
+ m_block_ipv6(false),
|
||||
+ m_prefer_ipv6(false) {
|
||||
|
||||
m_bindAddress = (new rak::socket_address())->c_sockaddr();
|
||||
m_localAddress = (new rak::socket_address())->c_sockaddr();
|
||||
diff --git a/src/torrent/connection_manager.h b/src/torrent/connection_manager.h
|
||||
index cf43b0bf..09ccdd28 100644
|
||||
--- a/src/torrent/connection_manager.h
|
||||
+++ b/src/torrent/connection_manager.h
|
||||
@@ -167,6 +167,15 @@ public:
|
||||
// For internal usage.
|
||||
Listen* listen() { return m_listen; }
|
||||
|
||||
+ bool is_block_ipv4() const { return m_block_ipv4; }
|
||||
+ void set_block_ipv4(bool v) { m_block_ipv4 = v; }
|
||||
+
|
||||
+ bool is_block_ipv6() const { return m_block_ipv6; }
|
||||
+ void set_block_ipv6(bool v) { m_block_ipv6 = v; }
|
||||
+
|
||||
+ bool is_prefer_ipv6() const { return m_prefer_ipv6; }
|
||||
+ void set_prefer_ipv6(bool v) { m_prefer_ipv6 = v; }
|
||||
+
|
||||
private:
|
||||
ConnectionManager(const ConnectionManager&);
|
||||
void operator = (const ConnectionManager&);
|
||||
@@ -190,6 +199,10 @@ private:
|
||||
slot_filter_type m_slot_filter;
|
||||
slot_resolver_type m_slot_resolver;
|
||||
slot_throttle_type m_slot_address_throttle;
|
||||
+
|
||||
+ bool m_block_ipv4;
|
||||
+ bool m_block_ipv6;
|
||||
+ bool m_prefer_ipv6;
|
||||
};
|
||||
|
||||
}
|
||||
diff --git a/src/tracker/tracker_http.cc b/src/tracker/tracker_http.cc
|
||||
index de3a39ab..fdbbd58a 100644
|
||||
--- a/src/tracker/tracker_http.cc
|
||||
+++ b/src/tracker/tracker_http.cc
|
||||
@@ -109,16 +109,13 @@ TrackerHttp::send_state(int state) {
|
||||
const rak::socket_address* localAddress = rak::socket_address::cast_from(manager->connection_manager()->local_address());
|
||||
|
||||
if (localAddress->is_address_any()) {
|
||||
- auto ipv4_address = detect_local_sin_addr();
|
||||
- auto ipv6_address = detect_local_sin6_addr();
|
||||
+ if (manager->connection_manager()->is_prefer_ipv6()) {
|
||||
+ auto ipv6_address = detect_local_sin6_addr();
|
||||
|
||||
- if (ipv4_address != nullptr) {
|
||||
- s << "&ipv4=" << sin_addr_str(ipv4_address.get());
|
||||
+ if (ipv6_address != nullptr) {
|
||||
+ s << "&ip=" << sin6_addr_str(ipv6_address.get());
|
||||
+ }
|
||||
}
|
||||
- if (ipv6_address != nullptr) {
|
||||
- s << "&ipv6=" << sin6_addr_str(ipv6_address.get());
|
||||
- }
|
||||
-
|
||||
} else {
|
||||
s << "&ip=" << localAddress->address_str();
|
||||
}
|
||||
|
|
@ -1,444 +0,0 @@
|
|||
From 54caef85baca975e0be30b4f3f6de01db19c8e19 Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Mon, 21 Jun 2021 21:28:02 +0900
|
||||
Subject: [PATCH] Removed obsolete files.
|
||||
|
||||
---
|
||||
src/Makefile.am | 2 -
|
||||
src/net/local_addr.cc | 329 ------------------------------------
|
||||
src/net/local_addr.h | 64 -------
|
||||
src/tracker/tracker_http.cc | 1 -
|
||||
4 files changed, 396 deletions(-)
|
||||
delete mode 100644 src/net/local_addr.cc
|
||||
delete mode 100644 src/net/local_addr.h
|
||||
|
||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||
index 95e6a7ae..925e7e15 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -76,8 +76,6 @@ libtorrent_other_la_SOURCES = \
|
||||
net/address_list.cc \
|
||||
net/address_list.h \
|
||||
net/data_buffer.h \
|
||||
- net/local_addr.cc \
|
||||
- net/local_addr.h \
|
||||
net/listen.cc \
|
||||
net/listen.h \
|
||||
net/protocol_buffer.h \
|
||||
diff --git a/src/net/local_addr.cc b/src/net/local_addr.cc
|
||||
deleted file mode 100644
|
||||
index 0c7116cb..00000000
|
||||
--- a/src/net/local_addr.cc
|
||||
+++ /dev/null
|
||||
@@ -1,329 +0,0 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2007, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
-// TODO: Remove.
|
||||
-
|
||||
-#include "config.h"
|
||||
-
|
||||
-#include <stdio.h>
|
||||
-#include <rak/socket_address.h>
|
||||
-#include <sys/types.h>
|
||||
-#include <errno.h>
|
||||
-
|
||||
-#ifdef __linux__
|
||||
-#include <linux/netlink.h>
|
||||
-#include <linux/rtnetlink.h>
|
||||
-#endif
|
||||
-
|
||||
-#include "torrent/exceptions.h"
|
||||
-#include "socket_fd.h"
|
||||
-#include "local_addr.h"
|
||||
-
|
||||
-namespace torrent {
|
||||
-
|
||||
-#ifdef __linux__
|
||||
-
|
||||
-namespace {
|
||||
-
|
||||
-// IPv4 priority, from highest to lowest:
|
||||
-//
|
||||
-// 1. Everything else (global address)
|
||||
-// 2. Private address space (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
|
||||
-// 3. Empty/INADDR_ANY (0.0.0.0)
|
||||
-// 4. Link-local address (169.254.0.0/16)
|
||||
-// 5. Localhost (127.0.0.0/8)
|
||||
-int
|
||||
-get_priority_ipv4(const in_addr& addr) {
|
||||
- if ((addr.s_addr & htonl(0xff000000U)) == htonl(0x7f000000U)) {
|
||||
- return 5;
|
||||
- }
|
||||
- if ((addr.s_addr & htonl(0xffff0000U)) == htonl(0xa9fe0000U)) {
|
||||
- return 4;
|
||||
- }
|
||||
- if (addr.s_addr == htonl(0)) {
|
||||
- return 3;
|
||||
- }
|
||||
- if ((addr.s_addr & htonl(0xff000000U)) == htonl(0x0a000000U) ||
|
||||
- (addr.s_addr & htonl(0xfff00000U)) == htonl(0xac100000U) ||
|
||||
- (addr.s_addr & htonl(0xffff0000U)) == htonl(0xc0a80000U)) {
|
||||
- return 2;
|
||||
- }
|
||||
- return 1;
|
||||
-}
|
||||
-
|
||||
-// IPv6 priority, from highest to lowest:
|
||||
-//
|
||||
-// 1. Global address (2000::/16 not in 6to4 or Teredo)
|
||||
-// 2. 6to4 (2002::/16)
|
||||
-// 3. Teredo (2001::/32)
|
||||
-// 4. Empty/INADDR_ANY (::)
|
||||
-// 5. Everything else (link-local, ULA, etc.)
|
||||
-int
|
||||
-get_priority_ipv6(const in6_addr& addr) {
|
||||
- const uint32_t *addr32 = reinterpret_cast<const uint32_t *>(addr.s6_addr);
|
||||
- if (addr32[0] == htonl(0) &&
|
||||
- addr32[1] == htonl(0) &&
|
||||
- addr32[2] == htonl(0) &&
|
||||
- addr32[3] == htonl(0)) {
|
||||
- return 4;
|
||||
- }
|
||||
- if (addr32[0] == htonl(0x20010000)) {
|
||||
- return 3;
|
||||
- }
|
||||
- if ((addr32[0] & htonl(0xffff0000)) == htonl(0x20020000)) {
|
||||
- return 2;
|
||||
- }
|
||||
- if ((addr32[0] & htonl(0xe0000000)) == htonl(0x20000000)) {
|
||||
- return 1;
|
||||
- }
|
||||
- return 5;
|
||||
-}
|
||||
-
|
||||
-int
|
||||
-get_priority(const rak::socket_address& addr) {
|
||||
- switch (addr.family()) {
|
||||
- case AF_INET:
|
||||
- return get_priority_ipv4(addr.c_sockaddr_inet()->sin_addr);
|
||||
- case AF_INET6:
|
||||
- return get_priority_ipv6(addr.c_sockaddr_inet6()->sin6_addr);
|
||||
- default:
|
||||
- throw torrent::internal_error("Unknown address family given to compare");
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-}
|
||||
-
|
||||
-// Linux-specific implementation that understands how to filter away
|
||||
-// understands how to filter away secondary addresses.
|
||||
-bool get_local_address(sa_family_t family, rak::socket_address *address) {
|
||||
- rak::socket_address best_addr;
|
||||
- switch (family) {
|
||||
- case AF_INET:
|
||||
- best_addr.sa_inet()->clear();
|
||||
- break;
|
||||
- case AF_INET6:
|
||||
- best_addr.sa_inet6()->clear();
|
||||
- break;
|
||||
- default:
|
||||
- throw torrent::internal_error("Unknown address family given to get_local_address");
|
||||
- }
|
||||
-
|
||||
- // The bottom bit of the priority is used to hold if the address is
|
||||
- // a secondary address (e.g. with IPv6 privacy extensions) or not;
|
||||
- // secondary addresses have lower priority (higher number).
|
||||
- int best_addr_pri = get_priority(best_addr) * 2;
|
||||
-
|
||||
- // Get all the addresses via Linux' netlink interface.
|
||||
- int fd = ::socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||
- if (fd == -1) {
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- struct sockaddr_nl nladdr;
|
||||
- memset(&nladdr, 0, sizeof(nladdr));
|
||||
- nladdr.nl_family = AF_NETLINK;
|
||||
- if (::bind(fd, (sockaddr *)&nladdr, sizeof(nladdr))) {
|
||||
- ::close(fd);
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- const int seq_no = 1;
|
||||
- struct {
|
||||
- nlmsghdr nh;
|
||||
- rtgenmsg g;
|
||||
- } req;
|
||||
- memset(&req, 0, sizeof(req));
|
||||
-
|
||||
- req.nh.nlmsg_len = sizeof(req);
|
||||
- req.nh.nlmsg_type = RTM_GETADDR;
|
||||
- req.nh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
|
||||
- req.nh.nlmsg_pid = getpid();
|
||||
- req.nh.nlmsg_seq = seq_no;
|
||||
- req.g.rtgen_family = AF_UNSPEC;
|
||||
-
|
||||
- int ret;
|
||||
- do {
|
||||
- ret = ::sendto(fd, &req, sizeof(req), 0, (sockaddr *)&nladdr, sizeof(nladdr));
|
||||
- } while (ret == -1 && errno == EINTR);
|
||||
-
|
||||
- if (ret == -1) {
|
||||
- ::close(fd);
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- bool done = false;
|
||||
- do {
|
||||
- char buf[4096];
|
||||
- socklen_t len = sizeof(nladdr);
|
||||
- do {
|
||||
- ret = ::recvfrom(fd, buf, sizeof(buf), 0, (sockaddr *)&nladdr, &len);
|
||||
- } while (ret == -1 && errno == EINTR);
|
||||
-
|
||||
- if (ret < 0) {
|
||||
- ::close(fd);
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- for (const nlmsghdr *nlmsg = (const nlmsghdr *)buf;
|
||||
- NLMSG_OK(nlmsg, ret);
|
||||
- nlmsg = NLMSG_NEXT(nlmsg, ret)) {
|
||||
- if (nlmsg->nlmsg_seq != seq_no)
|
||||
- continue;
|
||||
- if (nlmsg->nlmsg_type == NLMSG_DONE) {
|
||||
- done = true;
|
||||
- break;
|
||||
- }
|
||||
- if (nlmsg->nlmsg_type == NLMSG_ERROR) {
|
||||
- ::close(fd);
|
||||
- return false;
|
||||
- }
|
||||
- if (nlmsg->nlmsg_type != RTM_NEWADDR)
|
||||
- continue;
|
||||
-
|
||||
- const ifaddrmsg *ifa = (const ifaddrmsg *)NLMSG_DATA(nlmsg);
|
||||
-
|
||||
- if (ifa->ifa_family != family)
|
||||
- continue;
|
||||
-
|
||||
-#ifdef IFA_F_OPTIMISTIC
|
||||
- if ((ifa->ifa_flags & IFA_F_OPTIMISTIC) != 0)
|
||||
- continue;
|
||||
-#endif
|
||||
-#ifdef IFA_F_DADFAILED
|
||||
- if ((ifa->ifa_flags & IFA_F_DADFAILED) != 0)
|
||||
- continue;
|
||||
-#endif
|
||||
-#ifdef IFA_F_DEPRECATED
|
||||
- if ((ifa->ifa_flags & IFA_F_DEPRECATED) != 0)
|
||||
- continue;
|
||||
-#endif
|
||||
-#ifdef IFA_F_TENTATIVE
|
||||
- if ((ifa->ifa_flags & IFA_F_TENTATIVE) != 0)
|
||||
- continue;
|
||||
-#endif
|
||||
-
|
||||
- // Since there can be point-to-point links on the machine, we need to keep
|
||||
- // track of the addresses we've seen for this interface; if we see both
|
||||
- // IFA_LOCAL and IFA_ADDRESS for an interface, keep only the IFA_LOCAL.
|
||||
- rak::socket_address this_addr;
|
||||
- bool seen_addr = false;
|
||||
- int plen = IFA_PAYLOAD(nlmsg);
|
||||
- for (const rtattr *rta = IFA_RTA(ifa);
|
||||
- RTA_OK(rta, plen);
|
||||
- rta = RTA_NEXT(rta, plen)) {
|
||||
- if (rta->rta_type != IFA_LOCAL &&
|
||||
- rta->rta_type != IFA_ADDRESS) {
|
||||
- continue;
|
||||
- }
|
||||
- if (rta->rta_type == IFA_ADDRESS && seen_addr) {
|
||||
- continue;
|
||||
- }
|
||||
- seen_addr = true;
|
||||
- switch (ifa->ifa_family) {
|
||||
- case AF_INET:
|
||||
- this_addr.sa_inet()->clear();
|
||||
- this_addr.sa_inet()->set_address(*(const in_addr *)RTA_DATA(rta));
|
||||
- break;
|
||||
- case AF_INET6:
|
||||
- this_addr.sa_inet6()->clear();
|
||||
- this_addr.sa_inet6()->set_address(*(const in6_addr *)RTA_DATA(rta));
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
- if (!seen_addr)
|
||||
- continue;
|
||||
-
|
||||
- int this_addr_pri = get_priority(this_addr) * 2;
|
||||
- if ((ifa->ifa_flags & IFA_F_SECONDARY) == IFA_F_SECONDARY) {
|
||||
- ++this_addr_pri;
|
||||
- }
|
||||
-
|
||||
- if (this_addr_pri < best_addr_pri) {
|
||||
- best_addr = this_addr;
|
||||
- best_addr_pri = this_addr_pri;
|
||||
- }
|
||||
- }
|
||||
- } while (!done);
|
||||
-
|
||||
- ::close(fd);
|
||||
- if (!best_addr.is_address_any()) {
|
||||
- *address = best_addr;
|
||||
- return true;
|
||||
- } else {
|
||||
- return false;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-#else
|
||||
-
|
||||
-// Generic POSIX variant.
|
||||
-bool
|
||||
-get_local_address(sa_family_t family, rak::socket_address *address) {
|
||||
- SocketFd sock;
|
||||
- if (!sock.open_datagram()) {
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- rak::socket_address dummy_dest;
|
||||
- dummy_dest.clear();
|
||||
-
|
||||
- switch (family) {
|
||||
- case rak::socket_address::af_inet:
|
||||
- dummy_dest.set_address_c_str("4.0.0.0");
|
||||
- break;
|
||||
- case rak::socket_address::af_inet6:
|
||||
- dummy_dest.set_address_c_str("2001:1::");
|
||||
- break;
|
||||
- default:
|
||||
- throw internal_error("Unknown address family");
|
||||
- }
|
||||
-
|
||||
- dummy_dest.set_port(80);
|
||||
-
|
||||
- if (!sock.connect(dummy_dest)) {
|
||||
- sock.close();
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- bool ret = sock.getsockname(address);
|
||||
- sock.close();
|
||||
-
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-#endif
|
||||
-
|
||||
-}
|
||||
diff --git a/src/net/local_addr.h b/src/net/local_addr.h
|
||||
deleted file mode 100644
|
||||
index 43bc8206..00000000
|
||||
--- a/src/net/local_addr.h
|
||||
+++ /dev/null
|
||||
@@ -1,64 +0,0 @@
|
||||
-// libTorrent - BitTorrent library
|
||||
-// Copyright (C) 2005-2007, Jari Sundell
|
||||
-//
|
||||
-// This program is free software; you can redistribute it and/or modify
|
||||
-// it under the terms of the GNU General Public License as published by
|
||||
-// the Free Software Foundation; either version 2 of the License, or
|
||||
-// (at your option) any later version.
|
||||
-//
|
||||
-// This program is distributed in the hope that it will be useful,
|
||||
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-// GNU General Public License for more details.
|
||||
-//
|
||||
-// You should have received a copy of the GNU General Public License
|
||||
-// along with this program; if not, write to the Free Software
|
||||
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-//
|
||||
-// In addition, as a special exception, the copyright holders give
|
||||
-// permission to link the code of portions of this program with the
|
||||
-// OpenSSL library under certain conditions as described in each
|
||||
-// individual source file, and distribute linked combinations
|
||||
-// including the two.
|
||||
-//
|
||||
-// You must obey the GNU General Public License in all respects for
|
||||
-// all of the code used other than OpenSSL. If you modify file(s)
|
||||
-// with this exception, you may extend this exception to your version
|
||||
-// of the file(s), but you are not obligated to do so. If you do not
|
||||
-// wish to do so, delete this exception statement from your version.
|
||||
-// If you delete this exception statement from all source files in the
|
||||
-// program, then also delete it here.
|
||||
-//
|
||||
-// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
-//
|
||||
-// Skomakerveien 33
|
||||
-// 3185 Skoppum, NORWAY
|
||||
-
|
||||
-// A routine to get a local IP address that can be presented to a tracker.
|
||||
-// (Does not use UPnP etc., so will not understand NAT.)
|
||||
-// On a machine with multiple network cards, address selection can be a
|
||||
-// complex process, and in general what's selected is a source/destination
|
||||
-// address pair. However, this routine will give an approximation that will
|
||||
-// be good enough for most purposes and users.
|
||||
-
|
||||
-#ifndef LIBTORRENT_NET_LOCAL_ADDR_H
|
||||
-#define LIBTORRENT_NET_LOCAL_ADDR_H
|
||||
-
|
||||
-#include <unistd.h>
|
||||
-
|
||||
-namespace rak {
|
||||
- class socket_address;
|
||||
-}
|
||||
-
|
||||
-namespace torrent {
|
||||
-
|
||||
-// Note: family must currently be rak::af_inet or rak::af_inet6
|
||||
-// (rak::af_unspec won't do); anything else will throw an exception.
|
||||
-// Returns false if no address of the given family could be found,
|
||||
-// either because there are none, or because something went wrong in
|
||||
-// the process (e.g., no free file descriptors).
|
||||
-bool get_local_address(sa_family_t family, rak::socket_address *address);
|
||||
-
|
||||
-}
|
||||
-
|
||||
-#endif /* LIBTORRENT_NET_LOCAL_ADDR_H */
|
||||
diff --git a/src/tracker/tracker_http.cc b/src/tracker/tracker_http.cc
|
||||
index fdbbd58a..22c409a1 100644
|
||||
--- a/src/tracker/tracker_http.cc
|
||||
+++ b/src/tracker/tracker_http.cc
|
||||
@@ -8,7 +8,6 @@
|
||||
#import <rak/string_manip.h>
|
||||
|
||||
#import "net/address_list.h"
|
||||
-#import "net/local_addr.h"
|
||||
#import "torrent/connection_manager.h"
|
||||
#import "torrent/download_info.h"
|
||||
#import "torrent/exceptions.h"
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,29 +0,0 @@
|
|||
From eca577e2a29d64251b5df1c69be53c5b1ffe6bde Mon Sep 17 00:00:00 2001
|
||||
From: Jari Sundell <sundell.software@gmail.com>
|
||||
Date: Thu, 8 Sep 2022 05:08:44 +0900
|
||||
Subject: [PATCH] Create FUNDING.yml
|
||||
|
||||
---
|
||||
.github/FUNDING.yml | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
create mode 100644 .github/FUNDING.yml
|
||||
|
||||
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
|
||||
new file mode 100644
|
||||
index 00000000..ad5998e8
|
||||
--- /dev/null
|
||||
+++ b/.github/FUNDING.yml
|
||||
@@ -0,0 +1,13 @@
|
||||
+# These are supported funding model platforms
|
||||
+
|
||||
+github: [rakshasa]
|
||||
+patreon: rtorrent
|
||||
+open_collective: # Replace with a single Open Collective username
|
||||
+ko_fi: # Replace with a single Ko-fi username
|
||||
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
+liberapay: # Replace with a single Liberapay username
|
||||
+issuehunt: # Replace with a single IssueHunt username
|
||||
+otechie: # Replace with a single Otechie username
|
||||
+lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
+custom: ['https://rakshasa.github.io/rtorrent/donate.html']
|
||||
|
|
@ -6,57 +6,12 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=393a5ca445f6965873eca0259a17f833"
|
|||
|
||||
DEPENDS = "zlib libsigc++-2.0 openssl cppunit"
|
||||
|
||||
SRC_URI = "git://github.com/rakshasa/libtorrent;branch=master;protocol=https \
|
||||
file://0001-Fix-compilation-issue-with-gcc-v6.x-and-empty-CXXFLA.patch \
|
||||
file://0002-Modfiy-gcc-v6.x-fix-for-empty-CXXFLAGS-See-10.patch \
|
||||
file://0003-Add-space-to-fmt-str-in-log_gz_file_write.patch \
|
||||
file://0004-IPv4-filter-enhancement-11IPv4-filter-enhancement-Cl.patch \
|
||||
file://0005-Disable-extents-test-to-pass-TravisCI-See-11.patch \
|
||||
file://0006-Bumped-version-to-0.13.7.patch \
|
||||
file://0007-Added-support-for-openssl-1.1.patch \
|
||||
file://0008-Use-AC_COMPILE-instead-of-AC_RUN-to-check-for-execin.patch \
|
||||
file://0009-Modify-configure-to-prevent-unnecessary-kqueue-check.patch \
|
||||
file://0010-Display-info-on-failed-tracker-bencode-parsing-See-9.patch \
|
||||
file://0011-Strip-tags-also-when-displaying-info-on-failed-track.patch \
|
||||
file://0012-Switch-to-C-11-MRT-RNG-for-random-bytes.patch \
|
||||
file://0013-Prevent-loss-of-m_ipv6_socket-attribute-which-led-to.patch \
|
||||
file://0014-If-during-socket-creation-AF_INET6-failes-initialize.patch \
|
||||
file://0015-Fixes-https-github.com-rakshasa-rtorrent-issues-731.patch \
|
||||
file://0016-Fix-honoring-throttle.min_peers-settings-in-rtorrent.patch \
|
||||
file://0017-increase-piece-length-max.patch \
|
||||
file://0018-Set-max-piece-size-512mb.patch \
|
||||
file://0019-Fixed-compiler-warning.patch \
|
||||
file://0020-Added-_GNU_SOURCE-to-fallocate-test.-neheb.patch \
|
||||
file://0021-Fixed-diffie-hellman-implementation.patch \
|
||||
file://0022-Increased-max-timeout-for-tracker-requests.patch \
|
||||
file://0023-Close-log-files-when-reusing-a-name.patch \
|
||||
file://0024-Bumped-to-version-0.13.8.patch \
|
||||
file://0025-Allow-logs-to-be-appended-rather-than-overwritten.patch \
|
||||
file://0026-Removed-log-append-function.-Added-append-parameter-.patch \
|
||||
file://0027-Backport-changes-from-feature-bind.-200.patch \
|
||||
file://0028-libtorrent.pc.in-add-Libs.Private-202.patch \
|
||||
file://0029-Fix-for-inotify-missing-quickly-renamed-files-203.patch \
|
||||
file://0030-Fix-compiler-warnings.-204.patch \
|
||||
file://0031-Fix-log-format-so-GCC-can-check-it.-205.patch \
|
||||
file://0032-Consolidate-make-script-to-optimize-build.-206.patch \
|
||||
file://0033-Refactor-make-process.-207.patch \
|
||||
file://0034-Changes-automake-required-files.patch \
|
||||
file://0035-Replaced-custom-execinfo-autoconf-test.patch \
|
||||
file://0036-Added-option-to-disable-pthread_setname_np.patch \
|
||||
file://0037-Improved-backtrace-error-checking.patch \
|
||||
file://0038-Fixed-issue-with-multiple-connections-from-NAT-not-w.patch \
|
||||
file://0039-Added-disable-execinfo-option-to-configure.patch \
|
||||
file://0040-Detect-ip-address.patch \
|
||||
file://0041-Added-ipv6-options.patch \
|
||||
file://0042-Removed-obsolete-files.patch \
|
||||
file://0043-Updated-and-cleaned-up-automake.-224.patch \
|
||||
file://0044-Create-FUNDING.yml.patch \
|
||||
"
|
||||
SRCREV = "c167c5a9e0bcf0df23ae5efd91396aae0e37eb87"
|
||||
SRC_URI = "git://github.com/rakshasa/libtorrent;branch=master;protocol=https"
|
||||
SRCREV = "e60f222241319aaae482789517ad00ae9344bd13"
|
||||
|
||||
CVE_STATUS[CVE-2009-1760] = "backported-patch: patched in our product"
|
||||
|
||||
PV = "1"
|
||||
PV = "0.13.8+git${SRCPV}"
|
||||
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user