mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-19 09:25:28 +00:00
11e54f6552
- 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
37 lines
848 B
C++
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
|