mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-03 23:15:52 +00:00
bdc54835c2
- updated CMake build script - builds with Microsoft C++ 19.1x. such builds require Windows 8.1 or later unless you have the .NET Server 2003-toolset (v141_xp) - windows port requires a C++17 compiler since cpp17::filesystem is POSIX-only - HAVE_CXX17_FILESYSTEM manual toggle in CMake. You must manually specify where std::[experimental::]filesystem is defined in LDFLAGS or CMAKE_x_LINKER_FLAGS. - IPv6 support can be added at any time, and the windows sdk still has that inline getaddrinfo(3) if it can't find a suitable IPv6 stack. - inline code for mingw-w64: there's a few bits and pieces still missing simply because mingw-w64 derives its windows sdk from wine and reactos, and then writing all the newer stuff into it by hand straight from the MSDN manpages. - misc. C++11 stuff (nullptr and friends) - Internal file handling code takes UTF-8 or plain 8-bit text, NTFS is UTF-16, so std::filesystem::path::c_str() is wchar_t. That's no good unless you first call std::filesystem::path::string(). - implemented getifaddrs(3) and if_nametoindex(3) on top of GetAdapters[Info|Addresses](2). - updated readme with new info BONUS: may implement Solaris/illumos IOCP someday... -despair86
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
#ifndef _WIN32
|
|
#include <arpa/inet.h>
|
|
#endif
|
|
|
|
#include <llarp/bencode.h>
|
|
#include <llarp/exit_route.h>
|
|
#include <llarp/string.h>
|
|
|
|
bool
|
|
llarp_xr_bencode(struct llarp_xr* xr, llarp_buffer_t* buff)
|
|
{
|
|
char addr_buff[128] = {0};
|
|
const char* addr;
|
|
|
|
if(!bencode_start_dict(buff))
|
|
return false;
|
|
|
|
/** gateway */
|
|
addr = inet_ntop(AF_INET6, &xr->gateway, addr_buff, sizeof(addr_buff));
|
|
if(!addr)
|
|
return false;
|
|
if(!bencode_write_bytestring(buff, "a", 1))
|
|
return false;
|
|
if(!bencode_write_bytestring(buff, addr, strnlen(addr, sizeof(addr_buff))))
|
|
return false;
|
|
|
|
/** netmask */
|
|
addr = inet_ntop(AF_INET6, &xr->netmask, addr_buff, sizeof(addr_buff));
|
|
if(!addr)
|
|
return false;
|
|
if(!bencode_write_bytestring(buff, "b", 1))
|
|
return false;
|
|
if(!bencode_write_bytestring(buff, addr, strnlen(addr, sizeof(addr_buff))))
|
|
return false;
|
|
|
|
/** source */
|
|
addr = inet_ntop(AF_INET6, &xr->source, addr_buff, sizeof(addr_buff));
|
|
if(!addr)
|
|
return false;
|
|
if(!bencode_write_bytestring(buff, "c", 1))
|
|
return false;
|
|
if(!bencode_write_bytestring(buff, addr, strnlen(addr, sizeof(addr_buff))))
|
|
return false;
|
|
|
|
/** lifetime */
|
|
if(!bencode_write_bytestring(buff, "l", 1))
|
|
return false;
|
|
if(!bencode_write_uint64(buff, xr->lifetime))
|
|
return false;
|
|
|
|
/** version */
|
|
if(!bencode_write_version_entry(buff))
|
|
return false;
|
|
|
|
/* end */
|
|
return bencode_end(buff);
|
|
}
|