aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-08 18:26:36 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-09 22:16:58 +0000
commit27aa8ce95bf0e863f3b6a8942a0a91bbb85b8e52 (patch)
treefde92facaacdd36f10b5a2bdd895f1e879a19ae6
parentepee: fix kv_unserialize return value when a field is not found (diff)
downloadmonero-27aa8ce95bf0e863f3b6a8942a0a91bbb85b8e52.tar.xz
net_utils_base: fix peer list parsing
Fields are written with their "name" as key, and that name changed.
-rw-r--r--contrib/epee/include/net/net_utils_base.h28
1 files changed, 25 insertions, 3 deletions
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<is_store>::serialize(type, stg, hparent_section, "type");
+ if (!epee::serialization::selector<is_store>::serialize(type, stg, hparent_section, "type"))
+ return false;
switch (type)
{
case ipv4_network_address::ID:
+ {
if (!is_store)
+ {
const_cast<network_address&>(this_ref) = ipv4_network_address{0, 0};
- KV_SERIALIZE(template as_mutable<ipv4_network_address>());
+ auto &addr = this_ref.template as_mutable<ipv4_network_address>();
+ if (epee::serialization::selector<is_store>::serialize(addr, stg, hparent_section, "addr"))
+ MDEBUG("Found as addr: " << this_ref.str());
+ else if (epee::serialization::selector<is_store>::serialize(addr, stg, hparent_section, "template as<ipv4_network_address>()"))
+ MDEBUG("Found as template as<ipv4_network_address>(): " << this_ref.str());
+ else if (epee::serialization::selector<is_store>::serialize(addr, stg, hparent_section, "template as_mutable<ipv4_network_address>()"))
+ MDEBUG("Found as template as_mutable<ipv4_network_address>(): " << this_ref.str());
+ else
+ {
+ MWARNING("Address not found");
+ return false;
+ }
+ }
+ else
+ {
+ auto &addr = this_ref.template as_mutable<ipv4_network_address>();
+ if (!epee::serialization::selector<is_store>::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()
};