1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/include/llarp/exit_info.hpp

51 lines
1,013 B
C++
Raw Normal View History

2018-08-30 20:48:43 +02:00
#ifndef LLARP_XI_HPP
#define LLARP_XI_HPP
2018-08-31 14:46:54 +02:00
#include <llarp/bencode.hpp>
2018-08-30 20:48:43 +02:00
#include <llarp/crypto.hpp>
#include <llarp/net.h>
#include <iostream>
#include <llarp/bits.hpp>
/**
* exit_info.h
*
* utilities for handling exits on the llarp network
*/
/// Exit info model
namespace llarp
{
2018-08-31 14:46:54 +02:00
struct ExitInfo : public IBEncodeMessage
2018-08-30 20:48:43 +02:00
{
struct in6_addr address;
struct in6_addr netmask;
PubKey pubkey;
2018-08-31 14:46:54 +02:00
~ExitInfo();
2018-08-30 20:48:43 +02:00
bool
BEncode(llarp_buffer_t *buf) const;
bool
2018-08-31 14:46:54 +02:00
DecodeKey(llarp_buffer_t k, llarp_buffer_t *buf);
2018-08-30 20:48:43 +02:00
2018-08-31 15:51:24 +02:00
ExitInfo &
operator=(const ExitInfo &other);
2018-08-30 20:48:43 +02:00
friend std::ostream &
operator<<(std::ostream &out, const ExitInfo &xi)
{
char tmp[128] = {0};
if(inet_ntop(AF_INET6, &xi.address, tmp, sizeof(tmp)))
out << std::string(tmp);
else
return out;
out << std::string("/");
return out << std::to_string(
llarp::bits::count_array_bits(xi.netmask.s6_addr));
}
};
} // namespace llarp
#endif