mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
DRY
This commit is contained in:
parent
3753dfbddb
commit
ebed21c392
1 changed files with 10 additions and 12 deletions
|
@ -228,22 +228,20 @@ namespace llarp
|
|||
DnsConfig::defineConfigOptions(ConfigDefinition& conf, const ConfigGenParameters& params)
|
||||
{
|
||||
(void)params;
|
||||
|
||||
conf.defineOption<std::string>(
|
||||
"dns", "upstream", false, true, std::nullopt, [=](std::string arg) {
|
||||
IpAddress addr{arg};
|
||||
const auto maybePort = addr.getPort();
|
||||
if (not maybePort.has_value())
|
||||
addr.setPort(53);
|
||||
m_upstreamDNS.push_back(std::move(addr));
|
||||
});
|
||||
|
||||
conf.defineOption<std::string>("dns", "bind", false, std::nullopt, [=](std::string arg) {
|
||||
static auto parseDNSAddr = [](auto arg) {
|
||||
IpAddress addr{arg};
|
||||
const auto maybePort = addr.getPort();
|
||||
if (not maybePort.has_value())
|
||||
addr.setPort(53);
|
||||
m_bind = std::move(addr);
|
||||
return addr;
|
||||
};
|
||||
conf.defineOption<std::string>(
|
||||
"dns", "upstream", false, true, std::nullopt, [=](std::string arg) {
|
||||
m_upstreamDNS.push_back(parseDNSAddr(std::move(arg)));
|
||||
});
|
||||
|
||||
conf.defineOption<std::string>("dns", "bind", false, std::nullopt, [=](std::string arg) {
|
||||
m_bind = parseDNSAddr(std::move(arg));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue