upstream #447

Merged
wowario merged 13 commits from wowario/wownero:dev-upstream into dev 1 year ago

@ -158,6 +158,7 @@ jobs:
- name: tests - name: tests
env: env:
CTEST_OUTPUT_ON_FAILURE: ON CTEST_OUTPUT_ON_FAILURE: ON
DNS_PUBLIC: tcp://9.9.9.9
run: | run: |
${{env.CCACHE_SETTINGS}} ${{env.CCACHE_SETTINGS}}
${{env.BUILD_DEFAULT_LINUX}} ${{env.BUILD_DEFAULT_LINUX}}

@ -814,7 +814,7 @@ else()
set(USE_LTO_DEFAULT false) set(USE_LTO_DEFAULT false)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,10485760") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,10485760")
if(NOT BUILD_64) if(NOT BUILD_64)
add_definitions(-DWINVER=0x0501 -D_WIN32_WINNT=0x0501) add_definitions(-DWINVER=0x0600 -D_WIN32_WINNT=0x0600)
endif() endif()
endif() endif()
set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes") set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes")
@ -1159,7 +1159,9 @@ if (HIDAPI_FOUND OR LibUSB_COMPILE_TEST_PASSED)
endif() endif()
endif() endif()
option(USE_READLINE "Build with GNU readline support." ON) if(NOT OPENBSD)
option(USE_READLINE "Build with GNU readline support." ON)
endif()
if(USE_READLINE AND NOT DEPENDS) if(USE_READLINE AND NOT DEPENDS)
find_package(Readline) find_package(Readline)
if(READLINE_FOUND AND GNU_READLINE_FOUND) if(READLINE_FOUND AND GNU_READLINE_FOUND)

