mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-17 07:32:32 +00:00
Add handshake/stream encryption RPC commands
Replace protocol.encryption.set bitmask flags with protocol.encryption.handshake.set and protocol.encryption.stream.set. Add encryption_config to map commands to libtorrent EncryptionPolicy. Startup default matches the old preset (allow_incoming, enable_retry, prefer_plaintext → handshake=allow, stream=allow). Update docs and examples. Peer list distinguishes RC4 (R/L), handshake-only (H/h), and plain (r/l). Fix ui encrypted column conditional. Add encryption config tests; remove OPTION_ENCRYPTION parse tests. Drop the encryption command redirect.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "test/src/test_encryption_config.h"
|
||||
|
||||
#include <torrent/runtime/encryption_policy.h>
|
||||
|
||||
#include "encryption_config.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestEncryptionConfig);
|
||||
|
||||
void
|
||||
TestEncryptionConfig::test_default_policy() {
|
||||
const auto policy = encryption_config::default_policy();
|
||||
|
||||
CPPUNIT_ASSERT(policy.handshake == encryption_config::Policy::Mode::allow);
|
||||
CPPUNIT_ASSERT(policy.stream == encryption_config::Policy::Mode::allow);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("handshake=allow stream=allow"),
|
||||
encryption_config::summary_string(policy));
|
||||
}
|
||||
|
||||
void
|
||||
TestEncryptionConfig::test_granular_round_trip() {
|
||||
auto round_trip_handshake = [](const std::string& value) {
|
||||
encryption_config::Policy policy;
|
||||
encryption_config::apply_mode_value(policy, &encryption_config::Policy::handshake, value);
|
||||
return encryption_config::mode_to_string(policy.handshake);
|
||||
};
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("deny"), round_trip_handshake("deny"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("allow"), round_trip_handshake("allow"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("prefer"), round_trip_handshake("prefer"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("require"), round_trip_handshake("require"));
|
||||
|
||||
auto round_trip_stream = [](const std::string& value) {
|
||||
encryption_config::Policy policy;
|
||||
encryption_config::apply_mode_value(policy, &encryption_config::Policy::stream, value);
|
||||
return encryption_config::mode_to_string(policy.stream);
|
||||
};
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("deny"), round_trip_stream("deny"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("allow"), round_trip_stream("allow"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("prefer"), round_trip_stream("prefer"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("require"), round_trip_stream("require"));
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "test/helpers/test_fixture.h"
|
||||
|
||||
class TestEncryptionConfig : public test_fixture {
|
||||
CPPUNIT_TEST_SUITE(TestEncryptionConfig);
|
||||
CPPUNIT_TEST(test_default_policy);
|
||||
CPPUNIT_TEST(test_granular_round_trip);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void test_default_policy();
|
||||
void test_granular_round_trip();
|
||||
};
|
||||
Reference in New Issue
Block a user