From 27aa8ce95bf0e863f3b6a8942a0a91bbb85b8e52 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 8 Dec 2017 18:26:36 +0000 Subject: net_utils_base: fix peer list parsing Fields are written with their "name" as key, and that name changed. --- contrib/epee/include/net/net_utils_base.h | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'contrib/epee/include/net') diff --git a/contrib/epee/include/net/net_utils_base.h b/contrib/epee/include/net/net_utils_base.h index 0e31ee86f..04e3fe6a4 100644 --- a/contrib/epee/include/net/net_utils_base.h +++ b/contrib/epee/include/net/net_utils_base.h @@ -166,15 +166,37 @@ namespace net_utils BEGIN_KV_SERIALIZE_MAP() uint8_t type = is_store ? this_ref.get_type_id() : 0; - epee::serialization::selector::serialize(type, stg, hparent_section, "type"); + if (!epee::serialization::selector::serialize(type, stg, hparent_section, "type")) + return false; switch (type) { case ipv4_network_address::ID: + { if (!is_store) + { const_cast(this_ref) = ipv4_network_address{0, 0}; - KV_SERIALIZE(template as_mutable()); + auto &addr = this_ref.template as_mutable(); + if (epee::serialization::selector::serialize(addr, stg, hparent_section, "addr")) + MDEBUG("Found as addr: " << this_ref.str()); + else if (epee::serialization::selector::serialize(addr, stg, hparent_section, "template as()")) + MDEBUG("Found as template as(): " << this_ref.str()); + else if (epee::serialization::selector::serialize(addr, stg, hparent_section, "template as_mutable()")) + MDEBUG("Found as template as_mutable(): " << this_ref.str()); + else + { + MWARNING("Address not found"); + return false; + } + } + else + { + auto &addr = this_ref.template as_mutable(); + if (!epee::serialization::selector::serialize(addr, stg, hparent_section, "addr")) + return false; + } break; - default: MERROR("Unsupported network address type: " << type); return false; + } + default: MERROR("Unsupported network address type: " << (unsigned)type); return false; } END_KV_SERIALIZE_MAP() }; -- cgit v1.2.3