19#define WHO "dnsfilter"
26 logmsg(
WHO,111,FATAL,
"out of memory");
44static stralloc partial;
67 for (j = 0; j <
x[i].
middle.len; ++j)
72int main(
int argc,
char **argv)
81 char qflags[2] = { 1, 0 };
83 while ((opt = getoptb(argc,argv,
"c:l:")) != opteof)
88 if (
u > 1000)
u = 1000;
94 if (
u > 1000000)
u = 1000000;
98 logmsg(
WHO,100,USAGE,
"dnsfilter [ -c concurrency ] [ -l lines ]");
103 byte_zero((
char *)
x,
xmax *
sizeof(
struct line));
105 io = (iopause_fd *) alloc((
xmax + 1) *
sizeof(iopause_fd));
108 if (!stralloc_copys(&partial,
""))
nomem();
113 taia_uint(&deadline,120);
114 taia_add(&deadline,&deadline,&stamp);
122 inio->events = IOPAUSE_READ;
125 for (i = 0; i <
xnum; ++i)
131 iopause(
io,
iolen,&deadline,&stamp);
143 for (i = 0; i <
xnum; ++i)
163 buffer_put(buffer_1,
x[0].
left.s,
x[0].
left.len);
166 buffer_flush(buffer_1);
169 for (i = 0;i <
xnum;++i)
x[i] =
x[i + 1];
184 if (!stralloc_catb(&partial,
inbuf,i))
nomem();
189 i = byte_chr(partial.s,partial.len,
'\n');
190 i = byte_chr(partial.s,i,
'\t');
191 i = byte_chr(partial.s,i,
' ');
195 if (!stralloc_copyb(&
x[
xnum].
right,partial.s + i,partial.len - i))
nomem();
199 if (!stralloc_0(&partial))
nomem();
200 if (str_chr(partial.s,
':') == partial.len - 1) {
207 logmsg(
WHO,111,FATAL,
"unable to read /etc/resolv.conf");
int dns_name_packet(stralloc *out, const char *buf, unsigned int len)
int dns_name4_domain(char name[DNS_NAME4_DOMAIN], const char ip[4])
int dns_name6_domain(char name[DNS_NAME6_DOMAIN], const char ip[16])
int dns_resolvconfip(char s[QUERY_MAXIPLEN], uint32 scope[QUERY_MAXNS])
void dns_transmit_io(struct dns_transmit *d, iopause_fd *x, struct taia *deadline)
int dns_transmit_start6(struct dns_transmit *d, const char servers[QUERY_MAXIPLEN], char qflags[2], const char *q, const char qtype[2], const char localip[16], const uint32 scopes[QUERY_MAXNS])
int dns_transmit_get(struct dns_transmit *d, const iopause_fd *x, const struct taia *when)
char servers[QUERY_MAXIPLEN]
uint32 scopes[QUERY_MAXNS]
char name[DNS_NAME6_DOMAIN]