Skip to content

Commit

Permalink
add udns-0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuo committed Mar 7, 2012
1 parent 71154e9 commit c94fcc6
Show file tree
Hide file tree
Showing 34 changed files with 9,175 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
udns-0.2/*.o
38 changes: 38 additions & 0 deletions Makefile
@@ -0,0 +1,38 @@
#MUDUO_DIRECTORY ?= $(HOME)/build/debug-install
MUDUO_DIRECTORY ?= $(HOME)/build/release-install
MUDUO_INCLUDE = $(MUDUO_DIRECTORY)/include
MUDUO_LIBRARY = $(MUDUO_DIRECTORY)/lib
SRC = .

UDNSDIR = $(SRC)/udns-0.2
UDNSSRCS = udns_dn.c udns_dntosp.c udns_parse.c udns_resolver.c udns_init.c \
udns_misc.c udns_XtoX.c \
udns_rr_a.c udns_rr_ptr.c udns_rr_mx.c udns_rr_txt.c udns_bl.c \
udns_rr_srv.c udns_rr_naptr.c udns_codes.c udns_jran.c
UDNSHEADERS = config.h udns.h

BUILDDIR = build

CXXFLAGS = -g -O0 -Wall -Wextra -Werror \
-Wconversion -Wno-unused-parameter \
-Wold-style-cast -Woverloaded-virtual \
-Wpointer-arith -Wshadow -Wwrite-strings \
-march=native -rdynamic \
-I$(MUDUO_INCLUDE)

CFLAGS = -Wall -W -O2 -pipe -g

LDFLAGS = -L$(MUDUO_LIBRARY) -lmuduo_net -lmuduo_base -lpthread

all: libudns
clean:
rm -f core $(UDNSDIR)/libudns.a
cd $(UDNSDIR) && make clean

libudns:$(UDNSDIR)/libudns.a

$(UDNSDIR)/libudns.a:
cd $(UDNSDIR) && CFLAGS='$(CFLAGS)' ./configure --disable-ipv6 && make


.PHONY: all clean libudns
502 changes: 502 additions & 0 deletions udns-0.2/COPYING.LGPL

Large diffs are not rendered by default.

196 changes: 196 additions & 0 deletions udns-0.2/Makefile.in
@@ -0,0 +1,196 @@
#! /usr/bin/make -rf
# Makefile.in
# libudns Makefile
#
# Copyright (C) 2005 Michael Tokarev <mjt@corpit.ru>
# This file is part of UDNS library, an async DNS stub resolver.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library, in file named COPYING.LGPL; if not,
# write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA

NAME = udns
VERS = 0.2
SOVER = 0

SRCS = udns_dn.c udns_dntosp.c udns_parse.c udns_resolver.c udns_init.c \
udns_misc.c udns_XtoX.c \
udns_rr_a.c udns_rr_ptr.c udns_rr_mx.c udns_rr_txt.c udns_bl.c \
udns_rr_srv.c udns_rr_naptr.c udns_codes.c udns_jran.c
USRCS = dnsget.c rblcheck.c ex-rdns.c
DIST = COPYING.LGPL udns.h udns.3 dnsget.1 rblcheck.1 $(SRCS) $(USRCS) \
NEWS TODO NOTES Makefile.in configure configure.lib \
inet_XtoX.c getopt.c

OBJS = $(SRCS:.c=.o) $(GEN:.c=.o)
LIB = lib$(NAME).a
LIBFL = -L. -l$(NAME)

SOBJS = $(OBJS:.o=.lo)
SOLIB = lib$(NAME)_s.so
SOLIBV = lib$(NAME).so.$(SOVER)
SOLIBFL= -L. -l$(NAME)_s

LIBS = $(LIB) $(SOLIBV)

UTILS = $(USRCS:.c=)
UOBJS = $(USRCS:.c=.o)
SOUTILS = $(USRCS:.c=_s)

NAMEPFX = $(NAME)-$(VERS)

CC = @CC@
CFLAGS = @CFLAGS@
CDEFS = @CDEFS@
PICFLAGS = -fPIC
AWK = awk

all: static

.SUFFIXES: .c .o .lo

static: $(LIB) $(UTILS)
staticlib: $(LIB)
$(LIB): $(OBJS)
-rm -f $@
$(AR) rv $@ $(OBJS)
.c.o:
$(CC) $(CFLAGS) $(CDEFS) -c $<

shared: $(SOLIBV) $(SOUTILS)
sharedlib: $(SOLIBV)

$(SOLIBV): $(SOBJS)
$(CC) -shared -Wl,--soname,$(SOLIBV) -o $@ $(SOBJS)
$(SOLIB): $(SOLIBV)
rm -f $@
ln -s $(SOLIBV) $@
.c.lo:
$(CC) $(CFLAGS) $(PICFLAGS) $(CDEFS) -o $@ -c $<

# udns_codes.c is generated from udns.h
udns_codes.c: udns.h
@echo Generating $@
@set -e; exec >$@.tmp; \
set T type C class R rcode; \
echo "/* Automatically generated. */"; \
echo "#include \"udns.h\""; \
while [ "$$1" ]; do \
echo; \
echo "const struct dns_nameval dns_$${2}tab[] = {"; \
$(AWK) "/^ DNS_$${1}_[A-Z0-9_]+[ ]*=/ \
{ printf \" {%s,\\\"%s\\\"},\\n\", \$$1, substr(\$$1,7) }" \
udns.h ; \
echo " {0,0}};"; \
echo "const char *dns_$${2}name(enum dns_$${2} code) {"; \
echo " static char nm[20];"; \
echo " switch(code) {"; \
$(AWK) "BEGIN{i=0} \
/^ DNS_$${1}_[A-Z0-9_]+[ ]*=/ \
{printf \" case %s: return dns_$${2}tab[%d].name;\\n\",\$$1,i++}\
" udns.h ; \
echo " }"; \
echo " return _dns_format_code(nm,\"$$2\",code);"; \
echo "}"; \
shift 2; \
done
@mv $@.tmp $@