@ -72,7 +72,6 @@ namespace http
virtual bool is_connected(bool *ssl = NULL) = 0; virtual bool is_connected(bool *ssl = NULL) = 0;
virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0; virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual bool invoke_get(const boost::string_ref uri, std::chrono::milliseconds timeout, const std::string& body = std::string(), const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0; virtual bool invoke_get(const boost::string_ref uri, std::chrono::milliseconds timeout, const std::string& body = std::string(), const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual bool invoke_post(const boost::string_ref uri, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual uint64_t get_bytes_sent() const = 0; virtual uint64_t get_bytes_sent() const = 0;
virtual uint64_t get_bytes_received() const = 0; virtual uint64_t get_bytes_received() const = 0;
}; };

@ -55,20 +55,8 @@ namespace net_utils
http_method_unknown http_method_unknown
}; };
enum http_content_type
{
http_content_type_text_html,
http_content_type_image_gif,
http_content_type_other,
http_content_type_not_set
};
typedef std::list<std::pair<std::string, std::string> > fields_list; typedef std::list<std::pair<std::string, std::string> > fields_list;
std::string get_value_from_fields_list(const std::string& param_name, const net_utils::http::fields_list& fields);
std::string get_value_from_uri_line(const std::string& param_name, const std::string& uri);
static inline void add_field(std::string& out, const boost::string_ref name, const boost::string_ref value) static inline void add_field(std::string& out, const boost::string_ref name, const boost::string_ref value)
{ {
out.append(name.data(), name.size()).append(": "); out.append(name.data(), name.size()).append(": ");

@ -32,7 +32,6 @@
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/optional/optional.hpp> #include <boost/optional/optional.hpp>
#include <boost/utility/string_ref.hpp> #include <boost/utility/string_ref.hpp>
//#include <mbstring.h>
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
#include <functional> #include <functional>
@ -48,57 +47,13 @@
#include "net_parse_helpers.h" #include "net_parse_helpers.h"
#include "syncobj.h" #include "syncobj.h"
//#include "shlwapi.h"
//#pragma comment(lib, "shlwapi.lib")
#undef MONERO_DEFAULT_LOG_CATEGORY #undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.http" #define MONERO_DEFAULT_LOG_CATEGORY "net.http"
extern epee::critical_section gregexp_lock;
namespace epee namespace epee
{ {
namespace net_utils namespace net_utils
{ {
/*struct url
{
public:
void parse(const std::string& url_s)
{
const string prot_end("://");
string::const_iterator prot_i = search(url_s.begin(), url_s.end(),
prot_end.begin(), prot_end.end());
protocol_.reserve(distance(url_s.begin(), prot_i));
transform(url_s.begin(), prot_i,
back_inserter(protocol_),
ptr_fun<int,int>(tolower)); // protocol is icase
if( prot_i == url_s.end() )
return;
advance(prot_i, prot_end.length());
string::const_iterator path_i = find(prot_i, url_s.end(), '/');
host_.reserve(distance(prot_i, path_i));
transform(prot_i, path_i,
back_inserter(host_),
ptr_fun<int,int>(tolower)); // host is icase
string::const_iterator query_i = find(path_i, url_s.end(), '?');
path_.assign(path_i, query_i);
if( query_i != url_s.end() )
++query_i;
query_.assign(query_i, url_s.end());
}
std::string protocol_;
std::string host_;
std::string path_;
std::string query_;
};*/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
namespace http namespace http
{ {
@ -135,7 +90,6 @@ namespace net_utils
http_response_info m_response_info; http_response_info m_response_info;
size_t m_len_in_summary; size_t m_len_in_summary;
size_t m_len_in_remain; size_t m_len_in_remain;
//std::string* m_ptarget_buffer;
boost::shared_ptr<i_sub_handler> m_pcontent_encoding_handler; boost::shared_ptr<i_sub_handler> m_pcontent_encoding_handler;
reciev_machine_state m_state; reciev_machine_state m_state;
chunked_state m_chunked_state; chunked_state m_chunked_state;
@ -300,12 +254,6 @@ namespace net_utils
return false; return false;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
inline bool invoke_post(const boost::string_ref uri, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) override
{
CRITICAL_REGION_LOCAL(m_lock);
return invoke(uri, "POST", body, timeout, ppresponse_info, additional_params);
}
//---------------------------------------------------------------------------
bool test(const std::string &s, std::chrono::milliseconds timeout) // TEST FUNC ONLY bool test(const std::string &s, std::chrono::milliseconds timeout) // TEST FUNC ONLY
{ {
CRITICAL_REGION_LOCAL(m_lock); CRITICAL_REGION_LOCAL(m_lock);

@ -37,7 +37,6 @@ monero_add_library(epee byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_cli
misc_language.cpp misc_language.cpp
file_io_utils.cpp file_io_utils.cpp
net_parse_helpers.cpp net_parse_helpers.cpp
http_base.cpp
${EPEE_HEADERS_PUBLIC} ${EPEE_HEADERS_PUBLIC}
) )

@ -1,71 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Andrey N. Sabelnikov nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include "net/http_base.h"
#include "memwipe.h"
#include "string_tools.h"
#include <boost/regex.hpp>
#include <string>
#include <utility>
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.http"
namespace epee
{
namespace net_utils
{
namespace http
{
std::string get_value_from_fields_list(const std::string& param_name, const net_utils::http::fields_list& fields)
{
fields_list::const_iterator it = fields.begin();
for(; it != fields.end(); ++it)
if(!string_tools::compare_no_case(param_name, it->first))
break;
if(it==fields.end())
return std::string();
return it->second;
}
std::string get_value_from_uri_line(const std::string& param_name, const std::string& uri)
{
std::string buff = "([\\?|&])";
buff += param_name + "=([^&]*)";
boost::regex match_param(buff.c_str(), boost::regex::icase | boost::regex::normal);
boost::smatch result;
if(boost::regex_search(uri, result, match_param, boost::match_default) && result[0].matched)
{
return result[2];
}
return std::string();
}
}
}
}

Binary file not shown.

@ -227,6 +227,7 @@ namespace cryptonote
ADD_CHECKPOINT2(334000, "17d3b15f8e1a73e1c61335ee7979e9e3d211b9055e8a7fb2481e5f49a51b1c22", "0x7ddd5a79d69c4"); ADD_CHECKPOINT2(334000, "17d3b15f8e1a73e1c61335ee7979e9e3d211b9055e8a7fb2481e5f49a51b1c22", "0x7ddd5a79d69c4");
ADD_CHECKPOINT2(348500, "2d43a157f369e2aa26a329b56456142ecd1361f5808c688d97112a2e3bbd23f4", "0x90889ed877ada"); ADD_CHECKPOINT2(348500, "2d43a157f369e2aa26a329b56456142ecd1361f5808c688d97112a2e3bbd23f4", "0x90889ed877ada");
ADD_CHECKPOINT2(489400, "b14f49eae77398117ea93435676100d8b655a804689f73a5a4d0d5e71160d603", "0x1123c39bb52f7e"); ADD_CHECKPOINT2(489400, "b14f49eae77398117ea93435676100d8b655a804689f73a5a4d0d5e71160d603", "0x1123c39bb52f7e");
ADD_CHECKPOINT2(491200, "cedba73ad35ce7f51aaca2beb36dc32d79ecc716d146eb8211e6a815f3666c4a", "0x11334734abbd17");
return true; return true;
} }

@ -30,6 +30,8 @@
// check local first (in the event of static or in-source compilation of libunbound) // check local first (in the event of static or in-source compilation of libunbound)
#include "unbound.h" #include "unbound.h"
#include <deque>
#include <set>
#include <stdlib.h> #include <stdlib.h>
#include "include_base_utils.h" #include "include_base_utils.h"
#include "common/threadpool.h" #include "common/threadpool.h"
@ -320,11 +322,6 @@ std::vector<std::string> DNSResolver::get_record(const std::string& url, int rec
dnssec_available = false; dnssec_available = false;
dnssec_valid = false; dnssec_valid = false;
if (!check_address_syntax(url.c_str()))
{
return addresses;
}
// destructor takes care of cleanup // destructor takes care of cleanup
ub_result_ptr result; ub_result_ptr result;
@ -407,16 +404,6 @@ DNSResolver DNSResolver::create()
return DNSResolver(); return DNSResolver();
} }
bool DNSResolver::check_address_syntax(const char *addr) const
{
// if string doesn't contain a dot, we won't consider it a url for now.
if (strchr(addr,'.') == NULL)
{
return false;
}
return true;
}
namespace dns_utils namespace dns_utils
{ {

@ -159,15 +159,6 @@ private:
// TODO: modify this to accommodate DNSSEC // TODO: modify this to accommodate DNSSEC
std::vector<std::string> get_record(const std::string& url, int record_type, boost::optional<std::string> (*reader)(const char *,size_t), bool& dnssec_available, bool& dnssec_valid); std::vector<std::string> get_record(const std::string& url, int record_type, boost::optional<std::string> (*reader)(const char *,size_t), bool& dnssec_available, bool& dnssec_valid);
/**
* @brief Checks a string to see if it looks like a URL
*
* @param addr the string to be checked
*
* @return true if it looks enough like a URL, false if not
*/
bool check_address_syntax(const char *addr) const;
DNSResolverData *m_data; DNSResolverData *m_data;
}; // class DNSResolver }; // class DNSResolver

@ -31,6 +31,7 @@
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp> #include <boost/thread/thread.hpp>
#include <cstddef> #include <cstddef>
#include <deque>
#include <functional> #include <functional>
#include <utility> #include <utility>
#include <vector> #include <vector>

@ -38,7 +38,6 @@ DISABLE_VS_WARNINGS(4146 4244)
/* Predeclarations */ /* Predeclarations */
static void fe_mul(fe, const fe, const fe);
static void fe_sq(fe, const fe); static void fe_sq(fe, const fe);
static void ge_madd(ge_p1p1 *, const ge_p3 *, const ge_precomp *); static void ge_madd(ge_p1p1 *, const ge_p3 *, const ge_precomp *);
static void ge_msub(ge_p1p1 *, const ge_p3 *, const ge_precomp *); static void ge_msub(ge_p1p1 *, const ge_p3 *, const ge_precomp *);
@ -72,7 +71,7 @@ uint64_t load_4(const unsigned char *in)
h = 0 h = 0
*/ */
static void fe_0(fe h) { void fe_0(fe h) {
h[0] = 0; h[0] = 0;
h[1] = 0; h[1] = 0;
h[2] = 0; h[2] = 0;
@ -375,7 +374,7 @@ Can get away with 11 carries, but then data flow is much deeper.
With tighter constraints on inputs can squeeze carries into int32. With tighter constraints on inputs can squeeze carries into int32.
*/ */
static void fe_mul(fe h, const fe f, const fe g) { void fe_mul(fe h, const fe f, const fe g) {
int32_t f0 = f[0]; int32_t f0 = f[0];
int32_t f1 = f[1]; int32_t f1 = f[1];
int32_t f2 = f[2]; int32_t f2 = f[2];

@ -30,6 +30,8 @@
#pragma once #pragma once
#include <stdint.h>
/* From fe.h */ /* From fe.h */
typedef int32_t fe[10]; typedef int32_t fe[10];
@ -161,5 +163,7 @@ void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q);
void fe_add(fe h, const fe f, const fe g); void fe_add(fe h, const fe f, const fe g);
void fe_tobytes(unsigned char *, const fe); void fe_tobytes(unsigned char *, const fe);
void fe_invert(fe out, const fe z); void fe_invert(fe out, const fe z);
void fe_mul(fe out, const fe, const fe);
void fe_0(fe h);
int ge_p3_is_point_at_infinity_vartime(const ge_p3 *p); int ge_p3_is_point_at_infinity_vartime(const ge_p3 *p);

@ -335,8 +335,16 @@ namespace crypto {
inline bool operator<(const public_key &p1, const public_key &p2) { return memcmp(&p1, &p2, sizeof(public_key)) < 0; } inline bool operator<(const public_key &p1, const public_key &p2) { return memcmp(&p1, &p2, sizeof(public_key)) < 0; }
inline bool operator>(const public_key &p1, const public_key &p2) { return p2 < p1; } inline bool operator>(const public_key &p1, const public_key &p2) { return p2 < p1; }
inline bool operator<(const key_image &p1, const key_image &p2) { return memcmp(&p1, &p2, sizeof(key_image)) < 0; }
inline bool operator>(const key_image &p1, const key_image &p2) { return p2 < p1; }
} }
// type conversions for easier calls to sc_add(), sc_sub(), hash functions
inline unsigned char* to_bytes(crypto::ec_scalar &scalar) { return &reinterpret_cast<unsigned char&>(scalar); }
inline const unsigned char* to_bytes(const crypto::ec_scalar &scalar) { return &reinterpret_cast<const unsigned char&>(scalar); }
inline unsigned char* to_bytes(crypto::ec_point &point) { return &reinterpret_cast<unsigned char&>(point); }
inline const unsigned char* to_bytes(const crypto::ec_point &point) { return &reinterpret_cast<const unsigned char&>(point); }
CRYPTO_MAKE_HASHABLE(public_key) CRYPTO_MAKE_HASHABLE(public_key)
CRYPTO_MAKE_HASHABLE_CONSTANT_TIME(secret_key) CRYPTO_MAKE_HASHABLE_CONSTANT_TIME(secret_key)
CRYPTO_MAKE_HASHABLE_CONSTANT_TIME(public_key_memsafe) CRYPTO_MAKE_HASHABLE_CONSTANT_TIME(public_key_memsafe)

@ -48,7 +48,6 @@
#include "file_io_utils.h" #include "file_io_utils.h"
#include "int-util.h" #include "int-util.h"
#include "common/threadpool.h" #include "common/threadpool.h"
#include "common/boost_serialization_helper.h"
#include "warnings.h" #include "warnings.h"
#include "crypto/hash.h" #include "crypto/hash.h"
#include "cryptonote_core.h" #include "cryptonote_core.h"
@ -5730,7 +5729,7 @@ void Blockchain::cancel()
} }
#if defined(PER_BLOCK_CHECKPOINT) #if defined(PER_BLOCK_CHECKPOINT)
static const char expected_block_hashes_hash[] = "cdb3d018fc4c2505619423a24b2d694348103df9af9a3f4f0cc203f4e21363bd"; static const char expected_block_hashes_hash[] = "8de0d27f32eb1589dc297314dcd9c419bd69cae8e9d5a7705c1bc6d8bdd3d4a7";
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints) void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
{ {
if (get_checkpoints == nullptr || !m_fast_sync) if (get_checkpoints == nullptr || !m_fast_sync)

@ -40,7 +40,6 @@
#include "blockchain.h" #include "blockchain.h"
#include "blockchain_db/locked_txn.h" #include "blockchain_db/locked_txn.h"
#include "blockchain_db/blockchain_db.h" #include "blockchain_db/blockchain_db.h"
#include "common/boost_serialization_helper.h"
#include "int-util.h" #include "int-util.h"
#include "misc_language.h" #include "misc_language.h"
#include "warnings.h" #include "warnings.h"

@ -1687,7 +1687,7 @@ namespace cryptonote
switch (num) switch (num)
{ {
case 1: case 1:
MGINFO_MAGENTA("*•.¸♡ ♡¸.•* synced *•.¸♡ ♡¸.•* " << current_blockchain_height << "/" << target_blockchain_height << progress_message << timing_message << " ˚ ༘♡ ⋆。˚"); MGINFO_MAGENTA("*•.¸♡ ♡¸.•* synced *•.¸♡ ♡¸.•* " << current_blockchain_height << "/" << target_blockchain_height << progress_message << timing_message << " ˚ ༘♡ ⋆。˚");
break; break;
case 2: case 2:
MGINFO_YELLOW("ˏˋ°•*⁀➷ pǝɔuʎs ˏˋ°•*⁀➷ " << current_blockchain_height << "/" << target_blockchain_height << progress_message << timing_message << " ︶︶༉‧₊ ☄. *.⋆"); MGINFO_YELLOW("ˏˋ°•*⁀➷ pǝɔuʎs ˏˋ°•*⁀➷ " << current_blockchain_height << "/" << target_blockchain_height << progress_message << timing_message << " ︶︶༉‧₊ ☄. *.⋆");

@ -38,7 +38,7 @@ namespace net
{ {
void get_network_address_host_and_port(const std::string& address, std::string& host, std::string& port) void get_network_address_host_and_port(const std::string& address, std::string& host, std::string& port)
{ {
// require ipv6 address format "[addr:addr:addr:...:addr]:port" // If IPv6 address format with port "[addr:addr:addr:...:addr]:port"
if (address.find(']') != std::string::npos) if (address.find(']') != std::string::npos)
{ {
host = address.substr(1, address.rfind(']') - 1); host = address.substr(1, address.rfind(']') - 1);
@ -47,6 +47,12 @@ namespace net
port = address.substr(address.rfind(':') + 1); port = address.substr(address.rfind(':') + 1);
} }
} }
// Else if IPv6 address format without port e.g. "addr:addr:addr:...:addr"
else if (std::count(address.begin(), address.end(), ':') >= 2)
{
host = address;
}
// Else IPv4, Tor, I2P address or hostname
else else
{ {
host = address.substr(0, address.rfind(':')); host = address.substr(0, address.rfind(':'));

@ -38,6 +38,16 @@
namespace net namespace net
{ {
/*!
* \brief Takes a valid address string (IP, Tor, I2P, or DNS name) and splits it into host and port
*
* The host of an IPv6 addresses in the format "[x:x:..:x]:port" will have the braces stripped.
* For example, when the address is "[ffff::2023]", host will be set to "ffff::2023".
*
* \param address The address string one wants to split
* \param[out] host The host part of the address string. Is always set.
* \param[out] port The port part of the address string. Is only set when address string contains a port.
*/
void get_network_address_host_and_port(const std::string& address, std::string& host, std::string& port); void get_network_address_host_and_port(const std::string& address, std::string& host, std::string& port);
/*! /*!

@ -645,20 +645,10 @@ namespace nodetool
{ {
using namespace boost::asio; using namespace boost::asio;
std::string host = addr; // Split addr string into host string and port string
std::string host;
std::string port = std::to_string(default_port); std::string port = std::to_string(default_port);
size_t colon_pos = addr.find_last_of(':'); net::get_network_address_host_and_port(addr, host, port);
size_t dot_pos = addr.find_last_of('.');
size_t square_brace_pos = addr.find('[');
// IPv6 will have colons regardless. IPv6 and IPv4 address:port will have a colon but also either a . or a [
// as IPv6 addresses specified as address:port are to be specified as "[addr:addr:...:addr]:port"
// One may also specify an IPv6 address as simply "[addr:addr:...:addr]" without the port; in that case
// the square braces will be stripped here.
if ((std::string::npos != colon_pos && std::string::npos != dot_pos) || std::string::npos != square_brace_pos)
{
net::get_network_address_host_and_port(addr, host, port);
}
MINFO("Resolving node address: host=" << host << ", port=" << port); MINFO("Resolving node address: host=" << host << ", port=" << port);
io_service io_srv; io_service io_srv;
@ -2408,7 +2398,7 @@ namespace nodetool
return false; return false;
} }
return true; return true;
}); }, "0.0.0.0", m_ssl_support);
if(!r) if(!r)
{ {
LOG_WARNING_CC(context, "Failed to call connect_async, network error."); LOG_WARNING_CC(context, "Failed to call connect_async, network error.");

@ -671,7 +671,7 @@ namespace rct {
//Elliptic Curve Diffie Helman: encodes and decodes the amount b and mask a //Elliptic Curve Diffie Helman: encodes and decodes the amount b and mask a
// where C= aG + bH // where C= aG + bH
static key ecdhHash(const key &k) key genAmountEncodingFactor(const key &k)
{ {
char data[38]; char data[38];
rct::key hash; rct::key hash;
@ -700,7 +700,7 @@ namespace rct {
if (v2) if (v2)
{ {
unmasked.mask = zero(); unmasked.mask = zero();
xor8(unmasked.amount, ecdhHash(sharedSec)); xor8(unmasked.amount, genAmountEncodingFactor(sharedSec));
} }
else else
{ {
@ -715,7 +715,7 @@ namespace rct {
if (v2) if (v2)
{ {
masked.mask = genCommitmentMask(sharedSec); masked.mask = genCommitmentMask(sharedSec);
xor8(masked.amount, ecdhHash(sharedSec)); xor8(masked.amount, genAmountEncodingFactor(sharedSec));
} }
else else
{ {

@ -184,6 +184,7 @@ namespace rct {
//Elliptic Curve Diffie Helman: encodes and decodes the amount b and mask a //Elliptic Curve Diffie Helman: encodes and decodes the amount b and mask a
// where C= aG + bH // where C= aG + bH
key genAmountEncodingFactor(const key &k);
key genCommitmentMask(const key &sk); key genCommitmentMask(const key &sk);
void ecdhEncode(ecdhTuple & unmasked, const key & sharedSec, bool v2); void ecdhEncode(ecdhTuple & unmasked, const key & sharedSec, bool v2);
void ecdhDecode(ecdhTuple & masked, const key & sharedSec, bool v2); void ecdhDecode(ecdhTuple & masked, const key & sharedSec, bool v2);

@ -39,7 +39,9 @@
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/asio/ip/address.hpp> #include <boost/asio/ip/address.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/range/adaptor/transformed.hpp> #include <boost/range/adaptor/transformed.hpp>
#include <boost/preprocessor/stringize.hpp> #include <boost/preprocessor/stringize.hpp>
#include <openssl/evp.h> #include <openssl/evp.h>
@ -64,7 +66,6 @@ using namespace epee;
#include "multisig/multisig_account.h" #include "multisig/multisig_account.h"
#include "multisig/multisig_kex_msg.h" #include "multisig/multisig_kex_msg.h"
#include "multisig/multisig_tx_builder_ringct.h" #include "multisig/multisig_tx_builder_ringct.h"
#include "common/boost_serialization_helper.h"
#include "common/command_line.h" #include "common/command_line.h"
#include "common/threadpool.h" #include "common/threadpool.h"
#include "int-util.h" #include "int-util.h"

@ -44,7 +44,7 @@
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include "include_base_utils.h" #include "include_base_utils.h"
#include "common/boost_serialization_helper.h" #include "chaingen_serialization.h"
#include "common/command_line.h" #include "common/command_line.h"
#include "common/threadpool.h" #include "common/threadpool.h"

@ -158,6 +158,17 @@ TEST(DNSResolver, GetTXTRecord)
EXPECT_STREQ("donate.getmonero.org", addr.c_str()); EXPECT_STREQ("donate.getmonero.org", addr.c_str());
} }
TEST(DNSResolver, Localhost)
{
tools::DNSResolver resolver = tools::DNSResolver::create();
bool avail, valid;
std::vector<std::string> ips = resolver.get_ipv4("localhost", avail, valid);
ASSERT_EQ(1, ips.size());
ASSERT_EQ("127.0.0.1", ips[0]);
}
bool is_equal(const char *s, const std::vector<std::string> &v) { return v.size() == 1 && v[0] == s; } bool is_equal(const char *s, const std::vector<std::string> &v) { return v.size() == 1 && v[0] == s; }
TEST(DNS_PUBLIC, empty) { EXPECT_TRUE(tools::dns_utils::parse_dns_public("").empty()); } TEST(DNS_PUBLIC, empty) { EXPECT_TRUE(tools::dns_utils::parse_dns_public("").empty()); }

@ -936,6 +936,41 @@ TEST(get_network_address, ipv4subnet)
EXPECT_STREQ("12.34.0.0/16", address->str().c_str()); EXPECT_STREQ("12.34.0.0/16", address->str().c_str());
} }
namespace
{
void na_host_and_port_test(std::string addr, std::string exp_host, std::string exp_port)
{
std::string host{"xxxxx"};
std::string port{"xxxxx"};
net::get_network_address_host_and_port(addr, host, port);
EXPECT_EQ(exp_host, host);
EXPECT_EQ(exp_port, port);
}
} // anonymous namespace
TEST(get_network_address_host_and_port, ipv4)
{
na_host_and_port_test("9.9.9.9", "9.9.9.9", "xxxxx");
na_host_and_port_test("9.9.9.9:18081", "9.9.9.9", "18081");
}
TEST(get_network_address_host_and_port, ipv6)
{
na_host_and_port_test("::ffff", "::ffff", "xxxxx");
na_host_and_port_test("[::ffff]", "::ffff", "xxxxx");
na_host_and_port_test("[::ffff]:00231", "::ffff", "00231");
na_host_and_port_test("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "xxxxx");
na_host_and_port_test("[7777:7777:7777:7777:7777:7777:7777:7777]", "7777:7777:7777:7777:7777:7777:7777:7777", "xxxxx");
na_host_and_port_test("[7777:7777:7777:7777:7777:7777:7777:7777]:48080", "7777:7777:7777:7777:7777:7777:7777:7777", "48080");
}
TEST(get_network_address_host_and_port, hostname)
{
na_host_and_port_test("localhost", "localhost", "xxxxx");
na_host_and_port_test("bar:29080", "bar", "29080"); // Issue https://github.com/monero-project/monero/issues/8633
na_host_and_port_test("xmrchain.net:18081", "xmrchain.net", "18081");
}
namespace namespace
{ {
using stream_type = boost::asio::ip::tcp; using stream_type = boost::asio::ip::tcp;

@ -13,18 +13,18 @@ p7gDvxXOGxzq0sqfPTWTBdCj1OPfunHbbeH8ypwBlNpwVG40fJdya+Dqjwu25qX6
Xh5vxLzeJTBmlawa97MCliPvzzJgW9qHRVCa9lLloGVYLiUOS0N+dZ/r/QARAQAB Xh5vxLzeJTBmlawa97MCliPvzzJgW9qHRVCa9lLloGVYLiUOS0N+dZ/r/QARAQAB
t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tb+zt6BGoBCietwQHm
@ -48,5 +48,5 @@ DZc98z3iS2EU3dFSCCCkrC9xupJ63hbWYzsUcox28hqqssBCFRqn9Unn4h05zhvl
YmZWTzkSzbu4/vwI08g51kfQyekeG8ho2LSTlbgyStqQhmmu+VMk6MhqqrGI4aQl YmZWTzkSzbu4/vwI08g51kfQyekeG8ho2LSTlbgyStqQhmmu+VMk6MhqqrGI4aQl
ZULb8ntkFefYwVy7jw0nxkc8jAhHrkKFPb7JR3vePfmUgfFMHjBraPWIcESgsMDA ZULb8ntkFefYwVy7jw0nxkc8jAhHrkKFPb7JR3vePfmUgfFMHjBraPWIcESgsMDA
3j6BmRzehQtWCsEg4JtSsKxcKt6kazvPDpbsyDqmfY/AVeIrFdY2ZQ== 3j6BmRzehQtWCsEg4JtSsKxcKt6kazvPDpbsyDqmfY/AVeIrFdY2ZQ==
=BfKA =lTeM
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----

Loading…
Cancel
Save