Permalink
Browse files

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.
  • Loading branch information...
1 parent 77d407d commit 41d89f611fef833daad5324cf638dd974a735c3a @ry ry committed Jul 28, 2009
View
4 LICENSE
@@ -22,6 +22,10 @@ are:
- The SCONS build system, located at tools/scons. Copyrighted by the SCONS
Foundation. Released under an MIT license.
+ - UDNS, an asynchronous DNS client, located at deps/udns. Copyrighted by
+ Michael Tokarev <mjt@corpit.ru>. Released under the GNU Lesser General
+ Public License version 2.1.
+
Additionally deps/http_parser is based on Zed Shaw's Mongrel. Mongrel is
copyrighted by Zed Shaw and distributed under GPL2 or a permissive open
licence. See deps/http_parser/LICENCE for more information.
View
14 deps/udns/.cvsignore
@@ -0,0 +1,14 @@
+udns*.tar.gz
+udns_codes.c
+udns.3.html
+*.lo
+*_s
+libudns.so.*
+dnsget
+ex-rdns
+rblcheck
+Makefile
+config.h
+config.status
+config.log
+build-stamp
View
504 deps/udns/COPYING.LGPL
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
View
196 deps/udns/Makefile.in
@@ -0,0 +1,196 @@
+#! /usr/bin/make -rf
+# $Id: Makefile.in,v 1.11 2007/01/15 21:19:08 mjt Exp $
+# 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.0.9
+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
+USRCS = dnsget.c rblcheck.c ex-rdns.c
+DEB = debian/copyright debian/changelog debian/control debian/rules
+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)
+
+SOVER = 0
+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) $(DEB)
+ mkdir $(NAMEPFX) $(NAMEPFX)/debian
+ ln $(DIST) $(NAMEPFX)
+ ln $(DEB) $(NAMEPFX)/debian
+ tar cvfz $@ $(NAMEPFX)
+ rm -rf $(NAMEPFX)
+subdist:
+ cp -p $(DIST) $(TARGET)/
+
+clean:
+ rm -f $(OBJS)
+ rm -f $(SOBJS)
+ rm -f $(UOBJS)
+ rm -f build-stamp 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
+dnsget.o dnsget.lo: dnsget.c config.h udns.h getopt.c
+rblcheck.o rblcheck.lo: rblcheck.c 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)
View
85 deps/udns/NEWS
@@ -0,0 +1,85 @@
+$Id: NEWS,v 1.11 2007/01/15 21:19:08 mjt Exp $
+
+User-visible changes in udns library. Recent changes on top.
+
+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,
+ 0.1 will have more changes and will increment so version
+
+ - 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.
View
222 deps/udns/NOTES
@@ -0,0 +1,222 @@
+Assorted notes about udns (library).
+
+UDP-only mode
+~~~~~~~~~~~~~
+
+First of all, since udns is (currently) UDP-only, there are some
+shortcomings.
+
+It assumes that a reply will fit into a UDP buffer. With adoption of EDNS0,
+and general robustness of IP stacks, in most cases it's not an issue. But
+in some cases there may be problems:
+
+ - if an RRset is "very large" so it does not fit even in buffer of size
+ requested by the library (current default is 4096; some servers limits
+ it further), we will not see the reply, or will only see "damaged"
+ reply (depending on the server).
+
+ - many DNS servers ignores EDNS0 option requests. In this case, no matter
+ which buffer size udns library will request, such servers reply is limited
+ to 512 bytes (standard pre-EDNS0 DNS packet size). (Udns falls back to
+ non-EDNO0 query if EDNS0-enabled one received FORMERR or NOTIMPL error).
+
+The problem is that with this, udns currently will not consider replies with
+TC (truncation) bit set, and will treat such replies the same way as it
+treats SERVFAIL replies, thus trying next server, or temp-failing the query
+if no more servers to try. In other words, if the reply is really large, or
+if the servers you're using don't support EDNS0, your application will be
+unable to resolve a given name.
+
+Yet it's not common situation - in practice, it's very rare.
+
+Implementing TCP mode isn't difficult, but it complicates API significantly.
+Currently udns uses only single UDP socket (or - maybe in the future - two,
+see below), but in case of TCP, it will need to open and close sockets for
+TCP connections left and right, and that have to be integrated into an
+application's event loop in an easy and efficient way. Plus all the
+timeouts - different for connect(), write, and several stages of read.
+
+IPv6 vs IPv4 usage
+~~~~~~~~~~~~~~~~~~
+
+This is only relevant for nameservers reachable over IPv6, NOT for IPv6
+queries. I.e., if you've IPv6 addresses in 'nameservers' line in your
+/etc/resolv.conf file. Even more: if you have BOTH IPv6 AND IPv4 addresses
+there. Or pass them to udns initialization routines.
+
+Since udns uses a single UDP socket to communicate with all nameservers,
+it should support both v4 and v6 communications. Most current platforms
+supports this mode - using PF_INET6 socket and V4MAPPED addresses, i.e,
+"tunnelling" IPv4 inside IPv6. But not all systems supports this. And
+more, it has been said that such mode is deprecated.
+
+So, list only IPv4 or only IPv6 addresses, but don't mix them, in your
+/etc/resolv.conf.
+
+An alternative is to use two sockets instead of 1 - one for IPv6 and one
+for IPv4. For now I'm not sure if it's worth the complexity - again, of
+the API, not the library itself (but this will not simplify library either).
+
+Single socket for all queries
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Using single UDP socket for sending queries to all nameservers has obvious
+advantages. First it's, again, trivial, simple to use API. And simple
+library too. Also, after sending queries to all nameservers (in case first
+didn't reply in time), we will be able to receive late reply from first
+nameserver and accept it.
+
+But this mode has disadvantages too. Most important is that it's much easier
+to send fake reply to us, as the UDP port where we expects the reply to come
+to is constant during the whole lifetime of an application. More secure
+implementations uses random port for every single query. While port number
+(16 bits integer) can not hold much randomness, it's still of some help.
+Ok, udns is a stub resolver, so it expects sorta friendly environment, but
+on LAN it's usually much easier to fire an attack, due to the speed of local
+network, where a bad guy can generate alot of packets in a short time.
+
+Choosing of DNS QueryID
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Currently, udns uses sequential number for query IDs. Which simplifies
+attacks even more (c.f. the previous item about single UDP port), making
+them nearly trivial. The library should use random number for query ID.
+But there's no portable way to get random numbers, even on various flavors
+of Unix. It's possible to use low bits from tv_nsec field returned by
+gettimeofday() (current time, nanoseconds), but I wrote the library in
+a way to avoid making system calls where possible, because many syscalls
+means many context switches and slow processes as a result. Maybe use some
+application-supplied callback to get random values will be a better way,
+defaulting to gettimeofday() method.
+
+Note that a single query - even if (re)sent to different nameservers, several
+times (due to no reply received in time), uses the same qID assigned when it
+was first dispatched. So we have: single UDP socket (fixed port number),
+sequential (= trivially predictable) qIDs, and long lifetime of those qIDs.
+This all makes (local) attacks against the library really trivial.
+
+See also comments in udns_resolver.c, udns_newid().
+
+And note that at least some other stub resolvers out there (like c-ares
+for example) also uses sequential qID.
+
+Assumptions about RRs returned
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Currently udns processes records in the reply it received sequentially.
+This means that order of the records is significant. For example, if
+we asked for foo.bar A, but the server returned that foo.bar is a CNAME
+(alias) for bar.baz, and bar.baz, in turn, has address 1.2.3.4, when
+the CNAME should come first in reply, followed by A. While DNS specs
+does not say anything about order of records - it's an rrSET - unordered, -
+I think an implementation which returns the records in "wrong" order is
+somewhat insane...
+
+CNAME recursion
+~~~~~~~~~~~~~~~
+
+Another interesting point is the handling of CNAMEs returned as replies
+to non-CNAME queries. If we asked for foo.bar A, but it's a CNAME, udns
+expects BOTH the CNAME itself and the target DN to be present in the reply.
+In other words, udns DOES NOT RECURSE CNAMES. If we asked for foo.bar A,
+but only record in reply was that foo.bar is a CNAME for bar.baz, udns will
+return no records to an application (NXDOMAIN). Strictly speaking, udns
+should repeat the query asking for bar.baz A, and recurse. But since it's
+stub resolver, recursive resolver should recurse for us instead.
+
+It's not very difficult to implement, however. Probably with some (global?)
+flag to en/dis-able the feature. Provided there's some demand for it.
+
+To clarify: udns handles CNAME recursion in a single reply packet just fine.
+
+Note also that standard gethostbyname() routine does not recurse in this
+situation, too.
+
+Error reporting
+~~~~~~~~~~~~~~~
+
+Too many places in the code (various failure paths) sets generic "TEMPFAIL"
+error condition. For example, if no nameserver replied to our query, an
+application will get generic TEMPFAIL, instead of something like TIMEDOUT.
+This probably should be fixed, but most applications don't care about the
+exact reasons of failure - 4 common cases are already too much:
+ - query returned some valid data
+ - NXDOMAIN
+ - valid domain but no data of requested type - =NXDOMAIN in most cases
+ - temporary error - this one sometimes (incorrectly!) treated as NXDOMAIN
+ by (naive) applications.
+DNS isn't yes/no, it's at least 3 variants, temp err being the 3rd important
+case! And adding more variations for the temp error case is complicating things
+even more - again, from an application writer standpoint. For diagnostics,
+such more specific error cases are of good help.
+
+Planned API changes
+~~~~~~~~~~~~~~~~~~~
+
+At least one thing I want to change for 0.1 version is a way how queries are
+submitted and how replies are handled.
+
+I want to made dns_query object to be owned by an application. So that instead
+of udns library allocating it for the lifetime of query, it will be pre-
+allocated by an application. This simplifies and enhances query submitting
+interface, and complicates it a bit too, in simplest cases.
+
+Currently, we have:
+
+dns_submit_dn(dn, cls, typ, flags, parse, cbck, data)
+dns_submit_p(name, cls, typ, flags, parse, cbck, data)
+dns_submit_a4(ctx, name, flags, cbck, data)
+
+and so on -- with many parameters missed for type-specific cases, but generic
+cases being too complex for most common usage.
+
+Instead, with dns_query being owned by an app, we will be able to separately
+set up various parts of the query - domain name (various forms), type&class,
+parser, flags, callback... and even change them at runtime. And we will also
+be able to reuse query structures, instead of allocating/freeing them every
+time. So the whole thing will look something like:
+
+ q = dns_alloc_query();
+ dns_submit(dns_q_flags(dns_q_a4(q, name, cbck), DNS_F_NOSRCH), data);
+
+The idea is to have a set of functions accepting struct dns_query* and
+returning it (so the calls can be "nested" like the above), to set up
+relevant parts of the query - specific type of callback, conversion from
+(type-specific) query parameters into a domain name (this is for type-
+specific query initializers), and setting various flags and options and
+type&class things.
+
+One example where this is almost essential - if we want to support
+per-query set of nameservers (which isn't at all useless: imagine a
+high-volume mail server, were we want to direct DNSBL queries to a separate
+set of nameservers, and rDNS queries to their own set and so on). Adding
+another argument (set of nameservers to use) to EVERY query submitting
+routine is.. insane. Especially since in 99% cases it will be set to
+default NULL. But with such "nesting" of query initializers, it becomes
+trivial.
+
+Another way to do the same is to manipulate query object right after a
+query has been submitted, but before any events processing (during this
+time, query object is allocated and initialized, but no actual network
+packets were sent - it will happen on the next event processing). But
+this way it become impossible to perform syncronous resolver calls, since
+those calls hide query objects they use internally.
+
+Speaking of replies handling - the planned change is to stop using dynamic
+memory (malloc) inside the library. That is, instead of allocating a buffer
+for a reply dynamically in a parsing routine (or memdup'ing the raw reply
+packet if no parsing routine is specified), I want udns to return the packet
+buffer it uses internally, and change parsing routines to expect a buffer
+for result. When parsing, a routine will return true amount of memory it
+will need to place the result, regardless of whenever it has enough room
+or not, so that an application can (re)allocate properly sized buffer and
+call a parsing routine again.
+
+Another modification I plan to include is to have an ability to work in
+terms of domain names (DNs) as used with on-wire DNS packets, not only
+with asciiz representations of them. For this to work, the above two
+changes (query submission and result passing) have to be completed first
+(esp. the query submission part), so that it will be possible to specify
+some additional query flags (for example) to request domain names instead
+of the text strings, and to allow easy query submissions with either DNs
+or text strings.
View
69 deps/udns/TODO
@@ -0,0 +1,69 @@
+$Id: TODO,v 1.13 2007/01/15 21:19:08 mjt Exp $
+
+The following is mostly an internal, not user-visible stuff.
+
+* rearrange an API to make dns_query object owned by application,
+ so that it'll look like this:
+ struct dns_query *q;
+ q = udns_query_alloc(ctx);
+ udns_query_set(q, options, domain_name, flags, ...);
+ udns_query_submit(ctx, q);
+ or
+ udns_query_resolve(ctx, q);
+
+* allow NULL callbacks? Or provide separate resolver
+ context list of queries which are done but wich did not
+ have callback, and dns_pick() routine to retrieve results
+ from this query, i.e. allow non-callback usage? The
+ non-callback usage may be handy sometimes (any *good*
+ example?), but it will be difficult to provide type-safe
+ non-callback interface due to various RR-specific types
+ in use.
+
+* DNS_OPT_FLAGS should be DNS_OPT_ADDFLAGS and DNS_OPT_SETFLAGS.
+ Currently one can't add a single flag bit but preserve
+ existing bits... at least not without retrieving all current
+ flags before, which isn't that bad anyway.
+
+* dns_set_opts() may process flags too (such as aaonly etc)
+
+* a way to disable $NSCACHEIP et al processing?
+ (with now separate dns_init() and dns_reset(), it has finer
+ control, but still no way to init from system files but ignore
+ environment variables and the like)
+
+* initialize/open the context automatically, and be more
+ liberal about initialization in general?
+
+* dns_init(ctx, do_open) - make the parameter opposite, aka
+ dns_init(ctx, skip_open) ?
+
+* allow TCP queue?
+
+* And oh, qID should really be random. Or... not.
+ See notes in udns_resolver.c, dns_newid().
+
+* more accurate error reporting. Currently, udns always returns TEMPFAIL,
+ but don't specify why it happened (ENOMEM, timeout, etc).
+
+* check the error value returned by recvfrom() and
+ sendto() and determine which errors to ignore.
+
+* maybe merge dns_timeouts() and dns_ioevent(), to have
+ only one entry point for everything? For traditional
+ select-loop-based eventloop it may be easier, but for
+ callback-driven event loops the two should be separate.
+ Provide an option, or a single dns_events() entry point
+ for select-loop approach, or just call dns_ioevent()
+ from within dns_timeouts() (probably after renaming
+ it to be dns_events()) ?
+
+* implement /etc/hosts lookup too, ala [c-]ares??
+
+* sortlist support?
+
+* windows port? Oh no please!.. At least, I can't do it myself
+ because of the lack of platform.
+ Ok ok, the Windows port is in progress. Christian Prahauser
+ from cosy.sbg.ac.at is helping with that.
+ Other folks done some more work in this area.
View
167 deps/udns/configure
@@ -0,0 +1,167 @@
+#! /bin/sh
+# $Id: configure,v 1.4 2007/01/07 23:19:40 mjt Exp $
+# autoconf-style configuration script
+#
+
+set -e
+
+name=udns
+
+if [ -f udns.h -a -f udns_resolver.c ] ; then :
+else
+ echo "configure: error: sources not found at `pwd`" >&2
+ exit 1
+fi
+
+options="ipv6"
+
+for opt in $options; do
+ eval enable_$opt=
+done
+
+if [ -f config.status ]; then
+ . ./config.status
+fi
+
+enable() {
+ opt=`echo "$1" | sed 's/^--[^-]*-//'`
+ case "$opt" in
+ ipv6|stats|master_dump|zlib|dso) ;;
+ master-dump) opt=master_dump ;;
+ *) echo "configure: unrecognized option \`$1'" >&2; exit 1;;
+ esac
+ eval enable_$opt=$2
+}
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --disable-*|--without-*|--no-*) enable "$1" n;;
+ --enable-*|--with-*) enable "$1" y;;
+ --help | --hel | --he | --h | -help | -hel | -he | -h )
+ cat <<EOF
+configure: configure $name package.
+Usage: ./configure [options]
+where options are:
+ --enable-option, --with-option --
+ enable the named option/feature
+ --disable-option, --without-option, --no-option --
+ disable the named option/feature
+ --help - print this help and exit
+Optional features (all enabled by default if system supports a feature):
+ ipv6 - enable/disable IP version 6 (IPv6) support
+EOF
+ exit 0
+ ;;
+ *) echo "configure: unknown option \`$1'" >&2; exit 1 ;;
+ esac
+ shift
+done
+
+. ./configure.lib
+
+ac_msg "configure"
+ac_result "$name package"
+
+ac_prog_c_compiler_v
+ac_prog_ranlib_v
+
+ac_ign ac_yesno "for getopt()" ac_have GETOPT ac_link <<EOF
+#include <stdio.h>
+extern int optind;
+extern char *optarg;
+extern int getopt(int, char **, char *);
+int main(int argc, char **argv) {
+ getopt(argc, argv, "abc");
+ return optarg ? optind : 0;
+}
+EOF
+
+ac_ign \
+ ac_yesno "for inet_pton() && inet_ntop()" \
+ ac_have INET_PTON_NTOP \
+ ac_link <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+int main() {
+ char buf[64];
+ long x = 0;
+ inet_pton(AF_INET, &x, buf);
+ return inet_ntop(AF_INET, &x, buf, sizeof(buf));
+}
+EOF
+
+if ac_yesno "for socklen_t" ac_compile <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+int foo() { socklen_t len; len = 0; return len; }
+EOF
+then :
+else
+ ac_define socklen_t int
+fi
+
+if ac_library_find_v 'socket and connect' "" "-lsocket -lnsl" <<EOF
+int main() { socket(); connect(); return 0; }
+EOF
+then :
+else
+ ac_fatal "cannot find libraries needed for sockets"
+fi
+
+if [ n != "$enable_ipv6" ]; then
+if ac_yesno "for IPv6" ac_have IPv6 ac_compile <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+int main() {
+ struct sockaddr_in6 sa;
+ sa.sin6_family = AF_INET6;
+ return 0;
+}
+EOF
+then :
+elif [ "$enable_ipv6" ]; then
+ ac_fatal "IPv6 is requested but not available"
+fi
+fi # !disable_ipv6?
+
+if ac_yesno "for poll()" ac_have POLL ac_link <<EOF
+#include <sys/types.h>
+#include <sys/poll.h>
+int main() {
+ struct pollfd pfd[2];
+ return poll(pfd, 2, 10);
+}
+EOF
+then :
+else
+ ac_ign ac_yesno "for sys/select.h" ac_have SYS_SELECT_H ac_cpp <<EOF
+#include <sys/types.h>
+#include <sys/select.h>
+EOF
+fi
+
+ac_config_h
+ac_output Makefile
+ac_msg "creating config.status"
+rm -f config.status
+{
+echo "# automatically generated by configure to hold command-line options"
+echo
+found=
+for opt in $options; do
+ eval val=\$enable_$opt
+ if [ -n "$val" ]; then
+ echo enable_$opt=$val
+ found=y
+ fi
+done
+if [ ! "$found" ]; then
+ echo "# (no options encountered)"
+fi
+} > config.status
+ac_result ok
+
+ac_result "all done."
+exit 0
View
268 deps/udns/configure.lib
@@ -0,0 +1,268 @@
+# configure.lib
+# a library of shell routines for simple autoconf system
+#
+
+set -e
+ac_substitutes=
+rm -f conftest* config.log
+exec 5>config.log
+cat <<EOF >&5
+This file contains any messages produced by compilers etc while
+running configure, to aid debugging if configure script makes a mistake.
+
+EOF
+
+case `echo "a\c"` in
+ *c*) ac_en=-n ac_ec= ;;
+ *) ac_en= ac_ec='\c' ;;
+esac
+
+##### Messages
+ac_msg() {
+ echo $ac_en "$*... $ac_ec"
+ echo ">>> $*" >&5
+}
+ac_checking() {
+ echo $ac_en "checking $*... $ac_ec"
+ echo ">>> checking $*" >&5
+}
+ac_result() {
+ echo "$1"
+ echo "=== $1" >&5
+}
+ac_fatal() {
+ echo "configure: fatal: $*" >&2
+ echo "=== FATAL: $*" >&5
+ exit 1
+}
+ac_warning() {
+ echo "configure: warning: $*" >&2
+ echo "=== WARNING: $*" >&5
+}
+ac_ign() {
+ "$@" || :
+}
+
+# ac_run command...
+# captures output in conftest.out
+ac_run() {
+ # apparently UnixWare (for one) /bin/sh optimizes the following "if"
+ # "away", by checking if there's such a command BEFORE redirecting
+ # output. So error message (like "gcc: command not found") goes
+ # to stderr instead of to conftest.out, and `cat conftest.out' below
+ # fails.
+ if "$@" >conftest.out 2>&1; then
+ return 0
+ else
+ echo "==== Command invocation failed. Command line was:" >&5
+ echo "$*" >&5
+ echo "==== compiler input was:" >&5
+ cat conftest.c >&5
+ echo "==== output was:" >&5
+ cat conftest.out >&5
+ echo "====" >&5
+ return 1
+ fi
+}
+
+# common case for ac_verbose: yes/no result
+ac_yesno() {
+ ac_checking "$1"
+ shift
+ if "$@"; then
+ ac_result yes
+ return 0
+ else
+ ac_result no
+ return 1
+ fi
+}
+
+ac_subst() {
+ ac_substitutes="$ac_substitutes $*"
+}
+
+ac_define() {
+ CDEFS="$CDEFS -D$1=${2:-1}"
+}
+
+ac_have() {
+ ac_what=$1; shift
+ if "$@"; then
+ ac_define HAVE_$ac_what
+ eval ac_have_$ac_what=yes
+ return 0
+ else
+ eval ac_have_$ac_what=no
+ return 1
+ fi
+}
+
+##### Compiling, linking
+
+# run a compiler
+ac_run_compiler() {
+ rm -f conftest*; cat >conftest.c
+ ac_run $CC $CFLAGS $CDEFS "$@" conftest.c
+}
+
+ac_compile() {
+ ac_run_compiler -c
+}
+
+ac_link() {
+ ac_run_compiler -o conftest $LIBS "$@"
+}
+
+ac_cpp() {
+ ac_run_compiler -E "$@"
+}
+
+### check for C compiler. Set $CC, $CFLAGS etc
+ac_prog_c_compiler_v() {
+ ac_checking "for C compiler"
+ rm -f conftest*
+ echo 'int main(int argc, char **argv) { return 0; }' >conftest.c
+
+ if [ -n "$CC" ]; then
+ if ac_run $CC -o conftest conftest.c && ac_run ./conftest; then
+ ac_result "\$CC ($CC)"
+ else
+ ac_result no
+ ac_fatal "\$CC ($CC) is not a working compiler"
+ fi
+ else
+ for cc in gcc cc ; do
+ if ac_run $cc -o conftest conftest.c && ac_run ./conftest; then
+ ac_result "$cc"
+ CC=$cc
+ break
+ fi
+ done
+ if [ -z "$CC" ]; then
+ ac_result no
+ ac_fatal "no working C compiler found in \$PATH. please set \$CC variable"
+ fi
+ fi
+ if [ -z "$CFLAGS" ]; then
+ if ac_yesno "whenever C compiler ($CC) is GNU CC" \
+ ac_grep_cpp yEs_mAsTeR <<EOF
+#ifdef __GNUC__
+ yEs_mAsTeR;
+#endif
+EOF
+ then
+ CFLAGS="-Wall -W -O2 -pipe"
+ else
+ CFLAGS=-O
+ fi
+ fi
+ cc="$CC $CFLAGS"
+ ccld="$cc"
+ if [ -n "$LDFLAGS" ]; then ccld="$ccld $LDFLAGS"; fi
+ if [ -n "$LIBS" ]; then ccld="$ccld $LIBS"; fi
+ if ac_yesno "whenever the C compiler ($ccld)
+ can produce executables" \
+ ac_compile_run <<EOF
+int main() { return 0; }
+EOF
+ then :
+ else
+ ac_fatal "no working C compiler found"
+ fi
+ LD='$(CC)'
+ [ -n "$AR" ] || AR=ar
+ [ -n "$ARFLAGS" ] || ARFLAGS=rv
+ [ -n "$AWK" ] || AWK=awk
+ ac_substitutes="$ac_substitutes CC CFLAGS CDEFS LD LDFLAGS LIBS AR ARFLAGS AWK"
+}
+
+
+ac_prog_ranlib_v() {
+ ac_checking "for ranlib"
+ if [ -n "$RANLIB" ]; then
+ ac_result "\$RANLIB ($RANLIB)"
+ else
+ ifs="$IFS"
+ IFS=:
+ for dir in $PATH; do
+ [ -n "$dir" ] || dir=.
+ if [ -f $dir/ranlib ]; then
+ RANLIB=ranlib
+ break
+ fi
+ done
+ IFS="$ifs"
+ if [ -z "$RANLIB" ]; then ac_result no; RANLIB=:
+ else ac_result "$RANLIB"
+ fi
+ fi
+ ac_substitutes="$ac_substitutes RANLIB"
+}
+
+ac_library_find_v() {
+ ac_checking "for libraries needed for $1"
+ shift
+ fond=
+ rm -f conftest*; cat >conftest.c
+ for lib in "$@"; do
+ if ac_run $CC $CFLAGS $LDFLAGS conftest.c -o conftest $LIBS $lib; then
+ found=y
+ break
+ fi
+ done
+ if [ ! "$found" ]; then
+ ac_result "not found"
+ return 1
+ fi
+ if [ -z "$lib" ]; then
+ ac_result "ok (none needed)"
+ else
+ ac_result "ok ($lib)"
+ LIBS="$LIBS $lib"
+ fi
+}
+
+ac_compile_run() {
+ ac_link "$@" && ac_run ./conftest
+}
+
+ac_grep_cpp() {
+ pattern="$1"; shift
+ ac_cpp "$@" && grep "$pattern" conftest.out >/dev/null
+}
+
+ac_output() {
+ for var in $ac_substitutes; do
+ eval echo "\"s|@$var@|\$$var|\""
+ done >conftest.sed
+ for file in "$@"; do
+ ac_msg "creating $file"
+ if [ -f $file.in ]; then
+ sed -f conftest.sed $file.in > $file.tmp
+ mv -f $file.tmp $file
+ ac_result ok
+ else
+ ac_result failed
+ ac_fatal "$file.in not found"
+ fi
+ done
+ rm -f conftest*
+}
+
+ac_config_h() {
+ h=${1:-config.h}
+ ac_msg "creating $h"
+ rm -f $1.tmp
+ echo "/* automatically generated by configure. */" > $h.tmp
+ echo "$CDEFS" | tr ' ' '
+' | sed -e 's/^-D/#define /' -e 's/=/ /' >> $h.tmp
+ if [ -f $h ] && cmp -s $h.tmp $h ; then
+ rm -f $h.tmp
+ ac_result unchanged
+ else
+ mv -f $h.tmp $h
+ ac_result ok
+ fi
+ CDEFS=-DHAVE_CONFIG_H
+}
View
136 deps/udns/debian/changelog
@@ -0,0 +1,136 @@
+udns (0.0.9) unstable; urgency=low
+
+ * s/EOVERFLOW/ENFILE, partly to make win32 happy
+
+ * several win32 fixes
+
+ * don't use `class' in udns.h, to make C++ happy
+ (thanks Markus Koetter for pointing this out)
+
+ * fixed CNAME handling in dnsget tool. Another Thank You! goes
+ to Markus Koetter.
+
+ * NAPTR (RFC3403) support, thanks to Mikael Magnusson
+ <mikma at users.sourceforge.net> for this.
+
+ * more Win32 fixes from Mikael Magnusson. I have to admit
+ I never tried to compile it on Win32.
+
+ * added NOTES file
+
+ * reworked initialisation stuff. Minor API changes -- new dns_reset(),
+ dns_init() now has one more argument, corrections to dns_close(),
+ dns_open(), dns_free(). Cleaned up *_internal() routines.
+
+ * moved dns_init() routine into separate file.
+
+ * reworked dn suffix searching. As a result, query only has
+ dnsq_dn[] field -- no header and EDNS0 "suffix", and query
+ packet is now formatted in dns_send()
+
+ * added inet_XtoX.c - public domain implementations of inet_pton()
+ and inet_ntop(), inet_aton() and inet_ntoa() routines.
+
+ * added getopt.c - public domain implementation of getopt() routine.
+
+ * switched to autoconf-style configuration
+
+ * introduce dns_random16() to generate query IDs
+ (currently based on gettimeofday.tv_usec)
+
+ * dnsget: fix printing of -t ANY and -c any records,
+ thanks to Jaroslaw Rafa
+
+ * implement dns_ntop() and dns_pton() as either wrappers or
+ reimplementations (using inet_XtoX.c) of inet_ntop() and inet_pton().
+ Too much troubles with portability - it was a complete mess, each
+ OS has its own problems with them.
+ And use those routines everywhere.
+
+ * s/WIN32/WINDOWS/g to allow building on WIN64. Oh well.
+
+ * try to find query by ID first, don't drop header-only replies early.
+ This is in order to support FORMERR replies from nameservers which
+ don't understand EDNS0.
+
+ * retry queries w/o EDNS0 if sent with it and if
+ server reported FORMERR or NOTIMPL
+
+ * fixed debian/copyright and debian/control
+
+ * rblcheck revamp
+
+ -- Michael Tokarev <mjt@corpit.ru> Tue, 16 Jan 2007 00:00:28 +0300
+
+udns (0.0.8) unstable; urgency=low
+
+ * don't compare sockaddr_in's, but individual parts only
+ (on some OSes, there are additional fields in this structure
+ so memcmp() does not quite work)
+
+ * use dnsc_t instead of unsigned char for DNs everywhere
+
+ * SRV records (rfc2782) parsing, thanks to
+ Thadeu Lima de Souza Cascardo.
+
+ * manpage fixes
+
+ -- Michael Tokarev <mjt@corpit.ru> Mon, 12 Sep 2005 16:06:45 +0400
+
+udns (0.0.7) unstable; urgency=low
+
+ * added dnsget.1 and rblcheck.1 manpages.
+
+ * internal: use generic list implementation in udns_resolver.c
+
+ * don't assume only backward DN pointers in replies, allow forward
+ pointers too. This is quite large change, involves changing
+ parsing API all over the places.
+
+ * internal: typedef dnsc_t and dnscc_t for [const] unsigned char, to
+ make function prototypes shorter to better fit on a single line.
+
+ * in parsing routines, verify (assert) that the query type
+ is the one we can handle.
+
+ * recognize names (and resolve them) as nameservers in dnsget.
+
+ * when new request is submitted, don't send it immediately, but
+ add it into the head of the active queue with deadline=0.
+ This will allow us to tweak some query settings before it will
+ be processed.
+ Note API change: removed `now' argument from all dns_submit_*()
+ routines.
+
+ * use single per-context user timer, not per-query.
+ Note API change: different user timer callback
+
+ * add dnsc_salen field -- length of the socket address used
+
+ * fix dns_set_opt(DNS_OPT_FLAGS) which didn't work before
+
+ * allow to set some options for a context wich is open but with no
+ active queries
+
+ -- Michael Tokarev <mjt@corpit.ru> Thu, 5 May 2005 23:14:29 +0400
+
+udns (0.0.6) unstable; urgency=low
+
+ * 0.0.6 release.
+ ALOT of changes all over. Keep 'em in CVS logs!
+
+ -- Michael Tokarev <mjt@corpit.ru> Fri, 8 Apr 2005 19:51:38 +0400
+
+udns (0.0.5) unstable; urgency=low
+
+ * Initial Release.
+ * Provides 3 packages:
+ libudns0 - shared library
+ libudns-dev - development files and static library
+ udns-utils - dnsget, rblcheck
+
+ -- Michael Tokarev <mjt@corpit.ru> Thu, 7 Apr 2005 00:05:24 +0400
+
+Local variables:
+mode: debian-changelog
+End:
View
33 deps/udns/debian/control
@@ -0,0 +1,33 @@
+Source: udns
+Priority: optional
+Maintainer: Michael Tokarev <mjt@corpit.ru>
+Build-Depends: debhelper (>= 4.0.0)
+Standards-Version: 3.7.2
+
+Package: libudns0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: async-capable DNS stub resolver library
+ libudns0 package provides libudns shared library needed
+ to run programs using it
+
+Package: libudns-dev
+Section: libdevel
+Architecture: any
+Depends: libudns0 (= ${Source-Version})
+Description: async-capable DNS stub resolver library, development files
+ This package provides development files needed
+ to build programs using udns library
+
+Package: udns-utils
+Section: net
+Architecture: any
+Depends: ${shlibs:Depends}
+Conflicts: rblcheck
+Description: Several DNS-related utilities built on top of udns library
+ This package includes the following utilities:
+ dnsget - a simple DNS query tool, like `host' or `dig' for usage from
+ a command line, and dnsip, dnsname etc for usage in scripts
+ rblcheck - DNSBL (rbl) checker
+ All the utilities are built using udns library
View
23 deps/udns/debian/copyright
@@ -0,0 +1,23 @@
+This is udns, written and maintained by Michael Tokarev <mjt@corpit.ru>
+
+The original source can always be found at:
+ http://www.corpit.ru/mjt/udns.html
+
+Copyright (C) 2005,2006,2007 Michael Tokarev
+
+ 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
+ General Lesser Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+On Debian systems, the complete text of the GNU Lesser General
+Public License can be found in `/usr/share/common-licenses/LGPL'.
View
93 deps/udns/debian/rules
@@ -0,0 +1,93 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+export DH_COMPAT=4
+
+CFLAGS = -Wall -W -Wmissing-prototypes -g
+CDEFS = -DHAVE_POOL
+
+INSTALL = install
+INSTALL_PROGRAM = $(INSTALL) -p
+INSTALL_DATA = $(INSTALL) -p -m0644
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+ifeq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+# CDEFS += -DNDEBUG
+endif
+
+SOVER = 0
+
+config.h: ./configure Makefile.in
+ dh_testdir
+ ./configure --enable-ipv6
+
+build: build-stamp
+build-stamp: config.h
+ dh_testdir
+ $(MAKE) CFLAGS="$(CFLAGS)" SOVER=$(SOVER) \
+ staticlib sharedlib rblcheck_s dnsget_s
+ mv -f dnsget_s dnsget
+ mv -f rblcheck_s rblcheck
+ mv -f libudns_s.so libudns.so
+ echo
+ touch $@
+
+clean:
+ dh_testdir
+ rm -f build-stamp
+ if [ -f Makefile ]; then $(MAKE) distclean; fi
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean
+ dh_installdirs
+ dh_installdocs -A NEWS
+
+# libudns
+ dh_install -plibudns$(SOVER) libudns.so.$(SOVER) usr/lib
+
+# libudns-dev
+ dh_install -plibudns-dev libudns.a libudns.so usr/lib
+ dh_install -plibudns-dev udns.h usr/include
+ dh_installman -plibudns-dev udns.3
+ dh_installdocs -plibudns-dev TODO NOTES
+ dh_installexamples -plibudns-dev ex-rdns.c
+
+# udns-utils
+ dh_install -pudns-utils dnsget rblcheck usr/bin
+ dh_installman -pudns-utils dnsget.1 rblcheck.1
+
+binary-indep: build install
+
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_makeshlibs -V
+ dh_installdeb
+ dh_shlibdeps -L libudns$(SOVER) -l .
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
View
182 deps/udns/dnsget.1
@@ -0,0 +1,182 @@
+.\" $Id: dnsget.1,v 1.3 2005/04/20 00:55:34 mjt Exp $
+.\" dnsget manpage
+.\"
+.\" 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
+
+.TH dnsget 1 "Apr 2005" "User Utilities"
+
+.SH NAME
+dnsget \- DNS lookup utility
+
+.SH SYNOPSYS
+.B dnsget
+.RB [\| \-v \||\| \-q \|]
+.RB [\| \-c
+.IR class \|]
+.RB [\| \-t
+.IR type \|]
+.RB [\| \-o
+.IR option : value \]
+.IR name \|.\|.\|.
+
+.SH DESCRIPTION
+.B dnsget
+is a simple command-line to perform DNS lookups, similar to
+.BR host (1)
+and
+.BR dig (1).
+It is useable for both interactive/debugging scenarious and
+in scripts.
+The program is implemented using
+.BR udns (3)
+library.
+
+.PP
+By default,
+.B dnsget
+produces a human-readable output, similar to
+.RS
+.nf
+alias.example.com. CNAME www.example.com.
+www.example.com. A 192.168.1.1
+www.example.com. MX 10 mx.example.com.
+.fi
+.RE
+which is just sufficient to see how a given name resolves.
+Output format is controllable with
+.B \-v
+and
+.B \-q
+options -- the former increases verbosity level up to printing
+the whole DNS contents of all packets sent and received, which
+is suitable for debugging DNS problems, while the latter reduces
+the level, making output more quiet, up to bare result with no
+error messages, which is good for scripts.
+
+.SH OPTIONS
+
+The following options are recognized by
+.BR dnsget :
+
+.TP
+.B \-v
+produce more detailed output. More
+.BR \-v 's
+means more details will be produced. With single
+.BR \-v , dnsget
+will print contents of all received DNS packets (in a readable format),
+while with
+.BR \-vv ,
+it will output all outgoing DNS packets too.
+
+.TP
+.B \-q
+the opposite for \fB\-v\fR -- produce less detailed output.
+With single
+.BR \-q , dnsget
+will only show (decoded) data from final DNS resource records (RR),
+while
+.B \-qq
+also suppresses error messages.
+
+.TP
+\fB\-t \fItype\fR
+request record(s) of the given type \fItype\fR. By default,
+.B dnsget
+will ask for IPv4 address (A) record, or for PTR record if the
+argument in question is an IPv4 or IPv6 address. Recognized
+types include A, AAAA, MX, TXT, CNAME, PTR, NS, SOA, ANY and
+others.
+
+.TP
+\fB\-c \fIclass\fR
+request DNS record(s) of the given class \fIclass\fR. By
+default
+.B dnsget
+uses IN class. Valid classes include IN, CH, HS, ANY.
+
+.TP
+.B \-a
+(compatibility option). Equivalent to setting query type to
+.B ANY
+and increasing verbosity level
+.RB ( \-v ).
+
+.TP
+.B \-C
+(planned)
+
+.TP
+.B \-x
+(planned)
+
+.TP
+\fB\-o \fIoption\fR:\fIvalue\fR
+Set resolver option \fIoption\fR to the value \fIvalue\fR
+(may be specified several times). The same as setting
+.RB $ RES_OPTIONS
+environment variable. The following options are recognized:
+.RS
+.TP
+\fBtimeout\fR:\fIsec\fR
+Set initial query timeout to \fIsec\fR.
+.TP
+\fBattempts\fR:\fInum\fR
+(re)try every query \fInum\fR times before failing.
+.TP
+\fBudpbuf\fR:\fIbytes\fR
+set DNS UDP buffer size to \fIbytes\fR bytes. Valid values
+are from 512 to 65535. If \fIbytes\fR is greather than 512,
+EDNS0 (RFC 2671) extensions will be used.
+.TP
+\fBport\fR:\fInum\fR
+Use given UDP port number \fInum\fR instead of the default port 53 (domain).
+.RE
+
+.TP
+\fB\-n \fInameserver\fR
+Use the given nameserver(s) (may be specified more than once)
+instead of the default. Using this option has the same same effect as
+.RB $ NSCACHEIP
+or
+.RB $ NAMESERVERS
+environment variables, with the only difference that only IPv4 addresses
+are recognized for now, and it is possible to specify names (which will
+be resolved using default settings) instead of IP addresses.
+
+.TP
+.B \-h
+print short help and exit.
+
+.SH "RETURN VALUE"
+When all names where resovled successefully,
+.B dnsget
+exits with zero exit status. If at least one name was not found,
+.B dnsget
+will exit with return code 100. If some other error occured during
+name resolution, it will exit with code 99. In case of usage or
+initialization error,
+.B dnsget
+will return 1.
+
+.SH "SEE ALSO"
+.BR host (1)
+.BR dig (1)
+.BR resolv.conf (5)
+.BR udns (3).
View
726 deps/udns/dnsget.c
@@ -0,0 +1,726 @@
+/* $Id: dnsget.c,v 1.31 2007/01/08 01:14:44 mjt Exp $
+ simple host/dig-like application using UDNS library
+
+ 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
+
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+#ifdef WINDOWS
+#include <windows.h>
+#include <winsock2.h>
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+#include <time.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "udns.h"
+
+#ifndef HAVE_GETOPT
+# include "getopt.c"
+#endif
+
+#ifndef AF_INET6
+# define AF_INET6 10
+#endif
+
+static char *progname;
+static int verbose = 1;
+static int errors;
+static int notfound;
+
+/* verbosity level:
+ * <0 - bare result
+ * 0 - bare result and error messages
+ * 1 - readable result
+ * 2 - received packet contents and `trying ...' stuff
+ * 3 - sent and received packet contents
+ */
+
+static void die(int errnum, const char *fmt, ...) {
+ va_list ap;
+ fprintf(stderr, "%s: ", progname);
+ va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap);
+ if (errnum) fprintf(stderr, ": %s\n", strerror(errnum));
+ else putc('\n', stderr);
+ fflush(stderr);
+ exit(1);
+}
+
+static const char *dns_xntop(int af, const void *src) {
+ static char buf[6*5+4*4];
+ return dns_ntop(af, src, buf, sizeof(buf));
+}
+
+struct query {
+ const char *name; /* original query string */
+ unsigned char *dn; /* the DN being looked up */
+ enum dns_type qtyp; /* type of the query */
+};
+
+static void query_free(struct query *q) {
+ free(q->dn);
+ free(q);
+}
+
+static struct query *
+query_new(const char *name, const unsigned char *dn, enum dns_type qtyp) {
+ struct query *q = malloc(sizeof(*q));
+ unsigned l = dns_dnlen(dn);
+ unsigned char *cdn = malloc(l);
+ if (!q || !cdn) die(0, "out of memory");
+ memcpy(cdn, dn, l);
+ q->name = name;
+ q->dn = cdn;
+ q->qtyp = qtyp;
+ return q;
+}
+
+static enum dns_class qcls = DNS_C_IN;
+
+static void
+dnserror(struct query *q, int errnum) {
+ if (verbose >= 0)
+ fprintf(stderr, "%s: unable to lookup %s record for %s: %s\n", progname,
+ dns_typename(q->qtyp), dns_dntosp(q->dn), dns_strerror(errnum));
+ if (errnum == DNS_E_NXDOMAIN || errnum == DNS_E_NODATA)
+ ++notfound;
+ else
+ ++errors;
+ query_free(q);
+}
+
+static const unsigned char *
+printtxt(const unsigned char *c) {
+ unsigned n = *c++;
+ const unsigned char *e = c + n;
+ if (verbose > 0) while(c < e) {
+ if (*c < ' ' || *c >= 127) printf("\\%02x", *c);
+ else if (*c == '\\' || *c == '"') printf("\\%c", *c);
+ else putchar(*c);
+ ++c;
+ }
+ else
+ fwrite(c, n, 1, stdout);
+ return e;
+}
+
+static void
+printhex(const unsigned char *c, const unsigned char *e) {
+ while(c < e)
+ printf("%02x", *c++);
+}
+
+static unsigned char to_b64[] =
+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static void
+printb64(const unsigned char *c, const unsigned char *e) {
+ while(c < e) {
+ putchar(to_b64[c[0] >> 2]);
+ if (c+1 < e) {
+ putchar(to_b64[(c[0] & 0x3) << 4 | c[1] >> 4]);
+ if (c+2 < e) {
+ putchar(to_b64[(c[1] & 0xf) << 2 | c[2] >> 6]);
+ putchar(to_b64[c[2] & 0x3f]);
+ }
+ else {
+ putchar(to_b64[(c[1] & 0xf) << 2]);
+ putchar('=');
+ break;
+ }
+ }
+ else {
+ putchar(to_b64[(c[0] & 0x3) << 4]);
+ putchar('=');
+ putchar('=');
+ break;
+ }
+ c += 3;
+ }
+}
+
+static void
+printdate(time_t time) {
+ struct tm *tm = gmtime(&time);
+ printf("%04d%02d%02d%02d%02d%02d",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+}
+
+static void
+printrr(const struct dns_parse *p, struct dns_rr *rr) {
+ const unsigned char *pkt = p->dnsp_pkt;
+ const unsigned char *end = p->dnsp_end;
+ const unsigned char *dptr = rr->dnsrr_dptr;
+ const unsigned char *dend = rr->dnsrr_dend;
+ unsigned char *dn = rr->dnsrr_dn;
+ const unsigned char *c;
+ unsigned n;
+
+ if (verbose > 0) {
+ if (verbose > 1) {
+ if (!p->dnsp_rrl && !rr->dnsrr_dn[0] && rr->dnsrr_typ == DNS_T_OPT) {
+ printf(";EDNS0 OPT record (UDPsize: %d): %d bytes\n",
+ rr->dnsrr_cls, rr->dnsrr_dsz);
+ return;
+ }
+ n = printf("%s.", dns_dntosp(rr->dnsrr_dn));
+ printf("%s%u\t%s\t%s\t",
+ n > 15 ? "\t" : n > 7 ? "\t\t" : "\t\t\t",
+ rr->dnsrr_ttl,
+ dns_classname(rr->dnsrr_cls),
+ dns_typename(rr->dnsrr_typ));
+ }
+ else
+ printf("%s. %s ", dns_dntosp(rr->dnsrr_dn), dns_typename(rr->dnsrr_typ));
+ }
+
+ switch(rr->dnsrr_typ) {
+
+ case DNS_T_CNAME:
+ case DNS_T_PTR:
+ case DNS_T_NS:
+ case DNS_T_MB:
+ case DNS_T_MD:
+ case DNS_T_MF:
+ case DNS_T_MG:
+ case DNS_T_MR:
+ if (dns_getdn(pkt, &dptr, end, dn, DNS_MAXDN) <= 0) goto xperr;
+ printf("%s.", dns_dntosp(dn));
+ break;
+
+ case DNS_T_A:
+ if (rr->dnsrr_dsz != 4) goto xperr;
+ printf("%d.%d.%d.%d", dptr[0], dptr[1], dptr[2], dptr[3]);
+ break;
+
+ case DNS_T_AAAA:
+ if (rr->dnsrr_dsz != 16) goto xperr;
+ printf("%s", dns_xntop(AF_INET6, dptr));
+ break;
+
+ case DNS_T_MX:
+ c = dptr + 2;
+ if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend) goto xperr;
+ printf("%d %s.", dns_get16(dptr), dns_dntosp(dn));
+ break;
+
+ case DNS_T_TXT:
+ /* first verify it */
+ for(c = dptr; c < dend; c += n) {
+ n = *c++;
+ if (c + n > dend) goto xperr;
+ }
+ c = dptr; n = 0;
+ while (c < dend) {
+ if (verbose > 0) printf(n++ ? "\" \"":"\"");
+ c = printtxt(c);
+ }
+ if (verbose > 0) putchar('"');
+ break;
+
+ case DNS_T_HINFO: /* CPU, OS */
+ c = dptr;
+ n = *c++; if ((c += n) >= dend) goto xperr;
+ n = *c++; if ((c += n) != dend) goto xperr;
+ c = dptr;
+ if (verbose > 0) putchar('"');
+ c = printtxt(c);
+ if (verbose > 0) printf("\" \""); else putchar(' ');
+ printtxt(c);
+ if (verbose > 0) putchar('"');
+ break;
+
+ case DNS_T_WKS:
+ c = dptr;
+ if (dptr + 4 + 2 >= end) goto xperr;
+ printf("%s %d", dns_xntop(AF_INET, dptr), dptr[4]);
+ c = dptr + 5;
+ for (n = 0; c < dend; ++c, n += 8) {
+ if (*c) {
+ unsigned b;
+ for (b = 0; b < 8; ++b)
+ if (*c & (1 << (7-b))) printf(" %d", n + b);
+ }
+ }
+ break;
+
+ case DNS_T_SRV: /* prio weight port targetDN */
+ c = dptr;
+ c += 2 + 2 + 2;
+ if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend) goto xperr;
+ c = dptr;
+ printf("%d %d %d %s.",
+ dns_get16(c+0), dns_get16(c+2), dns_get16(c+4),
+ dns_dntosp(dn));
+ break;
+
+ case DNS_T_NAPTR: /* order pref flags serv regexp repl */
+ c = dptr;
+ c += 4; /* order, pref */
+ for (n = 0; n < 3; ++n)
+ if (c >= dend) goto xperr;
+ else c += *c + 1;
+ if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend) goto xperr;
+ c = dptr;
+ printf("%u %u", dns_get16(c+0), dns_get16(c+2));
+ c += 4;
+ for(n = 0; n < 3; ++n) {
+ putchar(' ');
+ if (verbose > 0) putchar('"');
+ c = printtxt(c);
+ if (verbose > 0) putchar('"');
+ }
+ printf(" %s.", dns_dntosp(dn));
+ break;
+
+ case DNS_T_KEY: /* flags(2) proto(1) algo(1) pubkey */
+ c = dptr;
+ if (c + 2 + 1 + 1 > dend) goto xperr;
+ printf("%d %d %d", dns_get16(c), c[2], c[3]);
+ c += 2 + 1 + 1;
+ if (c < dend) {
+ putchar(' ');
+ printb64(c, dend);
+ }
+ break;
+
+ case DNS_T_SIG:
+ /* type(2) algo(1) labels(1) ottl(4) sexp(4) sinc(4) tag(2) sdn sig */
+ c = dptr;
+ c += 2 + 1 + 1 + 4 + 4 + 4 + 2;
+ if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0) goto xperr;
+ printf("%d %u %u %u ",
+ dns_get16(dptr), dptr[2], dptr[3], dns_get32(dptr+4));
+ printdate(dns_get32(dptr+8));
+ putchar(' ');
+ printdate(dns_get32(dptr+12));
+ printf(" %d %s. ", dns_get16(dptr+10), dns_dntosp(dn));
+ printb64(c, dend);
+ break;
+
+#if 0 /* unused RR types? */
+ case DNS_T_DS:
+ c = dptr;
+ if (c + 2 + 2 >= dend) goto xperr;
+ printf("%u %u %u ", dns_get16(c), c[2], c[3]);
+ printhex(c + 4, dend);
+ break;
+
+ case DNS_T_NSEC:
+ c = dptr;
+ if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0) goto xperr;
+ printf("%s.", dns_dntosp(dn));
+ unfinished.
+ break;
+#endif
+
+
+ case DNS_T_SOA:
+ c = dptr;
+ if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 ||
+ dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 ||
+ c + 4*5 != dend)
+ goto xperr;
+ dns_getdn(pkt, &dptr, end, dn, DNS_MAXDN);
+ printf("%s. ", dns_dntosp(dn));
+ dns_getdn(pkt, &dptr, end, dn, DNS_MAXDN);
+ printf("%s. ", dns_dntosp(dn));
+ printf("%u %u %u %u %u",
+ dns_get32(dptr), dns_get32(dptr+4), dns_get32(dptr+8),
+ dns_get32(dptr+12), dns_get32(dptr+16));
+ break;
+
+ case DNS_T_MINFO:
+ c = dptr;
+ if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 ||
+ dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 ||
+ c != dend)
+ goto xperr;
+ dns_getdn(pkt, &dptr, end, dn, DNS_MAXDN);
+ printf("%s. ", dns_dntosp(dn));
+ dns_getdn(pkt, &dptr, end, dn, DNS_MAXDN);
+ printf("%s.", dns_dntosp(dn));
+ break;
+
+ case DNS_T_NULL:
+ default:
+ printhex(dptr, dend);
+ break;
+ }
+ putchar('\n');
+ return;
+
+xperr:
+ printf("<parse error>\n");
+ ++errors;
+}
+
+static int
+printsection(struct dns_parse *p, int nrr, const char *sname) {
+ struct dns_rr rr;
+ int r;
+ if (!nrr) return 0;
+ if (verbose > 1) printf("\n;; %s section (%d):\n", sname, nrr);
+
+ p->dnsp_rrl = nrr;
+ while((r = dns_nextrr(p, &rr)) > 0)
+ printrr(p, &rr);
+ if (r < 0) printf("<<ERROR>>\n");
+ return r;
+}
+
+/* dbgcb will only be called if verbose > 1 */
+static void
+dbgcb(int code, const struct sockaddr *sa, unsigned slen,
+ const unsigned char *pkt, int r,
+ const struct dns_query *unused_q, void *unused_data) {
+ struct dns_parse p;
+ const unsigned char *cur, *end;
+ int numqd;
+
+ if (code > 0) {
+ printf(";; trying %s.\n", dns_dntosp(dns_payload(pkt)));
+ printf(";; sending %d bytes query to ", r);
+ }
+ else
+ printf(";; received %d bytes response from ", r);
+ if (sa->sa_family == AF_INET && slen >= sizeof(struct sockaddr_in))
+ printf("%s port %d\n",
+ dns_xntop(AF_INET, &((struct sockaddr_in*)sa)->sin_addr),
+ htons(((struct sockaddr_in*)sa)->sin_port));
+#ifdef HAVE_IPv6
+ else if (sa->sa_family == AF_INET6 && slen >= sizeof(struct sockaddr_in6))
+ printf("%s port %d\n",
+ dns_xntop(AF_INET6, &((struct sockaddr_in6*)sa)->sin6_addr),
+ htons(((struct sockaddr_in6*)sa)->sin6_port));
+#endif
+ else
+ printf("<<unknown socket type %d>>\n", sa->sa_family);
+ if (code > 0 && verbose < 3) {
+ putchar('\n');
+ return;
+ }
+
+ if (code == -2) printf(";; reply from unexpected source\n");
+ if (code == -5) printf(";; reply to a query we didn't sent (or old)\n");
+ if (r < DNS_HSIZE) {
+ printf(";; short packet (%d bytes)\n", r);
+ return;
+ }
+ if (dns_opcode(pkt) != 0)
+ printf(";; unexpected opcode %d\n", dns_opcode(pkt));
+ if (dns_tc(pkt) != 0)
+ printf(";; warning: TC bit set, probably incomplete reply\n");
+
+ printf(";; ->>HEADER<<- opcode: ");
+ switch(dns_opcode(pkt)) {
+ case 0: printf("QUERY"); break;
+ case 1: printf("IQUERY"); break;
+ case 2: printf("STATUS"); break;
+ default: printf("UNKNOWN(%u)", dns_opcode(pkt)); break;
+ }
+ printf(", status: %s, id: %d, size: %d\n;; flags:",
+ dns_rcodename(dns_rcode(pkt)), dns_qid(pkt), r);
+ if (dns_qr(pkt)) printf(" qr");
+ if (dns_rd(pkt)) printf(" rd");
+ if (dns_ra(pkt)) printf(" ra");
+ if (dns_aa(pkt)) printf(" aa");
+ if (dns_tc(pkt)) printf(" tc");
+ numqd = dns_numqd(pkt);
+ printf("; QUERY: %d, ANSWER: %d, AUTHORITY: %d, ADDITIONAL: %d\n",
+ numqd, dns_numan(pkt), dns_numns(pkt), dns_numar(pkt));
+ if (numqd != 1)
+ printf(";; unexpected number of entri