aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--contrib/epee/src/mlog.cpp4
-rw-r--r--contrib/epee/src/net_utils_base.cpp30
-rw-r--r--contrib/epee/src/readline_buffer.cpp1
-rw-r--r--contrib/epee/src/string_tools.cpp12
4 files changed, 47 insertions, 0 deletions
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index 74b7dd2f4..a30efbc6a 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -28,7 +28,11 @@
#ifndef _MLOG_H_
#define _MLOG_H_
+#include <time.h>
#include <atomic>
+#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
+#include "string_tools.h"
#include "misc_log_ex.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
diff --git a/contrib/epee/src/net_utils_base.cpp b/contrib/epee/src/net_utils_base.cpp
index 22afcf819..2f4015e81 100644
--- a/contrib/epee/src/net_utils_base.cpp
+++ b/contrib/epee/src/net_utils_base.cpp
@@ -1,5 +1,6 @@
#include "net/net_utils_base.h"
+#include "string_tools.h"
#include <cstring>
#include <typeindex>
@@ -56,5 +57,34 @@ namespace epee { namespace net_utils
if (typeid(*self_) != typeid(*other_self)) return false;
return self_->is_same_host(*other_self);
}
+
+ bool create_network_address(network_address &address, const std::string &string, uint16_t default_port)
+ {
+ uint32_t ip;
+ uint16_t port;
+ if (epee::string_tools::parse_peer_from_string(ip, port, string))
+ {
+ if (default_port && !port)
+ port = default_port;
+ address = ipv4_network_address{ip, port};
+ return true;
+ }
+ return false;
+ }
+
+ std::string print_connection_context(const connection_context_base& ctx)
+ {
+ std::stringstream ss;
+ ss << ctx.m_remote_address.str() << " " << epee::string_tools::get_str_from_guid_a(ctx.m_connection_id) << (ctx.m_is_income ? " INC":" OUT");
+ return ss.str();
+ }
+
+ std::string print_connection_context_short(const connection_context_base& ctx)
+ {
+ std::stringstream ss;
+ ss << ctx.m_remote_address.str() << (ctx.m_is_income ? " INC":" OUT");
+ return ss.str();
+ }
+
}}
diff --git a/contrib/epee/src/readline_buffer.cpp b/contrib/epee/src/readline_buffer.cpp
index 291bba94c..00c2ddd62 100644
--- a/contrib/epee/src/readline_buffer.cpp
+++ b/contrib/epee/src/readline_buffer.cpp
@@ -3,6 +3,7 @@
#include <readline/history.h>
#include <sys/select.h>
#include <unistd.h>
+#include <iostream>
#include <boost/thread.hpp>
#include <boost/algorithm/string.hpp>
diff --git a/contrib/epee/src/string_tools.cpp b/contrib/epee/src/string_tools.cpp
index d04b16b75..fd0254016 100644
--- a/contrib/epee/src/string_tools.cpp
+++ b/contrib/epee/src/string_tools.cpp
@@ -26,6 +26,8 @@
#include "string_tools.h"
+#include <ctype.h>
+
#ifdef _WIN32
# include <winsock2.h>
#else
@@ -56,6 +58,16 @@ namespace string_tools
return true;
}
+ //----------------------------------------------------------------------------
+ bool validate_hex(uint64_t length, const std::string& str)
+ {
+ if (str.size() != length)
+ return false;
+ for (char c: str)
+ if (!isxdigit(c))
+ return false;
+ return true;
+ }
}
}