2018-07-30 04:38:14 +00:00
|
|
|
#ifndef _WIN32
|
2018-04-05 14:43:16 +00:00
|
|
|
#include <arpa/inet.h>
|
2018-07-30 04:38:14 +00:00
|
|
|
#endif
|
|
|
|
|
2018-04-04 16:10:27 +00:00
|
|
|
#include <llarp/bencode.h>
|
2018-08-31 12:46:54 +00:00
|
|
|
#include <llarp/exit_info.hpp>
|
2018-05-10 23:32:46 +00:00
|
|
|
#include <llarp/mem.h>
|
2018-04-05 14:23:14 +00:00
|
|
|
#include <llarp/string.h>
|
2018-05-28 13:49:44 +00:00
|
|
|
#include <list>
|
2018-05-10 23:32:46 +00:00
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
namespace llarp
|
2018-05-22 15:54:19 +00:00
|
|
|
{
|
2018-08-31 12:46:54 +00:00
|
|
|
ExitInfo::~ExitInfo()
|
2018-05-22 15:54:19 +00:00
|
|
|
{
|
2018-05-10 23:32:46 +00:00
|
|
|
}
|
2018-05-22 15:54:19 +00:00
|
|
|
|
2018-08-31 13:51:24 +00:00
|
|
|
ExitInfo&
|
|
|
|
ExitInfo::operator=(const ExitInfo& other)
|
|
|
|
{
|
|
|
|
memcpy(address.s6_addr, other.address.s6_addr, 16);
|
|
|
|
memcpy(netmask.s6_addr, other.netmask.s6_addr, 16);
|
|
|
|
pubkey = other.pubkey;
|
|
|
|
version = other.version;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
bool
|
|
|
|
ExitInfo::BEncode(llarp_buffer_t* buf) const
|
2018-05-22 15:54:19 +00:00
|
|
|
{
|
2018-08-31 12:46:54 +00:00
|
|
|
char tmp[128] = {0};
|
|
|
|
if(!bencode_start_dict(buf))
|
2018-05-22 15:54:19 +00:00
|
|
|
return false;
|
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
if(!inet_ntop(AF_INET6, &address, tmp, sizeof(tmp)))
|
2018-05-22 15:54:19 +00:00
|
|
|
return false;
|
2018-08-31 12:46:54 +00:00
|
|
|
if(!BEncodeWriteDictString("a", std::string(tmp), buf))
|
2018-05-22 15:54:19 +00:00
|
|
|
return false;
|
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
if(!inet_ntop(AF_INET6, &netmask, tmp, sizeof(tmp)))
|
2018-05-22 15:54:19 +00:00
|
|
|
return false;
|
2018-08-31 12:46:54 +00:00
|
|
|
if(!BEncodeWriteDictString("b", std::string(tmp), buf))
|
2018-05-22 15:54:19 +00:00
|
|
|
return false;
|
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
if(!BEncodeWriteDictEntry("k", pubkey, buf))
|
2018-05-22 15:54:19 +00:00
|
|
|
return false;
|
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
if(!BEncodeWriteDictInt("v", version, buf))
|
|
|
|
return false;
|
2018-05-22 15:54:19 +00:00
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
return bencode_end(buf);
|
|
|
|
}
|
2018-05-22 15:54:19 +00:00
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
bool
|
2018-11-07 15:30:22 +00:00
|
|
|
ExitInfo::DecodeKey(__attribute__((unused)) llarp_buffer_t k,
|
|
|
|
__attribute__((unused)) llarp_buffer_t* buf)
|
2018-08-31 12:46:54 +00:00
|
|
|
{
|
|
|
|
bool read = false;
|
2018-08-31 13:51:24 +00:00
|
|
|
// TODO: implement me
|
2018-08-31 12:46:54 +00:00
|
|
|
return read;
|
|
|
|
}
|
2018-05-30 20:56:47 +00:00
|
|
|
|
2018-08-31 12:46:54 +00:00
|
|
|
} // namespace llarp
|