mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
review fixes
This commit is contained in:
parent
39c70b575d
commit
2ee70921bc
6 changed files with 134 additions and 107 deletions
|
@ -14,28 +14,42 @@ option(WITH_WINDOWS_32 "build 32 bit windows" OFF)
|
|||
# to .r[o]data section one after the other!
|
||||
add_compile_options(-fno-ident -Wa,-mbig-obj)
|
||||
|
||||
function(expand_urls output source_file)
|
||||
set(expanded)
|
||||
foreach(mirror ${ARGN})
|
||||
list(APPEND expanded "${mirror}/${source_file}")
|
||||
endforeach()
|
||||
set(${output} "${expanded}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(add_static_target target ext_target libname)
|
||||
add_library(${target} STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(${target} ${ext_target})
|
||||
set_target_properties(${target} PROPERTIES
|
||||
IMPORTED_LOCATION ${DEPS_DESTDIR}/lib/${libname}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
if(EMBEDDED_CFG)
|
||||
link_libatomic()
|
||||
endif()
|
||||
|
||||
set(WINTUN_VERSION 0.14.1 CACHE STRING "wintun version")
|
||||
set(WINTUN_MIRROR https://www.wintun.net/builds
|
||||
set(WINTUN_MIRROR ${LOCAL_MIRROR} https://www.wintun.net/builds
|
||||
CACHE STRING "wintun mirror(s)")
|
||||
set(WINTUN_SOURCE wintun-${WINTUN_VERSION}.zip)
|
||||
set(WINTUN_HASH SHA256=07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51
|
||||
CACHE STRING "wintun source hash")
|
||||
|
||||
set(WINDIVERT_VERSION 2.2.2-A CACHE STRING "windivert version")
|
||||
set(WINDIVERT_MIRROR https://reqrypt.org/download
|
||||
set(WINDIVERT_MIRROR ${LOCAL_MIRROR} https://reqrypt.org/download
|
||||
CACHE STRING "windivert mirror(s)")
|
||||
set(WINDIVERT_SOURCE WinDivert-${WINDIVERT_VERSION}.zip)
|
||||
set(WINDIVERT_HASH SHA512=92eb2ef98ced175d44de1cdb7c52f2ebc534b6a997926baeb83bfe94cba9287b438f796aff11f6163918bcdbc25bcd4e3383715f139f690d207ce219f846a345
|
||||
CACHE STRING "windivert source hash")
|
||||
|
||||
set(WINTUN_URL ${WINTUN_MIRROR}/${WINTUN_SOURCE}
|
||||
CACHE STRING "wintun download url")
|
||||
set(WINDIVERT_URL ${WINDIVERT_MIRROR}/${WINDIVERT_SOURCE}
|
||||
CACHE STRING "windivert download url")
|
||||
expand_urls(WINTUN_URL ${WINTUN_SOURCE} ${WINTUN_MIRROR})
|
||||
expand_urls(WINDIVERT_URL ${WINDIVERT_SOURCE} ${WINDIVERT_MIRROR})
|
||||
|
||||
message(STATUS "Downloading wintun from ${WINTUN_URL}")
|
||||
file(DOWNLOAD ${WINTUN_URL} ${CMAKE_BINARY_DIR}/wintun.zip EXPECTED_HASH ${WINTUN_HASH})
|
||||
|
|
|
@ -52,12 +52,12 @@ llarp_apple_init(llarp_apple_config* appleconf)
|
|||
auto config = std::make_shared<llarp::Config>(config_dir);
|
||||
fs::path config_path = config_dir / "lokinet.ini";
|
||||
if (!fs::exists(config_path))
|
||||
llarp::ensureConfig(config_dir, config_path, /*overwrite=*/false, /*asRouter=*/false);
|
||||
config->Load(config_path);
|
||||
llarp::ensure_config(config_dir, config_path, /*overwrite=*/false, /*asRouter=*/false);
|
||||
config->load(config_path);
|
||||
|
||||
// If no range is specified then go look for a free one, set that in the config, and then return
|
||||
// it to the caller via the char* parameters.
|
||||
auto& range = config->network.m_ifaddr;
|
||||
auto& range = config->network.if_addr;
|
||||
if (!range.addr.h)
|
||||
{
|
||||
if (auto maybe = llarp::net::Platform::Default_ptr()->FindFreeRange())
|
||||
|
@ -84,7 +84,7 @@ llarp_apple_init(llarp_apple_config* appleconf)
|
|||
appleconf->tunnel_ipv6_prefix = 48;
|
||||
|
||||
appleconf->upstream_dns[0] = '\0';
|
||||
for (auto& upstream : config->dns.m_upstreamDNS)
|
||||
for (auto& upstream : config->dns.upstream_dns)
|
||||
{
|
||||
if (upstream.isIPv4())
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace llarp::apple
|
|||
if (enable)
|
||||
tun->ReconfigureDNS({SockAddr{127, 0, 0, 1, {dns_trampoline_port}}});
|
||||
else
|
||||
tun->ReconfigureDNS(router->config()->dns.m_upstreamDNS);
|
||||
tun->ReconfigureDNS(router->config()->dns.upstream_dns);
|
||||
|
||||
trampoline_active = enable;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <llarp/constants/version.hpp>
|
||||
#include <llarp/net/ip.hpp>
|
||||
#include <llarp/net/net.hpp>
|
||||
#include <llarp/net/sock_addr.hpp>
|
||||
#include <llarp/router_contact.hpp>
|
||||
#include <llarp/service/name.hpp>
|
||||
#include <llarp/util/file.hpp>
|
||||
|
@ -33,7 +34,7 @@ namespace llarp
|
|||
struct ConfigGenParameters_impl : public ConfigGenParameters
|
||||
{
|
||||
const llarp::net::Platform*
|
||||
Net_ptr() const
|
||||
Net_ptr() const override
|
||||
{
|
||||
return llarp::net::Platform::Default_ptr();
|
||||
}
|
||||
|
@ -933,7 +934,6 @@ namespace llarp
|
|||
},
|
||||
[this](uint16_t arg) { public_port = net::port_t::from_host(arg); });
|
||||
|
||||
// DISCUSS: does this need to be an optional?
|
||||
auto parse_addr_for_link = [net_ptr](const std::string& arg) {
|
||||
std::optional<oxen::quic::Address> maybe = std::nullopt;
|
||||
std::string_view arg_v;
|
||||
|
@ -946,14 +946,18 @@ namespace llarp
|
|||
|
||||
if (arg_v[0] == ':')
|
||||
{
|
||||
uint16_t res = std::atoi(arg_v.substr(1).data());
|
||||
uint16_t res;
|
||||
if (auto rv = llarp::parse_int<uint16_t>(arg_v.substr(1), res); not rv)
|
||||
res = DEFAULT_LISTEN_PORT;
|
||||
|
||||
maybe = oxen::quic::Address{""s, res ? res : DEFAULT_LISTEN_PORT};
|
||||
maybe = oxen::quic::Address{""s, res};
|
||||
}
|
||||
else if (auto pos = arg_v.find(':'); pos != arg_v.npos)
|
||||
{
|
||||
auto h = arg_v.substr(0, pos);
|
||||
uint16_t p = std::atoi(arg_v.substr(pos + 1).data());
|
||||
uint16_t p;
|
||||
if (auto rv = llarp::parse_int<uint16_t>(arg_v.substr(pos + 1), p); not rv)
|
||||
p = DEFAULT_LISTEN_PORT;
|
||||
|
||||
maybe = oxen::quic::Address{std::string{h}, p};
|
||||
|
||||
|
@ -968,7 +972,7 @@ namespace llarp
|
|||
maybe = oxen::quic::Address{*maybe_ifname};
|
||||
}
|
||||
|
||||
if (maybe->port() == 0)
|
||||
if (maybe && maybe->port() == 0)
|
||||
maybe = oxen::quic::Address{maybe->host(), DEFAULT_LISTEN_PORT};
|
||||
|
||||
return maybe;
|
||||
|
@ -987,9 +991,9 @@ namespace llarp
|
|||
"public IP address and use that IP (and will exit with an error if no such IP is found",
|
||||
"on the system). If port is omitted then lokinet defaults to 1090.",
|
||||
"",
|
||||
"Note: only one address will be accepted. If this option is not specified, it will "
|
||||
"Note: only one address will be accepted. If this option is not specified, it will ",
|
||||
"default",
|
||||
"to the inbound or outbound value. Conversely, specifying this option will supercede "
|
||||
"to the inbound or outbound value. Conversely, specifying this option will supercede ",
|
||||
"the",
|
||||
"deprecated inbound/outbound opts.",
|
||||
"",
|
||||
|
@ -1016,6 +1020,7 @@ namespace llarp
|
|||
"inbound",
|
||||
RelayOnly,
|
||||
MultiValue,
|
||||
Hidden,
|
||||
Comment{
|
||||
"********** DEPRECATED **********",
|
||||
"Note: the new API dictates the lokinet bind address through the 'listen' config",
|
||||
|
@ -1097,50 +1102,47 @@ namespace llarp
|
|||
addr = oxen::quic::Address{""s, DEFAULT_LISTEN_PORT};
|
||||
});
|
||||
|
||||
// DISCUSS: drop this shit?
|
||||
// conf.add_undeclared_handler(
|
||||
// "bind", [this, net_ptr](std::string_view, std::string_view key, std::string_view val) {
|
||||
// LogWarn(
|
||||
// "using the [bind] section with *=/IP=/INTERFACE= is deprecated; use the inbound= "
|
||||
// "and/or outbound= settings instead");
|
||||
// std::optional<SockAddr> addr;
|
||||
// // special case: wildcard for outbound
|
||||
// if (key == "*")
|
||||
// {
|
||||
// addr = net_ptr->Wildcard();
|
||||
// // set port, zero is acceptable here.
|
||||
// if (auto port = std::stoi(std::string{val});
|
||||
// port < std::numeric_limits<uint16_t>::max())
|
||||
// {
|
||||
// addr->setPort(port);
|
||||
// }
|
||||
// else
|
||||
// throw std::invalid_argument{fmt::format("invalid port value: '{}'", val)};
|
||||
// outbound_links.emplace_back(std::move(*addr));
|
||||
// return;
|
||||
// }
|
||||
// // try as interface name first
|
||||
// addr = net_ptr->GetInterfaceAddr(key, AF_INET);
|
||||
// if (addr and net_ptr->IsLoopbackAddress(addr->getIP()))
|
||||
// throw std::invalid_argument{fmt::format("{} is a loopback interface", key)};
|
||||
// // try as ip address next, throws if unable to parse
|
||||
// if (not addr)
|
||||
// {
|
||||
// addr = SockAddr{key, huint16_t{0}};
|
||||
// if (net_ptr->IsLoopbackAddress(addr->getIP()))
|
||||
// throw std::invalid_argument{fmt::format("{} is a loopback address", key)};
|
||||
// }
|
||||
// // parse port and set if acceptable non zero value
|
||||
// if (auto port = std::stoi(std::string{val});
|
||||
// port and port < std::numeric_limits<uint16_t>::max())
|
||||
// {
|
||||
// addr->setPort(port);
|
||||
// }
|
||||
// else
|
||||
// throw std::invalid_argument{fmt::format("invalid port value: '{}'", val)};
|
||||
conf.add_undeclared_handler(
|
||||
"bind", [this, net_ptr](std::string_view, std::string_view key, std::string_view val) {
|
||||
if (using_new_api)
|
||||
throw std::runtime_error{"USE THE NEW API -- SPECIFY LOCAL ADDRESS UNDER [LISTEN]"};
|
||||
|
||||
// inbound_listen_addrs.emplace_back(std::move(*addr));
|
||||
// });
|
||||
log::warning(
|
||||
logcat, "Using the [bind] section is beyond deprecated; use [listen] instead");
|
||||
|
||||
// special case: wildcard for outbound
|
||||
if (key == "*")
|
||||
{
|
||||
uint16_t port{0};
|
||||
|
||||
if (auto rv = llarp::parse_int<uint16_t>(val, port); not rv)
|
||||
log::warning(
|
||||
logcat, "Could not parse port; stop using this deprecated handler you nonce");
|
||||
|
||||
addr = oxen::quic::Address{"", port}; // TODO: drop the "" after bumping libquic
|
||||
return;
|
||||
}
|
||||
|
||||
oxen::quic::Address temp;
|
||||
// try as interface name first
|
||||
auto saddr = net_ptr->GetInterfaceAddr(key, AF_INET);
|
||||
|
||||
if (saddr and net_ptr->IsLoopbackAddress(saddr->getIP()))
|
||||
throw std::invalid_argument{fmt::format("{} is a loopback interface", key)};
|
||||
|
||||
temp = oxen::quic::Address{saddr->in()};
|
||||
|
||||
if (temp.is_addressable())
|
||||
{
|
||||
addr = std::move(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
log::warning(
|
||||
logcat,
|
||||
"Could not parse address values; stop using this deprecated handler you nonce");
|
||||
addr = oxen::quic::Address{""s, DEFAULT_LISTEN_PORT};
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -18,16 +18,16 @@ namespace llarp
|
|||
void
|
||||
SockAddr::init()
|
||||
{
|
||||
llarp::Zero(&m_addr, sizeof(m_addr));
|
||||
m_addr.sin6_family = AF_INET6;
|
||||
llarp::Zero(&m_addr4, sizeof(m_addr4));
|
||||
m_addr4.sin_family = AF_INET;
|
||||
llarp::Zero(&addr6, sizeof(addr6));
|
||||
addr6.sin6_family = AF_INET6;
|
||||
llarp::Zero(&addr4, sizeof(addr4));
|
||||
addr4.sin_family = AF_INET;
|
||||
}
|
||||
|
||||
void
|
||||
SockAddr::applyIPv4MapBytes()
|
||||
{
|
||||
std::memcpy(m_addr.sin6_addr.s6_addr, ipv4_map_prefix.data(), ipv4_map_prefix.size());
|
||||
std::memcpy(addr6.sin6_addr.s6_addr, ipv4_map_prefix.data(), ipv4_map_prefix.size());
|
||||
}
|
||||
|
||||
SockAddr::SockAddr()
|
||||
|
@ -86,7 +86,7 @@ namespace llarp
|
|||
SockAddr&
|
||||
SockAddr::operator=(const SockAddr& other)
|
||||
{
|
||||
*this = other.m_addr;
|
||||
*this = other.addr6;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -121,10 +121,10 @@ namespace llarp
|
|||
applyIPv4MapBytes();
|
||||
|
||||
// avoid byte order conversion (this is NBO -> NBO)
|
||||
memcpy(m_addr.sin6_addr.s6_addr + 12, &other.sin_addr.s_addr, sizeof(in_addr));
|
||||
m_addr.sin6_port = other.sin_port;
|
||||
m_addr4.sin_addr.s_addr = other.sin_addr.s_addr;
|
||||
m_addr4.sin_port = other.sin_port;
|
||||
memcpy(addr6.sin6_addr.s6_addr + 12, &other.sin_addr.s_addr, sizeof(in_addr));
|
||||
addr6.sin6_port = other.sin_port;
|
||||
addr4.sin_addr.s_addr = other.sin_addr.s_addr;
|
||||
addr4.sin_port = other.sin_port;
|
||||
m_empty = false;
|
||||
|
||||
return *this;
|
||||
|
@ -140,7 +140,7 @@ namespace llarp
|
|||
{
|
||||
init();
|
||||
|
||||
memcpy(&m_addr, &other, sizeof(sockaddr_in6));
|
||||
memcpy(&addr6, &other, sizeof(sockaddr_in6));
|
||||
if (IPRange::V4MappedRange().Contains(asIPv6()))
|
||||
{
|
||||
setIPv4(
|
||||
|
@ -148,7 +148,7 @@ namespace llarp
|
|||
other.sin6_addr.s6_addr[13],
|
||||
other.sin6_addr.s6_addr[14],
|
||||
other.sin6_addr.s6_addr[15]);
|
||||
m_addr4.sin_port = m_addr.sin6_port;
|
||||
addr4.sin_port = addr6.sin6_port;
|
||||
}
|
||||
m_empty = false;
|
||||
|
||||
|
@ -164,11 +164,11 @@ namespace llarp
|
|||
SockAddr::operator=(const in6_addr& other)
|
||||
{
|
||||
init();
|
||||
memcpy(&m_addr.sin6_addr.s6_addr, &other.s6_addr, sizeof(m_addr.sin6_addr.s6_addr));
|
||||
memcpy(&addr6.sin6_addr.s6_addr, &other.s6_addr, sizeof(addr6.sin6_addr.s6_addr));
|
||||
if (IPRange::V4MappedRange().Contains(asIPv6()))
|
||||
{
|
||||
setIPv4(other.s6_addr[12], other.s6_addr[13], other.s6_addr[14], other.s6_addr[15]);
|
||||
m_addr4.sin_port = m_addr.sin6_port;
|
||||
addr4.sin_port = addr6.sin6_port;
|
||||
}
|
||||
m_empty = false;
|
||||
|
||||
|
@ -177,48 +177,48 @@ namespace llarp
|
|||
|
||||
SockAddr::operator const sockaddr*() const
|
||||
{
|
||||
return isIPv4() ? reinterpret_cast<const sockaddr*>(&m_addr4)
|
||||
: reinterpret_cast<const sockaddr*>(&m_addr);
|
||||
return isIPv4() ? reinterpret_cast<const sockaddr*>(&addr4)
|
||||
: reinterpret_cast<const sockaddr*>(&addr6);
|
||||
}
|
||||
|
||||
SockAddr::operator const sockaddr_in*() const
|
||||
{
|
||||
return &m_addr4;
|
||||
return &addr4;
|
||||
}
|
||||
|
||||
SockAddr::operator const sockaddr_in6*() const
|
||||
{
|
||||
return &m_addr;
|
||||
return &addr6;
|
||||
}
|
||||
|
||||
size_t
|
||||
SockAddr::sockaddr_len() const
|
||||
{
|
||||
return isIPv6() ? sizeof(m_addr) : sizeof(m_addr4);
|
||||
return isIPv6() ? sizeof(addr6) : sizeof(addr4);
|
||||
}
|
||||
|
||||
bool
|
||||
SockAddr::operator<(const SockAddr& other) const
|
||||
{
|
||||
return m_addr < other.m_addr;
|
||||
return addr6 < other.addr6;
|
||||
}
|
||||
|
||||
bool
|
||||
SockAddr::operator==(const SockAddr& other) const
|
||||
{
|
||||
return m_addr == other.m_addr;
|
||||
return addr6 == other.addr6;
|
||||
}
|
||||
|
||||
huint128_t
|
||||
SockAddr::asIPv6() const
|
||||
{
|
||||
return net::In6ToHUInt(m_addr.sin6_addr);
|
||||
return net::In6ToHUInt(addr6.sin6_addr);
|
||||
}
|
||||
|
||||
huint32_t
|
||||
SockAddr::asIPv4() const
|
||||
{
|
||||
const nuint32_t n{m_addr4.sin_addr.s_addr};
|
||||
const nuint32_t n{addr4.sin_addr.s_addr};
|
||||
return ToHost(n);
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ namespace llarp
|
|||
if (splits.size() > 2)
|
||||
{
|
||||
std::string data{str};
|
||||
if (inet_pton(AF_INET6, data.c_str(), m_addr.sin6_addr.s6_addr) == -1)
|
||||
if (inet_pton(AF_INET6, data.c_str(), addr6.sin6_addr.s6_addr) == -1)
|
||||
throw std::runtime_error{"invalid ip6 address: " + data};
|
||||
return;
|
||||
}
|
||||
|
@ -290,11 +290,11 @@ namespace llarp
|
|||
if (isIPv4())
|
||||
{
|
||||
// IPv4 mapped addrs
|
||||
inet_ntop(AF_INET, &m_addr4.sin_addr.s_addr, buf.data(), buf.size());
|
||||
inet_ntop(AF_INET, &addr4.sin_addr.s_addr, buf.data(), buf.size());
|
||||
return buf.data();
|
||||
}
|
||||
|
||||
inet_ntop(AF_INET6, &m_addr.sin6_addr.s6_addr, buf.data(), buf.size());
|
||||
inet_ntop(AF_INET6, &addr6.sin6_addr.s6_addr, buf.data(), buf.size());
|
||||
if (not ipv6_brackets)
|
||||
return buf.data();
|
||||
|
||||
|
@ -321,7 +321,7 @@ namespace llarp
|
|||
nuint32_t
|
||||
SockAddr::getIPv4() const
|
||||
{
|
||||
return {m_addr4.sin_addr.s_addr};
|
||||
return {addr4.sin_addr.s_addr};
|
||||
}
|
||||
|
||||
nuint128_t
|
||||
|
@ -331,7 +331,7 @@ namespace llarp
|
|||
// Explicit cast to void* here to avoid non-trivial type copying warnings (technically this
|
||||
// isn't trivial because of the zeroing default constructor, but it's trivial enough that this
|
||||
// copy is safe).
|
||||
std::memcpy(static_cast<void*>(&a), &m_addr.sin6_addr, 16);
|
||||
std::memcpy(static_cast<void*>(&a), &addr6.sin6_addr, 16);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -346,13 +346,13 @@ namespace llarp
|
|||
void
|
||||
SockAddr::setIPv4(nuint32_t ip)
|
||||
{
|
||||
uint8_t* ip6 = m_addr.sin6_addr.s6_addr;
|
||||
llarp::Zero(ip6, sizeof(m_addr.sin6_addr.s6_addr));
|
||||
uint8_t* ip6 = addr6.sin6_addr.s6_addr;
|
||||
llarp::Zero(ip6, sizeof(addr6.sin6_addr.s6_addr));
|
||||
|
||||
applyIPv4MapBytes();
|
||||
|
||||
std::memcpy(ip6 + 12, &ip, 4);
|
||||
m_addr4.sin_addr.s_addr = ip.n;
|
||||
addr4.sin_addr.s_addr = ip.n;
|
||||
m_empty = false;
|
||||
}
|
||||
|
||||
|
@ -365,8 +365,8 @@ namespace llarp
|
|||
void
|
||||
SockAddr::setIPv4(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
|
||||
{
|
||||
uint8_t* ip6 = m_addr.sin6_addr.s6_addr;
|
||||
llarp::Zero(ip6, sizeof(m_addr.sin6_addr.s6_addr));
|
||||
uint8_t* ip6 = addr6.sin6_addr.s6_addr;
|
||||
llarp::Zero(ip6, sizeof(addr6.sin6_addr.s6_addr));
|
||||
|
||||
applyIPv4MapBytes();
|
||||
|
||||
|
@ -375,7 +375,7 @@ namespace llarp
|
|||
ip6[14] = c;
|
||||
ip6[15] = d;
|
||||
const auto ip = ipaddr_ipv4_bits(a, b, c, d);
|
||||
m_addr4.sin_addr.s_addr = htonl(ip.h);
|
||||
addr4.sin_addr.s_addr = htonl(ip.h);
|
||||
m_empty = false;
|
||||
}
|
||||
|
||||
|
@ -388,23 +388,23 @@ namespace llarp
|
|||
void
|
||||
SockAddr::setIPv6(nuint128_t ip)
|
||||
{
|
||||
std::memcpy(&m_addr.sin6_addr, &ip, sizeof(m_addr.sin6_addr));
|
||||
std::memcpy(&addr6.sin6_addr, &ip, sizeof(addr6.sin6_addr));
|
||||
if (isIPv4())
|
||||
{
|
||||
setIPv4(
|
||||
m_addr.sin6_addr.s6_addr[12],
|
||||
m_addr.sin6_addr.s6_addr[13],
|
||||
m_addr.sin6_addr.s6_addr[14],
|
||||
m_addr.sin6_addr.s6_addr[15]);
|
||||
m_addr4.sin_port = m_addr.sin6_port;
|
||||
addr6.sin6_addr.s6_addr[12],
|
||||
addr6.sin6_addr.s6_addr[13],
|
||||
addr6.sin6_addr.s6_addr[14],
|
||||
addr6.sin6_addr.s6_addr[15]);
|
||||
addr4.sin_port = addr6.sin6_port;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SockAddr::setPort(nuint16_t port)
|
||||
{
|
||||
m_addr.sin6_port = port.n;
|
||||
m_addr4.sin_port = port.n;
|
||||
addr6.sin6_port = port.n;
|
||||
addr4.sin_port = port.n;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -416,7 +416,7 @@ namespace llarp
|
|||
net::port_t
|
||||
SockAddr::port() const
|
||||
{
|
||||
return net::port_t{m_addr.sin6_port};
|
||||
return net::port_t{addr6.sin6_port};
|
||||
}
|
||||
|
||||
} // namespace llarp
|
||||
|
|
|
@ -177,10 +177,21 @@ namespace llarp
|
|||
huint32_t
|
||||
asIPv4() const;
|
||||
|
||||
const sockaddr_in*
|
||||
in()
|
||||
{
|
||||
return &addr4;
|
||||
}
|
||||
const sockaddr_in6*
|
||||
in6()
|
||||
{
|
||||
return &addr6;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_empty = true;
|
||||
sockaddr_in6 m_addr;
|
||||
sockaddr_in m_addr4;
|
||||
sockaddr_in6 addr6;
|
||||
sockaddr_in addr4;
|
||||
|
||||
void
|
||||
init();
|
||||
|
|
Loading…
Reference in a new issue