2021-03-09 22:24:35 +00:00
|
|
|
#include "policy.hpp"
|
2018-11-12 16:43:40 +00:00
|
|
|
|
2023-08-31 16:28:02 +00:00
|
|
|
namespace llarp::exit
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
2023-08-31 16:28:02 +00:00
|
|
|
void
|
|
|
|
Policy::bt_encode(oxenc::bt_dict_producer& btdp) const
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
2023-08-31 16:28:02 +00:00
|
|
|
try
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
2023-08-31 16:28:02 +00:00
|
|
|
btdp.append("a", proto);
|
|
|
|
btdp.append("b", port);
|
|
|
|
btdp.append("d", drop);
|
|
|
|
btdp.append("v", version);
|
2018-11-12 16:43:40 +00:00
|
|
|
}
|
2023-08-31 16:28:02 +00:00
|
|
|
catch (...)
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
2023-08-31 16:28:02 +00:00
|
|
|
log::critical(policy_cat, "Error: exit Policy failed to bt encode contents!");
|
2018-11-12 16:43:40 +00:00
|
|
|
}
|
2023-08-31 16:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-11-12 16:43:40 +00:00
|
|
|
|
2023-08-31 16:28:02 +00:00
|
|
|
} // namespace llarp::exit
|