|
|
@ -131,6 +131,8 @@ namespace llarp
|
|
|
|
m_Resolver->Restart();
|
|
|
|
m_Resolver->Restart();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constexpr auto DefaultAlignmentTimeout = 10s;
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
TunEndpoint::Configure(const NetworkConfig& conf, const DnsConfig& dnsConf)
|
|
|
|
TunEndpoint::Configure(const NetworkConfig& conf, const DnsConfig& dnsConf)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -167,6 +169,13 @@ namespace llarp
|
|
|
|
|
|
|
|
|
|
|
|
m_BaseV6Address = conf.m_baseV6Address;
|
|
|
|
m_BaseV6Address = conf.m_baseV6Address;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (conf.m_PathAlignmentTimeout)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_PathAlignmentTimeout = *conf.m_PathAlignmentTimeout;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
m_PathAlignmentTimeout = DefaultAlignmentTimeout;
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& item : conf.m_mapAddrs)
|
|
|
|
for (const auto& item : conf.m_mapAddrs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (not MapAddress(item.second, item.first, false))
|
|
|
|
if (not MapAddress(item.second, item.first, false))
|
|
|
@ -259,8 +268,6 @@ namespace llarp
|
|
|
|
return service::Address{itr->second.as_array()};
|
|
|
|
return service::Address{itr->second.as_array()};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
constexpr auto TrafficAlignmentTimeout = 10s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
TunEndpoint::HandleHookedDNSMessage(dns::Message msg, std::function<void(dns::Message)> reply)
|
|
|
|
TunEndpoint::HandleHookedDNSMessage(dns::Message msg, std::function<void(dns::Message)> reply)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -272,7 +279,7 @@ namespace llarp
|
|
|
|
SendDNSReply(snode, s, msg, reply, isV6);
|
|
|
|
SendDNSReply(snode, s, msg, reply, isV6);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
auto ReplyToLokiDNSWhenReady = [this, reply](
|
|
|
|
auto ReplyToLokiDNSWhenReady = [this, reply, timeout = m_PathAlignmentTimeout](
|
|
|
|
service::Address addr, auto msg, bool isV6) -> bool {
|
|
|
|
service::Address addr, auto msg, bool isV6) -> bool {
|
|
|
|
using service::Address;
|
|
|
|
using service::Address;
|
|
|
|
using service::OutboundContext;
|
|
|
|
using service::OutboundContext;
|
|
|
@ -281,7 +288,7 @@ namespace llarp
|
|
|
|
[this, addr, msg, reply, isV6](const Address&, OutboundContext* ctx) {
|
|
|
|
[this, addr, msg, reply, isV6](const Address&, OutboundContext* ctx) {
|
|
|
|
SendDNSReply(addr, ctx, msg, reply, isV6);
|
|
|
|
SendDNSReply(addr, ctx, msg, reply, isV6);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TrafficAlignmentTimeout);
|
|
|
|
timeout);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
auto ReplyToDNSWhenReady = [ReplyToLokiDNSWhenReady, ReplyToSNodeDNSWhenReady](
|
|
|
|
auto ReplyToDNSWhenReady = [ReplyToLokiDNSWhenReady, ReplyToSNodeDNSWhenReady](
|
|
|
@ -298,7 +305,8 @@ namespace llarp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
auto ReplyToLokiSRVWhenReady = [this, reply](service::Address addr, auto msg) -> bool {
|
|
|
|
auto ReplyToLokiSRVWhenReady = [this, reply, timeout = m_PathAlignmentTimeout](
|
|
|
|
|
|
|
|
service::Address addr, auto msg) -> bool {
|
|
|
|
using service::Address;
|
|
|
|
using service::Address;
|
|
|
|
using service::OutboundContext;
|
|
|
|
using service::OutboundContext;
|
|
|
|
|
|
|
|
|
|
|
@ -312,7 +320,7 @@ namespace llarp
|
|
|
|
msg->AddSRVReply(introset.GetMatchingSRVRecords(addr.subdomain));
|
|
|
|
msg->AddSRVReply(introset.GetMatchingSRVRecords(addr.subdomain));
|
|
|
|
reply(*msg);
|
|
|
|
reply(*msg);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TrafficAlignmentTimeout);
|
|
|
|
timeout);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.answers.size() > 0)
|
|
|
|
if (msg.answers.size() > 0)
|
|
|
@ -924,7 +932,7 @@ namespace llarp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self->SendToOrQueue(addr, pkt.ConstBuffer(), service::ProtocolType::Exit);
|
|
|
|
self->SendToOrQueue(addr, pkt.ConstBuffer(), service::ProtocolType::Exit);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TrafficAlignmentTimeout);
|
|
|
|
m_PathAlignmentTimeout);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool rewriteAddrs = true;
|
|
|
|
bool rewriteAddrs = true;
|
|
|
|