mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
6 years ago
|
#ifndef _WIN32
|
||
6 years ago
|
#include <arpa/inet.h>
|
||
6 years ago
|
#endif
|
||
|
|
||
5 years ago
|
#include <net/exit_info.hpp>
|
||
5 years ago
|
#include <util/bencode.h>
|
||
|
#include <util/mem.h>
|
||
6 years ago
|
|
||
6 years ago
|
#include <list>
|
||
5 years ago
|
#include <string.h>
|
||
6 years ago
|
|
||
6 years ago
|
namespace llarp
|
||
6 years ago
|
{
|
||
6 years ago
|
ExitInfo::~ExitInfo()
|
||
6 years ago
|
{
|
||
6 years ago
|
}
|
||
6 years ago
|
|
||
6 years ago
|
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;
|
||
|
}
|
||
|
|
||
6 years ago
|
bool
|
||
|
ExitInfo::BEncode(llarp_buffer_t* buf) const
|
||
6 years ago
|
{
|
||
6 years ago
|
char tmp[128] = {0};
|
||
|
if(!bencode_start_dict(buf))
|
||
6 years ago
|
return false;
|
||
|
|
||
6 years ago
|
if(!inet_ntop(AF_INET6, (void*)&address, tmp, sizeof(tmp)))
|
||
6 years ago
|
return false;
|
||
6 years ago
|
if(!BEncodeWriteDictString("a", std::string(tmp), buf))
|
||
6 years ago
|
return false;
|
||
|
|
||
6 years ago
|
if(!inet_ntop(AF_INET6, (void*)&netmask, tmp, sizeof(tmp)))
|
||
6 years ago
|
return false;
|
||
6 years ago
|
if(!BEncodeWriteDictString("b", std::string(tmp), buf))
|
||
6 years ago
|
return false;
|
||
|
|
||
6 years ago
|
if(!BEncodeWriteDictEntry("k", pubkey, buf))
|
||
6 years ago
|
return false;
|
||
|
|
||
6 years ago
|
if(!BEncodeWriteDictInt("v", version, buf))
|
||
|
return false;
|
||
6 years ago
|
|
||
6 years ago
|
return bencode_end(buf);
|
||
|
}
|
||
6 years ago
|
|
||
6 years ago
|
bool
|
||
6 years ago
|
ExitInfo::DecodeKey(__attribute__((unused)) llarp_buffer_t k,
|
||
|
__attribute__((unused)) llarp_buffer_t* buf)
|
||
6 years ago
|
{
|
||
|
bool read = false;
|
||
6 years ago
|
// TODO: implement me
|
||
6 years ago
|
return read;
|
||
|
}
|
||
6 years ago
|
|
||
6 years ago
|
} // namespace llarp
|