diff options
Diffstat (limited to 'contrib/epee')
-rw-r--r-- | contrib/epee/include/console_handler.h | 25 | ||||
-rw-r--r-- | contrib/epee/include/misc_language.h | 10 | ||||
-rw-r--r-- | contrib/epee/include/net/abstract_http_client.h | 1 | ||||
-rw-r--r-- | contrib/epee/include/net/http_client.h | 8 | ||||
-rw-r--r-- | contrib/epee/include/rolling_median.h | 4 | ||||
-rw-r--r-- | contrib/epee/src/abstract_http_client.cpp | 5 |
6 files changed, 43 insertions, 10 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/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; + } } } } |