lokinet/llarp/exit/policy.cpp
dr7ana 11e54f6552 More message refactoring
- routing messages and surrounding code
- shim code in place for iteration and optimization after deciding what to do with buffer, string handling, and subsequent function calls
2023-08-31 09:28:16 -07:00

37 lines
848 B
C++

#include "policy.hpp"
namespace llarp::exit
{
void
Policy::bt_encode(oxenc::bt_dict_producer& btdp) const
{
try
{
btdp.append("a", proto);
btdp.append("b", port);
btdp.append("d", drop);
btdp.append("v", version);
}
catch (...)
{
log::critical(policy_cat, "Error: exit Policy failed to bt encode contents!");
}
}
bool
Policy::decode_key(const llarp_buffer_t& k, llarp_buffer_t* buf)
{
bool read = false;
if (!BEncodeMaybeReadDictInt("a", proto, read, k, buf))
return false;
if (!BEncodeMaybeReadDictInt("b", port, read, k, buf))
return false;
if (!BEncodeMaybeReadDictInt("d", drop, read, k, buf))
return false;
if (!BEncodeMaybeReadDictInt("v", version, read, k, buf))
return false;
return read;
}
} // namespace llarp::exit