2018-08-30 18:48:43 +00:00
|
|
|
#ifndef LLARP_XI_HPP
|
|
|
|
#define LLARP_XI_HPP
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2019-01-13 16:30:07 +00:00
|
|
|
#include <crypto/types.hpp>
|
2020-05-06 20:38:44 +00:00
|
|
|
#include <net/ip_address.hpp>
|
2019-01-10 19:41:51 +00:00
|
|
|
#include <util/bencode.hpp>
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2019-02-07 00:22:54 +00:00
|
|
|
#include <iosfwd>
|
2018-08-30 18:48:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* exit_info.h
|
|
|
|
*
|
|
|
|
* utilities for handling exits on the llarp network
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// Exit info model
|
|
|
|
namespace llarp
|
|
|
|
{
|
2019-05-24 02:01:36 +00:00
|
|
|
struct ExitInfo
|
2018-08-30 18:48:43 +00:00
|
|
|
{
|
2020-05-06 20:38:44 +00:00
|
|
|
IpAddress ipAddress;
|
2020-05-15 12:38:04 +00:00
|
|
|
IpAddress netmask;
|
2018-08-30 18:48:43 +00:00
|
|
|
PubKey pubkey;
|
2019-05-24 02:01:36 +00:00
|
|
|
uint64_t version = LLARP_PROTO_VERSION;
|
2018-08-30 18:48:43 +00:00
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
ExitInfo() = default;
|
2019-05-24 02:01:36 +00:00
|
|
|
|
2020-05-06 20:38:44 +00:00
|
|
|
ExitInfo(const PubKey& pk, const IpAddress& address) : ipAddress(address), pubkey(pk)
|
2018-11-14 19:34:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-24 02:01:36 +00:00
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
2018-09-06 11:46:19 +00:00
|
|
|
|
2019-05-24 02:01:36 +00:00
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
BDecode(llarp_buffer_t* buf)
|
2018-09-06 11:46:19 +00:00
|
|
|
{
|
2019-05-24 02:01:36 +00:00
|
|
|
return bencode_decode_dict(*this, buf);
|
2018-09-06 11:46:19 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* buf);
|
2019-02-24 23:46:37 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::ostream&
|
|
|
|
print(std::ostream& stream, int level, int spaces) const;
|
2018-08-30 18:48:43 +00:00
|
|
|
};
|
2019-02-07 00:22:54 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
inline std::ostream&
|
|
|
|
operator<<(std::ostream& out, const ExitInfo& xi)
|
2019-02-24 23:46:37 +00:00
|
|
|
{
|
|
|
|
return xi.print(out, -1, -1);
|
|
|
|
}
|
2018-08-30 18:48:43 +00:00
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|