aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/depends/packages/sodium.mk4
-rw-r--r--contrib/depends/patches/sodium/fix-whitespace.patch4
-rw-r--r--contrib/epee/include/console_handler.h9
-rw-r--r--contrib/epee/include/md5_l.h2
-rw-r--r--contrib/epee/include/net/http_server_handlers_map2.h2
-rw-r--r--contrib/epee/include/net/net_helper.h2
-rw-r--r--contrib/epee/include/serialization/keyvalue_serialization_overloads.h24
-rw-r--r--contrib/epee/include/span.h3
-rw-r--r--contrib/epee/include/storages/levin_abstract_invoke2.h48
-rw-r--r--contrib/epee/include/storages/parserse_base_utils.h1
-rw-r--r--contrib/epee/include/storages/portable_storage.h52
-rw-r--r--contrib/epee/include/storages/portable_storage_base.h8
-rw-r--r--contrib/epee/include/storages/portable_storage_from_bin.h6
-rw-r--r--contrib/epee/include/storages/portable_storage_from_json.h18
-rw-r--r--contrib/epee/include/string_tools.h4
-rw-r--r--contrib/epee/src/http_auth.cpp2
-rw-r--r--contrib/epee/src/net_ssl.cpp44
-rwxr-xr-xcontrib/gitian/gitian-build.py2
18 files changed, 162 insertions, 73 deletions
diff --git a/contrib/depends/packages/sodium.mk b/contrib/depends/packages/sodium.mk
index dbf86fc5a..462bd2415 100644
--- a/contrib/depends/packages/sodium.mk
+++ b/contrib/depends/packages/sodium.mk
@@ -1,8 +1,8 @@
package=sodium
-$(package)_version=1.0.16
+$(package)_version=1.0.18
$(package)_download_path=https://download.libsodium.org/libsodium/releases/
$(package)_file_name=libsodium-$($(package)_version).tar.gz
-$(package)_sha256_hash=eeadc7e1e1bcef09680fb4837d448fbdf57224978f865ac1c16745868fbd0533
+$(package)_sha256_hash=6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1
$(package)_patches=fix-whitespace.patch
define $(package)_set_vars
diff --git a/contrib/depends/patches/sodium/fix-whitespace.patch b/contrib/depends/patches/sodium/fix-whitespace.patch
index efbfe4e83..c3d3af0b4 100644
--- a/contrib/depends/patches/sodium/fix-whitespace.patch
+++ b/contrib/depends/patches/sodium/fix-whitespace.patch
@@ -5,8 +5,8 @@ index b29f769..ca008ae 100755
@@ -591,7 +591,7 @@ MAKEFLAGS=
PACKAGE_NAME='libsodium'
PACKAGE_TARNAME='libsodium'
- PACKAGE_VERSION='1.0.16'
--PACKAGE_STRING='libsodium 1.0.16'
+ PACKAGE_VERSION='1.0.18'
+-PACKAGE_STRING='libsodium 1.0.18'
+PACKAGE_STRING='libsodium'
PACKAGE_BUGREPORT='https://github.com/jedisct1/libsodium/issues'
PACKAGE_URL='https://github.com/jedisct1/libsodium'
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
index 13747b0c8..1b716fca4 100644
--- a/contrib/epee/include/console_handler.h
+++ b/contrib/epee/include/console_handler.h
@@ -605,10 +605,17 @@ eof:
std::unique_ptr<boost::thread> m_console_thread;
async_console_handler m_console_handler;
public:
+ ~console_handlers_binder() {
+ stop_handling();
+ if (m_console_thread.get() != nullptr)
+ {
+ m_console_thread->join();
+ }
+ }
+
bool start_handling(std::function<std::string(void)> prompt, const std::string& usage_string = "", std::function<void(void)> exit_handler = NULL)
{
m_console_thread.reset(new boost::thread(boost::bind(&console_handlers_binder::run_handling, this, prompt, usage_string, exit_handler)));
- m_console_thread->detach();
return true;
}
bool start_handling(const std::string &prompt, const std::string& usage_string = "", std::function<void(void)> exit_handler = NULL)
diff --git a/contrib/epee/include/md5_l.h b/contrib/epee/include/md5_l.h
index a45d91bc8..bc7122650 100644
--- a/contrib/epee/include/md5_l.h
+++ b/contrib/epee/include/md5_l.h
@@ -85,7 +85,7 @@ namespace md5
MD5Update( &ctx, input, ilen );
MD5Final( output, &ctx);
- memset( &ctx, 0, sizeof( MD5_CTX) );
+ memwipe( &ctx, sizeof( MD5_CTX ));
return true;
}
diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h
index 07ed8157b..0c0653cd6 100644
--- a/contrib/epee/include/net/http_server_handlers_map2.h
+++ b/contrib/epee/include/net/http_server_handlers_map2.h
@@ -120,6 +120,7 @@
#define BEGIN_JSON_RPC_MAP(uri) else if(query_info.m_URI == uri) \
{ \
uint64_t ticks = epee::misc_utils::get_tick_count(); \
+ response_info.m_mime_tipe = "application/json"; \
epee::serialization::portable_storage ps; \
if(!ps.load_from_json(query_info.m_body)) \
{ \
@@ -148,6 +149,7 @@
#define PREPARE_OBJECTS_FROM_JSON(command_type) \
handled = true; \
+ response_info.m_mime_tipe = "application/json"; \
boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
epee::json_rpc::request<command_type::request>& req = static_cast<epee::json_rpc::request<command_type::request>&>(req_);\
if(!req.load(ps)) \
diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h
index 81545e502..9446e3588 100644
--- a/contrib/epee/include/net/net_helper.h
+++ b/contrib/epee/include/net/net_helper.h
@@ -103,8 +103,8 @@ namespace net_utils
blocked_mode_client() :
m_io_service(),
m_ctx(boost::asio::ssl::context::tlsv12),
- m_connector(direct_connect{}),
m_ssl_socket(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(m_io_service, m_ctx)),
+ m_connector(direct_connect{}),
m_ssl_options(epee::net_utils::ssl_support_t::e_ssl_support_autodetect),
m_initialized(true),
m_connected(false),
diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
index fc8b90a2c..1f9d6b6d7 100644
--- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
+++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
@@ -48,22 +48,10 @@ namespace epee
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
- static bool serialize_t_val(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
- {
- return stg.set_value(pname, d, hparent_section);
- }
- //-------------------------------------------------------------------------------------------------------------------
- template<class t_type, class t_storage>
- static bool unserialize_t_val(t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
- {
- return stg.get_value(pname, d, hparent_section);
- }
- //-------------------------------------------------------------------------------------------------------------------
- template<class t_type, class t_storage>
static bool serialize_t_val_as_blob(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
std::string blob((const char *)&d, sizeof(d));
- return stg.set_value(pname, blob, hparent_section);
+ return stg.set_value(pname, std::move(blob), hparent_section);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
@@ -114,13 +102,15 @@ namespace epee
template<class stl_container, class t_storage>
static bool serialize_stl_container_t_val (const stl_container& container, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
+ using value_type = typename stl_container::value_type;
+
if(!container.size()) return true;
typename stl_container::const_iterator it = container.begin();
- typename t_storage::harray hval_array = stg.insert_first_value(pname, *it, hparent_section);
+ typename t_storage::harray hval_array = stg.insert_first_value(pname, value_type(*it), hparent_section);
CHECK_AND_ASSERT_MES(hval_array, false, "failed to insert first value to storage");
it++;
for(;it!= container.end();it++)
- stg.insert_next_value(hval_array, *it);
+ stg.insert_next_value(hval_array, value_type(*it));
return true;
}
@@ -149,7 +139,7 @@ namespace epee
*p_elem = v;
p_elem++;
}
- return stg.set_value(pname, mb, hparent_section);
+ return stg.set_value(pname, std::move(mb), hparent_section);
}
//--------------------------------------------------------------------------------------------------------------------
template<class stl_container, class t_storage>
@@ -221,7 +211,7 @@ namespace epee
template<class t_type, class t_storage>
static bool kv_serialize(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
- return stg.set_value(pname, d, hparent_section);
+ return stg.set_value(pname, t_type(d), hparent_section);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
diff --git a/contrib/epee/include/span.h b/contrib/epee/include/span.h
index e100452ca..59895535f 100644
--- a/contrib/epee/include/span.h
+++ b/contrib/epee/include/span.h
@@ -110,7 +110,8 @@ namespace epee
constexpr std::size_t size() const noexcept { return len; }
constexpr std::size_t size_bytes() const noexcept { return size() * sizeof(value_type); }
- const T &operator[](size_t idx) const { return ptr[idx]; }
+ T &operator[](size_t idx) noexcept { return ptr[idx]; }
+ const T &operator[](size_t idx) const noexcept { return ptr[idx]; }
private:
T* ptr;
diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h
index 06eb9bdaf..b18e04a27 100644
--- a/contrib/epee/include/storages/levin_abstract_invoke2.h
+++ b/contrib/epee/include/storages/levin_abstract_invoke2.h
@@ -34,10 +34,28 @@
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
+namespace
+{
+ template<typename context_t>
+ void on_levin_traffic(const context_t &context, bool initiator, bool sent, bool error, size_t bytes, const char *category)
+ {
+ MCINFO("net.p2p.traffic", context << bytes << " bytes " << (sent ? "sent" : "received") << (error ? "/corrupt" : "")
+ << " for category " << category << " initiated by " << (initiator ? "us" : "peer"));
+ }
+ template<typename context_t>
+ void on_levin_traffic(const context_t &context, bool initiator, bool sent, bool error, size_t bytes, int command)
+ {
+ char buf[32];
+ snprintf(buf, sizeof(buf), "command-%u", command);
+ return on_levin_traffic(context, initiator, sent, error, bytes, buf);
+ }
+}
+
namespace epee
{
namespace net_utils
{
+#if 0
template<class t_arg, class t_result, class t_transport>
bool invoke_remote_command2(int command, const t_arg& out_struct, t_result& result_struct, t_transport& transport)
{
@@ -83,16 +101,18 @@ namespace epee
}
return true;
}
+#endif
template<class t_arg, class t_result, class t_transport>
- bool invoke_remote_command2(boost::uuids::uuid conn_id, int command, const t_arg& out_struct, t_result& result_struct, t_transport& transport)
+ bool invoke_remote_command2(const epee::net_utils::connection_context_base context, int command, const t_arg& out_struct, t_result& result_struct, t_transport& transport)
{
-
+ 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);
+ 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);
if( res <=0 )
{
@@ -102,24 +122,30 @@ namespace epee
typename serialization::portable_storage stg_ret;
if(!stg_ret.load_from_binary(buff_to_recv))
{
+ on_levin_traffic(context, true, false, true, buff_to_recv.size(), command);
LOG_ERROR("Failed to load_from_binary on command " << command);
return false;
}
+ on_levin_traffic(context, true, false, false, buff_to_recv.size(), command);
return result_struct.load(stg_ret);
}
template<class t_result, class t_arg, class callback_t, class t_transport>
- bool async_invoke_remote_command2(boost::uuids::uuid conn_id, int command, const t_arg& out_struct, t_transport& transport, const callback_t &cb, size_t inv_timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
+ bool async_invoke_remote_command2(const epee::net_utils::connection_context_base &context, int command, const t_arg& out_struct, t_transport& transport, const callback_t &cb, size_t inv_timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
{
+ 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);
+ 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
{
t_result result_struct = AUTO_VAL_INIT(result_struct);
if( code <=0 )
{
+ if (!buff.empty())
+ on_levin_traffic(context, true, false, true, buff.size(), command);
LOG_PRINT_L1("Failed to invoke command " << command << " return code " << code);
cb(code, result_struct, context);
return false;
@@ -127,16 +153,19 @@ namespace epee
serialization::portable_storage stg_ret;
if(!stg_ret.load_from_binary(buff))
{
+ on_levin_traffic(context, true, false, true, buff.size(), command);
LOG_ERROR("Failed to load_from_binary on command " << command);
cb(LEVIN_ERROR_FORMAT, result_struct, context);
return false;
}
if (!result_struct.load(stg_ret))
{
+ on_levin_traffic(context, true, false, true, buff.size(), command);
LOG_ERROR("Failed to load result struct on command " << command);
cb(LEVIN_ERROR_FORMAT, result_struct, context);
return false;
}
+ on_levin_traffic(context, true, false, false, buff.size(), command);
cb(code, result_struct, context);
return true;
}, inv_timeout);
@@ -149,14 +178,15 @@ namespace epee
}
template<class t_arg, class t_transport>
- bool notify_remote_command2(boost::uuids::uuid conn_id, int command, const t_arg& out_struct, t_transport& transport)
+ bool notify_remote_command2(const typename t_transport::connection_context &context, int command, const t_arg& out_struct, t_transport& transport)
{
-
+ const boost::uuids::uuid &conn_id = context.m_connection_id;
serialization::portable_storage stg;
out_struct.store(stg);
std::string 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);
if(res <=0 )
{
@@ -173,6 +203,7 @@ namespace epee
serialization::portable_storage strg;
if(!strg.load_from_binary(in_buff))
{
+ on_levin_traffic(context, false, false, true, in_buff.size(), command);
LOG_ERROR("Failed to load_from_binary in command " << command);
return -1;
}
@@ -181,9 +212,11 @@ namespace epee
if (!static_cast<t_in_type&>(in_struct).load(strg))
{
+ on_levin_traffic(context, false, false, true, in_buff.size(), command);
LOG_ERROR("Failed to load in_struct in command " << command);
return -1;
}
+ on_levin_traffic(context, false, false, false, in_buff.size(), command);
int res = cb(command, static_cast<t_in_type&>(in_struct), static_cast<t_out_type&>(out_struct), context);
serialization::portable_storage strg_out;
static_cast<t_out_type&>(out_struct).store(strg_out);
@@ -193,6 +226,7 @@ namespace epee
LOG_ERROR("Failed to store_to_binary in command" << command);
return -1;
}
+ on_levin_traffic(context, false, true, false, buff_out.size(), command);
return res;
}
@@ -203,15 +237,18 @@ namespace epee
serialization::portable_storage strg;
if(!strg.load_from_binary(in_buff))
{
+ on_levin_traffic(context, false, false, true, in_buff.size(), command);
LOG_ERROR("Failed to load_from_binary in notify " << command);
return -1;
}
boost::value_initialized<t_in_type> in_struct;
if (!static_cast<t_in_type&>(in_struct).load(strg))
{
+ on_levin_traffic(context, false, false, true, in_buff.size(), command);
LOG_ERROR("Failed to load in_struct in notify " << command);
return -1;
}
+ on_levin_traffic(context, false, false, false, in_buff.size(), command);
return cb(command, in_struct, context);
}
@@ -296,6 +333,7 @@ namespace epee
#define END_INVOKE_MAP2() \
LOG_ERROR("Unknown command:" << command); \
+ on_levin_traffic(context, false, false, true, in_buff.size(), "invalid-command"); \
return LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED; \
}
}
diff --git a/contrib/epee/include/storages/parserse_base_utils.h b/contrib/epee/include/storages/parserse_base_utils.h
index fe53628a5..8a498130c 100644
--- a/contrib/epee/include/storages/parserse_base_utils.h
+++ b/contrib/epee/include/storages/parserse_base_utils.h
@@ -157,7 +157,6 @@ namespace misc_utils
while (fi != buf_end && ((lut[(uint8_t)*fi] & 32)) == 0)
++fi;
val.assign(it, fi);
- val.reserve(std::distance(star_end_string, buf_end));
it = fi;
for(;it != buf_end;it++)
{
diff --git a/contrib/epee/include/storages/portable_storage.h b/contrib/epee/include/storages/portable_storage.h
index d0e40d606..4b759a24f 100644
--- a/contrib/epee/include/storages/portable_storage.h
+++ b/contrib/epee/include/storages/portable_storage.h
@@ -28,6 +28,8 @@
#pragma once
+#include <type_traits>
+
#include "misc_language.h"
#include "portable_storage_base.h"
#include "portable_storage_to_bin.h"
@@ -59,7 +61,7 @@ namespace epee
bool get_value(const std::string& value_name, t_value& val, hsection hparent_section);
bool get_value(const std::string& value_name, storage_entry& val, hsection hparent_section);
template<class t_value>
- bool set_value(const std::string& value_name, const t_value& target, hsection hparent_section);
+ bool set_value(const std::string& value_name, t_value&& target, hsection hparent_section);
//serial access for arrays of values --------------------------------------
//values
@@ -68,9 +70,9 @@ namespace epee
template<class t_value>
bool get_next_value(harray hval_array, t_value& target);
template<class t_value>
- harray insert_first_value(const std::string& value_name, const t_value& target, hsection hparent_section);
+ harray insert_first_value(const std::string& value_name, t_value&& target, hsection hparent_section);
template<class t_value>
- bool insert_next_value(harray hval_array, const t_value& target);
+ bool insert_next_value(harray hval_array, t_value&& target);
//sections
harray get_first_section(const std::string& pSectionName, hsection& h_child_section, hsection hparent_section);
bool get_next_section(harray hSecArray, hsection& h_child_section);
@@ -94,7 +96,7 @@ namespace epee
hsection get_root_section() {return &m_root;}
storage_entry* find_storage_entry(const std::string& pentry_name, hsection psection);
template<class entry_type>
- storage_entry* insert_new_entry_get_storage_entry(const std::string& pentry_name, hsection psection, const entry_type& entry);
+ storage_entry* insert_new_entry_get_storage_entry(const std::string& pentry_name, hsection psection, entry_type&& entry);
hsection insert_new_section(const std::string& pentry_name, hsection psection);
@@ -241,21 +243,22 @@ namespace epee
}
//---------------------------------------------------------------------------------------------------------------
template<class t_value>
- bool portable_storage::set_value(const std::string& value_name, const t_value& v, hsection hparent_section)
+ bool portable_storage::set_value(const std::string& value_name, t_value&& v, hsection hparent_section)
{
- BOOST_MPL_ASSERT(( boost::mpl::contains<boost::mpl::push_front<storage_entry::types, storage_entry>::type, t_value> ));
+ using t_real_value = typename std::decay<t_value>::type;
+ BOOST_MPL_ASSERT(( boost::mpl::contains<boost::mpl::push_front<storage_entry::types, storage_entry>::type, t_real_value> ));
TRY_ENTRY();
if(!hparent_section)
hparent_section = &m_root;
storage_entry* pentry = find_storage_entry(value_name, hparent_section);
if(!pentry)
{
- pentry = insert_new_entry_get_storage_entry(value_name, hparent_section, v);
+ pentry = insert_new_entry_get_storage_entry(value_name, hparent_section, std::forward<t_value>(v));
if(!pentry)
return false;
return true;
}
- *pentry = storage_entry(v);
+ *pentry = std::forward<t_value>(v);
return true;
CATCH_ENTRY("portable_storage::template<>set_value", false);
}
@@ -274,11 +277,12 @@ namespace epee
}
//---------------------------------------------------------------------------------------------------------------
template<class entry_type>
- storage_entry* portable_storage::insert_new_entry_get_storage_entry(const std::string& pentry_name, hsection psection, const entry_type& entry)
+ storage_entry* portable_storage::insert_new_entry_get_storage_entry(const std::string& pentry_name, hsection psection, entry_type&& entry)
{
+ static_assert(std::is_rvalue_reference<entry_type&&>(), "unexpected copy of value");
TRY_ENTRY();
CHECK_AND_ASSERT(psection, nullptr);
- auto ins_res = psection->m_entries.insert(std::pair<std::string, storage_entry>(pentry_name, entry));
+ auto ins_res = psection->m_entries.emplace(pentry_name, std::forward<entry_type>(entry));
return &ins_res.first->second;
CATCH_ENTRY("portable_storage::insert_new_entry_get_storage_entry", nullptr);
}
@@ -362,41 +366,45 @@ namespace epee
}
//---------------------------------------------------------------------------------------------------------------
template<class t_value>
- harray portable_storage::insert_first_value(const std::string& value_name, const t_value& target, hsection hparent_section)
+ harray portable_storage::insert_first_value(const std::string& value_name, t_value&& target, hsection hparent_section)
{
+ using t_real_value = typename std::decay<t_value>::type;
+ static_assert(std::is_rvalue_reference<t_value&&>(), "unexpected copy of value");
TRY_ENTRY();
if(!hparent_section) hparent_section = &m_root;
storage_entry* pentry = find_storage_entry(value_name, hparent_section);
if(!pentry)
{
- pentry = insert_new_entry_get_storage_entry(value_name, hparent_section, array_entry(array_entry_t<t_value>()));
+ pentry = insert_new_entry_get_storage_entry(value_name, hparent_section, array_entry(array_entry_t<t_real_value>()));
if(!pentry)
return nullptr;
}
if(pentry->type() != typeid(array_entry))
- *pentry = storage_entry(array_entry(array_entry_t<t_value>()));
+ *pentry = storage_entry(array_entry(array_entry_t<t_real_value>()));
array_entry& arr = boost::get<array_entry>(*pentry);
- if(arr.type() != typeid(array_entry_t<t_value>))
- arr = array_entry(array_entry_t<t_value>());
+ if(arr.type() != typeid(array_entry_t<t_real_value>))
+ arr = array_entry(array_entry_t<t_real_value>());
- array_entry_t<t_value>& arr_typed = boost::get<array_entry_t<t_value> >(arr);
- arr_typed.insert_first_val(target);
+ array_entry_t<t_real_value>& arr_typed = boost::get<array_entry_t<t_real_value> >(arr);
+ arr_typed.insert_first_val(std::forward<t_value>(target));
return &arr;
CATCH_ENTRY("portable_storage::insert_first_value", nullptr);
}
//---------------------------------------------------------------------------------------------------------------
template<class t_value>
- bool portable_storage::insert_next_value(harray hval_array, const t_value& target)
+ bool portable_storage::insert_next_value(harray hval_array, t_value&& target)
{
+ using t_real_value = typename std::decay<t_value>::type;
+ static_assert(std::is_rvalue_reference<t_value&&>(), "unexpected copy of value");
TRY_ENTRY();
CHECK_AND_ASSERT(hval_array, false);
- CHECK_AND_ASSERT_MES(hval_array->type() == typeid(array_entry_t<t_value>),
- false, "unexpected type in insert_next_value: " << typeid(array_entry_t<t_value>).name());
+ CHECK_AND_ASSERT_MES(hval_array->type() == typeid(array_entry_t<t_real_value>),
+ false, "unexpected type in insert_next_value: " << typeid(array_entry_t<t_real_value>).name());
- array_entry_t<t_value>& arr_typed = boost::get<array_entry_t<t_value> >(*hval_array);
- arr_typed.insert_next_value(target);
+ array_entry_t<t_real_value>& arr_typed = boost::get<array_entry_t<t_real_value> >(*hval_array);
+ arr_typed.insert_next_value(std::forward<t_value>(target));
return true;
CATCH_ENTRY("portable_storage::insert_next_value", false);
}
diff --git a/contrib/epee/include/storages/portable_storage_base.h b/contrib/epee/include/storages/portable_storage_base.h
index ca7c81ddc..40c7524fb 100644
--- a/contrib/epee/include/storages/portable_storage_base.h
+++ b/contrib/epee/include/storages/portable_storage_base.h
@@ -111,16 +111,16 @@ namespace epee
return (t_entry_type*)&(*(m_it++));//fuckoff
}
- t_entry_type& insert_first_val(const t_entry_type& v)
+ t_entry_type& insert_first_val(t_entry_type&& v)
{
m_array.clear();
m_it = m_array.end();
- return insert_next_value(v);
+ return insert_next_value(std::move(v));
}
- t_entry_type& insert_next_value(const t_entry_type& v)
+ t_entry_type& insert_next_value(t_entry_type&& v)
{
- m_array.push_back(v);
+ m_array.push_back(std::move(v));
return m_array.back();
}
diff --git a/contrib/epee/include/storages/portable_storage_from_bin.h b/contrib/epee/include/storages/portable_storage_from_bin.h
index c0b6cc7b1..b39dc7c92 100644
--- a/contrib/epee/include/storages/portable_storage_from_bin.h
+++ b/contrib/epee/include/storages/portable_storage_from_bin.h
@@ -143,7 +143,7 @@ namespace epee
//TODO: add some optimization here later
while(size--)
sa.m_array.push_back(read<type_name>());
- return storage_entry(array_entry(sa));
+ return storage_entry(array_entry(std::move(sa)));
}
inline
@@ -213,7 +213,7 @@ namespace epee
{
RECURSION_LIMITATION();
section s;//use extra variable due to vs bug, line "storage_entry se(section()); " can't be compiled in visual studio
- storage_entry se(s);
+ storage_entry se(std::move(s));
section& section_entry = boost::get<section>(se);
read(section_entry);
return se;
@@ -268,7 +268,7 @@ namespace epee
//read section name string
std::string sec_name;
read_sec_name(sec_name);
- sec.m_entries.insert(std::make_pair(sec_name, load_storage_entry()));
+ sec.m_entries.emplace(std::move(sec_name), load_storage_entry());
}
}
inline
diff --git a/contrib/epee/include/storages/portable_storage_from_json.h b/contrib/epee/include/storages/portable_storage_from_json.h
index 3e3052541..2b2dc7ff9 100644
--- a/contrib/epee/include/storages/portable_storage_from_json.h
+++ b/contrib/epee/include/storages/portable_storage_from_json.h
@@ -128,20 +128,20 @@ namespace epee
errno = 0;
int64_t nval = strtoll(val.data(), NULL, 10);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- stg.set_value(name, nval, current_section);
+ stg.set_value(name, int64_t(nval), current_section);
}else
{
errno = 0;
uint64_t nval = strtoull(val.data(), NULL, 10);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- stg.set_value(name, nval, current_section);
+ stg.set_value(name, uint64_t(nval), current_section);
}
}else
{
errno = 0;
double nval = strtod(val.data(), NULL);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- stg.set_value(name, nval, current_section);
+ stg.set_value(name, double(nval), current_section);
}
state = match_state_wonder_after_value;
}else if(isalpha(*it) )
@@ -219,13 +219,13 @@ namespace epee
errno = 0;
int64_t nval = strtoll(val.data(), NULL, 10);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- h_array = stg.insert_first_value(name, nval, current_section);
+ h_array = stg.insert_first_value(name, int64_t(nval), current_section);
}else
{
errno = 0;
uint64_t nval = strtoull(val.data(), NULL, 10);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- h_array = stg.insert_first_value(name, nval, current_section);
+ h_array = stg.insert_first_value(name, uint64_t(nval), current_section);
}
CHECK_AND_ASSERT_THROW_MES(h_array, " failed to insert values section entry");
}else
@@ -233,7 +233,7 @@ namespace epee
errno = 0;
double nval = strtod(val.data(), NULL);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- h_array = stg.insert_first_value(name, nval, current_section);
+ h_array = stg.insert_first_value(name, double(nval), current_section);
CHECK_AND_ASSERT_THROW_MES(h_array, " failed to insert values section entry");
}
@@ -310,20 +310,20 @@ namespace epee
errno = 0;
int64_t nval = strtoll(val.data(), NULL, 10);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- insert_res = stg.insert_next_value(h_array, nval);
+ insert_res = stg.insert_next_value(h_array, int64_t(nval));
}else
{
errno = 0;
uint64_t nval = strtoull(val.data(), NULL, 10);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- insert_res = stg.insert_next_value(h_array, nval);
+ insert_res = stg.insert_next_value(h_array, uint64_t(nval));
}
}else
{
errno = 0;
double nval = strtod(val.data(), NULL);
if (errno) throw std::runtime_error("Invalid number: " + std::string(val));
- insert_res = stg.insert_next_value(h_array, nval);
+ insert_res = stg.insert_next_value(h_array, double(nval));
}
CHECK_AND_ASSERT_THROW_MES(insert_res, "Failed to insert next value");
state = match_state_array_after_value;
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h
index 1be5eb5e1..319c0121b 100644
--- a/contrib/epee/include/string_tools.h
+++ b/contrib/epee/include/string_tools.h
@@ -188,8 +188,10 @@ POP_WARNINGS
return boost::lexical_cast<std::string>(val);
}
//----------------------------------------------------------------------------
- inline std::string to_string_hex(uint32_t val)
+ template<typename T>
+ inline std::string to_string_hex(const T &val)
{
+ static_assert(std::is_arithmetic<T>::value, "only arithmetic types");
std::stringstream ss;
ss << std::hex << val;
std::string s;
diff --git a/contrib/epee/src/http_auth.cpp b/contrib/epee/src/http_auth.cpp
index 289069daa..5f4907cc2 100644
--- a/contrib/epee/src/http_auth.cpp
+++ b/contrib/epee/src/http_auth.cpp
@@ -584,8 +584,8 @@ namespace
explicit server_parameters(const auth_message& request, const DigestIter& digest)
: nonce(request.nonce)
, opaque(request.opaque)
- , stale(request.stale)
, realm(request.realm)
+ , stale(request.stale)
, value_generator()
, index(boost::fusion::distance(boost::fusion::begin(digest_algorithms), digest))
{
diff --git a/contrib/epee/src/net_ssl.cpp b/contrib/epee/src/net_ssl.cpp
index 16454fce0..946499129 100644
--- a/contrib/epee/src/net_ssl.cpp
+++ b/contrib/epee/src/net_ssl.cpp
@@ -43,6 +43,10 @@
// openssl req -new -key /tmp/KEY -out /tmp/REQ
// openssl x509 -req -days 999999 -sha256 -in /tmp/REQ -signkey /tmp/KEY -out /tmp/CERT
+#ifdef _WIN32
+static void add_windows_root_certs(SSL_CTX *ctx) noexcept;
+#endif
+
namespace
{
struct openssl_bio_free
@@ -285,7 +289,7 @@ ssl_options_t::ssl_options_t(std::vector<std::vector<std::uint8_t>> fingerprints
boost::asio::ssl::context ssl_options_t::create_context() const
{
- boost::asio::ssl::context ssl_context{boost::asio::ssl::context::tlsv12};
+ boost::asio::ssl::context ssl_context{boost::asio::ssl::context::tls};
if (!bool(*this))
return ssl_context;
@@ -324,7 +328,12 @@ boost::asio::ssl::context ssl_options_t::create_context() const
switch (verification)
{
case ssl_verification_t::system_ca:
+#ifdef _WIN32
+ try { add_windows_root_certs(ssl_context.native_handle()); }
+ catch (const std::exception &e) { ssl_context.set_default_verify_paths(); }
+#else
ssl_context.set_default_verify_paths();
+#endif
break;
case ssl_verification_t::user_certificates:
ssl_context.set_verify_depth(0);
@@ -558,3 +567,36 @@ bool ssl_support_from_string(ssl_support_t &ssl, boost::string_ref s)
} // namespace
} // namespace
+#ifdef _WIN32
+
+// https://stackoverflow.com/questions/40307541
+// Because Windows always has to do things wonkily
+#include <wincrypt.h>
+static void add_windows_root_certs(SSL_CTX *ctx) noexcept
+{
+ HCERTSTORE hStore = CertOpenSystemStore(0, "ROOT");
+ if (hStore == NULL) {
+ return;
+ }
+
+ X509_STORE *store = X509_STORE_new();
+ PCCERT_CONTEXT pContext = NULL;
+ while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) != NULL) {
+ // convert from DER to internal format
+ X509 *x509 = d2i_X509(NULL,
+ (const unsigned char **)&pContext->pbCertEncoded,
+ pContext->cbCertEncoded);
+ if(x509 != NULL) {
+ X509_STORE_add_cert(store, x509);
+ X509_free(x509);
+ }
+ }
+
+ CertFreeCertificateContext(pContext);
+ CertCloseStore(hStore, 0);
+
+ // attach X509_STORE to boost ssl context
+ SSL_CTX_set_cert_store(ctx, store);
+}
+#endif
+
diff --git a/contrib/gitian/gitian-build.py b/contrib/gitian/gitian-build.py
index 64eb218bb..0b36fb4a1 100755
--- a/contrib/gitian/gitian-build.py
+++ b/contrib/gitian/gitian-build.py
@@ -66,7 +66,7 @@ def rebuild():
print('\nCompiling ' + args.version + ' ' + os_name)
infile = 'inputs/monero/contrib/gitian/gitian-' + tag_name + '.yml'
subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'monero='+args.commit, '--url', 'monero='+args.url, infile])
- subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-linux', '--destination', '../sigs/', infile])
+ subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-'+tag_name, '--destination', '../sigs/', infile])
subprocess.check_call('mv build/out/monero-*.' + suffix + ' ../out/'+args.version, shell=True)
print('Moving var/install.log to var/install-' + tag_name + '.log')
subprocess.check_call('mv var/install.log var/install-' + tag_name + '.log', shell=True)