Skip to content

Commit 41d89f6

Browse files
committed
Add DNS API.
Missing functional tests. I'm not sure how to do tests because I don't want to rely on the fact that users have an internet connection.
1 parent 77d407d commit 41d89f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+9585
-33
lines changed

LICENSE

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ are:
2222
- The SCONS build system, located at tools/scons. Copyrighted by the SCONS
2323
Foundation. Released under an MIT license.
2424

25+
- UDNS, an asynchronous DNS client, located at deps/udns. Copyrighted by
26+
Michael Tokarev <[email protected]>. Released under the GNU Lesser General
27+
Public License version 2.1.
28+
2529
Additionally deps/http_parser is based on Zed Shaw's Mongrel. Mongrel is
2630
copyrighted by Zed Shaw and distributed under GPL2 or a permissive open
2731
licence. See deps/http_parser/LICENCE for more information.

deps/udns/.cvsignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
udns*.tar.gz
2+
udns_codes.c
3+
udns.3.html
4+
*.lo
5+
*_s
6+
libudns.so.*
7+
dnsget
8+
ex-rdns
9+
rblcheck
10+
Makefile
11+
config.h
12+
config.status
13+
config.log
14+
build-stamp

deps/udns/COPYING.LGPL

+504
Large diffs are not rendered by default.

