9static stralloc
data = {0};
10static stralloc ifname = {0};
29 x = env_get(
"DNSCACHEIP");
31 while (iplen <= 240 && *
x !=
'\0') {
35 if ((i = ip6_ifscan(
x,ip + iplen,&ifname))) {
36 if (ifname.len > 2) sid[k] = socket_getifidx(ifname.s);
38 if (*(
x += i) ==
'\0')
break;
43 i = openreadclose(
"/etc/resolv.conf",&data,64);
46 if (!stralloc_append(&data,
"\n"))
return DNS_MEM;
48 for (j = 0; j <
data.len; ++j)
49 if (
data.s[j] ==
'\n') {
50 if (byte_equal(
"nameserver ",11,
data.s + i) || byte_equal(
"nameserver\t",11,
data.s + i)) {
52 while ((
data.s[i] ==
' ') || (
data.s[i] ==
'\t'))
57 if (byte_equal(
ip4,4,
"\0\0\0\0"))
58 byte_copy(
ip4,4,
"\177\0\0\1");
59 byte_copy(ip + iplen,12,V4mappedprefix);
60 byte_copy(ip + iplen+12,4,
ip4);
61 sid[k] = 0; iplen += 16; k++;
62 }
else if (ip6_ifscan(
data.s + i,ip + iplen,&ifname)) {
63 if (ifname.len > 2) sid[k] = socket_getifidx(ifname.s);
74 byte_copy(ip,16,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1");
82static unsigned int uses;
83static struct taia deadline;
92 if (taia_less(&deadline,&
now)) ok = 0;
97 taia_uint(&deadline,600);
98 taia_add(&deadline,&
now,&deadline);
105 byte_copy(scope,128,scopes);
int dns_resolvconfip(char s[QUERY_MAXIPLEN], uint32 scope[QUERY_MAXNS])