aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/depends/packages/openssl.mk31
-rw-r--r--contrib/depends/patches/openssl/fix_arflags.patch24
-rw-r--r--contrib/epee/include/byte_stream.h17
-rw-r--r--contrib/epee/include/net/abstract_http_client.h2
-rw-r--r--contrib/epee/include/net/http_client.h2
-rw-r--r--contrib/epee/include/net/http_server_handlers_map2.h4
-rw-r--r--contrib/epee/include/net/levin_base.h4
-rw-r--r--contrib/epee/include/net/levin_protocol_handler_async.h5
-rw-r--r--contrib/epee/include/net/net_helper.h5
-rw-r--r--contrib/epee/include/storages/http_abstract_invoke.h7
-rw-r--r--contrib/epee/include/storages/levin_abstract_invoke2.h31
-rw-r--r--contrib/epee/include/storages/portable_storage.h20
-rw-r--r--contrib/epee/include/storages/portable_storage_template_helper.h11
-rw-r--r--contrib/epee/src/CMakeLists.txt2
-rw-r--r--contrib/epee/src/byte_stream.cpp11
-rw-r--r--contrib/epee/src/portable_storage.cpp29
-rwxr-xr-xcontrib/tor/monero-over-tor.sh93
17 files changed, 185 insertions, 113 deletions
diff --git a/contrib/depends/packages/openssl.mk b/contrib/depends/packages/openssl.mk
index 9d3c28465..62e975e50 100644
--- a/contrib/depends/packages/openssl.mk
+++ b/contrib/depends/packages/openssl.mk
@@ -1,36 +1,31 @@
package=openssl
-$(package)_version=1.0.2r
-$(package)_download_path=https://ftp.openssl.org/source/old/1.0.2
+$(package)_version=1.1.1i
+$(package)_download_path=https://www.openssl.org/source
$(package)_file_name=$(package)-$($(package)_version).tar.gz
-$(package)_sha256_hash=ae51d08bba8a83958e894946f15303ff894d75c2b8bbd44a852b64e3fe11d0d6
-$(package)_patches=fix_arflags.patch
+$(package)_sha256_hash=e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
define $(package)_set_vars
$(package)_config_env=AR="$($(package)_ar)" ARFLAGS=$($(package)_arflags) RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)"
+$(package)_config_env_arm_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
+$(package)_config_env_aarch64_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
+$(package)_build_env_arm_android=ANDROID_NDK_HOME="$(host_prefix)/native"
+$(package)_build_env_aarch64_android=ANDROID_NDK_HOME="$(host_prefix)/native"
$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl
$(package)_config_opts+=no-capieng
$(package)_config_opts+=no-dso
$(package)_config_opts+=no-dtls1
$(package)_config_opts+=no-ec_nistp_64_gcc_128
$(package)_config_opts+=no-gost
-$(package)_config_opts+=no-gmp
$(package)_config_opts+=no-heartbeats
-$(package)_config_opts+=no-jpake
-$(package)_config_opts+=no-krb5
-$(package)_config_opts+=no-libunbound
$(package)_config_opts+=no-md2
$(package)_config_opts+=no-rc5
$(package)_config_opts+=no-rdrand
$(package)_config_opts+=no-rfc3779
-$(package)_config_opts+=no-rsax
$(package)_config_opts+=no-sctp
-$(package)_config_opts+=no-sha0
$(package)_config_opts+=no-shared
$(package)_config_opts+=no-ssl-trace
$(package)_config_opts+=no-ssl2
$(package)_config_opts+=no-ssl3
-$(package)_config_opts+=no-static_engine
-$(package)_config_opts+=no-store
$(package)_config_opts+=no-unit-test
$(package)_config_opts+=no-weak-ssl-ciphers
$(package)_config_opts+=no-zlib
@@ -42,8 +37,8 @@ $(package)_config_opts_x86_64_linux=linux-x86_64
$(package)_config_opts_i686_linux=linux-generic32
$(package)_config_opts_arm_linux=linux-generic32
$(package)_config_opts_aarch64_linux=linux-generic64
-$(package)_config_opts_arm_android=--static android-armv7 no-asm
-$(package)_config_opts_aarch64_android=--static android no-asm
+$(package)_config_opts_arm_android=--static android-arm
+$(package)_config_opts_aarch64_android=--static android-arm64
$(package)_config_opts_riscv64_linux=linux-generic64
$(package)_config_opts_mipsel_linux=linux-generic32
$(package)_config_opts_mips_linux=linux-generic32
@@ -55,10 +50,8 @@ $(package)_config_opts_x86_64_freebsd=BSD-x86_64
endef
define $(package)_preprocess_cmds
- sed -i.old "/define DATE/d" util/mkbuildinf.pl && \
- sed -i.old "s|engines apps test|engines|" Makefile.org && \
- sed -i -e "s/-mandroid //" Configure && \
- patch < $($(package)_patch_dir)/fix_arflags.patch
+ sed -i.old 's|"engines", "apps", "test", "util", "tools", "fuzz"|"engines", "tools"|' Configure && \
+ sed -i -e 's|cflags --sysroot.*",|cflags",|' Configurations/15-android.conf
endef
define $(package)_config_cmds
@@ -70,7 +63,7 @@ define $(package)_build_cmds
endef
define $(package)_stage_cmds
- $(MAKE) INSTALL_PREFIX=$($(package)_staging_dir) -j1 install_sw
+ $(MAKE) DESTDIR=$($(package)_staging_dir) -j1 install_sw
endef
define $(package)_postprocess_cmds
diff --git a/contrib/depends/patches/openssl/fix_arflags.patch b/contrib/depends/patches/openssl/fix_arflags.patch
deleted file mode 100644
index 2d2900d80..000000000
--- a/contrib/depends/patches/openssl/fix_arflags.patch
+++ /dev/null
@@ -1,24 +0,0 @@
---- Makefile.org.O 2019-02-26 14:20:20.000000000 +0000
-+++ Makefile.org 2019-11-15 13:05:54.370086856 +0000
-@@ -63,8 +63,8 @@
- PEX_LIBS=
- EX_LIBS=
- EXE_EXT=
--ARFLAGS=
--AR=ar $(ARFLAGS) r
-+ARFLAGS= r
-+AR=ar $(ARFLAGS)
- RANLIB= ranlib
- RC= windres
- NM= nm
---- Configure.O 2019-02-26 14:20:20.000000000 +0000
-+++ Configure 2019-11-16 07:43:14.933990774 +0000
-@@ -1251,7 +1251,7 @@
- my $shared_extension = $fields[$idx_shared_extension];
- my $ranlib = $ENV{'RANLIB'} || $fields[$idx_ranlib];
- my $ar = $ENV{'AR'} || "ar";
--my $arflags = $fields[$idx_arflags];
-+my $arflags = $ENV{'ARFLAGS'} || $fields[$idx_arflags];
- my $windres = $ENV{'RC'} || $ENV{'WINDRES'} || "windres";
- my $multilib = $fields[$idx_multilib];
-
diff --git a/contrib/epee/include/byte_stream.h b/contrib/epee/include/byte_stream.h
index 42a9e1dd9..93f9ac85c 100644
--- a/contrib/epee/include/byte_stream.h
+++ b/contrib/epee/include/byte_stream.h
@@ -58,7 +58,6 @@ namespace epee
byte_buffer buffer_; //! Beginning of buffer
std::uint8_t* next_write_; //! Current write position
const std::uint8_t* end_; //! End of buffer
- std::size_t increase_size_; //! Minimum buffer size increase
//! \post `requested <= available()`
void overflow(const std::size_t requested);
@@ -75,29 +74,17 @@ namespace epee
using char_type = std::uint8_t;
using Ch = char_type;
- //! \return Default minimum size increase on buffer overflow
- static constexpr std::size_t default_increase() noexcept { return 4096; }
-
//! Increase internal buffer by at least `byte_stream_increase` bytes.
byte_stream() noexcept
- : byte_stream(default_increase())
- {}
-
- //! Increase internal buffer by at least `increase` bytes.
- explicit byte_stream(const std::size_t increase) noexcept
: buffer_(nullptr),
next_write_(nullptr),
- end_(nullptr),
- increase_size_(increase)
+ end_(nullptr)
{}
byte_stream(byte_stream&& rhs) noexcept;
~byte_stream() noexcept = default;
byte_stream& operator=(byte_stream&& rhs) noexcept;
- //! \return The minimum increase size on buffer overflow
- std::size_t increase_size() const noexcept { return increase_size_; }
-
const std::uint8_t* data() const noexcept { return buffer_.get(); }
std::uint8_t* tellp() const noexcept { return next_write_; }
std::size_t available() const noexcept { return end_ - next_write_; }
@@ -188,7 +175,7 @@ namespace epee
void put_n(const std::uint8_t ch, const std::size_t count)
{
check(count);
- std::memset(tellp(), count, ch);
+ std::memset(tellp(), ch, count);
next_write_ += count;
}
diff --git a/contrib/epee/include/net/abstract_http_client.h b/contrib/epee/include/net/abstract_http_client.h
index 1f8bbc605..5270824e1 100644
--- a/contrib/epee/include/net/abstract_http_client.h
+++ b/contrib/epee/include/net/abstract_http_client.h
@@ -70,7 +70,7 @@ namespace http
virtual bool connect(std::chrono::milliseconds timeout) = 0;
virtual bool disconnect() = 0;
virtual bool is_connected(bool *ssl = NULL) = 0;
- virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
+ virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual bool invoke_get(const boost::string_ref uri, std::chrono::milliseconds timeout, const std::string& body = std::string(), const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual bool invoke_post(const boost::string_ref uri, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual uint64_t get_bytes_sent() const = 0;
diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h
index 9645e896b..3725ef079 100644
--- a/contrib/epee/include/net/http_client.h
+++ b/contrib/epee/include/net/http_client.h
@@ -233,7 +233,7 @@ namespace net_utils
}
//---------------------------------------------------------------------------
- inline bool invoke(const boost::string_ref uri, const boost::string_ref method, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) override
+ inline bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) override
{
CRITICAL_REGION_LOCAL(m_lock);
if(!is_connected())
diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h
index ac22cd7a9..1665fdac7 100644
--- a/contrib/epee/include/net/http_server_handlers_map2.h
+++ b/contrib/epee/include/net/http_server_handlers_map2.h
@@ -118,8 +118,10 @@
return true; \
} \
uint64_t ticks2 = misc_utils::get_tick_count(); \
- epee::serialization::store_t_to_binary(static_cast<command_type::response&>(resp), response_info.m_body); \
+ epee::byte_slice buffer; \
+ epee::serialization::store_t_to_binary(static_cast<command_type::response&>(resp), buffer, 64 * 1024); \
uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
+ response_info.m_body.assign(reinterpret_cast<const char*>(buffer.data()), buffer.size()); \
response_info.m_mime_tipe = " application/octet-stream"; \
response_info.m_header_info.m_content_type = " application/octet-stream"; \
MDEBUG( s_pattern << "() processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms"); \
diff --git a/contrib/epee/include/net/levin_base.h b/contrib/epee/include/net/levin_base.h
index f9b6f9a81..ad561c5b6 100644
--- a/contrib/epee/include/net/levin_base.h
+++ b/contrib/epee/include/net/levin_base.h
@@ -31,7 +31,6 @@
#include <cstdint>
-#include "byte_slice.h"
#include "net_utils_base.h"
#include "span.h"
@@ -39,6 +38,7 @@
namespace epee
{
+class byte_slice;
namespace levin
{
#pragma pack(push)
@@ -86,7 +86,7 @@ namespace levin
template<class t_connection_context = net_utils::connection_context_base>
struct levin_commands_handler
{
- virtual int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_connection_context& context)=0;
+ virtual int invoke(int command, const epee::span<const uint8_t> in_buff, byte_slice& buff_out, t_connection_context& context)=0;
virtual int notify(int command, const epee::span<const uint8_t> in_buff, t_connection_context& context)=0;
virtual void callback(t_connection_context& context){};
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h
index 1341a4ae6..8cb2be3e1 100644
--- a/contrib/epee/include/net/levin_protocol_handler_async.h
+++ b/contrib/epee/include/net/levin_protocol_handler_async.h
@@ -514,16 +514,15 @@ public:
{
if(m_current_head.m_have_to_return_data)
{
- std::string return_buff;
+ byte_slice return_buff;
const uint32_t return_code = m_config.m_pcommands_handler->invoke(
m_current_head.m_command, buff_to_invoke, return_buff, m_connection_context
);
bucket_head2 head = make_header(m_current_head.m_command, return_buff.size(), LEVIN_PACKET_RESPONSE, false);
head.m_return_code = SWAP32LE(return_code);
- return_buff.insert(0, reinterpret_cast<const char*>(&head), sizeof(head));
- if(!m_pservice_endpoint->do_send(byte_slice{std::move(return_buff)}))
+ if(!m_pservice_endpoint->do_send(byte_slice{{epee::as_byte_span(head), epee::to_span(return_buff)}}))
return false;
MDEBUG(m_connection_context << "LEVIN_PACKET_SENT. [len=" << head.m_cb
diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h
index 9446e3588..508c79d76 100644
--- a/contrib/epee/include/net/net_helper.h
+++ b/contrib/epee/include/net/net_helper.h
@@ -44,6 +44,7 @@
#include <boost/lambda/lambda.hpp>
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/system/error_code.hpp>
+#include <boost/utility/string_ref.hpp>
#include <functional>
#include "net/net_utils_base.h"
#include "net/net_ssl.h"
@@ -280,7 +281,7 @@ namespace net_utils
inline
- bool send(const std::string& buff, std::chrono::milliseconds timeout)
+ bool send(const boost::string_ref buff, std::chrono::milliseconds timeout)
{
try
@@ -298,7 +299,7 @@ namespace net_utils
// object is used as a callback and will update the ec variable when the
// operation completes. The blocking_udp_client.cpp example shows how you
// can use boost::bind rather than boost::lambda.
- async_write(buff.c_str(), buff.size(), ec);
+ async_write(buff.data(), buff.size(), ec);
// Block until the asynchronous operation has completed.
while (ec == boost::asio::error::would_block)
diff --git a/contrib/epee/include/storages/http_abstract_invoke.h b/contrib/epee/include/storages/http_abstract_invoke.h
index a8bc945a8..c4cb91130 100644
--- a/contrib/epee/include/storages/http_abstract_invoke.h
+++ b/contrib/epee/include/storages/http_abstract_invoke.h
@@ -29,6 +29,7 @@
#include <boost/utility/string_ref.hpp>
#include <chrono>
#include <string>
+#include "byte_slice.h"
#include "portable_storage_template_helper.h"
#include "net/http_base.h"
#include "net/http_server_handlers_map2.h"
@@ -74,12 +75,12 @@ namespace epee
template<class t_request, class t_response, class t_transport>
bool invoke_http_bin(const boost::string_ref uri, const t_request& out_struct, t_response& result_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref method = "POST")
{
- std::string req_param;
- if(!serialization::store_t_to_binary(out_struct, req_param))
+ byte_slice req_param;
+ if(!serialization::store_t_to_binary(out_struct, req_param, 16 * 1024))
return false;
const http::http_response_info* pri = NULL;
- if(!transport.invoke(uri, method, req_param, timeout, std::addressof(pri)))
+ if(!transport.invoke(uri, method, boost::string_ref{reinterpret_cast<const char*>(req_param.data()), req_param.size()}, timeout, std::addressof(pri)))
{
LOG_PRINT_L1("Failed to invoke http request to " << uri);
return false;
diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h
index cf1262486..95f0bb410 100644
--- a/contrib/epee/include/storages/levin_abstract_invoke2.h
+++ b/contrib/epee/include/storages/levin_abstract_invoke2.h
@@ -27,8 +27,10 @@
#pragma once
#include "portable_storage_template_helper.h"
+#include <boost/utility/string_ref.hpp>
#include <boost/utility/value_init.hpp>
#include <functional>
+#include "byte_slice.h"
#include "span.h"
#include "net/levin_base.h"
@@ -110,11 +112,12 @@ namespace epee
const boost::uuids::uuid &conn_id = context.m_connection_id;
typename serialization::portable_storage stg;
out_struct.store(stg);
- std::string buff_to_send, buff_to_recv;
- stg.store_to_binary(buff_to_send);
+ byte_slice buff_to_send;
+ std::string buff_to_recv;
+ stg.store_to_binary(buff_to_send, 16 * 1024);
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
- int res = transport.invoke(command, buff_to_send, buff_to_recv, conn_id);
+ int res = transport.invoke(command, boost::string_ref{reinterpret_cast<const char*>(buff_to_send.data()), buff_to_send.size()}, buff_to_recv, conn_id);
if( res <=0 )
{
LOG_PRINT_L1("Failed to invoke command " << command << " return code " << res);
@@ -137,10 +140,10 @@ namespace epee
const boost::uuids::uuid &conn_id = context.m_connection_id;
typename serialization::portable_storage stg;
const_cast<t_arg&>(out_struct).store(stg);//TODO: add true const support to searilzation
- std::string buff_to_send;
- stg.store_to_binary(buff_to_send);
+ byte_slice buff_to_send;
+ stg.store_to_binary(buff_to_send, 16 * 1024);
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
- int res = transport.invoke_async(command, epee::strspan<uint8_t>(buff_to_send), conn_id, [cb, command](int code, const epee::span<const uint8_t> buff, typename t_transport::connection_context& context)->bool
+ int res = transport.invoke_async(command, epee::to_span(buff_to_send), conn_id, [cb, command](int code, const epee::span<const uint8_t> buff, typename t_transport::connection_context& context)->bool
{
t_result result_struct = AUTO_VAL_INIT(result_struct);
if( code <=0 )
@@ -184,11 +187,11 @@ namespace epee
const boost::uuids::uuid &conn_id = context.m_connection_id;
serialization::portable_storage stg;
out_struct.store(stg);
- std::string buff_to_send;
+ byte_slice buff_to_send;
stg.store_to_binary(buff_to_send);
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
- int res = transport.notify(command, epee::strspan<uint8_t>(buff_to_send), conn_id);
+ int res = transport.notify(command, epee::to_span(buff_to_send), conn_id);
if(res <=0 )
{
MERROR("Failed to notify command " << command << " return code " << res);
@@ -199,7 +202,7 @@ namespace epee
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
template<class t_owner, class t_in_type, class t_out_type, class t_context, class callback_t>
- int buff_to_t_adapter(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, callback_t cb, t_context& context )
+ int buff_to_t_adapter(int command, const epee::span<const uint8_t> in_buff, byte_slice& buff_out, callback_t cb, t_context& context )
{
serialization::portable_storage strg;
if(!strg.load_from_binary(in_buff))
@@ -222,7 +225,7 @@ namespace epee
serialization::portable_storage strg_out;
static_cast<t_out_type&>(out_struct).store(strg_out);
- if(!strg_out.store_to_binary(buff_out))
+ if(!strg_out.store_to_binary(buff_out, 32 * 1024))
{
LOG_ERROR("Failed to store_to_binary in command" << command);
return -1;
@@ -254,7 +257,7 @@ namespace epee
}
#define CHAIN_LEVIN_INVOKE_MAP2(context_type) \
- int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, context_type& context) \
+ int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, context_type& context) \
{ \
bool handled = false; \
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
@@ -263,13 +266,13 @@ namespace epee
#define CHAIN_LEVIN_NOTIFY_MAP2(context_type) \
int notify(int command, const epee::span<const uint8_t> in_buff, context_type& context) \
{ \
- bool handled = false; std::string fake_str;\
+ bool handled = false; epee::byte_slice fake_str; \
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
}
#define CHAIN_LEVIN_INVOKE_MAP() \
- int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, epee::net_utils::connection_context_base& context) \
+ int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, epee::net_utils::connection_context_base& context) \
{ \
bool handled = false; \
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
@@ -289,7 +292,7 @@ namespace epee
}
#define BEGIN_INVOKE_MAP2(owner_type) \
- template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_context& context, bool& handled) \
+ template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, t_context& context, bool& handled) \
{ \
try { \
typedef owner_type internal_owner_type_name;
diff --git a/contrib/epee/include/storages/portable_storage.h b/contrib/epee/include/storages/portable_storage.h
index 4b759a24f..589e6ad63 100644
--- a/contrib/epee/include/storages/portable_storage.h
+++ b/contrib/epee/include/storages/portable_storage.h
@@ -32,7 +32,6 @@
#include "misc_language.h"
#include "portable_storage_base.h"
-#include "portable_storage_to_bin.h"
#include "portable_storage_from_bin.h"
#include "portable_storage_to_json.h"
#include "portable_storage_from_json.h"
@@ -42,6 +41,7 @@
namespace epee
{
+ class byte_slice;
namespace serialization
{
/************************************************************************/
@@ -83,7 +83,7 @@ namespace epee
bool delete_entry(const std::string& pentry_name, hsection hparent_section = nullptr);
//-------------------------------------------------------------------------------
- bool store_to_binary(binarybuffer& target);
+ bool store_to_binary(byte_slice& target, std::size_t initial_buffer_size = 8192);
bool load_from_binary(const epee::span<const uint8_t> target);
bool load_from_binary(const std::string& target) { return load_from_binary(epee::strspan<uint8_t>(target)); }
template<class trace_policy>
@@ -133,22 +133,6 @@ namespace epee
{
return false;//TODO: don't think i ever again will use xml - ambiguous and "overtagged" format
}
-
- inline
- bool portable_storage::store_to_binary(binarybuffer& target)
- {
- TRY_ENTRY();
- std::stringstream ss;
- storage_block_header sbh = AUTO_VAL_INIT(sbh);
- sbh.m_signature_a = SWAP32LE(PORTABLE_STORAGE_SIGNATUREA);
- sbh.m_signature_b = SWAP32LE(PORTABLE_STORAGE_SIGNATUREB);
- sbh.m_ver = PORTABLE_STORAGE_FORMAT_VER;
- ss.write((const char*)&sbh, sizeof(storage_block_header));
- pack_entry_to_buff(ss, m_root);
- target = ss.str();
- return true;
- CATCH_ENTRY("portable_storage::store_to_binary", false)
- }
inline
bool portable_storage::load_from_binary(const epee::span<const uint8_t> source)
{
diff --git a/contrib/epee/include/storages/portable_storage_template_helper.h b/contrib/epee/include/storages/portable_storage_template_helper.h
index 13c870d44..39f900c8d 100644
--- a/contrib/epee/include/storages/portable_storage_template_helper.h
+++ b/contrib/epee/include/storages/portable_storage_template_helper.h
@@ -28,6 +28,7 @@
#include <string>
+#include "byte_slice.h"
#include "parserse_base_utils.h"
#include "portable_storage.h"
#include "file_io_utils.h"
@@ -111,18 +112,18 @@ namespace epee
}
//-----------------------------------------------------------------------------------------------------------
template<class t_struct>
- bool store_t_to_binary(t_struct& str_in, std::string& binary_buff, size_t indent = 0)
+ bool store_t_to_binary(t_struct& str_in, byte_slice& binary_buff, size_t initial_buffer_size = 8192)
{
portable_storage ps;
str_in.store(ps);
- return ps.store_to_binary(binary_buff);
+ return ps.store_to_binary(binary_buff, initial_buffer_size);
}
//-----------------------------------------------------------------------------------------------------------
template<class t_struct>
- std::string store_t_to_binary(t_struct& str_in, size_t indent = 0)
+ byte_slice store_t_to_binary(t_struct& str_in, size_t initial_buffer_size = 8192)
{
- std::string binary_buff;
- store_t_to_binary(str_in, binary_buff, indent);
+ byte_slice binary_buff;
+ store_t_to_binary(str_in, binary_buff, initial_buffer_size);
return binary_buff;
}
}
diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt
index 8adf69162..5e101a86a 100644
--- a/contrib/epee/src/CMakeLists.txt
+++ b/contrib/epee/src/CMakeLists.txt
@@ -29,7 +29,7 @@
add_library(epee STATIC byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_client.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp
wipeable_string.cpp levin_base.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp mlocker.cpp buffer.cpp net_ssl.cpp
- int-util.cpp)
+ int-util.cpp portable_storage.cpp)
if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW)))
add_library(epee_readline STATIC readline_buffer.cpp)
diff --git a/contrib/epee/src/byte_stream.cpp b/contrib/epee/src/byte_stream.cpp
index e87d9f0bc..73bba92f2 100644
--- a/contrib/epee/src/byte_stream.cpp
+++ b/contrib/epee/src/byte_stream.cpp
@@ -34,6 +34,11 @@
#include <iostream>
+namespace
+{
+ constexpr const std::size_t minimum_increase = 4096;
+}
+
namespace epee
{
void byte_stream::overflow(const std::size_t requested)
@@ -46,7 +51,7 @@ namespace epee
const std::size_t len = size();
const std::size_t cap = capacity();
- const std::size_t increase = std::max(need, increase_size());
+ const std::size_t increase = std::max(std::max(need, cap), minimum_increase);
next_write_ = nullptr;
end_ = nullptr;
@@ -62,8 +67,7 @@ namespace epee
byte_stream::byte_stream(byte_stream&& rhs) noexcept
: buffer_(std::move(rhs.buffer_)),
next_write_(rhs.next_write_),
- end_(rhs.end_),
- increase_size_(rhs.increase_size_)
+ end_(rhs.end_)
{
rhs.next_write_ = nullptr;
rhs.end_ = nullptr;
@@ -76,7 +80,6 @@ namespace epee
buffer_ = std::move(rhs.buffer_);
next_write_ = rhs.next_write_;
end_ = rhs.end_;
- increase_size_ = rhs.increase_size_;
rhs.next_write_ = nullptr;
rhs.end_ = nullptr;
}
diff --git a/contrib/epee/src/portable_storage.cpp b/contrib/epee/src/portable_storage.cpp
new file mode 100644
index 000000000..4534deff3
--- /dev/null
+++ b/contrib/epee/src/portable_storage.cpp
@@ -0,0 +1,29 @@
+
+#include "byte_slice.h"
+#include "byte_stream.h"
+#include "misc_log_ex.h"
+#include "span.h"
+#include "storages/portable_storage.h"
+#include "storages/portable_storage_to_bin.h"
+
+namespace epee
+{
+namespace serialization
+{
+ bool portable_storage::store_to_binary(byte_slice& target, const std::size_t initial_buffer_size)
+ {
+ TRY_ENTRY();
+ byte_stream ss;
+ ss.reserve(initial_buffer_size);
+ storage_block_header sbh{};
+ sbh.m_signature_a = SWAP32LE(PORTABLE_STORAGE_SIGNATUREA);
+ sbh.m_signature_b = SWAP32LE(PORTABLE_STORAGE_SIGNATUREB);
+ sbh.m_ver = PORTABLE_STORAGE_FORMAT_VER;
+ ss.write(epee::as_byte_span(sbh));
+ pack_entry_to_buff(ss, m_root);
+ target = epee::byte_slice{std::move(ss)};
+ return true;
+ CATCH_ENTRY("portable_storage::store_to_binary", false)
+ }
+}
+}
diff --git a/contrib/tor/monero-over-tor.sh b/contrib/tor/monero-over-tor.sh
new file mode 100755
index 000000000..9fb4cdd36
--- /dev/null
+++ b/contrib/tor/monero-over-tor.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+DIR=$(realpath $(dirname $0))
+
+echo "Checking monerod..."
+monerod=""
+for dir in \
+ . \
+ "$DIR" \
+ "$DIR/../.." \
+ "$DIR/build/release/bin" \
+ "$DIR/../../build/release/bin" \
+ "$DIR/build/Linux/master/release/bin" \
+ "$DIR/../../build/Linux/master/release/bin" \
+ "$DIR/build/Windows/master/release/bin" \
+ "$DIR/../../build/Windows/master/release/bin"
+do
+ if test -x "$dir/monerod"
+ then
+ monerod="$dir/monerod"
+ break
+ fi
+done
+if test -z "$monerod"
+then
+ echo "monerod not found"
+ exit 1
+fi
+echo "Found: $monerod"
+
+TORDIR="$DIR/monero-over-tor"
+TORRC="$TORDIR/torrc"
+HOSTNAMEFILE="$TORDIR/hostname"
+echo "Creating configuration..."
+mkdir -p "$TORDIR"
+chmod 700 "$TORDIR"
+rm -f "$TORRC"
+cat << EOF > "$TORRC"
+ControlSocket $TORDIR/control
+ControlSocketsGroupWritable 1
+CookieAuthentication 1
+CookieAuthFile $TORDIR/control.authcookie
+CookieAuthFileGroupReadable 1
+HiddenServiceDir $TORDIR
+HiddenServicePort 18083 127.0.0.1:18083
+EOF
+
+echo "Starting Tor..."
+nohup tor -f "$TORRC" 2> "$TORDIR/tor.stderr" 1> "$TORDIR/tor.stdout" &
+ready=0
+for i in `seq 10`
+do
+ sleep 1
+ if test -f "$HOSTNAMEFILE"
+ then
+ ready=1
+ break
+ fi
+done
+if test "$ready" = 0
+then
+ echo "Error starting Tor"
+ cat "$TORDIR/tor.stdout"
+ exit 1
+fi
+
+echo "Starting monerod..."
+HOSTNAME=$(cat "$HOSTNAMEFILE")
+"$monerod" \
+ --anonymous-inbound "$HOSTNAME":18083,127.0.0.1:18083,25 --tx-proxy tor,127.0.0.1:9050,10 \
+ --add-priority-node zbjkbsxc5munw3qusl7j2hpcmikhqocdf4pqhnhtpzw5nt5jrmofptid.onion:18083 \
+ --add-priority-node 2xmrnode5itf65lz.onion:18083 \
+ --detach
+ready=0
+for i in `seq 10`
+do
+ sleep 1
+ status=$("$monerod" status)
+ echo "$status" | grep -q "Height:"
+ if test $? = 0
+ then
+ ready=1
+ break
+ fi
+done
+if test "$ready" = 0
+then
+ echo "Error starting monerod"
+ tail -n 400 "$HOME/.bitmonero/bitmonero.log" | grep -Ev stacktrace\|"Error: Couldn't connect to daemon:"\|"src/daemon/main.cpp:.*Monero\ \'" | tail -n 20
+ exit 1
+fi
+
+echo "Ready. Your Tor hidden service is $HOSTNAME"