udns.3.html: udns.3
groff -man -Thtml udns.3 > $@.tmp
mv $@.tmp $@

dist: $(NAMEPFX).tar.gz
$(NAMEPFX).tar.gz: $(DIST)
mkdir $(NAMEPFX)
ln $(DIST) $(NAMEPFX)
tar cvfz $@ $(NAMEPFX)
rm -rf $(NAMEPFX)
subdist:
cp -p $(DIST) $(TARGET)/

clean:
rm -f $(OBJS)
rm -f $(SOBJS)
rm -f $(UOBJS)
rm -f config.log
distclean: clean
rm -f $(LIBS) $(SOLIB) udns.3.html
rm -f $(UTILS) $(SOUTILS)
rm -f config.status config.h Makefile


Makefile: configure configure.lib Makefile.in
./configure
@echo
@echo Please rerun make >&2
@exit 1

.PHONY: all static staticlib shared sharedlib dist clean distclean subdist \
depend dep deps

depend dep deps: $(SRCS) $(USRC)
@echo Generating deps for:
@echo \ $(SRCS)
@echo \ $(USRCS)
@sed '/^# depend/q' Makefile.in > Makefile.tmp
@set -e; \
for f in $(SRCS) $(USRCS); do \
echo $${f%.c}.o $${f%.c}.lo: $$f \
`sed -n 's/^#[ ]*include[ ]*"\(.*\)".*/\1/p' $$f`; \
done >> Makefile.tmp; \
for f in $(USRCS:.c=.o); do \
echo "$${f%.?}: $$f \$$(LIB)"; \
echo " \$$(CC) \$$(CFLAGS) -o \$$@ $$f \$$(LIBFL)"; \
echo "$${f%.?}_s: $$f \$$(SOLIB)"; \
echo " \$$(CC) \$$(CFLAGS) -o \$$@ $$f \$$(SOLIBFL)"; \
done >> Makefile.tmp ; \
if cmp Makefile.tmp Makefile.in >/dev/null 2>&1 ; then \
echo Makefile.in unchanged; rm -f Makefile.tmp; \
else \
echo Updating Makfile.in; mv -f Makefile.tmp Makefile.in ; \
fi

# depend
udns_dn.o udns_dn.lo: udns_dn.c udns.h
udns_dntosp.o udns_dntosp.lo: udns_dntosp.c udns.h
udns_parse.o udns_parse.lo: udns_parse.c udns.h
udns_resolver.o udns_resolver.lo: udns_resolver.c config.h udns.h
udns_init.o udns_init.lo: udns_init.c config.h udns.h
udns_misc.o udns_misc.lo: udns_misc.c udns.h
udns_XtoX.o udns_XtoX.lo: udns_XtoX.c config.h udns.h inet_XtoX.c
udns_rr_a.o udns_rr_a.lo: udns_rr_a.c udns.h
udns_rr_ptr.o udns_rr_ptr.lo: udns_rr_ptr.c udns.h
udns_rr_mx.o udns_rr_mx.lo: udns_rr_mx.c udns.h
udns_rr_txt.o udns_rr_txt.lo: udns_rr_txt.c udns.h
udns_bl.o udns_bl.lo: udns_bl.c udns.h
udns_rr_srv.o udns_rr_srv.lo: udns_rr_srv.c udns.h
udns_rr_naptr.o udns_rr_naptr.lo: udns_rr_naptr.c udns.h
udns_codes.o udns_codes.lo: udns_codes.c udns.h
udns_jran.o udns_jran.lo: udns_jran.c udns.h
dnsget.o dnsget.lo: dnsget.c config.h udns.h getopt.c
rblcheck.o rblcheck.lo: rblcheck.c config.h udns.h getopt.c
ex-rdns.o ex-rdns.lo: ex-rdns.c udns.h
dnsget: dnsget.o $(LIB)
$(CC) $(CFLAGS) -o $@ dnsget.o $(LIBFL)
dnsget_s: dnsget.o $(SOLIB)
$(CC) $(CFLAGS) -o $@ dnsget.o $(SOLIBFL)
rblcheck: rblcheck.o $(LIB)
$(CC) $(CFLAGS) -o $@ rblcheck.o $(LIBFL)
rblcheck_s: rblcheck.o $(SOLIB)
$(CC) $(CFLAGS) -o $@ rblcheck.o $(SOLIBFL)
ex-rdns: ex-rdns.o $(LIB)
$(CC) $(CFLAGS) -o $@ ex-rdns.o $(LIBFL)
ex-rdns_s: ex-rdns.o $(SOLIB)
$(CC) $(CFLAGS) -o $@ ex-rdns.o $(SOLIBFL)
123 changes: 123 additions & 0 deletions udns-0.2/NEWS
@@ -0,0 +1,123 @@
NEWS
User-visible changes in udns library. Recent changes on top.

