mirror of https://github.com/oxen-io/lokinet
try extracting dns bind addr from INI on windows
This commit is contained in:
parent
bee6dc23c3
commit
b4d6f89452
|
@ -152,7 +152,8 @@ extern "C"
|
|||
int flags; /* ifr.ifr_flags on Unix */
|
||||
char if_name[IF_NAMESIZE];
|
||||
#if defined(Windows)
|
||||
int idx; /* needed to set ipv6 address */
|
||||
int idx; /* needed to set ipv6 address */
|
||||
DWORD bindaddr; /* set DNS client address */
|
||||
#endif
|
||||
#if defined(FreeBSD)
|
||||
int mode;
|
||||
|
|
|
@ -207,6 +207,9 @@ struct llarp_tun_io
|
|||
{
|
||||
// TODO: more info?
|
||||
char ifaddr[128];
|
||||
#ifdef _WIN32
|
||||
uint32_t bindaddr;
|
||||
#endif
|
||||
int netmask;
|
||||
char ifname[IFNAMSIZ + 1];
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ win32_tun_io::setup()
|
|||
llarp::LogWarn("failed to put interface up: ", ebuf);
|
||||
return false;
|
||||
}
|
||||
tunif->bindaddr = t->bindaddr;
|
||||
|
||||
if(tuntap_set_ip(tunif, t->ifaddr, t->ifaddr, t->netmask) == -1)
|
||||
{
|
||||
|
|
|
@ -37,10 +37,17 @@ namespace llarp
|
|||
, m_Resolver(std::make_shared< dns::Proxy >(
|
||||
r->netloop(), r->logic(), r->netloop(), r->logic(), this))
|
||||
, m_Name(name)
|
||||
#ifdef _WIN32
|
||||
, m_Tun
|
||||
{
|
||||
{0}, 0, 0, {0}, nullptr, nullptr, nullptr,
|
||||
#else
|
||||
, m_Tun{{0}, 0, {0}, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr}
|
||||
, m_LocalResolverAddr("127.0.0.1", 53)
|
||||
, m_InetToNetwork(name + "_exit_rx", r->netloop(), r->netloop())
|
||||
#endif
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr
|
||||
}
|
||||
, m_LocalResolverAddr("127.0.0.1", 53),
|
||||
m_InetToNetwork(name + "_exit_rx", r->netloop(), r->netloop())
|
||||
|
||||
{
|
||||
m_Tun.user = this;
|
||||
|
|
|
@ -218,6 +218,9 @@ namespace llarp
|
|||
dnsport = std::atoi(v.substr(pos + 1).c_str());
|
||||
}
|
||||
m_LocalResolverAddr = llarp::Addr(resolverAddr, dnsport);
|
||||
#ifdef _WIN32
|
||||
tunif->bindaddr = m_LocalResolverAddr.ton();
|
||||
#endif
|
||||
llarp::LogInfo(Name(), " binding DNS server to ", m_LocalResolverAddr);
|
||||
}
|
||||
if(k == "upstream-dns")
|
||||
|
|
|
@ -417,9 +417,11 @@ tuntap_sys_set_ipv4(struct device *dev, t_tun_in_addr *s, uint32_t mask)
|
|||
* inline */
|
||||
dns.dhcp_opt = 6;
|
||||
dns.length = 4;
|
||||
dns.value[0] =
|
||||
htonl(0x7F000001); /* apparently this doesn't show in network properties,
|
||||
if (dev->bindaddr)
|
||||
dns.value[0] = dev->bindaddr; /* apparently this doesn't show in network properties,
|
||||
but it works */
|
||||
else
|
||||
dns.value[0] = htonl(0x7f000001);
|
||||
dns.value[1] = 0;
|
||||
|
||||
ret = DeviceIoControl(dev->tun_fd, TAP_IOCTL_CONFIG_DHCP_SET_OPT, &dns,
|
||||
|
|
Loading…
Reference in New Issue