mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-13 20:56:17 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c507c581f | |||
| af0b600b54 | |||
| c984a69fd1 | |||
| 20002ce937 | |||
| 3caa31113d | |||
| 0373d227c1 | |||
| a8be7e443a | |||
| f327523a07 |
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
m4_pattern_allow([PKG_CHECK_EXISTS])
|
m4_pattern_allow([PKG_CHECK_EXISTS])
|
||||||
|
|
||||||
AC_INIT([rtorrent],[0.16.21],[sundell.software@gmail.com])
|
AC_INIT([rtorrent],[0.16.22],[sundell.software@gmail.com])
|
||||||
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
AC_CONFIG_MACRO_DIRS([scripts])
|
AC_CONFIG_MACRO_DIRS([scripts])
|
||||||
@@ -49,7 +49,7 @@ fi
|
|||||||
|
|
||||||
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
||||||
PKG_CHECK_MODULES([ZLIB], [zlib])
|
PKG_CHECK_MODULES([ZLIB], [zlib])
|
||||||
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.21])
|
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.22])
|
||||||
|
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
TORRENT_WITH_XMLRPC_C
|
TORRENT_WITH_XMLRPC_C
|
||||||
|
|||||||
@@ -206,6 +206,9 @@ ipv4_range_parse(const char* address, uint32_t* address_start, uint32_t* address
|
|||||||
if (mask_bits == 0) {
|
if (mask_bits == 0) {
|
||||||
mask = 0;
|
mask = 0;
|
||||||
end_mask = ~(uint32_t)0;
|
end_mask = ~(uint32_t)0;
|
||||||
|
} else if (mask_bits == 32) {
|
||||||
|
mask = ~(uint32_t)0;
|
||||||
|
end_mask = 0;
|
||||||
} else {
|
} else {
|
||||||
mask = (~mask) << (32-mask_bits);
|
mask = (~mask) << (32-mask_bits);
|
||||||
end_mask = (~end_mask) >> mask_bits;
|
end_mask = (~end_mask) >> mask_bits;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <torrent/utils/log.h>
|
#include <torrent/utils/log.h>
|
||||||
#include <torrent/utils/resume.h>
|
#include <torrent/utils/resume.h>
|
||||||
#include <torrent/object.h>
|
#include <torrent/object.h>
|
||||||
@@ -39,6 +40,11 @@ static constexpr const char* session_invalid_message = "Session data is invalid,
|
|||||||
|
|
||||||
static std::unique_ptr<torrent::Object>
|
static std::unique_ptr<torrent::Object>
|
||||||
download_factory_load_stream(const char* filename, bool* is_invalid) {
|
download_factory_load_stream(const char* filename, bool* is_invalid) {
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if (stat(filename, &sb) != 0 || !S_ISREG(sb.st_mode))
|
||||||
|
return std::unique_ptr<torrent::Object>();
|
||||||
|
|
||||||
std::fstream stream(filename, std::ios::in | std::ios::binary);
|
std::fstream stream(filename, std::ios::in | std::ios::binary);
|
||||||
|
|
||||||
if (!stream.is_open())
|
if (!stream.is_open())
|
||||||
@@ -167,11 +173,19 @@ void
|
|||||||
DownloadFactory::receive_success() {
|
DownloadFactory::receive_success() {
|
||||||
bool session_invalid = false;
|
bool session_invalid = false;
|
||||||
|
|
||||||
auto rtorrent_object = download_factory_load_stream((expand_path(m_uri) + ".rtorrent").c_str(), &session_invalid);
|
std::unique_ptr<torrent::Object> rtorrent_object;
|
||||||
auto libtorrent_resume_object = download_factory_load_stream((expand_path(m_uri) + ".libtorrent_resume").c_str(), &session_invalid);
|
std::unique_ptr<torrent::Object> libtorrent_resume_object;
|
||||||
|
|
||||||
if (session_invalid)
|
if (m_session) {
|
||||||
lt_log_print(torrent::LOG_ERROR, "%s: %s", session_invalid_message, m_uri.c_str());
|
if (m_uri.empty())
|
||||||
|
throw torrent::input_error("Session torrent URI is empty.");
|
||||||
|
|
||||||
|
rtorrent_object = download_factory_load_stream((expand_path(m_uri) + ".rtorrent").c_str(), &session_invalid);
|
||||||
|
libtorrent_resume_object = download_factory_load_stream((expand_path(m_uri) + ".libtorrent_resume").c_str(), &session_invalid);
|
||||||
|
|
||||||
|
if (session_invalid)
|
||||||
|
lt_log_print(torrent::LOG_ERROR, "%s: %s", session_invalid_message, m_uri.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t tracker_key;
|
uint32_t tracker_key;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ class SCgiTask : public torrent::system::Event {
|
|||||||
public:
|
public:
|
||||||
static constexpr int default_buffer_size = 8191;
|
static constexpr int default_buffer_size = 8191;
|
||||||
static constexpr int max_header_size = 2000;
|
static constexpr int max_header_size = 2000;
|
||||||
static constexpr int max_content_size = (2 << 23);
|
static constexpr int max_content_size = (1 << 26);
|
||||||
|
|
||||||
static constexpr auto timeout_request = std::chrono::seconds(60);
|
static constexpr auto timeout_request = std::chrono::seconds(60);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
int parse_main_options(int argc, char** argv);
|
int parse_main_options(int argc, char** argv);
|
||||||
void parse_config_file(int argc, char** argv, std::function<void (const std::string&)> parse_fn);
|
void parse_config_file(int argc, char** argv, std::function<void (const std::string&)> parse_fn);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
|
|
||||||
|
#include "utils/functional.h"
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -21,6 +23,8 @@ gzip_compress_to_vector(const char* buffer, unsigned int length, std::vector<cha
|
|||||||
if (deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, window_bits | gzip_encoding, gzip_level, Z_DEFAULT_STRATEGY) != Z_OK)
|
if (deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, window_bits | gzip_encoding, gzip_level, Z_DEFAULT_STRATEGY) != Z_OK)
|
||||||
throw torrent::internal_error("gzip_compress_to_vector(...) could not initialize gzip deflate.");
|
throw torrent::internal_error("gzip_compress_to_vector(...) could not initialize gzip deflate.");
|
||||||
|
|
||||||
|
scope_guard guard([&zs]() { deflateEnd(&zs); });
|
||||||
|
|
||||||
auto max_response_size = deflateBound(&zs, length);
|
auto max_response_size = deflateBound(&zs, length);
|
||||||
|
|
||||||
output.resize(offset + max_response_size);
|
output.resize(offset + max_response_size);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define RTORRENT_UTILS_GZIP_H
|
#define RTORRENT_UTILS_GZIP_H
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ rtorrent_Test_Rpc_SOURCES = $(rtorrent_Test_Common) \
|
|||||||
rtorrent_Test_Src_SOURCES = $(rtorrent_Test_Common) \
|
rtorrent_Test_Src_SOURCES = $(rtorrent_Test_Common) \
|
||||||
src/test_command_dynamic.cc \
|
src/test_command_dynamic.cc \
|
||||||
src/test_command_dynamic.h \
|
src/test_command_dynamic.h \
|
||||||
|
src/test_command_ip.cc \
|
||||||
|
src/test_command_ip.h \
|
||||||
src/test_command_system.cc \
|
src/test_command_system.cc \
|
||||||
src/test_command_system.h \
|
src/test_command_system.h \
|
||||||
src/test_command_path.cc \
|
src/test_command_path.cc \
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "test/src/test_command_ip.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION(TestCommandIp);
|
||||||
|
|
||||||
|
bool ipv4_range_parse(const char* address, uint32_t* address_start, uint32_t* address_end);
|
||||||
|
|
||||||
|
static uint32_t
|
||||||
|
ipv4(uint32_t a, uint32_t b, uint32_t c, uint32_t d) {
|
||||||
|
return (a << 24) | (b << 16) | (c << 8) | d;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RANGE_ASSERT(address, expected_start, expected_end) \
|
||||||
|
{ \
|
||||||
|
uint32_t start = 0; \
|
||||||
|
uint32_t end = 0; \
|
||||||
|
\
|
||||||
|
CPPUNIT_ASSERT(ipv4_range_parse(address, &start, &end)); \
|
||||||
|
CPPUNIT_ASSERT_EQUAL(expected_start, start); \
|
||||||
|
CPPUNIT_ASSERT_EQUAL(expected_end, end); \
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TestCommandIp::test_single_address() {
|
||||||
|
RANGE_ASSERT("10.1.2.3", ipv4(10, 1, 2, 3), ipv4(10, 1, 2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TestCommandIp::test_explicit_range() {
|
||||||
|
RANGE_ASSERT("10.1.2.3-10.1.2.9", ipv4(10, 1, 2, 3), ipv4(10, 1, 2, 9));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TestCommandIp::test_cidr() {
|
||||||
|
RANGE_ASSERT("10.0.0.0/8", ipv4(10, 0, 0, 0), ipv4(10, 255, 255, 255));
|
||||||
|
RANGE_ASSERT("10.1.2.0/24", ipv4(10, 1, 2, 0), ipv4(10, 1, 2, 255));
|
||||||
|
RANGE_ASSERT("10.1.2.128/25", ipv4(10, 1, 2, 128), ipv4(10, 1, 2, 255));
|
||||||
|
RANGE_ASSERT("10.1.2.3/31", ipv4(10, 1, 2, 2), ipv4(10, 1, 2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TestCommandIp::test_cidr_zero_mask() {
|
||||||
|
RANGE_ASSERT("0.0.0.0/0", ipv4(0, 0, 0, 0), ipv4(255, 255, 255, 255));
|
||||||
|
RANGE_ASSERT("10.1.2.3/0", ipv4(0, 0, 0, 0), ipv4(255, 255, 255, 255));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TestCommandIp::test_cidr_full_mask() {
|
||||||
|
RANGE_ASSERT("10.1.2.3/32", ipv4(10, 1, 2, 3), ipv4(10, 1, 2, 3));
|
||||||
|
RANGE_ASSERT("0.0.0.0/32", ipv4(0, 0, 0, 0), ipv4(0, 0, 0, 0));
|
||||||
|
RANGE_ASSERT("255.255.255.255/32", ipv4(255, 255, 255, 255), ipv4(255, 255, 255, 255));
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#include <cppunit/TestFixture.h>
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
// ipv4_range_parse is a pure function, so this does not use test_fixture and
|
||||||
|
// the mock and logging setup that comes with it.
|
||||||
|
class TestCommandIp : public CppUnit::TestFixture {
|
||||||
|
CPPUNIT_TEST_SUITE(TestCommandIp);
|
||||||
|
|
||||||
|
CPPUNIT_TEST(test_single_address);
|
||||||
|
CPPUNIT_TEST(test_explicit_range);
|
||||||
|
|
||||||
|
CPPUNIT_TEST(test_cidr);
|
||||||
|
CPPUNIT_TEST(test_cidr_zero_mask);
|
||||||
|
CPPUNIT_TEST(test_cidr_full_mask);
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void test_single_address();
|
||||||
|
void test_explicit_range();
|
||||||
|
|
||||||
|
void test_cidr();
|
||||||
|
void test_cidr_zero_mask();
|
||||||
|
void test_cidr_full_mask();
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user