0.2 (Dec 2011)

- bugfix: SRV RR handling: fix domain name parsing and crash in case
if no port is specified on input for SRV record query

- (trivial api) dns_set_opts() now returns number of unrecognized
options instead of always returning 0

- dnsget: combine -f and -o options in dnsget (and stop documenting -f),
and report unknown/invalid -o options (and error out)

- dnsget: pretty-print SSHFP RRs

0.1 (Dec 2010)

- bugfix: udns_new(old) - when actually cloning another context -
makes the new context referencing memory from old, which leads
to crashes when old is modified later

- use random queue IDs (the 16bit qID) in queries instead of sequentional
ones, based on simple pseudo-random RNG by Bob Jenkins (udns_jran.[ch]).
Some people believe that this improves security (CVE-2008-1447). I'm
still not convinced (see comments in udns_resolver.c), but it isn't
difficult to add after all.

- deprecate dns_random16() function which was declared in udns.h
(not anymore) but never documented. In order to keep ABI compatible
it is still exported.

- library has a way now to set query flags (DNS_SET_DO; DNS_SET_CD).

- dnsget now prints non-printable chars in all strings in DNS RRs using
decimal escape sequences (\%03u) instead of hexadecimal (\%02x) when
before - other DNS software does it like this.

- recognize a few more record types in dnsget, notable some DNSSEC RRs;
add -f option for dnsget to set query flags.

- udns is not a Debian native package anymore (was a wrong idea)

0.0.9 (16 Jan 2007)

- incompat: minor API changes in dns_init() &friends. dns_init()
now requires extra `struct dns_ctx *' argument. Not bumped
soversion yet - I only expect one "release" with this change.

- many small bugfixes, here and there

- more robust FORMERR replies handling - not only such replies are now
recognized, but udns retries queries without EDNS0 extensions if tried
with, but server reported FORMERR

- portability changes, udns now includes getopt() implementation fo
the systems lacking it (mostly windows), and dns_ntop()&dns_pton(),
which are either just wrappers for system functions or reimplementations.

- build is now based on autoconf-like configuration

- NAPTR (RFC3403) RR decoding support

- new file NOTES which complements TODO somewhat, and includes some
important shortcomings

- many internal cleanups, including some preparations for better error
recovery, security and robustness (and thus API changes)

- removed some #defines which are now unused (like DNS_MAXSRCH)

- changed WIN32 to WINDOWS everywhere in preprocessor tests,
to be able to build it on win64 as well

0.0.8 (12 Sep 2005)

- added SRV records (rfc2782) parsing,
thanks to Thadeu Lima de Souza Cascardo for implementation.

- bugfixes:
o use uninitialized value when no reply, library died with assertion:
assert((status < 0 && result == 0) || (status >= 0 && result != 0)).
o on some OSes, struct sockaddr_in has additional fields, so
memcmp'ing two sockaddresses does not work.

- rblcheck(.1)

0.0.7 (20 Apr 2005)

- dnsget.1 manpage and several enhancements to dnsget.

- allow nameserver names for -n option of dnsget.

- API change: all dns_submit*() routines now does not expect
last `now' argument, since requests aren't sent immediately
anymore.

- API change: different application timer callback mechanism.
Udns now uses single per-context timer instead of per-query.

- don't assume DNS replies only contain backward DN pointers,
allow forward pointers too. Change parsing API.

- debianize

0.0.6 (08 Apr 2005)

- use double sorted list for requests (sorted by deadline).
This should significantly speed up timeout processing for
large number of requests.

- changed debugging interface, so it is finally useable
(still not documented).

- dnsget routine is now Officially Useable, and sometimes
even more useable than `host' from BIND distribution
(and sometimes not - dnsget does not have -C option
and TCP mode)

- Debian packaging in debian/ -- udns is now maintained as a
native Debian package.

- alot (and I really mean alot) of code cleanups all over.

0 comments on commit c94fcc6

Please sign in to comment.