aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/depends/packages/hidapi.mk1
-rw-r--r--contrib/depends/toolchain.cmake.in2
-rw-r--r--contrib/epee/include/console_handler.h5
-rw-r--r--contrib/epee/include/misc_language.h3
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.h11
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.inl10
-rw-r--r--contrib/epee/include/net/connection_basic.hpp3
-rw-r--r--contrib/epee/include/net/http_protocol_handler.inl1
-rw-r--r--contrib/epee/include/net/levin_protocol_handler_async.h4
-rw-r--r--contrib/epee/src/connection_basic.cpp7
-rw-r--r--contrib/epee/src/mlog.cpp35
-rw-r--r--contrib/epee/src/network_throttle-detail.cpp1
12 files changed, 59 insertions, 24 deletions
diff --git a/contrib/depends/packages/hidapi.mk b/contrib/depends/packages/hidapi.mk
index d4dd80e22..1c43e525a 100644
--- a/contrib/depends/packages/hidapi.mk
+++ b/contrib/depends/packages/hidapi.mk
@@ -13,6 +13,7 @@ $(package)_config_opts_linux+=libudev_LIBS="-L$(host_prefix)/lib -ludev"
$(package)_config_opts_linux+=libudev_CFLAGS=-I$(host_prefix)/include
$(package)_config_opts_linux+=libusb_LIBS="-L$(host_prefix)/lib -lusb-1.0"
$(package)_config_opts_linux+=libusb_CFLAGS=-I$(host_prefix)/include/libusb-1.0
+$(package)_config_opts_linux+=--with-pic
endef
define $(package)_config_cmds
diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in
index f8548a724..66168facb 100644
--- a/contrib/depends/toolchain.cmake.in
+++ b/contrib/depends/toolchain.cmake.in
@@ -51,7 +51,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(APPLE True)
SET(BUILD_TAG "mac-x64")
SET(BUILD_64 ON)
+ if(NOT TRAVIS)
SET(ARCH "x86_64")
+ endif()
SET(BREW OFF)
SET(PORT OFF)
SET(CMAKE_OSX_SYSROOT "@sdk@/MacOSX10.11.sdk/")
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
index 2ccf5b095..6e7efd1d7 100644
--- a/contrib/epee/include/console_handler.h
+++ b/contrib/epee/include/console_handler.h
@@ -352,8 +352,11 @@ eof:
std::string command;
bool get_line_ret = m_stdin_reader.get_line(command);
- if (!m_running || m_stdin_reader.eos())
+ if (!m_running)
+ break;
+ if (m_stdin_reader.eos())
{
+ MGINFO("EOF on stdin, exiting");
break;
}
if (!get_line_ret)
diff --git a/contrib/epee/include/misc_language.h b/contrib/epee/include/misc_language.h
index d5157365c..7e4eb337d 100644
--- a/contrib/epee/include/misc_language.h
+++ b/contrib/epee/include/misc_language.h
@@ -147,7 +147,8 @@ namespace misc_utils
{}
~call_befor_die()
{
- m_func();
+ try { m_func(); }
+ catch (...) { /* ignore */ }
}
};
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h
index b2c05ebb0..3f726a352 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.h
+++ b/contrib/epee/include/net/abstract_tcp_server2.h
@@ -246,7 +246,6 @@ namespace net_utils
m_timer(io_serice)
{}
boost::asio::deadline_timer m_timer;
- uint64_t m_period;
};
template <class t_handler>
@@ -262,25 +261,27 @@ namespace net_utils
{
return m_handler();
}
+ uint64_t m_period;
};
template<class t_handler>
bool add_idle_handler(t_handler t_callback, uint64_t timeout_ms)
{
- boost::shared_ptr<idle_callback_conext_base> ptr(new idle_callback_conext<t_handler>(io_service_, t_callback, timeout_ms));
+ boost::shared_ptr<idle_callback_conext<t_handler>> ptr(new idle_callback_conext<t_handler>(io_service_, t_callback, timeout_ms));
//needed call handler here ?...
ptr->m_timer.expires_from_now(boost::posix_time::milliseconds(ptr->m_period));
- ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler, this, ptr));
+ ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler<t_handler>, this, ptr));
return true;
}
- bool global_timer_handler(/*const boost::system::error_code& err, */boost::shared_ptr<idle_callback_conext_base> ptr)
+ template<class t_handler>
+ bool global_timer_handler(/*const boost::system::error_code& err, */boost::shared_ptr<idle_callback_conext<t_handler>> ptr)
{
//if handler return false - he don't want to be called anymore
if(!ptr->call_handler())
return true;
ptr->m_timer.expires_from_now(boost::posix_time::milliseconds(ptr->m_period));
- ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler, this, ptr));
+ ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler<t_handler>, this, ptr));
return true;
}
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 3a5c83017..5dbb7a478 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -43,6 +43,8 @@
#include <boost/date_time/posix_time/posix_time.hpp> // TODO
#include <boost/thread/thread.hpp> // TODO
#include <boost/thread/condition_variable.hpp> // TODO
+#include "warnings.h"
+#include "string_tools.h"
#include "misc_language.h"
#include "net/local_ip.h"
#include "pragma_comp_defs.h"
@@ -51,8 +53,6 @@
#include <iomanip>
#include <algorithm>
-#include "../../../../src/cryptonote_core/cryptonote_core.h" // e.g. for the send_stop_signal()
-
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
@@ -149,10 +149,8 @@ PRAGMA_WARNING_DISABLE_VS(4355)
const unsigned long ip_{boost::asio::detail::socket_ops::host_to_network_long(remote_ep.address().to_v4().to_ulong())};
m_local = epee::net_utils::is_ip_loopback(ip_) || epee::net_utils::is_ip_local(ip_);
- // create a random uuid
- boost::uuids::uuid random_uuid;
- // that stuff turns out to be included, even though it's from src... Taking advantage
- random_uuid = crypto::rand<boost::uuids::uuid>();
+ // create a random uuid, we don't need crypto strength here
+ const boost::uuids::uuid random_uuid = boost::uuids::random_generator()();
context.set_details(random_uuid, epee::net_utils::ipv4_network_address(ip_, remote_ep.port()), is_income);
_dbg3("[sock " << socket_.native_handle() << "] new connection from " << print_connection_context_short(context) <<
diff --git a/contrib/epee/include/net/connection_basic.hpp b/contrib/epee/include/net/connection_basic.hpp
index 095e747a5..7e8750047 100644
--- a/contrib/epee/include/net/connection_basic.hpp
+++ b/contrib/epee/include/net/connection_basic.hpp
@@ -92,7 +92,6 @@ class connection_basic { // not-templated base class for rapid developmet of som
critical_section m_send_que_lock;
std::list<std::string> m_send_que;
volatile bool m_is_multithreaded;
- double m_start_time;
/// Strand to ensure the connection's handlers are not called concurrently.
boost::asio::io_service::strand strand_;
/// Socket for the connection.
@@ -112,8 +111,6 @@ class connection_basic { // not-templated base class for rapid developmet of som
void logger_handle_net_write(size_t size); // network data written
void logger_handle_net_read(size_t size); // network data read
- void set_start_time();
-
// config for rate limit
static void set_rate_up_limit(uint64_t limit);
diff --git a/contrib/epee/include/net/http_protocol_handler.inl b/contrib/epee/include/net/http_protocol_handler.inl
index 76db5346f..b53bdc200 100644
--- a/contrib/epee/include/net/http_protocol_handler.inl
+++ b/contrib/epee/include/net/http_protocol_handler.inl
@@ -32,6 +32,7 @@
#include "string_tools.h"
#include "file_io_utils.h"
#include "net_parse_helpers.h"
+#include "time_helper.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.http"
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h
index e9853ee26..08aa1d468 100644
--- a/contrib/epee/include/net/levin_protocol_handler_async.h
+++ b/contrib/epee/include/net/levin_protocol_handler_async.h
@@ -99,7 +99,7 @@ public:
size_t get_connections_count();
void set_handler(levin_commands_handler<t_connection_context>* handler, void (*destroy)(levin_commands_handler<t_connection_context>*) = NULL);
- async_protocol_handler_config():m_pcommands_handler(NULL), m_pcommands_handler_destroy(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE)
+ async_protocol_handler_config():m_pcommands_handler(NULL), m_pcommands_handler_destroy(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_invoke_timeout(LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
{}
~async_protocol_handler_config() { set_handler(NULL, NULL); }
void del_out_connections(size_t count);
@@ -272,6 +272,8 @@ public:
m_wait_count = 0;
m_oponent_protocol_ver = 0;
m_connection_initialized = false;
+ m_invoke_buf_ready = 0;
+ m_invoke_result_code = LEVIN_ERROR_CONNECTION;
}
virtual ~async_protocol_handler()
{
diff --git a/contrib/epee/src/connection_basic.cpp b/contrib/epee/src/connection_basic.cpp
index dea1928a7..9ab485839 100644
--- a/contrib/epee/src/connection_basic.cpp
+++ b/contrib/epee/src/connection_basic.cpp
@@ -250,22 +250,15 @@ void connection_basic::sleep_before_packet(size_t packet_size, int phase, int q
}
}
-void connection_basic::set_start_time() {
- CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out );
- m_start_time = network_throttle_manager::get_global_throttle_out().get_time_seconds();
-}
void connection_basic::do_send_handler_write(const void* ptr , size_t cb ) {
// No sleeping here; sleeping is done once and for all in connection<t_protocol_handler>::handle_write
MTRACE("handler_write (direct) - before ASIO write, for packet="<<cb<<" B (after sleep)");
- set_start_time();
}
void connection_basic::do_send_handler_write_from_queue( const boost::system::error_code& e, size_t cb, int q_len ) {
// No sleeping here; sleeping is done once and for all in connection<t_protocol_handler>::handle_write
MTRACE("handler_write (after write, from queue="<<q_len<<") - before ASIO write, for packet="<<cb<<" B (after sleep)");
-
- set_start_time();
}
void connection_basic::logger_handle_net_read(size_t size) { // network data read
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index 61d853ef4..638155b6b 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -28,6 +28,13 @@
#ifndef _MLOG_H_
#define _MLOG_H_
+#ifdef _WIN32
+#include <windows.h>
+#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
+#endif
+#endif
+
#include <time.h>
#include <atomic>
#include <boost/filesystem.hpp>
@@ -117,6 +124,31 @@ static const char *get_default_categories(int level)
return categories;
}
+#ifdef WIN32
+bool EnableVTMode()
+{
+ // Set output mode to handle virtual terminal sequences
+ HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (hOut == INVALID_HANDLE_VALUE)
+ {
+ return false;
+ }
+
+ DWORD dwMode = 0;
+ if (!GetConsoleMode(hOut, &dwMode))
+ {
+ return false;
+ }
+
+ dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+ if (!SetConsoleMode(hOut, dwMode))
+ {
+ return false;
+ }
+ return true;
+}
+#endif
+
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size, const std::size_t max_log_files)
{
el::Configurations c;
@@ -202,6 +234,9 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s
monero_log = get_default_categories(0);
}
mlog_set_log(monero_log);
+#ifdef WIN32
+ EnableVTMode();
+#endif
}
void mlog_set_categories(const char *categories)
diff --git a/contrib/epee/src/network_throttle-detail.cpp b/contrib/epee/src/network_throttle-detail.cpp
index 7eeade3a1..28c85bb78 100644
--- a/contrib/epee/src/network_throttle-detail.cpp
+++ b/contrib/epee/src/network_throttle-detail.cpp
@@ -146,6 +146,7 @@ network_throttle::network_throttle(const std::string &nameshort, const std::stri
m_network_add_cost = 128;
m_network_minimal_segment = 256;
m_network_max_segment = 1024*1024;
+ m_start_time = 0;
m_any_packet_yet = false;
m_slot_size = 1.0; // hard coded in few places
m_target_speed = 16 * 1024; // other defaults are probably defined in the command-line parsing code when this class is used e.g. as main global throttle