mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Fix pubkey parsing to be read as bytes
from_string was trying to parse it as base32z.snode Also leave FIXMEs behind for the badly named methods (both in RouterID itself and in ancestor classes).
This commit is contained in:
parent
636de93b1a
commit
febcd44ea1
3 changed files with 10 additions and 1 deletions
|
@ -32,9 +32,11 @@ namespace llarp
|
|||
std::string
|
||||
ToString() const;
|
||||
|
||||
// FIXME: this is deceptively named: it should be "from_hex" since that's what it does.
|
||||
bool
|
||||
FromString(const std::string& str);
|
||||
|
||||
// FIXME: this is deceptively named: it should be "from_hex" since that's what it does.
|
||||
static PubKey
|
||||
from_string(const std::string& s);
|
||||
|
||||
|
|
|
@ -61,7 +61,11 @@ namespace llarp
|
|||
"Invalid RC netid: expected {}, got {}; this is an RC for a different network!"_format(
|
||||
ACTIVE_NETID, netid)};
|
||||
|
||||
_router_id.from_string(data.require<std::string_view>("p"));
|
||||
auto pubkey = data.require<std::string_view>("p");
|
||||
if (pubkey.size() != 32)
|
||||
throw std::runtime_error{
|
||||
"Invalid RC pubkey: expected 32 bytes, got {}"_format(pubkey.size())};
|
||||
std::memcpy(_router_id.data(), pubkey.data(), 32);
|
||||
|
||||
// auto pk = data.require<std::string_view>("p");
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ namespace llarp
|
|||
std::string
|
||||
ShortString() const;
|
||||
|
||||
// FIXME: this is deceptively named: it parses something base32z formatted with .snode on the
|
||||
// end, so should probably be called "from_snode_address" or "from_base32z" or something that
|
||||
// doesn't sound exactly like the other (different) from_strings of its base classes.
|
||||
bool
|
||||
from_string(std::string_view str);
|
||||
|
||||
|
|
Loading…
Reference in a new issue