From 61b6e4cc67abd61a0dbffe271ee3f355b2e772bc Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Tue, 29 Dec 2020 19:58:53 -0500 Subject: Add aggressive restrictions to pre-handshake p2p buffer limit --- tests/fuzz/levin.cpp | 2 ++ tests/net_load_tests/net_load_tests.h | 2 ++ tests/unit_tests/epee_levin_protocol_handler_async.cpp | 3 +++ tests/unit_tests/levin.cpp | 1 + 4 files changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/fuzz/levin.cpp b/tests/fuzz/levin.cpp index b090c350b..079ea7dae 100644 --- a/tests/fuzz/levin.cpp +++ b/tests/fuzz/levin.cpp @@ -52,6 +52,8 @@ namespace struct test_levin_connection_context : public epee::net_utils::connection_context_base { + static constexpr int handshake_command() noexcept { return 1001; } + static constexpr bool handshake_complete() noexcept { return true; } }; typedef epee::levin::async_protocol_handler_config test_levin_protocol_handler_config; diff --git a/tests/net_load_tests/net_load_tests.h b/tests/net_load_tests/net_load_tests.h index e7e0ee247..532017efd 100644 --- a/tests/net_load_tests/net_load_tests.h +++ b/tests/net_load_tests/net_load_tests.h @@ -48,6 +48,8 @@ namespace net_load_tests struct test_connection_context : epee::net_utils::connection_context_base { test_connection_context(): epee::net_utils::connection_context_base(boost::uuids::nil_uuid(), {}, false, false), m_closed(false) {} + static constexpr int handshake_command() noexcept { return 1001; } + static constexpr bool handshake_complete() noexcept { return true; } volatile bool m_closed; }; diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp index ab6791324..3dbb36171 100644 --- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp +++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp @@ -43,6 +43,8 @@ namespace { struct test_levin_connection_context : public epee::net_utils::connection_context_base { + static constexpr int handshake_command() noexcept { return 1001; } + static constexpr bool handshake_complete() noexcept { return true; } }; typedef epee::levin::async_protocol_handler_config test_levin_protocol_handler_config; @@ -193,6 +195,7 @@ namespace { m_handler_config.set_handler(m_pcommands_handler, [](epee::levin::levin_commands_handler *handler) { delete handler; }); m_handler_config.m_invoke_timeout = invoke_timeout; + m_handler_config.m_initial_max_packet_size = max_packet_size; m_handler_config.m_max_packet_size = max_packet_size; } diff --git a/tests/unit_tests/levin.cpp b/tests/unit_tests/levin.cpp index 2ad149afe..dc854ef0c 100644 --- a/tests/unit_tests/levin.cpp +++ b/tests/unit_tests/levin.cpp @@ -178,6 +178,7 @@ namespace { using base_type = epee::net_utils::connection_context_base; static_cast(context_) = base_type{random_generator(), {}, is_incoming, false}; + context_.m_state = cryptonote::cryptonote_connection_context::state_normal; handler_.after_init_connection(); } -- cgit v1.2.3