deps/udns/Makefile.in

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
#! /usr/bin/make -rf
2+
# $Id: Makefile.in,v 1.11 2007/01/15 21:19:08 mjt Exp $
3+
# libudns Makefile
4+
#
5+
# Copyright (C) 2005 Michael Tokarev <[email protected]>
6+
# This file is part of UDNS library, an async DNS stub resolver.
7+
#
8+
# This library is free software; you can redistribute it and/or
9+
# modify it under the terms of the GNU Lesser General Public
10+
# License as published by the Free Software Foundation; either
11+
# version 2.1 of the License, or (at your option) any later version.
12+
#
13+
# This library is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
# Lesser General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU Lesser General Public
19+
# License along with this library, in file named COPYING.LGPL; if not,
20+
# write to the Free Software Foundation, Inc., 59 Temple Place,
21+
# Suite 330, Boston, MA 02111-1307 USA
22+
23+
NAME = udns
24+
VERS = 0.0.9
25+
SRCS = udns_dn.c udns_dntosp.c udns_parse.c udns_resolver.c udns_init.c \
26+
udns_misc.c udns_XtoX.c \
27+
udns_rr_a.c udns_rr_ptr.c udns_rr_mx.c udns_rr_txt.c udns_bl.c \
28+
udns_rr_srv.c udns_rr_naptr.c udns_codes.c
29+
USRCS = dnsget.c rblcheck.c ex-rdns.c
30+
DEB = debian/copyright debian/changelog debian/control debian/rules
31+
DIST = COPYING.LGPL udns.h udns.3 dnsget.1 rblcheck.1 $(SRCS) $(USRCS) \
32+
NEWS TODO NOTES Makefile.in configure configure.lib \
33+
inet_XtoX.c getopt.c
34+
35+
OBJS = $(SRCS:.c=.o) $(GEN:.c=.o)
36+
LIB = lib$(NAME).a
37+
LIBFL = -L. -l$(NAME)
38+
39+
SOVER = 0
40+
SOBJS = $(OBJS:.o=.lo)
41+
SOLIB = lib$(NAME)_s.so
42+
SOLIBV = lib$(NAME).so.$(SOVER)
43+
SOLIBFL= -L. -l$(NAME)_s
44+
45+
LIBS = $(LIB) $(SOLIBV)
46+
47+
UTILS = $(USRCS:.c=)
48+
UOBJS = $(USRCS:.c=.o)
49+
SOUTILS = $(USRCS:.c=_s)
50+
51+
NAMEPFX = $(NAME)-$(VERS)
52+
53+
CC = @CC@
54+
CFLAGS = @CFLAGS@
55+
CDEFS = @CDEFS@
56+
PICFLAGS = -fPIC
57+
AWK = awk
58+
59+
all: static
60+
61+
.SUFFIXES: .c .o .lo
62+
63+
static: $(LIB) $(UTILS)
64+
staticlib: $(LIB)
65+
$(LIB): $(OBJS)
66+
-rm -f $@
67+
$(AR) rv $@ $(OBJS)
68+
.c.o:
69+
$(CC) $(CFLAGS) $(CDEFS) -c $<
70+
71+
shared: $(SOLIBV) $(SOUTILS)
72+
sharedlib: $(SOLIBV)
73+
74+
$(SOLIBV): $(SOBJS)
75+
$(CC) -shared -Wl,--soname,$(SOLIBV) -o $@ $(SOBJS)
76+
$(SOLIB): $(SOLIBV)
77+
rm -f $@
78+
ln -s $(SOLIBV) $@
79+
.c.lo:
80+
$(CC) $(CFLAGS) $(PICFLAGS) $(CDEFS) -o $@ -c $<
81+
82+
# udns_codes.c is generated from udns.h
83+
udns_codes.c: udns.h
84+
@echo Generating $@
85+
@set -e; exec >$@.tmp; \
86+
set T type C class R rcode; \
87+
echo "/* Automatically generated. */"; \
88+
echo "#include \"udns.h\""; \
89+
while [ "$$1" ]; do \
90+
echo; \
91+
echo "const struct dns_nameval dns_$${2}tab[] = {"; \
92+
$(AWK) "/^ DNS_$${1}_[A-Z0-9_]+[ ]*=/ \
93+
{ printf \" {%s,\\\"%s\\\"},\\n\", \$$1, substr(\$$1,7) }" \
94+
udns.h ; \
95+
echo " {0,0}};"; \
96+
echo "const char *dns_$${2}name(enum dns_$${2} code) {"; \
97+
echo " static char nm[20];"; \
98+
echo " switch(code) {"; \
99+
$(AWK) "BEGIN{i=0} \
100+
/^ DNS_$${1}_[A-Z0-9_]+[ ]*=/ \
101+
{printf \" case %s: return dns_$${2}tab[%d].name;\\n\",\$$1,i++}\
102+
" udns.h ; \
103+
echo " }"; \
104+
echo " return _dns_format_code(nm,\"$$2\",code);"; \
105+
echo "}"; \
106+
shift 2; \
107+
done
108+
@mv $@.tmp $@
109+
110+
udns.3.html: udns.3
111+
groff -man -Thtml udns.3 > $@.tmp
112+
mv $@.tmp $@
113+
114+
dist: $(NAMEPFX).tar.gz
115+
$(NAMEPFX).tar.gz: $(DIST) $(DEB)
116+
mkdir $(NAMEPFX) $(NAMEPFX)/debian
117+
ln $(DIST) $(NAMEPFX)
118+
ln $(DEB) $(NAMEPFX)/debian
119+
tar cvfz $@ $(NAMEPFX)
120+
rm -rf $(NAMEPFX)
121+
subdist:
122+
cp -p $(DIST) $(TARGET)/
123+
124+
clean:
125+
rm -f $(OBJS)
126+
rm -f $(SOBJS)
127+
rm -f $(UOBJS)
128+
rm -f build-stamp config.log
129+
distclean: clean
130+
rm -f $(LIBS) $(SOLIB) udns.3.html
131+
rm -f $(UTILS) $(SOUTILS)
132+
rm -f config.status config.h Makefile
133+
134+
135+
Makefile: configure configure.lib Makefile.in
136+
./configure
137+
@echo
138+
@echo Please rerun make >&2
139+
@exit 1
140+
141+
.PHONY: all static staticlib shared sharedlib dist clean distclean subdist \
142+
depend dep deps
143+
144+
depend dep deps: $(SRCS) $(USRC)
145+
@echo Generating deps for:
146+
@echo \ $(SRCS)
147+
@echo \ $(USRCS)
148+
@sed '/^# depend/q' Makefile.in > Makefile.tmp
149+
@set -e; \
150+
for f in $(SRCS) $(USRCS); do \
151+
echo $${f%.c}.o $${f%.c}.lo: $$f \
152+
`sed -n 's/^#[ ]*include[ ]*"\(.*\)".*/\1/p' $$f`; \
153+
done >> Makefile.tmp; \
154+
for f in $(USRCS:.c=.o); do \
155+
echo "$${f%.?}: $$f \$$(LIB)"; \
156+
echo " \$$(CC) \$$(CFLAGS) -o \$$@ $$f \$$(LIBFL)"; \
157+
echo "$${f%.?}_s: $$f \$$(SOLIB)"; \
158+
echo " \$$(CC) \$$(CFLAGS) -o \$$@ $$f \$$(SOLIBFL)"; \
159+
done >> Makefile.tmp ; \
160+
if cmp Makefile.tmp Makefile.in >/dev/null 2>&1 ; then \
161+
echo Makefile.in unchanged; rm -f Makefile.tmp; \
162+
else \
163+
echo Updating Makfile.in; mv -f Makefile.tmp Makefile.in ; \
164+
fi
165+
166+
# depend
167+
udns_dn.o udns_dn.lo: udns_dn.c udns.h
168+
udns_dntosp.o udns_dntosp.lo: udns_dntosp.c udns.h
169+
udns_parse.o udns_parse.lo: udns_parse.c udns.h
170+
udns_resolver.o udns_resolver.lo: udns_resolver.c config.h udns.h
171+
udns_init.o udns_init.lo: udns_init.c config.h udns.h
172+
udns_misc.o udns_misc.lo: udns_misc.c udns.h
173+
udns_XtoX.o udns_XtoX.lo: udns_XtoX.c config.h udns.h inet_XtoX.c
174+
udns_rr_a.o udns_rr_a.lo: udns_rr_a.c udns.h
175+
udns_rr_ptr.o udns_rr_ptr.lo: udns_rr_ptr.c udns.h
176+
udns_rr_mx.o udns_rr_mx.lo: udns_rr_mx.c udns.h
177+
udns_rr_txt.o udns_rr_txt.lo: udns_rr_txt.c udns.h
178+
udns_bl.o udns_bl.lo: udns_bl.c udns.h
179+
udns_rr_srv.o udns_rr_srv.lo: udns_rr_srv.c udns.h
180+
udns_rr_naptr.o udns_rr_naptr.lo: udns_rr_naptr.c udns.h
181+
udns_codes.o udns_codes.lo: udns_codes.c udns.h
182+
dnsget.o dnsget.lo: dnsget.c config.h udns.h getopt.c
183+
rblcheck.o rblcheck.lo: rblcheck.c udns.h getopt.c
184+
ex-rdns.o ex-rdns.lo: ex-rdns.c udns.h
185+
dnsget: dnsget.o $(LIB)
186+
$(CC) $(CFLAGS) -o $@ dnsget.o $(LIBFL)
187+
dnsget_s: dnsget.o $(SOLIB)
188+
$(CC) $(CFLAGS) -o $@ dnsget.o $(SOLIBFL)
189+
rblcheck: rblcheck.o $(LIB)
190+
$(CC) $(CFLAGS) -o $@ rblcheck.o $(LIBFL)
191+
rblcheck_s: rblcheck.o $(SOLIB)
192+
$(CC) $(CFLAGS) -o $@ rblcheck.o $(SOLIBFL)
193+
ex-rdns: ex-rdns.o $(LIB)
194+
$(CC) $(CFLAGS) -o $@ ex-rdns.o $(LIBFL)
195+
ex-rdns_s: ex-rdns.o $(SOLIB)
196+
$(CC) $(CFLAGS) -o $@ ex-rdns.o $(SOLIBFL)

deps/udns/NEWS

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
$Id: NEWS,v 1.11 2007/01/15 21:19:08 mjt Exp $
2+
3+
User-visible changes in udns library. Recent changes on top.
4+
5+
0.0.9 (16 Jan 2007)
6+
7+
- incompat: minor API changes in dns_init() &friends. dns_init()
8+
now requires extra `struct dns_ctx *' argument. Not bumped
9+
soversion yet - I only expect one "release" with this change,
10+
0.1 will have more changes and will increment so version
11+
12+
- many small bugfixes, here and there
13+
14+
- more robust FORMERR replies handling - not only such replies are now
15+
recognized, but udns retries queries without EDNS0 extensions if tried
16+
with, but server reported FORMERR
17+
18+
- portability changes, udns now includes getopt() implementation fo
19+
the systems lacking it (mostly windows), and dns_ntop()&dns_pton(),
20+
which are either just wrappers for system functions or reimplementations.
21+
22+
- build is now based on autoconf-like configuration
23+
24+
- NAPTR (RFC3403) RR decoding support
25+
26+
- new file NOTES which complements TODO somewhat, and includes some
27+
important shortcomings
28+
29+
- many internal cleanups, including some preparations for better error
30+
recovery, security and robustness (and thus API changes)
31+
32+
- removed some #defines which are now unused (like DNS_MAXSRCH)
33+
34+
- changed WIN32 to WINDOWS everywhere in preprocessor tests,
35+
to be able to build it on win64 as well
36+
37+
0.0.8 (12 Sep 2005)
38+
39+
- added SRV records (rfc2782) parsing,
40+
thanks to Thadeu Lima de Souza Cascardo for implementation.
41+
42+
- bugfixes:
43+
o use uninitialized value when no reply, library died with assertion:
44+
assert((status < 0 && result == 0) || (status >= 0 && result != 0)).
45+
o on some OSes, struct sockaddr_in has additional fields, so
46+
memcmp'ing two sockaddresses does not work.
47+
48+
- rblcheck(.1)
49+
50+
0.0.7 (20 Apr 2005)
51+
52+
- dnsget.1 manpage and several enhancements to dnsget.
53+
54+
- allow nameserver names for -n option of dnsget.
55+
56+
- API change: all dns_submit*() routines now does not expect
57+
last `now' argument, since requests aren't sent immediately
58+
anymore.
59+
60+
- API change: different application timer callback mechanism.
61+
Udns now uses single per-context timer instead of per-query.
62+
63+
- don't assume DNS replies only contain backward DN pointers,
64+
allow forward pointers too. Change parsing API.
65+
66+
- debianize
67+
68+
0.0.6 (08 Apr 2005)
69+
70+
- use double sorted list for requests (sorted by deadline).
71+
This should significantly speed up timeout processing for
72+
large number of requests.
73+
74+
- changed debugging interface, so it is finally useable
75+
(still not documented).
76+
77+
- dnsget routine is now Officially Useable, and sometimes
78+
even more useable than `host' from BIND distribution
79+
(and sometimes not - dnsget does not have -C option
80+
and TCP mode)
81+
82+
- Debian packaging in debian/ -- udns is now maintained as a
83+
native Debian package.
84+
85+
- alot (and I really mean alot) of code cleanups all over.

0 commit comments

Comments
 (0)