aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/console_handler.h25
-rw-r--r--contrib/epee/include/misc_language.h10
-rw-r--r--contrib/epee/include/net/abstract_http_client.h1
-rw-r--r--contrib/epee/include/net/http_client.h8
-rw-r--r--contrib/epee/include/net/local_ip.h26
-rw-r--r--contrib/epee/include/rolling_median.h4
-rw-r--r--contrib/epee/src/abstract_http_client.cpp5
7 files changed, 43 insertions, 36 deletions
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
index 08d9b8802..219b593b0 100644
--- a/contrib/epee/include/console_handler.h
+++ b/contrib/epee/include/console_handler.h
@@ -543,6 +543,31 @@ eof:
return it->second.second;
}
+ std::vector<std::string> get_command_list(const std::vector<std::string>& keywords = std::vector<std::string>())
+ {
+ std::vector<std::string> list;
+ list.reserve(m_command_handlers.size());
+ for(auto const& x:m_command_handlers)
+ {
+ bool take = true;
+ for(auto const& y:keywords)
+ {
+ bool in_usage = x.second.second.first.find(y) != std::string::npos;
+ bool in_description = x.second.second.second.find(y) != std::string::npos;
+ if (!(in_usage || in_description))
+ {
+ take = false;
+ break;
+ }
+ }
+ if (take)
+ {
+ list.push_back(x.first);
+ }
+ }
+ return list;
+ }
+
void set_handler(const std::string& cmd, const callback& hndlr, const std::string& usage = "", const std::string& description = "")
{
lookup::mapped_type & vt = m_command_handlers[cmd];
diff --git a/contrib/epee/include/misc_language.h b/contrib/epee/include/misc_language.h
index 5f7202150..a04c63231 100644
--- a/contrib/epee/include/misc_language.h
+++ b/contrib/epee/include/misc_language.h
@@ -106,6 +106,14 @@ namespace misc_utils
return true;
}
+ template <typename T>
+ T get_mid(const T &a, const T &b)
+ {
+ //returns the average of two numbers; overflow safe and works with at least all integral and floating point types
+ //(a+b)/2 = (a/2) + (b/2) + ((a - 2*(a/2)) + (b - 2*(b/2)))/2
+ return (a/2) + (b/2) + ((a - 2*(a/2)) + (b - 2*(b/2)))/2;
+ }
+
template<class type_vec_type>
type_vec_type median(std::vector<type_vec_type> &v)
{
@@ -122,7 +130,7 @@ namespace misc_utils
return v[n];
}else
{//2, 4, 6...
- return (v[n-1] + v[n])/2;
+ return get_mid<type_vec_type>(v[n-1],v[n]);
}
}
diff --git a/contrib/epee/include/net/abstract_http_client.h b/contrib/epee/include/net/abstract_http_client.h
index 787ae2667..1f8bbc605 100644
--- a/contrib/epee/include/net/abstract_http_client.h
+++ b/contrib/epee/include/net/abstract_http_client.h
@@ -64,6 +64,7 @@ namespace http
abstract_http_client() {}
virtual ~abstract_http_client() {}
bool set_server(const std::string& address, boost::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect);
+ virtual bool set_proxy(const std::string& address);
virtual void set_server(std::string host, std::string port, boost::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect) = 0;
virtual void set_auto_connect(bool auto_connect) = 0;
virtual bool connect(std::chrono::milliseconds timeout) = 0;
diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h
index 86df48f65..9645e896b 100644
--- a/contrib/epee/include/net/http_client.h
+++ b/contrib/epee/include/net/http_client.h
@@ -885,14 +885,6 @@ namespace net_utils
}
};
typedef http_simple_client_template<blocked_mode_client> http_simple_client;
-
- class http_simple_client_factory : public http_client_factory
- {
- public:
- std::unique_ptr<abstract_http_client> create() override {
- return std::unique_ptr<epee::net_utils::http::abstract_http_client>(new epee::net_utils::http::http_simple_client());
- }
- };
}
}
}
diff --git a/contrib/epee/include/net/local_ip.h b/contrib/epee/include/net/local_ip.h
index 246cf6ad8..1eeab2dc5 100644
--- a/contrib/epee/include/net/local_ip.h
+++ b/contrib/epee/include/net/local_ip.h
@@ -28,8 +28,6 @@
#pragma once
#include <string>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/asio/ip/address_v6.hpp>
#include "int-util.h"
// IP addresses are kept in network byte order
@@ -40,30 +38,6 @@ namespace epee
{
namespace net_utils
{
-
- inline
- bool is_ipv6_local(const std::string& ip)
- {
- auto addr = boost::asio::ip::address_v6::from_string(ip);
-
- // ipv6 link-local unicast addresses are fe80::/10
- bool is_link_local = addr.is_link_local();
-
- auto addr_bytes = addr.to_bytes();
-
- // ipv6 unique local unicast addresses start with fc00::/7 -- (fcXX or fdXX)
- bool is_unique_local_unicast = (addr_bytes[0] == 0xfc || addr_bytes[0] == 0xfd);
-
- return is_link_local || is_unique_local_unicast;
- }
-
- inline
- bool is_ipv6_loopback(const std::string& ip)
- {
- // ipv6 loopback is ::1
- return boost::asio::ip::address_v6::from_string(ip).is_loopback();
- }
-
inline
bool is_ip_local(uint32_t ip)
{
diff --git a/contrib/epee/include/rolling_median.h b/contrib/epee/include/rolling_median.h
index 11275aa70..088a71d3e 100644
--- a/contrib/epee/include/rolling_median.h
+++ b/contrib/epee/include/rolling_median.h
@@ -34,6 +34,8 @@
#pragma once
+#include "misc_language.h"
+
#include <stdlib.h>
#include <stdint.h>
@@ -226,7 +228,7 @@ public:
Item v = data[heap[0]];
if (minCt < maxCt)
{
- v = (v + data[heap[-1]]) / 2;
+ v = get_mid<Item>(v, data[heap[-1]]);
}
return v;
}
diff --git a/contrib/epee/src/abstract_http_client.cpp b/contrib/epee/src/abstract_http_client.cpp
index 98b5b67d9..540917873 100644
--- a/contrib/epee/src/abstract_http_client.cpp
+++ b/contrib/epee/src/abstract_http_client.cpp
@@ -137,6 +137,11 @@ namespace http
set_server(std::move(parsed.host), std::to_string(parsed.port), std::move(user), std::move(ssl_options));
return true;
}
+
+ bool epee::net_utils::http::abstract_http_client::set_proxy(const std::string& address)
+ {
+ return false;
+ }
}
}
}