├── .github ├── FUNDING.yml └── workflows │ └── testsuite.yml ├── .gitignore ├── .gitmodules ├── Changelog ├── LICENSE ├── Makefile.in ├── README ├── README.git ├── README.snapshots ├── acx_nlnetlabs.m4 ├── ax_pkg_swig.m4 ├── ax_python_devel.m4 ├── buffer.c ├── compat ├── asctime_r.c ├── b64_ntop.c ├── b64_pton.c ├── calloc.c ├── ctime_r.c ├── fake-rfc2553.c ├── fake-rfc2553.h ├── gmtime_r.c ├── inet_aton.c ├── inet_ntop.c ├── inet_pton.c ├── isascii.c ├── isblank.c ├── localtime_r.c ├── malloc.c ├── memmove.c ├── realloc.c ├── snprintf.c ├── strlcpy.c └── timegm.c ├── configure.ac ├── contrib ├── NETLDNS.readme.txt ├── NETLDNS.tar.gz ├── build-solaris.sh ├── ldnsx │ ├── LICENSE │ ├── Makefile │ ├── README │ ├── examples │ │ ├── ldnsx-axfr.py │ │ ├── ldnsx-dnssec.py │ │ ├── ldnsx-mx1.py │ │ ├── ldnsx-mx2.py │ │ └── ldnsx-walk.py │ ├── ldnsx.py │ └── source │ │ ├── api │ │ ├── ldnsx.rst │ │ ├── packet.rst │ │ ├── resolver.rst │ │ └── resource_record.rst │ │ ├── conf.py │ │ ├── examples │ │ ├── ldnsx-axfr.rst │ │ ├── ldnsx-dnssec.rst │ │ ├── ldnsx-mx1.rst │ │ ├── ldnsx-mx2.rst │ │ └── ldnsx-walk.rst │ │ └── index.rst └── python │ ├── Changelog │ ├── LICENSE │ ├── Makefile │ ├── docs │ ├── Makefile │ └── source │ │ ├── conf.py │ │ ├── examples │ │ ├── example1.rst │ │ ├── example2.py │ │ ├── example2.rst │ │ ├── example3.rst │ │ ├── example4.rst │ │ ├── example5.rst │ │ ├── example6.rst │ │ ├── example7.rst │ │ ├── example8.rst │ │ └── index.rst │ │ ├── index.rst │ │ ├── install.rst │ │ └── modules │ │ ├── ldns.rst │ │ ├── ldns_buffer.rst │ │ ├── ldns_dname.rst │ │ ├── ldns_dnssec.rst │ │ ├── ldns_func.rst │ │ ├── ldns_key.rst │ │ ├── ldns_key_list.rst │ │ ├── ldns_pkt.rst │ │ ├── ldns_rdf.rst │ │ ├── ldns_resolver.rst │ │ ├── ldns_rr.rst │ │ ├── ldns_rr_list.rst │ │ └── ldns_zone.rst │ ├── examples │ ├── ldns-axfr.py │ ├── ldns-buf.py │ ├── ldns-dnssec.py │ ├── ldns-higher.py │ ├── ldns-keygen.py │ ├── ldns-mx.py │ ├── ldns-mx1.py │ ├── ldns-mx2.py │ ├── ldns-newpkt.py │ ├── ldns-signzone.py │ ├── ldns-zone.py │ ├── ldns_rr_iter_frm_fp_l.demo.py │ ├── ldns_rr_new_frm_fp_l.demo.py │ ├── python3 │ │ ├── ldns-axfr.py │ │ ├── ldns-buf.py │ │ ├── ldns-dnssec.py │ │ ├── ldns-higher.py │ │ ├── ldns-keygen.py │ │ ├── ldns-mx.py │ │ ├── ldns-mx1.py │ │ ├── ldns-mx2.py │ │ ├── ldns-newpkt.py │ │ ├── ldns-signzone.py │ │ ├── ldns-zone.py │ │ ├── ldns_rr_iter_frm_fp_l.demo.py │ │ └── ldns_rr_new_frm_fp_l.demo.py │ ├── test_buffer.py │ ├── test_dname.py │ ├── test_pkt.py │ ├── test_rdf.py │ ├── test_resolver.py │ ├── test_rr.py │ └── zone.txt │ ├── file_py3.i │ ├── ldns.i │ ├── ldns_buffer.i │ ├── ldns_dname.i │ ├── ldns_dnssec.i │ ├── ldns_key.i │ ├── ldns_packet.i │ ├── ldns_rdf.i │ ├── ldns_resolver.i │ ├── ldns_rr.i │ └── ldns_zone.i ├── dane.c ├── dname.c ├── dnssec.c ├── dnssec_sign.c ├── dnssec_verify.c ├── dnssec_zone.c ├── doc ├── API-header.xml ├── API.xml ├── CodingStyle ├── TODO ├── design.dox ├── dns-lib-implementations ├── doxyparse.pl ├── function_manpages ├── header.html ├── images │ ├── LogoInGradientBar2-y100.png │ ├── libdnsoverview.png │ └── libdnsoverview.svg ├── libdns.css ├── tutorial1_mx.dox ├── tutorial2_zone.dox └── tutorial3_signzone.dox ├── drill ├── ChangeLog.22-nov-2005 ├── README ├── REGRESSIONS ├── chasetrace.c ├── dnssec.c ├── drill.1.in ├── drill.c ├── drill.h ├── drill_util.c ├── drill_util.h ├── error.c ├── install-sh ├── root.c ├── securetrace.c └── work.c ├── duration.c ├── edns.c ├── error.c ├── examples ├── README ├── fake-rfc2553.h ├── ldns-chaos.1 ├── ldns-chaos.c ├── ldns-compare-zones.1 ├── ldns-compare-zones.c ├── ldns-dane.1.in ├── ldns-dane.c ├── ldns-dpa.1 ├── ldns-dpa.c ├── ldns-dpa.h ├── ldns-gen-zone.1 ├── ldns-gen-zone.c ├── ldns-key2ds.1 ├── ldns-key2ds.c ├── ldns-keyfetcher.1 ├── ldns-keyfetcher.c ├── ldns-keygen.1 ├── ldns-keygen.c ├── ldns-mx.1 ├── ldns-mx.c ├── ldns-notify.1 ├── ldns-notify.c ├── ldns-nsec3-hash.1 ├── ldns-nsec3-hash.c ├── ldns-read-zone.1 ├── ldns-read-zone.c ├── ldns-resolver.1 ├── ldns-resolver.c ├── ldns-revoke.1 ├── ldns-revoke.c ├── ldns-rrsig.1 ├── ldns-rrsig.c ├── ldns-signzone.1 ├── ldns-signzone.c ├── ldns-test-edns.1 ├── ldns-test-edns.c ├── ldns-testns.1 ├── ldns-testns.c ├── ldns-testpkts.c ├── ldns-testpkts.h ├── ldns-update.1 ├── ldns-update.c ├── ldns-verify-zone.1.in ├── ldns-verify-zone.c ├── ldns-version.1 ├── ldns-version.c ├── ldns-walk.1 ├── ldns-walk.c ├── ldns-zcat.1 ├── ldns-zcat.c ├── ldns-zsplit.1 ├── ldns-zsplit.c ├── ldnsd.1 ├── ldnsd.c └── nsd-test │ ├── Makefile.in │ ├── configure.ac │ ├── ldns-testns.c │ ├── nsd-ldnsd.c │ ├── nsec3-covers.c │ └── test.queries ├── higher.c ├── host2str.c ├── host2wire.c ├── keys.c ├── ldns ├── .c-mode-rc.el ├── buffer.h ├── common.h.in ├── dane.h ├── dname.h ├── dnssec.h ├── dnssec_sign.h ├── dnssec_verify.h ├── dnssec_zone.h ├── duration.h ├── edns.h ├── error.h ├── higher.h ├── host2str.h ├── host2wire.h ├── keys.h ├── ldns.h ├── net.h.in ├── packet.h ├── parse.h ├── radix.h ├── rbtree.h ├── rdata.h ├── resolver.h ├── rr.h ├── rr_functions.h ├── sha1.h ├── sha2.h ├── str2host.h ├── tsig.h ├── update.h ├── util.h.in ├── wire2host.h └── zone.h ├── libdns.doxygen.in ├── libdns.vim ├── linktest.c ├── lua ├── Makefile.in ├── README ├── configure.ac ├── echo.lua ├── lua.c ├── rdf.lua ├── rns-lib.lua ├── rns-specs ├── rns.lua ├── serv.lua ├── test.lua └── test2.lua ├── m4 ├── ax_config_feature.m4 └── ax_have_poll.m4 ├── makedist.sh ├── makewin.sh ├── masterdont ├── Makefile ├── README ├── config.h ├── config_file.c ├── config_file.h ├── example │ ├── example.com.1 │ ├── example.com.2 │ ├── example.com.3 │ ├── example.com.4 │ ├── example.com.5 │ ├── example.com.8 │ ├── masterdont.conf │ ├── zone.example.com.full.1 │ └── zone.example.com.index ├── main.c ├── makefile.dep ├── process.c ├── process.h ├── server.c ├── server.h ├── zinfo.c ├── zinfo.h ├── zones.c └── zones.h ├── net.c ├── packaging ├── fedora │ └── ldns.spec ├── ldns-config.1 ├── ldns-config.in └── libldns.pc.in ├── packet.c ├── parse.c ├── pcat ├── Makefile.in ├── README.pcat ├── configure.ac ├── getdelim.c ├── pcat-diff.1 ├── pcat-diff.c ├── pcat-grep.pl ├── pcat-print.1 ├── pcat-print.c ├── pcat.1 ├── pcat.c └── todo ├── radix.c ├── rbtree.c ├── rdata.c ├── resolver.c ├── rr.c ├── rr_functions.c ├── sha1.c ├── sha2.c ├── str2host.c ├── test ├── 01-compile.tpkg │ ├── 01-compile.dsc │ ├── 01-compile.help │ └── 01-compile.test ├── 03-run.tpkg │ ├── 03-run.dsc │ ├── 03-run.help │ └── 03-run.test ├── 04-run-normal.tpkg │ ├── 04-run-normal.dsc │ ├── 04-run-normal.help │ └── 04-run-normal.test ├── 05-iana-rr-types.tpkg │ ├── ._05-iana-rr-types.dir │ ├── 05-iana-rr-types.dsc │ ├── 05-iana-rr-types.help │ └── 05-iana-rr-types.test ├── 08-zonereader.tpkg │ ├── 08-zonereader.dsc │ ├── 08-zonereader.help │ ├── 08-zonereader.inputzone │ ├── 08-zonereader.outputzone │ └── 08-zonereader.test ├── 09-doc-check.tpkg │ ├── 09-doc-check.dsc │ ├── 09-doc-check.help │ └── 09-doc-check.test ├── 10-ldns-compare-zones.tpkg │ ├── 10-ldns-compare-zones.diffs │ ├── 10-ldns-compare-zones.dsc │ ├── 10-ldns-compare-zones.help │ ├── 10-ldns-compare-zones.test │ ├── 10-ldns-compare-zones.zone1 │ └── 10-ldns-compare-zones.zone2 ├── 12-unit-tests-dnssec.tpkg │ ├── 12-unit-tests-dnssec.Makefile.in │ ├── 12-unit-tests-dnssec.c │ ├── 12-unit-tests-dnssec.configure.ac │ ├── 12-unit-tests-dnssec.dsc │ ├── 12-unit-tests-dnssec.help │ ├── 12-unit-tests-dnssec.pre │ └── 12-unit-tests-dnssec.test ├── 13-unit-tests-base.tpkg │ ├── 13-unit-tests-base.Makefile.in │ ├── 13-unit-tests-base.c │ ├── 13-unit-tests-base.configure.ac │ ├── 13-unit-tests-base.dsc │ ├── 13-unit-tests-base.help │ ├── 13-unit-tests-base.pre │ └── 13-unit-tests-base.test ├── 14-read-zone.tpkg │ ├── 14-read-zone.db │ ├── 14-read-zone.dsc │ ├── 14-read-zone.help │ └── 14-read-zone.test ├── 15-unit-tests-rrtypes.tpkg │ ├── 15-unit-tests-rrtypes.Makefile.in │ ├── 15-unit-tests-rrtypes.c │ ├── 15-unit-tests-rrtypes.configure.ac │ ├── 15-unit-tests-rrtypes.dsc │ ├── 15-unit-tests-rrtypes.help │ ├── 15-unit-tests-rrtypes.pre │ └── 15-unit-tests-rrtypes.test ├── 16-unit-tests-edns.tpkg │ ├── 16-unit-tests-edns.Makefile.in │ ├── 16-unit-tests-edns.c │ ├── 16-unit-tests-edns.configure.ac │ ├── 16-unit-tests-edns.dsc │ ├── 16-unit-tests-edns.pre │ └── 16-unit-tests-edns.test ├── 17-stub-resolver.tpkg │ ├── 17-resolv.conf1 │ ├── 17-resolv.conf2 │ ├── 17-resolv.conf3 │ ├── 17-resolv.conf4 │ ├── 17-resolv.conf5 │ ├── 17-resolv.conf6 │ ├── 17-stub-resolver.dsc │ ├── 17-stub-resolver.help │ └── 17-stub-resolver.test ├── 18-drill-tests1.tpkg │ ├── 18-drill-tests1.dsc │ ├── 18-drill-tests1.help │ ├── 18-drill-tests1.test │ ├── test1-answer-output │ ├── test1-drill-output │ ├── test1-server-data │ ├── test2-key │ └── test2-server-data ├── 19-keygen.tpkg │ ├── 19-keygen.dsc │ ├── 19-keygen.help │ └── 19-keygen.test ├── 20-sign-zone.tpkg │ ├── 20-sign-zone.db │ ├── 20-sign-zone.dsc │ ├── 20-sign-zone.help │ ├── 20-sign-zone.test │ ├── Kjelte.nlnetlabs.nl.+005+09693.key │ ├── Kjelte.nlnetlabs.nl.+005+09693.private │ ├── Kjelte.nlnetlabs.nl.+005+51181.key │ ├── Kjelte.nlnetlabs.nl.+005+51181.private │ └── jelte.nlnetlabs.nl ├── 25-ZONEMD.tpkg │ ├── 25-ZONEMD.dsc │ ├── 25-ZONEMD.help │ ├── 25-ZONEMD.test │ ├── A.1.Simple-EXAMPLE-Zone │ ├── A.2.Complex-EXAMPLE-Zone │ ├── A.3.EXAMPLE-Zone-with-multiple-digests │ ├── A.4.The-URI.ARPA-Zone │ ├── A.5.The-ROOT-SERVERS.NET-Zone │ └── repeated-ZONEMD-scheme-and-algorithm ├── 26-loc-centimetre.tpkg │ ├── 26-loc-centimetre.db │ ├── 26-loc-centimetre.dsc │ ├── 26-loc-centimetre.help │ └── 26-loc-centimetre.test ├── 27-tab-between-cstrings.tpkg │ ├── 27-tab-between-cstrings.db │ ├── 27-tab-between-cstrings.dsc │ ├── 27-tab-between-cstrings.help │ └── 27-tab-between-cstrings.test ├── 28-tab-instead-of-space.tpkg │ ├── 28-tab-instead-of-space.db │ ├── 28-tab-instead-of-space.dsc │ ├── 28-tab-instead-of-space.help │ └── 28-tab-instead-of-space.test ├── 29-generic-rdata-tab.tpkg │ ├── 29-generic-rdata-tab.db │ ├── 29-generic-rdata-tab.dsc │ ├── 29-generic-rdata-tab.help │ └── 29-generic-rdata-tab.test ├── 30-load-pyldns.tpkg │ ├── 30-load-pyldns.dsc │ ├── 30-load-pyldns.help │ └── 30-load-pyldns.test ├── 31-load-pyldnsx.tpkg │ ├── 31-load-pyldnsx.dsc │ ├── 31-load-pyldnsx.help │ └── 31-load-pyldnsx.test ├── 32-unbound-regression.tpkg │ ├── 32-unbound-regression.clean.sh │ ├── 32-unbound-regression.dsc │ ├── 32-unbound-regression.help │ └── 32-unbound-regression.test ├── 60-compile-builddir.tpkg │ ├── 60-compile-builddir.dsc │ ├── 60-compile-builddir.help │ └── 60-compile-builddir.test ├── 999-compile-nossl.tpkg │ ├── 999-compile-nossl.dsc │ ├── 999-compile-nossl.help │ └── 999-compile-nossl.test ├── codingstyle.tpkg │ ├── codingstyle.dsc │ ├── codingstyle.help │ └── codingstyle.test ├── common.sh ├── f ├── m ├── test_all.sh ├── test_ci.sh ├── testbed │ ├── do-tests.sh │ ├── testbed.sh │ ├── testbed.txt │ └── unitmain.c └── testdata │ └── host_file.template ├── tsig.c ├── update.c ├── util.c ├── wire2host.c └── zone.c /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [NLnetLabs] 2 | custom: ['https://nlnetlabs.nl/funding/'] 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "contrib/DNS-LDNS"] 2 | path = contrib/DNS-LDNS 3 | url = https://github.com/erikoest/DNS-LDNS 4 | [submodule "test/tpkg"] 5 | path = test/tpkg 6 | url = https://github.com/NLnetLabs/tpkg.git 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005,2006, NLnetLabs 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of NLnetLabs nor the names of its 13 | contributors may be used to endorse or promote products derived from this 14 | software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /README.git: -------------------------------------------------------------------------------- 1 | # The ldns git repository can found at: 2 | # git.nlnetlabs.nl/ldns/ 3 | 4 | # small list of commands to build all on a linux system 5 | # libtoolize is needed for most other targets 6 | 7 | # on Solaris, and other systems that may not have 8 | # the default 'automake' and 'aclocal' script aliases, 9 | # the correct versions may need to be set. On those 10 | # systems, the 'autoreconf' line should be changed to: 11 | # AUTOMAKE=automake-1.10 ACLOCAL=aclocal-1.10 autoreconf 12 | 13 | # older versions of libtoolize do not support --install 14 | # so you might need to remove that (with newer versions 15 | # it is needed) 16 | git submodule update --init 17 | libtoolize -ci 18 | autoreconf -fi 19 | ./configure --with-examples --with-drill # --with-pyldns --with-p5-dns-ldns 20 | make 21 | make doc # needs doxygen for the html pages 22 | (cd pcat && autoreconf && ./configure && make) 23 | (cd examples/nsd-test && autoreconf && ./configure && make) 24 | -------------------------------------------------------------------------------- /README.snapshots: -------------------------------------------------------------------------------- 1 | ldns - snapshot releases 2 | 3 | Snapshot releases are not official released. They can be released to 4 | interested parties for development. 5 | 6 | Snapshots can be recognized from the date in the tar file name. 7 | 8 | They should not be used for packaging in distributions. 9 | -------------------------------------------------------------------------------- /compat/asctime_r.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #ifdef HAVE_TIME_H 6 | #include 7 | #endif 8 | 9 | char *asctime_r(const struct tm *tm, char *buf) 10 | { 11 | /* no thread safety. */ 12 | char* result = asctime(tm); 13 | if(buf && result) 14 | strcpy(buf, result); 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /compat/calloc.c: -------------------------------------------------------------------------------- 1 | /* Just a replacement, if the original malloc is not 2 | GNU-compliant. See autoconf documentation. */ 3 | 4 | #if HAVE_CONFIG_H 5 | #include 6 | #endif 7 | 8 | void *calloc(); 9 | 10 | #if !HAVE_BZERO && HAVE_MEMSET 11 | # define bzero(buf, bytes) ((void) memset (buf, 0, bytes)) 12 | #endif 13 | 14 | void * 15 | calloc(size_t num, size_t size) 16 | { 17 | void *new = malloc(num * size); 18 | if (!new) { 19 | return NULL; 20 | } 21 | bzero(new, num * size); 22 | return new; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /compat/ctime_r.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #ifdef HAVE_TIME_H 6 | #include 7 | #endif 8 | 9 | char *ctime_r(const time_t *timep, char *buf) 10 | { 11 | /* no thread safety. */ 12 | char* result = ctime(timep); 13 | if(buf && result) 14 | strcpy(buf, result); 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /compat/gmtime_r.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #ifdef HAVE_TIME_H 6 | #include 7 | #endif 8 | 9 | struct tm *gmtime_r(const time_t *timep, struct tm *result) 10 | { 11 | /* no thread safety. */ 12 | *result = *gmtime(timep); 13 | return result; 14 | } 15 | -------------------------------------------------------------------------------- /compat/isascii.c: -------------------------------------------------------------------------------- 1 | /* Just a replacement, if the original isascii is not 2 | present */ 3 | 4 | #if HAVE_CONFIG_H 5 | #include 6 | #endif 7 | 8 | int isascii(int c); 9 | 10 | /* true if character is ascii. */ 11 | int 12 | isascii(int c) 13 | { 14 | return c >= 0 && c < 128; 15 | } 16 | -------------------------------------------------------------------------------- /compat/isblank.c: -------------------------------------------------------------------------------- 1 | /* Just a replacement, if the original isblank is not 2 | present */ 3 | 4 | #if HAVE_CONFIG_H 5 | #include 6 | #endif 7 | 8 | int isblank(int c); 9 | 10 | /* true if character is a blank (space or tab). C99. */ 11 | int 12 | isblank(int c) 13 | { 14 | return (c == ' ') || (c == '\t'); 15 | } 16 | -------------------------------------------------------------------------------- /compat/localtime_r.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #ifdef HAVE_TIME_H 6 | #include 7 | #endif 8 | 9 | struct tm *localtime_r(const time_t *timep, struct tm *result) 10 | { 11 | /* no thread safety. */ 12 | *result = *localtime(timep); 13 | return result; 14 | } 15 | -------------------------------------------------------------------------------- /compat/malloc.c: -------------------------------------------------------------------------------- 1 | /* Just a replacement, if the original malloc is not 2 | GNU-compliant. See autoconf documentation. */ 3 | 4 | #if HAVE_CONFIG_H 5 | #include 6 | #endif 7 | #undef malloc 8 | 9 | #include 10 | 11 | void *malloc (size_t n); 12 | 13 | /* Allocate an N-byte block of memory from the heap. 14 | If N is zero, allocate a 1-byte block. */ 15 | 16 | void * 17 | rpl_malloc (size_t n) 18 | { 19 | if (n == 0) 20 | n = 1; 21 | return malloc (n); 22 | } 23 | -------------------------------------------------------------------------------- /compat/memmove.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memmove.c: memmove compat implementation. 3 | * 4 | * Copyright (c) 2001-2008, NLnet Labs. All rights reserved. 5 | * 6 | * See LICENSE for the license. 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | void *memmove(void *dest, const void *src, size_t n); 13 | 14 | void *memmove(void *dest, const void *src, size_t n) 15 | { 16 | uint8_t* from = (uint8_t*) src; 17 | uint8_t* to = (uint8_t*) dest; 18 | 19 | if (from == to || n == 0) 20 | return dest; 21 | if (to > from && to-from < (int)n) { 22 | /* to overlaps with from */ 23 | /* */ 24 | /* */ 25 | /* copy in reverse, to avoid overwriting from */ 26 | int i; 27 | for(i=n-1; i>=0; i--) 28 | to[i] = from[i]; 29 | return dest; 30 | } 31 | if (from > to && from-to < (int)n) { 32 | /* to overlaps with from */ 33 | /* */ 34 | /* */ 35 | /* copy forwards, to avoid overwriting from */ 36 | size_t i; 37 | for(i=0; i 6 | #endif 7 | #undef realloc 8 | 9 | #include 10 | 11 | void *realloc (void*, size_t); 12 | void *malloc (size_t); 13 | 14 | /* Changes allocation to new sizes, copies over old data. 15 | * if oldptr is NULL, does a malloc. 16 | * if size is zero, allocate 1-byte block.... 17 | * (does not return NULL and free block) 18 | */ 19 | 20 | void * 21 | rpl_realloc (void* ptr, size_t n) 22 | { 23 | if (n == 0) 24 | n = 1; 25 | if(ptr == 0) { 26 | return malloc(n); 27 | } 28 | return realloc(ptr, n); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /compat/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* from openssh 4.3p2 compat/strlcpy.c */ 2 | /* 3 | * Copyright (c) 1998 Todd C. Miller 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */ 19 | 20 | #include 21 | #ifndef HAVE_STRLCPY 22 | 23 | #include 24 | #include 25 | 26 | /* 27 | * Copy src to string dst of size siz. At most siz-1 characters 28 | * will be copied. Always NUL terminates (unless siz == 0). 29 | * Returns strlen(src); if retval >= siz, truncation occurred. 30 | */ 31 | size_t 32 | strlcpy(char *dst, const char *src, size_t siz) 33 | { 34 | char *d = dst; 35 | const char *s = src; 36 | size_t n = siz; 37 | 38 | /* Copy as many bytes as will fit */ 39 | if (n != 0 && --n != 0) { 40 | do { 41 | if ((*d++ = *s++) == 0) 42 | break; 43 | } while (--n != 0); 44 | } 45 | 46 | /* Not enough room in dst, add NUL and traverse rest of src */ 47 | if (n == 0) { 48 | if (siz != 0) 49 | *d = '\0'; /* NUL-terminate dst */ 50 | while (*s++) 51 | ; 52 | } 53 | 54 | return(s - src - 1); /* count does not include NUL */ 55 | } 56 | 57 | #endif /* !HAVE_STRLCPY */ 58 | -------------------------------------------------------------------------------- /compat/timegm.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include 3 | #endif 4 | 5 | #include 6 | 7 | #ifdef HAVE_STDLIB_H 8 | #include 9 | #endif 10 | 11 | #include 12 | 13 | time_t 14 | timegm (struct tm *tm) { 15 | time_t ret; 16 | char *tz; 17 | 18 | tz = getenv("TZ"); 19 | putenv((char*)"TZ="); 20 | tzset(); 21 | ret = mktime(tm); 22 | if (tz) { 23 | char buf[256]; 24 | snprintf(buf, sizeof(buf), "TZ=%s", tz); 25 | putenv(tz); 26 | } 27 | else 28 | putenv((char*)"TZ"); 29 | tzset(); 30 | return ret; 31 | } 32 | -------------------------------------------------------------------------------- /contrib/NETLDNS.readme.txt: -------------------------------------------------------------------------------- 1 | NETLDNS is a functionality port of NLnet Labs' LDNS to the .NET 2 | 2.0 framework, contributed by Alex Nicoll of the Carnegie Mellon 3 | University Software Engineering Institute. NETLDNS is released 4 | under the BSD license. NETLDNS uses Mihnea Radulescu's BigInteger 5 | Library (http://www.codeproject.com/KB/cs/BigInteger_Library.aspx) 6 | from CodeProject to help with key manipulation. Please contact Alex at 7 | anicoll@cert.org with inquiries or requests for newer versions. 8 | 9 | This project is not supported by NLnet Labs. 10 | 11 | -------------------------------------------------------------------------------- /contrib/NETLDNS.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NLnetLabs/ldns/ae1243a7ba8630a60df5e6f128c49fdaaa7e6306/contrib/NETLDNS.tar.gz -------------------------------------------------------------------------------- /contrib/build-solaris.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | # 3 | # $Id$ 4 | 5 | 6 | PREFIX=/opt/ldns 7 | OPENSSL=/usr/sfw 8 | SUDO=sudo 9 | 10 | MAKE_PROGRAM=gmake 11 | MAKE_ARGS="-j 4" 12 | 13 | OBJ32=obj32 14 | OBJ64=obj64 15 | 16 | SRCDIR=`pwd` 17 | 18 | 19 | test -d $OBJ32 && $SUDO rm -fr $OBJ32 20 | mkdir $OBJ32 21 | 22 | export CFLAGS="" 23 | export LDFLAGS="-L${OPENSSL}/lib -R${OPENSSL}/lib" 24 | 25 | (cd $OBJ32; \ 26 | ${SRCDIR}/configure --with-ssl=${OPENSSL} --prefix=${PREFIX} --libdir=${PREFIX}/lib; \ 27 | $MAKE_PROGRAM $MAKE_ARGS) 28 | 29 | if [ `isainfo -k` = amd64 ]; then 30 | test -d $OBJ64 && $SUDO rm -fr $OBJ64 31 | mkdir $OBJ64 32 | 33 | export CFLAGS="-m64" 34 | export LDFLAGS="-L${OPENSSL}/lib/amd64 -R${OPENSSL}/lib/amd64" 35 | 36 | (cd $OBJ64; \ 37 | ${SRCDIR}/configure --with-ssl=${OPENSSL} --prefix=${PREFIX} --libdir=${PREFIX}/lib/amd64; \ 38 | $MAKE_PROGRAM $MAKE_ARGS) 39 | fi 40 | 41 | # optionally install 42 | # 43 | if [ x$1 = xinstall ]; then 44 | (cd $OBJ32; $SUDO $MAKE_PROGRAM install-h) 45 | (cd $OBJ32; $SUDO $MAKE_PROGRAM install-doc) 46 | (cd $OBJ32; $SUDO $MAKE_PROGRAM install-lib) 47 | if [ `isainfo -k` = amd64 ]; then 48 | (cd $OBJ64; $SUDO $MAKE_PROGRAM install-lib) 49 | fi 50 | fi 51 | -------------------------------------------------------------------------------- /contrib/ldnsx/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Xelerance 2 | Author: Christopher Olah 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of Xelerance nor the names of its 15 | contributors may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /contrib/ldnsx/README: -------------------------------------------------------------------------------- 1 | LDNSX: Easy DNS (including DNSSEC) via ldns. 2 | 3 | ldns is a great library. It is a powerful tool for 4 | working with DNS. python-ldns it is a straight up clone of the C 5 | interface, however that is not a very good interface for python. Its 6 | documentation is incomplete and some functions don't work as 7 | described. And some objects don't have a full python API. 8 | 9 | ldnsx aims to fix this. It wraps around the ldns python bindings, 10 | working around its limitations and providing a well-documented, more 11 | pythonistic interface. 12 | 13 | Written by Christopher Olah 14 | 15 | Examples 16 | ======== 17 | 18 | Query the default resolver for google.com's A records. Print the response 19 | packet. 20 | 21 | >>> import ldnsx 22 | >>> resolver = ldnsx.resolver() 23 | >>> print resolver.query("google.com","A") 24 | 25 | Print the NS records for com. from f.root-servers.net if we get a 26 | response, else an error message. 27 | 28 | >>> import ldnsx 29 | >>> pkt = ldnsx.resolver("f.root-servers.net").query("com.","NS") 30 | >>> if pkt: 31 | >>> for rr in pkt.answer(): 32 | >>> print rr 33 | >>> else: 34 | >>> print "response not received" 35 | 36 | 37 | -------------------------------------------------------------------------------- /contrib/ldnsx/examples/ldnsx-axfr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # vim:fileencoding=utf-8 3 | # 4 | # AXFR client with IDN (Internationalized Domain Names) support 5 | # 6 | 7 | import ldns 8 | import encodings.idna 9 | 10 | def utf2name(name): 11 | return '.'.join([encodings.idna.ToASCII(a) for a in name.split('.')]) 12 | def name2utf(name): 13 | return '.'.join([encodings.idna.ToUnicode(a) for a in name.split('.')]) 14 | 15 | resolver = ldnsx.resolver("zone.nic.cz") 16 | 17 | #Print results 18 | for rr in resolver.AXFR(utf2name(u"háčkyčárky.cz")): 19 | # rdf = rr.owner() 20 | # if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): 21 | # print "RDF owner: type=",rr.type(),"data=",name2utf(rr.owner()) 22 | # else: 23 | # print "RDF owner: type=",rdf.get_type_str(),"data=",str(rdf) 24 | # print " RR type=", rr.get_type_str()," ttl=",rr.ttl() 25 | # for rdf in rr.rdfs(): 26 | # if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): 27 | # print " RDF: type=",rdf.get_type_str(),"data=",name2utf(str(rdf)) 28 | # else: 29 | # print " RDF: type=",rdf.get_type_str(),"data=",str(rdf) 30 | 31 | -------------------------------------------------------------------------------- /contrib/ldnsx/examples/ldnsx-dnssec.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import ldnsx 4 | import sys 5 | 6 | debug = True 7 | 8 | if len(sys.argv) < 2: 9 | print "Usage:", sys.argv[0], "domain [resolver_addr]" 10 | sys.exit(1) 11 | 12 | name = sys.argv[1] 13 | 14 | # Create resolver 15 | resolver = ldnsx.resolver(dnssec=True) 16 | 17 | # Custom resolver 18 | if len(sys.argv) > 2: 19 | # Clear previous nameservers 20 | resolver.set_nameservers(sys.argv[2:]) 21 | 22 | # Resolve DNS name 23 | pkt = resolver.query(name, "A") 24 | 25 | if pkt and pkt.answer(): 26 | 27 | # Debug 28 | if debug: 29 | print "NS returned:", pkt.rcode(), "(AA: %d AD: %d)" % ( "AA" in pkt.flags(), "AD" in pkt.flags() ) 30 | 31 | # SERVFAIL indicated bogus name 32 | if pkt.rcode() == "SERVFAIL": 33 | print name, "failed to resolve" 34 | 35 | # Check AD (Authenticated) bit 36 | if pkt.rcode() == "NOERROR": 37 | if "AD" in pkt.flags(): print name, "is secure" 38 | else: print name, "is insecure" 39 | 40 | -------------------------------------------------------------------------------- /contrib/ldnsx/examples/ldnsx-mx1.py: -------------------------------------------------------------------------------- 1 | import ldnsx 2 | 3 | resolver = ldnsx.resolver() 4 | 5 | pkt = resolver.query("nic.cz", "MX") 6 | 7 | if (pkt): 8 | mx = pkt.answer() 9 | if (mx): 10 | mx.sort() 11 | print mx 12 | -------------------------------------------------------------------------------- /contrib/ldnsx/examples/ldnsx-mx2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # MX is a small program that prints out the mx records for a particular domain 4 | # 5 | import ldnsx 6 | 7 | resolver = ldnsx.resolver() 8 | 9 | pkt = resolver.query("nic.cz", "MX") 10 | if pkt: 11 | for rr in pkt.answer(rr_type = "MX"): 12 | rdf = rr.owner() 13 | print rr 14 | #Could also do: 15 | #print rr[0], rr[1], rr[2], rr[3], " ".join(rr[4:]) 16 | #print rr.owner(), rr.ttl(), rr.rr_clas(), rr.rr_type(), " ".join(rr[4:]) 17 | 18 | -------------------------------------------------------------------------------- /contrib/ldnsx/examples/ldnsx-walk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # vim:fileencoding=utf-8 3 | # 4 | # Walk a domain that's using NSEC and print in zonefile format. 5 | 6 | import sys 7 | import ldnsx 8 | 9 | def walk(domain): 10 | res = ldnsx.resolver("193.110.157.136", dnssec=True) 11 | pkt = res.query(domain, 666) 12 | try: 13 | nsec_rr = pkt.authority(rr_type="NSEC")[0] 14 | except: 15 | print "no NSEC found, domain is not signed or using NSEC3" 16 | sys.exit() 17 | for rr_type in nsec_rr[5].split(' ')[:-1]: 18 | for rr in ldnsx.get_rrs(domain, rr_type): 19 | print str(rr)[:-1] 20 | next_rec = nsec_rr[4] 21 | if (next_rec != domain) and (next_rec[-len(domain):] == domain): 22 | walk(next_rec) 23 | 24 | walk("xelerance.com") 25 | 26 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/api/ldnsx.rst: -------------------------------------------------------------------------------- 1 | LDNSX API Reference 2 | =================== 3 | 4 | .. automodule:: ldnsx 5 | :members: query, get_rrs, secure_query 6 | 7 | Classes 8 | ------- 9 | .. toctree:: 10 | :maxdepth: 1 11 | :glob: 12 | 13 | resolver 14 | packet 15 | resource_record 16 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/api/packet.rst: -------------------------------------------------------------------------------- 1 | Class packet 2 | ============== 3 | 4 | .. autoclass:: ldnsx.packet 5 | :members: 6 | :undoc-members: 7 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/api/resolver.rst: -------------------------------------------------------------------------------- 1 | Class resolver 2 | =============== 3 | 4 | .. autoclass:: ldnsx.resolver 5 | :members: 6 | :undoc-members: 7 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/api/resource_record.rst: -------------------------------------------------------------------------------- 1 | Class resource_record 2 | ===================== 3 | 4 | .. autoclass:: ldnsx.resource_record 5 | :members: 6 | :undoc-members: 7 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/examples/ldnsx-axfr.rst: -------------------------------------------------------------------------------- 1 | AXFR Example 2 | ============ 3 | 4 | .. literalinclude:: ../../examples/ldnsx-axfr.py 5 | :language: python 6 | :linenos: 7 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/examples/ldnsx-dnssec.rst: -------------------------------------------------------------------------------- 1 | DNSSEC Example 2 | ============== 3 | 4 | .. literalinclude:: ../../examples/ldnsx-dnssec.py 5 | :language: python 6 | :linenos: 7 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/examples/ldnsx-mx1.rst: -------------------------------------------------------------------------------- 1 | MX1 2 | === 3 | 4 | .. literalinclude:: ../../examples/ldnsx-mx1.py 5 | :language: python 6 | :linenos: 7 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/examples/ldnsx-mx2.rst: -------------------------------------------------------------------------------- 1 | MX2 2 | === 3 | 4 | .. literalinclude:: ../../examples/ldnsx-mx2.py 5 | :language: python 6 | :linenos: 7 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/examples/ldnsx-walk.rst: -------------------------------------------------------------------------------- 1 | NSEC Walker 2 | =========== 3 | 4 | .. literalinclude:: ../../examples/ldnsx-walk.py 5 | :language: python 6 | :linenos: 7 | -------------------------------------------------------------------------------- /contrib/ldnsx/source/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to ldnsx's documentation! 2 | ================================= 3 | 4 | LDNSX: Easy DNS (including DNSSEC) via ldns. 5 | 6 | ldns is a great library. It is a powerful tool for 7 | working with DNS. python-ldns it is a straight up clone of the C 8 | interface, however that is not a very good interface for python. Its 9 | documentation is incomplete and some functions don't work as 10 | described. And some objects don't have a full python API. 11 | 12 | ldnsx aims to fix this. It wraps around the ldns python bindings, 13 | working around its limitations and providing a well-documented, more 14 | pythonistic interface. 15 | 16 | Reference 17 | ========= 18 | 19 | .. toctree:: 20 | :maxdepth: 1 21 | 22 | api/ldnsx 23 | 24 | .. toctree:: 25 | :maxdepth: 2 26 | 27 | api/resolver 28 | api/packet 29 | api/resource_record 30 | 31 | Examples 32 | ======== 33 | 34 | Examples translated from ldns examples: 35 | 36 | .. toctree:: 37 | :maxdepth: 1 38 | 39 | examples/ldnsx-axfr 40 | examples/ldnsx-dnssec 41 | examples/ldnsx-mx1 42 | examples/ldnsx-mx2 43 | 44 | Others: 45 | 46 | .. toctree:: 47 | :maxdepth: 1 48 | 49 | examples/ldnsx-walk 50 | 51 | 52 | Indices and tables 53 | ================== 54 | 55 | * :ref:`genindex` 56 | * :ref:`search` 57 | 58 | -------------------------------------------------------------------------------- /contrib/python/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) 2 | Karel Slany (slany AT fit.vutbr.cz) 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the organization nor the names of its 14 | contributors may be used to endorse or promote products derived from this 15 | software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /contrib/python/docs/source/examples/example2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import ldns 4 | import sys 5 | 6 | debug = True 7 | 8 | # Check args 9 | argc = len(sys.argv) 10 | name = "www.nic.cz" 11 | if argc < 2: 12 | print("Usage:", sys.argv[0], "domain [resolver_addr]") 13 | sys.exit(1) 14 | else: 15 | name = sys.argv[1] 16 | 17 | # Create resolver 18 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 19 | resolver.set_dnssec(True) 20 | 21 | # Custom resolver 22 | if argc > 2: 23 | # Clear previous nameservers 24 | ns = resolver.pop_nameserver() 25 | while ns != None: 26 | ns = resolver.pop_nameserver() 27 | ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A) 28 | resolver.push_nameserver(ip) 29 | 30 | # Resolve DNS name 31 | pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) 32 | if pkt and pkt.answer(): 33 | 34 | # Debug 35 | if debug: 36 | print("NS returned:", pkt.get_rcode(), "(AA: %d AD: %d)" % ( pkt.ad(), pkt.ad() )) 37 | 38 | # SERVFAIL indicated bogus name 39 | if pkt.get_rcode() is ldns.LDNS_RCODE_SERVFAIL: 40 | print(name, "is bogus") 41 | 42 | # Check AD (Authenticated) bit 43 | if pkt.get_rcode() is ldns.LDNS_RCODE_NOERROR: 44 | if pkt.ad(): print(name, "is secure") 45 | else: print(name, "is insecure") 46 | -------------------------------------------------------------------------------- /contrib/python/docs/source/examples/example3.rst: -------------------------------------------------------------------------------- 1 | High-level functions 2 | =========================== 3 | 4 | This basic example shows how to get name by addr and vice versa. 5 | 6 | .. literalinclude:: ../../../examples/ldns-higher.py 7 | :language: python 8 | -------------------------------------------------------------------------------- /contrib/python/docs/source/examples/example4.rst: -------------------------------------------------------------------------------- 1 | AXFR client with IDN support 2 | =============================== 3 | 4 | This example shows how to get AXFR working and how to get involved Internationalized Domain Names (IDN) 5 | 6 | .. literalinclude:: ../../../examples/ldns-axfr.py 7 | :language: python 8 | -------------------------------------------------------------------------------- /contrib/python/docs/source/examples/example5.rst: -------------------------------------------------------------------------------- 1 | Examine the results 2 | =============================== 3 | 4 | This example shows how to go through the obtained results 5 | 6 | .. literalinclude:: ../../../examples/ldns-mx2.py 7 | :language: python 8 | 9 | This snippet of code prints:: 10 | 11 | nic.cz. 1761 IN MX 20 mx.cznic.org. 12 | nic.cz. 1761 IN MX 10 mail.nic.cz. 13 | nic.cz. 1761 IN MX 15 mail4.nic.cz. 14 | 15 | -------------------------------------------------------------------------------- /contrib/python/docs/source/examples/example6.rst: -------------------------------------------------------------------------------- 1 | Read zone file 2 | =============================== 3 | 4 | This example shows how to read the content of a zone file 5 | 6 | .. literalinclude:: ../../../examples/ldns-zone.py 7 | :language: python 8 | 9 | Zone file ``zone.txt``: 10 | 11 | .. literalinclude:: ../../../examples/zone.txt 12 | 13 | -------------------------------------------------------------------------------- /contrib/python/docs/source/examples/example7.rst: -------------------------------------------------------------------------------- 1 | Generate public/private key pair 2 | ======================================= 3 | 4 | This example shows how generate keys for DNSSEC (i.e. for signing a zone file according DNSSECbis). 5 | 6 | .. literalinclude:: ../../../examples/ldns-keygen.py 7 | :language: python 8 | 9 | -------------------------------------------------------------------------------- /contrib/python/docs/source/examples/example8.rst: -------------------------------------------------------------------------------- 1 | Signing of a zone file 2 | =============================== 3 | 4 | This example shows how to sign the content of the given zone file 5 | 6 | .. literalinclude:: ../../../examples/ldns-signzone.py 7 | :language: python 8 | 9 | In order to be able sign a zone file, you have to generate a key-pair using ``ldns-keygen.py``. Don't forget to modify tag number. 10 | 11 | Signing consists of three steps 12 | 13 | 1. In the first step, the content of a zone file is read and parsed. This can be done using :class:`ldns.ldns_zone` class. 14 | 15 | 2. In the second step, the private and public key is read and public key is inserted into zone (as DNSKEY). 16 | 17 | 3. In the last step, the DNSSEC zone instance is created and all the RRs from zone file are copied here. Then, all the records are signed using :meth:`ldns.ldns_zone.sign` method. If the signing was successful, the content of DNSSEC zone is written to a file. 18 | -------------------------------------------------------------------------------- /contrib/python/docs/source/examples/index.rst: -------------------------------------------------------------------------------- 1 | Tutorials 2 | ============================== 3 | 4 | Here you can find a set of simple applications which utilizes the ldns library in Python environment. 5 | 6 | `Tutorials` 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | :glob: 11 | 12 | example* 13 | -------------------------------------------------------------------------------- /contrib/python/docs/source/index.rst: -------------------------------------------------------------------------------- 1 | PyLDNS documentation 2 | ======================================= 3 | 4 | PyLDNS provides an `LDNS`_ wrapper (Python extension module) - the thinnest layer over the library possible. Everything you can do from the C API, you can do from Python, but with less effort. The purpose of porting LDNS library to Python is to simplify DNS programming and usage of LDNS, however, still preserve the performance of this library as the speed represents the main benefit of LDNS. The proposed object approach allows the users to be concentrated at the essential part of application only and don't bother with deallocation of objects and so on. 5 | 6 | .. _LDNS: http://www.nlnetlabs.nl/projects/ldns/ 7 | 8 | Contents 9 | ---------- 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | install.rst 14 | examples/index.rst 15 | modules/ldns 16 | 17 | Indices and tables 18 | ------------------- 19 | 20 | * :ref:`genindex` 21 | * :ref:`search` 22 | 23 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns.rst: -------------------------------------------------------------------------------- 1 | LDNS module documentation 2 | ================================ 3 | 4 | Here you can find the documentation of pyLDNS extension module. This module consists of several classes and a couple of functions. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | ldns_resolver 11 | ldns_pkt 12 | ldns_rr 13 | ldns_rdf 14 | ldns_dname 15 | ldns_rr_list 16 | ldns_zone 17 | ldns_key 18 | ldns_key_list 19 | ldns_buffer 20 | ldns_dnssec 21 | ldns_func 22 | 23 | 24 | 25 | 26 | **Differences against libLDNS** 27 | 28 | * You don't need to use ldns-compare functions, instances can be compared using standard operators <, >, = :: 29 | 30 | if (some_rr.owner() == another_rr.rdf(1)): 31 | pass 32 | 33 | * Classes contain static methods that create new instances, the name of these methods starts with the new\_ prefix (e.g. :meth:`ldns.ldns_pkt.new_frm_file`). 34 | 35 | * Is it possible to print the content of an object using ``print objinst`` (see :meth:`ldns.ldns_resolver.get_addr_by_name`). 36 | 37 | * Classes contain write_to_buffer method that writes the content into buffer. 38 | 39 | * All the methods that consume parameter of (const ldns_rdf) type allows to use string instead (see :meth:`ldns.ldns_resolver.query`). 40 | 41 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_buffer.rst: -------------------------------------------------------------------------------- 1 | Class ldns_buffer 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_buffer 8 | ------------------------------ 9 | .. autoclass:: ldns_buffer 10 | :members: 11 | :undoc-members: 12 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_dname.rst: -------------------------------------------------------------------------------- 1 | Class ldns_dname 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_dname 8 | ------------------------------ 9 | .. autoclass:: ldns_dname 10 | :members: 11 | :undoc-members: 12 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_dnssec.rst: -------------------------------------------------------------------------------- 1 | Class ldns_dnssec_zone 2 | ================================ 3 | 4 | .. automodule:: ldns 5 | 6 | Class ldns_dnssec_zone 7 | ------------------------------ 8 | .. autoclass:: ldns_dnssec_zone 9 | :members: 10 | :undoc-members: 11 | 12 | Class ldns_dnssec_name 13 | ------------------------------ 14 | .. autoclass:: ldns_dnssec_name 15 | :members: 16 | :undoc-members: 17 | 18 | Class ldns_dnssec_rrsets 19 | ------------------------------ 20 | .. autoclass:: ldns_dnssec_rrsets 21 | :members: 22 | :undoc-members: 23 | 24 | Class ldns_dnssec_rrs 25 | ------------------------------ 26 | .. autoclass:: ldns_dnssec_rrs 27 | :members: 28 | :undoc-members: 29 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_key.rst: -------------------------------------------------------------------------------- 1 | Class ldns_key 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_key 8 | ------------------------------ 9 | .. autoclass:: ldns_key 10 | :members: 11 | :undoc-members: 12 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_key_list.rst: -------------------------------------------------------------------------------- 1 | Class ldns_key_list 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_key_list 8 | ------------------------------ 9 | .. autoclass:: ldns_key_list 10 | :members: 11 | :undoc-members: 12 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_pkt.rst: -------------------------------------------------------------------------------- 1 | Class ldns_pkt 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_pkt 8 | ------------------------------ 9 | .. autoclass:: ldns_pkt 10 | :members: 11 | :undoc-members: 12 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_rdf.rst: -------------------------------------------------------------------------------- 1 | Class ldns_rdf 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_rdf 8 | ------------------------------ 9 | .. autoclass:: ldns_rdf 10 | :members: 11 | :undoc-members: 12 | 13 | Predefined constants 14 | ------------------------------ 15 | 16 | **RDF TYPE** 17 | * LDNS_RDF_TYPE_NONE, 18 | * LDNS_RDF_TYPE_DNAME, 19 | * LDNS_RDF_TYPE_INT8, 20 | * LDNS_RDF_TYPE_INT16, 21 | * LDNS_RDF_TYPE_INT32, 22 | * LDNS_RDF_TYPE_A, 23 | * LDNS_RDF_TYPE_AAAA, 24 | * LDNS_RDF_TYPE_STR, 25 | * LDNS_RDF_TYPE_APL, 26 | * LDNS_RDF_TYPE_B32_EXT, 27 | * LDNS_RDF_TYPE_B64, 28 | * LDNS_RDF_TYPE_HEX, 29 | * LDNS_RDF_TYPE_NSEC, 30 | * LDNS_RDF_TYPE_TYPE, 31 | * LDNS_RDF_TYPE_CLASS, 32 | * LDNS_RDF_TYPE_CERT_ALG, 33 | * LDNS_RDF_TYPE_ALG, 34 | * LDNS_RDF_TYPE_UNKNOWN, 35 | * LDNS_RDF_TYPE_TIME, 36 | * LDNS_RDF_TYPE_PERIOD, 37 | * LDNS_RDF_TYPE_TSIGTIME, 38 | * LDNS_RDF_TYPE_HIP, 39 | * LDNS_RDF_TYPE_INT16_DATA, 40 | * LDNS_RDF_TYPE_SERVICE, 41 | * LDNS_RDF_TYPE_LOC, 42 | * LDNS_RDF_TYPE_WKS, 43 | * LDNS_RDF_TYPE_NSAP, 44 | * LDNS_RDF_TYPE_IPSECKEY, 45 | * LDNS_RDF_TYPE_NSEC3_SALT, 46 | * LDNS_RDF_TYPE_NSEC3_NEXT_OWNER 47 | 48 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_resolver.rst: -------------------------------------------------------------------------------- 1 | Class ldns_resolver 2 | ================================ 3 | 4 | .. automodule:: ldns 5 | 6 | Class ldns_resolver 7 | ------------------------------ 8 | .. autoclass:: ldns_resolver 9 | :members: 10 | :undoc-members: 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_rr.rst: -------------------------------------------------------------------------------- 1 | Class ldns_rr 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_rr 8 | ------------------------------ 9 | .. autoclass:: ldns_rr 10 | :members: 11 | :undoc-members: 12 | 13 | Class ldns_rr_descriptor 14 | ------------------------------ 15 | .. autoclass:: ldns_rr_descriptor 16 | :members: 17 | :undoc-members: 18 | 19 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_rr_list.rst: -------------------------------------------------------------------------------- 1 | Class ldns_rr_list 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_rr_list 8 | ------------------------------ 9 | .. autoclass:: ldns_rr_list 10 | :members: 11 | :undoc-members: 12 | -------------------------------------------------------------------------------- /contrib/python/docs/source/modules/ldns_zone.rst: -------------------------------------------------------------------------------- 1 | Class ldns_zone 2 | ================================ 3 | 4 | 5 | .. automodule:: ldns 6 | 7 | Class ldns_zone 8 | ------------------------------ 9 | .. autoclass:: ldns_zone 10 | :members: 11 | :undoc-members: 12 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-axfr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # vim:fileencoding=utf-8 3 | # 4 | # AXFR client with IDN (Internationalized Domain Names) support 5 | # 6 | 7 | import ldns 8 | import encodings.idna 9 | 10 | def utf2name(name): 11 | return '.'.join([encodings.idna.ToASCII(a) for a in name.split('.')]) 12 | def name2utf(name): 13 | return '.'.join([encodings.idna.ToUnicode(a) for a in name.split('.')]) 14 | 15 | 16 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 17 | 18 | #addr = ldns.ldns_get_rr_list_addr_by_name(resolver, "zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD); 19 | addr = resolver.get_addr_by_name("zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD); 20 | if (not addr): 21 | raise Exception("Can't retrieve server address") 22 | 23 | print "Addr_by_name:",str(addr).replace("\n","; ") 24 | 25 | #remove all nameservers 26 | while resolver.pop_nameserver(): 27 | pass 28 | 29 | #insert server addr 30 | for rr in addr.rrs(): 31 | resolver.push_nameserver_rr(rr) 32 | 33 | #AXFR transfer 34 | status = resolver.axfr_start(utf2name(u"háčkyčárky.cz"), ldns.LDNS_RR_CLASS_IN) 35 | if status != ldns.LDNS_STATUS_OK: 36 | raise Exception("Can't start AXFR. Error: %s" % ldns.ldns_get_errorstr_by_id(status)) 37 | 38 | #Print results 39 | while True: 40 | rr = resolver.axfr_next() 41 | if not rr: 42 | break 43 | 44 | rdf = rr.owner() 45 | if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): 46 | print "RDF owner: type=",rdf.get_type_str(),"data=",name2utf(str(rdf)) 47 | else: 48 | print "RDF owner: type=",rdf.get_type_str(),"data=",str(rdf) 49 | print " RR type=", rr.get_type_str()," ttl=",rr.ttl() 50 | for rdf in rr.rdfs(): 51 | if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): 52 | print " RDF: type=",rdf.get_type_str(),"data=",name2utf(str(rdf)) 53 | else: 54 | print " RDF: type=",rdf.get_type_str(),"data=",str(rdf) 55 | 56 | print 57 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-buf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import ldns 4 | 5 | buf = ldns.ldns_buffer(1024) 6 | buf.printf("Test buffer") 7 | print buf 8 | 9 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-dnssec.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import ldns 4 | import sys 5 | 6 | debug = True 7 | 8 | # Check args 9 | argc = len(sys.argv) 10 | name = "www.nic.cz" 11 | if argc < 2: 12 | print "Usage:", sys.argv[0], "domain [resolver_addr]" 13 | sys.exit(1) 14 | else: 15 | name = sys.argv[1] 16 | 17 | # Create resolver 18 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 19 | resolver.set_dnssec(True) 20 | 21 | # Custom resolver 22 | if argc > 2: 23 | # Clear previous nameservers 24 | ns = resolver.pop_nameserver() 25 | while ns != None: 26 | ns = resolver.pop_nameserver() 27 | ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A) 28 | resolver.push_nameserver(ip) 29 | 30 | # Resolve DNS name 31 | pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) 32 | if pkt and pkt.answer(): 33 | 34 | # Debug 35 | if debug: 36 | print "NS returned:", pkt.get_rcode(), "(AA: %d AD: %d)" % ( pkt.ad(), pkt.ad() ) 37 | 38 | # SERVFAIL indicated bogus name 39 | if pkt.get_rcode() is ldns.LDNS_RCODE_SERVFAIL: 40 | print name, "is bogus" 41 | 42 | # Check AD (Authenticated) bit 43 | if pkt.get_rcode() is ldns.LDNS_RCODE_NOERROR: 44 | if pkt.ad(): print name, "is secure" 45 | else: print name, "is insecure" 46 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-higher.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import ldns 3 | 4 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 5 | 6 | dnn = ldns.ldns_dname("www.google.com") 7 | print dnn.get_type_str(), dnn 8 | 9 | dna = ldns.ldns_rdf.new_frm_str("74.125.43.99",ldns.LDNS_RDF_TYPE_A) 10 | print dna.get_type_str(), dna 11 | 12 | name = resolver.get_name_by_addr(dna) 13 | if (not name): raise Exception("Can't retrieve server name") 14 | for rr in name.rrs(): 15 | print rr 16 | 17 | name = resolver.get_name_by_addr("74.125.43.99") 18 | if (not name): raise Exception("Can't retrieve server name") 19 | for rr in name.rrs(): 20 | print rr 21 | 22 | addr = resolver.get_addr_by_name(dnn) 23 | if (not addr): raise Exception("Can't retrieve server address") 24 | for rr in addr.rrs(): 25 | print rr 26 | 27 | addr = resolver.get_addr_by_name("www.google.com") 28 | if (not addr): raise Exception("Can't retrieve server address") 29 | for rr in addr.rrs(): 30 | print rr 31 | 32 | hosts = ldns.ldns_rr_list.new_frm_file("/etc/hosts") 33 | if (not hosts): raise Exception("Can't retrieve the content of file") 34 | for rr in hosts.rrs(): 35 | print rr 36 | 37 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-keygen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # This example shows how to generate public/private key pair 4 | # 5 | import ldns 6 | 7 | algorithm = ldns.LDNS_SIGN_DSA 8 | bits = 512 9 | 10 | ldns.ldns_init_random(open("/dev/urandom","rb"), (bits+7)//8) 11 | 12 | domain = ldns.ldns_dname("example.") 13 | 14 | #generate a new key 15 | key = ldns.ldns_key.new_frm_algorithm(algorithm, bits); 16 | print key 17 | 18 | #set owner 19 | key.set_pubkey_owner(domain) 20 | 21 | #create the public from the ldns_key 22 | pubkey = key.key_to_rr() 23 | #previous command is equivalent to 24 | # pubkey = ldns.ldns_key2rr(key) 25 | print pubkey 26 | 27 | #calculate and set the keytag 28 | key.set_keytag(ldns.ldns_calc_keytag(pubkey)) 29 | 30 | #build the DS record 31 | ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1) 32 | print ds 33 | 34 | owner, tag = pubkey.owner(), key.keytag() 35 | 36 | #write public key to .key file 37 | fw = open("key-%s-%d.key" % (owner,tag), "wb") 38 | pubkey.print_to_file(fw) 39 | 40 | #write private key to .priv file 41 | fw = open("key-%s-%d.private" % (owner,tag), "wb") 42 | key.print_to_file(fw) 43 | 44 | #write DS to .ds file 45 | fw = open("key-%s-%d.ds" % (owner,tag), "wb") 46 | ds.print_to_file(fw) 47 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-mx.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # MX is a small program that prints out the mx records for a particular domain 4 | # 5 | import ldns 6 | 7 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 8 | 9 | pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) 10 | 11 | if (pkt): 12 | mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) 13 | if (mx): 14 | mx.sort() 15 | print mx 16 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-mx1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # MX is a small program that prints out the mx records for a particular domain 4 | # 5 | import ldns 6 | 7 | dname = ldns.ldns_dname("nic.cz") 8 | print dname 9 | 10 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 11 | 12 | pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) 13 | 14 | if (pkt): 15 | mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) 16 | if (mx): 17 | mx.sort() 18 | print mx 19 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-mx2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # MX is a small program that prints out the mx records for a particular domain 4 | # 5 | import ldns 6 | 7 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 8 | 9 | pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) 10 | if (pkt) and (pkt.answer()): 11 | 12 | for rr in pkt.answer().rrs(): 13 | if (rr.get_type() != ldns.LDNS_RR_TYPE_MX): 14 | continue 15 | 16 | rdf = rr.owner() 17 | print rdf," ",rr.ttl()," ",rr.get_class_str()," ",rr.get_type_str()," ", 18 | print " ".join(str(rdf) for rdf in rr.rdfs()) 19 | 20 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-newpkt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import ldns 4 | 5 | pkt = ldns.ldns_pkt.new_query_frm_str("www.google.com",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) 6 | 7 | rra = ldns.ldns_rr.new_frm_str("www.google.com. IN A 192.168.1.1",300) 8 | rrb = ldns.ldns_rr.new_frm_str("www.google.com. IN TXT Some\ Description",300) 9 | 10 | list = ldns.ldns_rr_list() 11 | if (rra): list.push_rr(rra) 12 | if (rrb): list.push_rr(rrb) 13 | 14 | pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, list) 15 | 16 | print "Packet:" 17 | print pkt 18 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-signzone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # This example shows how to sign a given zone file with private key 3 | 4 | import ldns 5 | import sys, os, time 6 | 7 | #private key TAG which identifies the private key 8 | #use ldns-keygen.py in order to obtain private key 9 | keytag = 30761 10 | 11 | # Read zone file 12 | #------------------------------------------------------------- 13 | 14 | zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN) 15 | soa = zone.soa() 16 | origin = soa.owner() 17 | 18 | # Prepare keys 19 | #------------------------------------------------------------- 20 | 21 | #Read private key from file 22 | keyfile = open("key-%s-%d.private" % (origin, keytag), "r"); 23 | key = ldns.ldns_key.new_frm_fp(keyfile) 24 | 25 | #Read public key from file 26 | pubfname = "key-%s-%d.key" % (origin, keytag) 27 | pubkey = None 28 | if os.path.isfile(pubfname): 29 | pubkeyfile = open(pubfname, "r"); 30 | pubkey,_,_,_ = ldns.ldns_rr.new_frm_fp(pubkeyfile) 31 | 32 | if not pubkey: 33 | #Create new public key 34 | pubkey = key.key_to_rr() 35 | 36 | #Set key expiration 37 | key.set_expiration(int(time.time()) + 365*60*60*24) #365 days 38 | 39 | #Set key owner (important step) 40 | key.set_pubkey_owner(origin) 41 | 42 | #Insert DNSKEY RR 43 | zone.push_rr(pubkey) 44 | 45 | # Sign zone 46 | #------------------------------------------------------------- 47 | 48 | #Create keylist and push private key 49 | keys = ldns.ldns_key_list() 50 | keys.push_key(key) 51 | 52 | #Add SOA 53 | signed_zone = ldns.ldns_dnssec_zone() 54 | signed_zone.add_rr(soa) 55 | 56 | #Add RRs 57 | for rr in zone.rrs().rrs(): 58 | print "RR:",str(rr), 59 | signed_zone.add_rr(rr) 60 | 61 | added_rrs = ldns.ldns_rr_list() 62 | status = signed_zone.sign(added_rrs, keys) 63 | if (status == ldns.LDNS_STATUS_OK): 64 | signed_zone.print_to_file(open("zone_signed.txt","w")) 65 | 66 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns-zone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import ldns 3 | 4 | #Read zone from file 5 | zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN) 6 | print zone 7 | 8 | print "SOA:", zone.soa() 9 | for r in zone.rrs().rrs(): 10 | print "RR:", r 11 | 12 | 13 | zone = ldns.ldns_zone() 14 | #print zone 15 | 16 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns_rr_iter_frm_fp_l.demo.py: -------------------------------------------------------------------------------- 1 | import ldns 2 | import sys 3 | 4 | if len(sys.argv) <= 1: 5 | print "Usage: %s zone_file" % sys.argv[0] 6 | sys.exit() 7 | 8 | inp = open(sys.argv[1],"r"); 9 | for rr in ldns.ldns_rr_iter_frm_fp_l(inp): 10 | print rr 11 | 12 | inp.close() 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /contrib/python/examples/ldns_rr_new_frm_fp_l.demo.py: -------------------------------------------------------------------------------- 1 | import ldns 2 | import sys 3 | 4 | if len(sys.argv) <= 1: 5 | print "Usage: %s zone_file" % sys.argv[0] 6 | sys.exit() 7 | 8 | inp = open(sys.argv[1],"r"); 9 | # variables that preserve the parsers state 10 | my_ttl = 3600; 11 | my_origin = None 12 | my_prev = None 13 | # additional state variables 14 | last_pos = 0 15 | line_nr = 0 16 | 17 | while True: 18 | ret = ldns.ldns_rr_new_frm_fp_l_(inp, my_ttl, my_origin, my_prev) 19 | s, rr, line_inc, new_ttl, new_origin, new_prev = ret # unpack the result 20 | line_nr += line_inc # increase number of parsed lines 21 | my_prev = new_prev # update ref to previous owner 22 | 23 | if s == ldns.LDNS_STATUS_SYNTAX_TTL: 24 | my_ttl = new_ttl # update default TTL 25 | print "$TTL:", my_ttl 26 | elif s == ldns.LDNS_STATUS_SYNTAX_ORIGIN: 27 | my_origin = new_origin # update reference to origin 28 | print "$ORIGIN:", my_origin 29 | elif s == ldns.LDNS_STATUS_SYNTAX_EMPTY: 30 | if last_pos == inp.tell(): 31 | break # no advance since last read - EOF 32 | last_pos = inp.tell() 33 | elif s != ldns.LDNS_STATUS_OK: 34 | print "! parse error in line", line_nr 35 | else: 36 | # we are sure to have LDNS_STATUS_OK 37 | print rr 38 | 39 | inp.close() 40 | print "--------------------" 41 | print "Read %d lines" % line_nr 42 | 43 | 44 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-axfr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # vim:fileencoding=utf-8 3 | # 4 | # AXFR client with IDN (Internationalized Domain Names) support 5 | # 6 | 7 | import ldns 8 | import encodings.idna 9 | 10 | def utf2name(name): 11 | return '.'.join([encodings.idna.ToASCII(a).decode("utf-8") for a in name.split('.')]) 12 | def name2utf(name): 13 | return '.'.join([encodings.idna.ToUnicode(a) for a in name.split('.')]) 14 | 15 | 16 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 17 | 18 | #addr = ldns.ldns_get_rr_list_addr_by_name(resolver, "zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD); 19 | addr = resolver.get_addr_by_name("zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD); 20 | if (not addr): 21 | raise Exception("Can't retrieve server address") 22 | 23 | print("Addr_by_name:",str(addr).replace("\n","; ")) 24 | 25 | #remove all nameservers 26 | while resolver.pop_nameserver(): 27 | pass 28 | 29 | #insert server addr 30 | for rr in addr.rrs(): 31 | resolver.push_nameserver_rr(rr) 32 | 33 | #AXFR transfer 34 | status = resolver.axfr_start(utf2name("háčkyčárky.cz"), ldns.LDNS_RR_CLASS_IN) 35 | if status != ldns.LDNS_STATUS_OK: 36 | raise Exception("Can't start AXFR. Error: %s" % ldns.ldns_get_errorstr_by_id(status)) 37 | 38 | #Print results 39 | while True: 40 | rr = resolver.axfr_next() 41 | if not rr: 42 | break 43 | 44 | rdf = rr.owner() 45 | if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): 46 | print("RDF owner: type=",rdf.get_type_str(),"data=",name2utf(str(rdf))) 47 | else: 48 | print("RDF owner: type=",rdf.get_type_str(),"data=",str(rdf)) 49 | print(" RR type=", rr.get_type_str()," ttl=",rr.ttl()) 50 | for rdf in rr.rdfs(): 51 | if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): 52 | print(" RDF: type=",rdf.get_type_str(),"data=",name2utf(str(rdf))) 53 | else: 54 | print(" RDF: type=",rdf.get_type_str(),"data=",str(rdf)) 55 | 56 | print() 57 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-buf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import ldns 4 | 5 | buf = ldns.ldns_buffer(1024) 6 | buf.printf("Test buffer") 7 | print(buf) 8 | 9 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-dnssec.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import ldns 4 | import sys 5 | 6 | debug = True 7 | 8 | # Check args 9 | argc = len(sys.argv) 10 | name = "www.nic.cz" 11 | if argc < 2: 12 | print("Usage:", sys.argv[0], "domain [resolver_addr]") 13 | sys.exit(1) 14 | else: 15 | name = sys.argv[1] 16 | 17 | # Create resolver 18 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 19 | resolver.set_dnssec(True) 20 | 21 | # Custom resolver 22 | if argc > 2: 23 | # Clear previous nameservers 24 | ns = resolver.pop_nameserver() 25 | while ns != None: 26 | ns = resolver.pop_nameserver() 27 | ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A) 28 | resolver.push_nameserver(ip) 29 | 30 | # Resolve DNS name 31 | pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) 32 | if pkt and pkt.answer(): 33 | 34 | # Debug 35 | if debug: 36 | print("NS returned:", pkt.get_rcode(), "(AA: %d AD: %d)" % ( pkt.ad(), pkt.ad() )) 37 | 38 | # SERVFAIL indicated bogus name 39 | if pkt.get_rcode() is ldns.LDNS_RCODE_SERVFAIL: 40 | print(name, "is bogus") 41 | 42 | # Check AD (Authenticated) bit 43 | if pkt.get_rcode() is ldns.LDNS_RCODE_NOERROR: 44 | if pkt.ad(): print(name, "is secure") 45 | else: print(name, "is insecure") 46 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-higher.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import ldns 3 | 4 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 5 | 6 | dnn = ldns.ldns_dname("www.google.com") 7 | print(dnn.get_type_str(), dnn) 8 | 9 | dna = ldns.ldns_rdf.new_frm_str("74.125.43.99",ldns.LDNS_RDF_TYPE_A) 10 | print(dna.get_type_str(), dna) 11 | 12 | name = resolver.get_name_by_addr(dna) 13 | if (not name): raise Exception("Can't retrieve server name") 14 | for rr in name.rrs(): 15 | print(rr) 16 | 17 | name = resolver.get_name_by_addr("74.125.43.99") 18 | if (not name): raise Exception("Can't retrieve server name") 19 | for rr in name.rrs(): 20 | print(rr) 21 | 22 | addr = resolver.get_addr_by_name(dnn) 23 | if (not addr): raise Exception("Can't retrieve server address") 24 | for rr in addr.rrs(): 25 | print(rr) 26 | 27 | addr = resolver.get_addr_by_name("www.google.com") 28 | if (not addr): raise Exception("Can't retrieve server address") 29 | for rr in addr.rrs(): 30 | print(rr) 31 | 32 | hosts = ldns.ldns_rr_list.new_frm_file("/etc/hosts") 33 | if (not hosts): raise Exception("Can't retrieve the content of file") 34 | for rr in hosts.rrs(): 35 | print(rr) 36 | 37 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-keygen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # This example shows how to generate public/private key pair 4 | # 5 | import ldns 6 | 7 | algorithm = ldns.LDNS_SIGN_DSA 8 | bits = 512 9 | 10 | ldns.ldns_init_random(open("/dev/random","rb"), (bits+7)//8) 11 | 12 | domain = ldns.ldns_dname("example.") 13 | 14 | #generate a new key 15 | key = ldns.ldns_key.new_frm_algorithm(algorithm, bits); 16 | print(key) 17 | 18 | #set owner 19 | key.set_pubkey_owner(domain) 20 | 21 | #create the public from the ldns_key 22 | pubkey = key.key_to_rr() 23 | #previous command is equivalent to 24 | # pubkey = ldns.ldns_key2rr(key) 25 | print(pubkey) 26 | 27 | #calculate and set the keytag 28 | key.set_keytag(ldns.ldns_calc_keytag(pubkey)) 29 | 30 | #build the DS record 31 | ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1) 32 | print(ds) 33 | 34 | owner, tag = pubkey.owner(), key.keytag() 35 | 36 | #write public key to .key file 37 | fw = open("key-%s-%d.key" % (owner,tag), "wb") 38 | pubkey.print_to_file(fw) 39 | 40 | #write private key to .priv file 41 | fw = open("key-%s-%d.private" % (owner,tag), "wb") 42 | key.print_to_file(fw) 43 | 44 | #write DS to .ds file 45 | fw = open("key-%s-%d.ds" % (owner,tag), "wb") 46 | ds.print_to_file(fw) 47 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-mx.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # MX is a small program that prints out the mx records for a particular domain 4 | # 5 | import ldns 6 | 7 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 8 | 9 | pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) 10 | 11 | if (pkt): 12 | mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) 13 | if (mx): 14 | mx.sort() 15 | print(mx) 16 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-mx1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # MX is a small program that prints out the mx records for a particular domain 4 | # 5 | import ldns 6 | 7 | dname = ldns.ldns_dname("nic.cz") 8 | print(dname) 9 | 10 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 11 | 12 | pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) 13 | 14 | if (pkt): 15 | mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) 16 | if (mx): 17 | mx.sort() 18 | print(mx) 19 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-mx2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # MX is a small program that prints out the mx records for a particular domain 4 | # 5 | import ldns 6 | 7 | resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") 8 | 9 | pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) 10 | if (pkt) and (pkt.answer()): 11 | 12 | for rr in pkt.answer().rrs(): 13 | if (rr.get_type() != ldns.LDNS_RR_TYPE_MX): 14 | continue 15 | 16 | rdf = rr.owner() 17 | print(rdf," ",rr.ttl()," ",rr.get_class_str()," ",rr.get_type_str()," ", end=" ") 18 | print(" ".join(str(rdf) for rdf in rr.rdfs())) 19 | 20 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-newpkt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import ldns 4 | 5 | pkt = ldns.ldns_pkt.new_query_frm_str("www.google.com",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) 6 | 7 | rra = ldns.ldns_rr.new_frm_str("www.google.com. IN A 192.168.1.1",300) 8 | rrb = ldns.ldns_rr.new_frm_str("www.google.com. IN TXT Some\ Description",300) 9 | 10 | list = ldns.ldns_rr_list() 11 | if (rra): list.push_rr(rra) 12 | if (rrb): list.push_rr(rrb) 13 | 14 | pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, list) 15 | 16 | print("Packet:") 17 | print(pkt) 18 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-signzone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # This example shows how to sign a given zone file with private key 3 | 4 | import ldns 5 | import sys, os, time 6 | 7 | #private key TAG which identifies the private key 8 | #use ldns-keygen.py in order to obtain private key 9 | keytag = 30761 10 | 11 | # Read zone file 12 | #------------------------------------------------------------- 13 | 14 | zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN) 15 | soa = zone.soa() 16 | origin = soa.owner() 17 | 18 | # Prepare keys 19 | #------------------------------------------------------------- 20 | 21 | #Read private key from file 22 | keyfile = open("key-%s-%d.private" % (origin, keytag), "r"); 23 | key = ldns.ldns_key.new_frm_fp(keyfile) 24 | 25 | #Read public key from file 26 | pubfname = "key-%s-%d.key" % (origin, keytag) 27 | pubkey = None 28 | if os.path.isfile(pubfname): 29 | pubkeyfile = open(pubfname, "r"); 30 | pubkey,_,_,_ = ldns.ldns_rr.new_frm_fp(pubkeyfile) 31 | 32 | if not pubkey: 33 | #Create new public key 34 | pubkey = key.key_to_rr() 35 | 36 | #Set key expiration 37 | key.set_expiration(int(time.time()) + 365*60*60*24) #365 days 38 | 39 | #Set key owner (important step) 40 | key.set_pubkey_owner(origin) 41 | 42 | #Insert DNSKEY RR 43 | zone.push_rr(pubkey) 44 | 45 | # Sign zone 46 | #------------------------------------------------------------- 47 | 48 | #Create keylist and push private key 49 | keys = ldns.ldns_key_list() 50 | keys.push_key(key) 51 | 52 | #Add SOA 53 | signed_zone = ldns.ldns_dnssec_zone() 54 | signed_zone.add_rr(soa) 55 | 56 | #Add RRs 57 | for rr in zone.rrs().rrs(): 58 | print("RR:", str(rr), end=" ") 59 | signed_zone.add_rr(rr) 60 | 61 | added_rrs = ldns.ldns_rr_list() 62 | status = signed_zone.sign(added_rrs, keys) 63 | if (status == ldns.LDNS_STATUS_OK): 64 | signed_zone.print_to_file(open("zone_signed.txt","w")) 65 | 66 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns-zone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import ldns 3 | 4 | #Read zone from file 5 | zone = ldns.ldns_zone.new_frm_fp(open("../zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN) 6 | print(zone) 7 | 8 | print("SOA:", zone.soa()) 9 | for r in zone.rrs().rrs(): 10 | print("RR:", r) 11 | 12 | 13 | zone = ldns.ldns_zone() 14 | #print zone 15 | 16 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns_rr_iter_frm_fp_l.demo.py: -------------------------------------------------------------------------------- 1 | import ldns 2 | import sys 3 | 4 | if len(sys.argv) <= 1: 5 | print("Usage: %s zone_file" % sys.argv[0]) 6 | sys.exit() 7 | 8 | inp = open(sys.argv[1],"r"); 9 | for rr in ldns.ldns_rr_iter_frm_fp_l(inp): 10 | print(rr) 11 | 12 | inp.close() 13 | -------------------------------------------------------------------------------- /contrib/python/examples/python3/ldns_rr_new_frm_fp_l.demo.py: -------------------------------------------------------------------------------- 1 | import ldns 2 | import sys 3 | 4 | if len(sys.argv) <= 1: 5 | print("Usage: %s zone_file" % sys.argv[0]) 6 | sys.exit() 7 | 8 | inp = open(sys.argv[1],"r"); 9 | # variables that preserve the parsers state 10 | my_ttl = 3600; 11 | my_origin = None 12 | my_prev = None 13 | # additional state variables 14 | last_pos = 0 15 | line_nr = 0 16 | 17 | while True: 18 | ret = ldns.ldns_rr_new_frm_fp_l_(inp, my_ttl, my_origin, my_prev) 19 | s, rr, line_inc, new_ttl, new_origin, new_prev = ret # unpack the result 20 | line_nr += line_inc # increase number of parsed lines 21 | my_prev = new_prev # update ref to previous owner 22 | 23 | if s == ldns.LDNS_STATUS_SYNTAX_TTL: 24 | my_ttl = new_ttl # update default TTL 25 | print("$TTL:", my_ttl) 26 | elif s == ldns.LDNS_STATUS_SYNTAX_ORIGIN: 27 | my_origin = new_origin # update reference to origin 28 | print("$ORIGIN:", my_origin) 29 | elif s == ldns.LDNS_STATUS_SYNTAX_EMPTY: 30 | if last_pos == inp.tell(): 31 | break # no advance since last read - EOF 32 | last_pos = inp.tell() 33 | elif s != ldns.LDNS_STATUS_OK: 34 | print("! parse error in line", line_nr) 35 | else: 36 | # we are sure to have LDNS_STATUS_OK 37 | print(rr) 38 | 39 | inp.close() 40 | print("--------------------") 41 | print("Read %d lines" % line_nr) 42 | 43 | 44 | -------------------------------------------------------------------------------- /contrib/python/examples/zone.txt: -------------------------------------------------------------------------------- 1 | $ORIGIN example. 2 | $TTL 600 3 | 4 | example. IN SOA example. admin.example. ( 5 | 2008022501 ; serial 6 | 28800 ; refresh (8 hours) 7 | 7200 ; retry (2 hours) 8 | 604800 ; expire (1 week) 9 | 18000 ; minimum (5 hours) 10 | ) 11 | 12 | @ IN MX 10 mail.example. 13 | @ IN NS ns1 14 | @ IN NS ns2 15 | @ IN A 192.168.1.1 16 | -------------------------------------------------------------------------------- /doc/TODO: -------------------------------------------------------------------------------- 1 | TODO 2 | 3 | Features: 4 | * Drill: print appropriate DS RRs (relates to Bug #355) 5 | * ldns-signzone optout to be really optout 6 | * Compression when generating wireformat. Preferably with a configurable 7 | policy: refer only backwards, case sensitivity, only refer to other owner 8 | names, etc. 9 | 10 | Bugfixes: 11 | * Bug #279: fix return values for net.h functions, and related: make return 12 | values for functions that cannot return memory-failure today. Needs medium 13 | version increase because of API change. 14 | * Lazy ABI 15 | -------------------------------------------------------------------------------- /doc/images/LogoInGradientBar2-y100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NLnetLabs/ldns/ae1243a7ba8630a60df5e6f128c49fdaaa7e6306/doc/images/LogoInGradientBar2-y100.png -------------------------------------------------------------------------------- /doc/images/libdnsoverview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NLnetLabs/ldns/ae1243a7ba8630a60df5e6f128c49fdaaa7e6306/doc/images/libdnsoverview.png -------------------------------------------------------------------------------- /drill/README: -------------------------------------------------------------------------------- 1 | QUICK INSTALL GUIDE 2 | 3 | drill is a subdirectory in ldns. 4 | 5 | To compile drill you need: 6 | autoreconf && ./configure && make 7 | 8 | If ldns is installed in a different location, use --with-ldns=directory 9 | See also ./configure --help 10 | 11 | In the first case you must run drill as: 12 | LD_LIBRARY_PATH=../.libs ./drill 13 | -------------------------------------------------------------------------------- /drill/REGRESSIONS: -------------------------------------------------------------------------------- 1 | REGRESSIONS 2 | 3 | This version of drill is based on ldns and as such some things 4 | are slightly changed. This file documents the changes. 5 | 6 | o When tracing (-T option) we use the local resolver (as specified 7 | in /etc/resolv.conf) to lookup names. This increases the speed 8 | dramatically, but you obviously need to be able to reach a recursive 9 | server/cache. 10 | Previously drill would try to resolve the names by itself. 11 | 12 | o Printing of DSs after DNSKEY records. Because we don't parse our 13 | own packets anymore, we cannot print the DS directly after the DNSKEY 14 | record. The DSs are now printed AFTER the packet. 15 | 16 | o The long options are removed. 17 | 18 | o The chase function has a different output, and will be subject to change 19 | in the near future. 20 | 21 | o The useless (for jokes only) -I option was dropped. 22 | 23 | FIXED: 24 | o the argument parsing is much smarter, the order doesn't matter (much) 25 | anymore 26 | -------------------------------------------------------------------------------- /drill/drill_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * util.h 3 | * util.c header file 4 | * in ldns 5 | * (c) 2005 NLnet Labs 6 | * 7 | * See the file LICENSE for the license 8 | * 9 | */ 10 | 11 | #ifndef _DRILL_UTIL_H_ 12 | #define _DRILL_UTIL_H_ 13 | #include 14 | 15 | 16 | /** 17 | * Read keys from filename and append to key_list. 18 | */ 19 | ldns_status read_key_file(const char *filename, ldns_rr_list *key_list, 20 | bool silently); 21 | 22 | /** 23 | * return a address rdf, either A or AAAA 24 | * NULL if anything goes wrong 25 | */ 26 | ldns_rdf * ldns_rdf_new_addr_frm_str(char *); 27 | 28 | /** 29 | * print all the ds of the keys in the packet 30 | */ 31 | void print_ds_of_keys(ldns_pkt *p); 32 | 33 | /** 34 | * print some rdfs of a signature 35 | */ 36 | void print_rrsig_abbr(FILE *fp, ldns_rr *sig); 37 | /** 38 | * print some rdfs of a dnskey 39 | */ 40 | void print_dnskey_abbr(FILE *fp, ldns_rr *key); 41 | /** 42 | * print some rdfs of a ds 43 | */ 44 | void print_ds_abbr(FILE *fp, ldns_rr *ds); 45 | 46 | /** 47 | * print some rdfs of a rr in a rr_list 48 | */ 49 | void print_rr_list_abbr(FILE *fp, ldns_rr_list *sig, const char *usr); 50 | 51 | /** 52 | * Alloc some memory, with error checking 53 | */ 54 | void *xmalloc(size_t s); 55 | 56 | /** 57 | * Realloc some memory, with error checking 58 | */ 59 | void *xrealloc(void *p, size_t s); 60 | 61 | /** 62 | * Free the data 63 | */ 64 | void xfree(void *q); 65 | #endif /* _DRILL_UTIL_H_ */ 66 | -------------------------------------------------------------------------------- /drill/error.c: -------------------------------------------------------------------------------- 1 | /** 2 | * error.c 3 | * 4 | * error reporting routines 5 | * basically wrappers around printf 6 | * 7 | * (c) 2005 NLnet Labs 8 | * 9 | * See the file LICENSE for the license 10 | * 11 | */ 12 | 13 | #include "drill.h" 14 | #include 15 | 16 | static void 17 | warning_va_list(const char *fmt, va_list args) 18 | { 19 | fprintf(stderr, "Warning: "); 20 | vfprintf(stderr, fmt, args); 21 | fprintf(stderr, "\n"); 22 | } 23 | 24 | void 25 | warning(const char *fmt, ...) 26 | { 27 | va_list args; 28 | va_start(args, fmt); 29 | warning_va_list(fmt, args); 30 | va_end(args); 31 | } 32 | 33 | static void 34 | error_va_list(const char *fmt, va_list args) 35 | { 36 | fprintf(stderr, "Error: "); 37 | vfprintf(stderr, fmt, args); 38 | fprintf(stderr, "\n"); 39 | } 40 | 41 | void 42 | error(const char *fmt, ...) 43 | { 44 | va_list args; 45 | va_start(args, fmt); 46 | error_va_list(fmt, args); 47 | va_end(args); 48 | exit(EXIT_FAILURE); 49 | } 50 | 51 | static void 52 | verbose_va_list(const char *fmt, va_list args) 53 | { 54 | vfprintf(stdout, fmt, args); 55 | fprintf(stdout, "\n"); 56 | } 57 | 58 | /* print stuff */ 59 | void 60 | mesg(const char *fmt, ...) 61 | { 62 | va_list args; 63 | if (verbosity == -1) { 64 | return; 65 | } 66 | fprintf(stdout, ";; "); 67 | va_start(args, fmt); 68 | verbose_va_list(fmt, args); 69 | va_end(args); 70 | } 71 | 72 | #if 0 73 | /* print stuff when in verbose mode (1) */ 74 | void 75 | verbose(const char *fmt, ...) 76 | { 77 | va_list args; 78 | if (verbosity < 1) { 79 | return; 80 | } 81 | 82 | va_start(args, fmt); 83 | verbose_va_list(fmt, args); 84 | va_end(args); 85 | } 86 | #endif 87 | -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | These tools are examples of ldns usage. They are not meant for production 2 | systems and will not be supported as such. 3 | 4 | Compilation: 5 | autoreconf && ./configure && make 6 | -------------------------------------------------------------------------------- /examples/ldns-chaos.1: -------------------------------------------------------------------------------- 1 | .TH ldns-chaos 1 "27 Apr 2005" 2 | .SH NAME 3 | ldns-chaos \- give some information about a nameserver 4 | .SH SYNOPSIS 5 | .B ldns-chaos 6 | .IR NAMESERVER 7 | 8 | .SH DESCRIPTION 9 | \fBldns-chaos\fR retrieves all the addresses of the nameserver and then queries 10 | each address for its \fIversion.bind\fR and \fIhostname.bind\fR. 11 | .PP 12 | \fBldns-chaos\fR is a bit more complex than \fBldns-mx\fR. 13 | 14 | .SH OPTIONS 15 | \fBldns-chaos\fR has no options. 16 | 17 | .SH AUTHOR 18 | Written by the ldns team as an example for ldns usage. 19 | 20 | .SH REPORTING BUGS 21 | Report bugs to . 22 | 23 | .SH COPYRIGHT 24 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 25 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 26 | PURPOSE. 27 | -------------------------------------------------------------------------------- /examples/ldns-dpa.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #if STDC_HEADERS 7 | #include 8 | #include 9 | #endif 10 | 11 | #ifdef HAVE_STDINT_H 12 | #include 13 | #endif 14 | 15 | #ifdef HAVE_SYS_SOCKET_H 16 | #include 17 | #endif 18 | 19 | #ifdef HAVE_NETINET_IN_H 20 | #include 21 | #endif 22 | 23 | #ifdef HAVE_ARPA_INET_H 24 | #include 25 | #endif 26 | 27 | #ifdef HAVE_NETINET_UDP_H 28 | #include 29 | #endif 30 | 31 | #ifdef HAVE_TIME_H 32 | #include 33 | #endif 34 | 35 | #ifdef HAVE_PCAP_H 36 | #include 37 | #endif 38 | 39 | #ifdef HAVE_NETINET_IN_SYSTM_H 40 | #include 41 | #endif 42 | 43 | #ifdef HAVE_NETINET_IP_H 44 | #include 45 | #endif 46 | 47 | #ifdef HAVE_NET_IF_H 48 | #include 49 | #endif 50 | 51 | #ifdef HAVE_NETINET_IF_ETHER_H 52 | #include 53 | #endif 54 | 55 | #ifdef HAVE_WINSOCK2_H 56 | #define USE_WINSOCK 1 57 | #include 58 | #endif 59 | 60 | #ifdef HAVE_WS2TCPIP_H 61 | #include 62 | #endif 63 | 64 | #ifndef HAVE_GETADDRINFO 65 | #include 66 | #endif 67 | 68 | #ifndef HAVE_RANDOM 69 | /* random can be replaced by rand for ldnsexamples */ 70 | #define random rand 71 | #endif 72 | 73 | #ifndef HAVE_SRANDOM 74 | /* srandom can be replaced by srand for ldnsexamples */ 75 | #define srandom srand 76 | #endif 77 | 78 | extern char *optarg; 79 | extern int optind, opterr; 80 | 81 | #ifndef EXIT_FAILURE 82 | #define EXIT_FAILURE 1 83 | #endif 84 | #ifndef EXIT_SUCCESS 85 | #define EXIT_SUCCESS 0 86 | #endif 87 | 88 | #ifdef S_SPLINT_S 89 | #define FD_ZERO(a) /* a */ 90 | #define FD_SET(a,b) /* a, b */ 91 | #endif 92 | 93 | -------------------------------------------------------------------------------- /examples/ldns-key2ds.1: -------------------------------------------------------------------------------- 1 | .TH ldns-key2ds 1 "30 May 2005" 2 | .SH NAME 3 | ldns-key2ds \- transform a DNSKEY RR to a DS RR 4 | .SH SYNOPSIS 5 | .B ldns-key2ds 6 | .IR file 7 | 8 | .SH DESCRIPTION 9 | \fBldns-key2ds\fR is used to transform a public DNSKEY RR to a DS RR. 10 | When run it will read \fIfile\fR with a DNSKEY RR in it and 11 | it will create a .ds file with the DS RR in it. 12 | 13 | It prints out the basename for this file (K++). 14 | 15 | By default it takes a pick of algorithm similar to the key algorithm, 16 | SHA1 for RSASHA1, and so on. 17 | 18 | .SH OPTIONS 19 | .TP 20 | \fB-f\fR 21 | Ignore SEP flag (i.e. make DS records for any key) 22 | 23 | .TP 24 | \fB-n\fR 25 | Write the result DS Resource Record to stdout instead of a file 26 | 27 | .TP 28 | \fB-1\fR 29 | Use SHA1 as the hash function. 30 | 31 | .TP 32 | \fB-2\fR 33 | Use SHA256 as the hash function 34 | 35 | .TP 36 | \fB-g\fR 37 | Use GOST as the hash function 38 | 39 | .TP 40 | \fB-4\fR 41 | Use SHA384 as the hash function 42 | 43 | .SH AUTHOR 44 | Written by the ldns team as an example for ldns usage. 45 | 46 | .SH REPORTING BUGS 47 | Report bugs to . 48 | 49 | .SH COPYRIGHT 50 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 51 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 52 | PURPOSE. 53 | -------------------------------------------------------------------------------- /examples/ldns-keyfetcher.1: -------------------------------------------------------------------------------- 1 | .TH ldns-keyfetcher 1 "4 Apr 2006" 2 | .SH NAME 3 | ldns-keyfetcher \- retrieve the DNSSEC DNSKEYs for a zone 4 | .SH SYNOPSIS 5 | .B ldns-keyfetcher 6 | [ 7 | .IR OPTIONS 8 | ] 9 | .IR DOMAIN 10 | 11 | .SH DESCRIPTION 12 | \fBldns-keyfetcher\fR is used to retrieve the DNSKEYs of a zone. 13 | 14 | First it finds all authoritative nameservers of the zone by tracing it from 15 | the root down. All authoritative nameservers are then queried (using TCP) 16 | for the DNSKEY RRset of the zone apex. If the results are all the same, 17 | the key resource record set is printed. 18 | 19 | 20 | .SH OPTIONS 21 | \fB-4\fR \fI\fR 22 | Only use IPv4 23 | 24 | \fB-6\fR \fI\fR 25 | Only use IPv6 26 | 27 | \fB-h\fR \fI\fR 28 | Show a help text and exit 29 | 30 | \fB-i\fR 31 | Insecurer mode; there will only be one query for the DNSKEYS. There will not 32 | be crosschecking of all authoritative nameservers. 33 | 34 | \fB-v\fR \fIverbosity\fR 35 | 36 | Set the verbosity level. The following levels are available: 37 | 38 | 0: default, only print the DNSKEY RRset found, or an error on failure. 39 | 1: Show the nameservers that are queried 40 | 2: Show more info on what is checked 41 | 3: Show the intermediate results (authority and dnskey rrsets) 42 | 4: Print the answer packets that are returned 43 | 44 | \fB-r\fR \fIfile\fR 45 | 46 | Use file as the root hints file, should contain A records in presentation 47 | format. The default is /etc/named.root. You can get this file from 48 | http://www.internic.net/zones/named.root. 49 | 50 | \fB-s\fR \fI\fR 51 | Don't print the keys to stdout, but store them in files. 52 | 53 | The filenames will be of the format K.+.+.key 54 | 55 | .SH AUTHOR 56 | Written by Jelte Jansen for NLnet Labs. 57 | 58 | .SH REPORTING BUGS 59 | Report bugs to . 60 | 61 | .SH COPYRIGHT 62 | Copyright (C) 2006 NLnet Labs. This is free software. There is NO 63 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 64 | PURPOSE. 65 | -------------------------------------------------------------------------------- /examples/ldns-mx.1: -------------------------------------------------------------------------------- 1 | .TH ldns-mx 1 "27 Apr 2005" 2 | .SH NAME 3 | ldns-mx \- print out the mx record(s) for a domain 4 | .SH SYNOPSIS 5 | .B ldns-mx 6 | .IR DOMAIN 7 | 8 | .SH DESCRIPTION 9 | \fBldns-mx\fR is used to print out mx information of a domain. 10 | 11 | .SH OPTIONS 12 | \fBldns-mx\fR has no options. 13 | 14 | .SH AUTHOR 15 | Written by the ldns team as an example for ldns usage. 16 | 17 | .SH REPORTING BUGS 18 | Report bugs to . 19 | 20 | .SH COPYRIGHT 21 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 22 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 23 | PURPOSE. 24 | -------------------------------------------------------------------------------- /examples/ldns-notify.1: -------------------------------------------------------------------------------- 1 | .TH ldns-notify 1 "9 Jan 2007" 2 | .SH NAME 3 | ldns-notify \- notify DNS servers that updates are available 4 | .SH SYNOPSIS 5 | .B ldns-notify 6 | [options] 7 | \-z zone 8 | .IR servers 9 | 10 | .SH DESCRIPTION 11 | 12 | \fBldns-notify\fR sends a NOTIFY message to DNS servers. This tells them 13 | that an updated zone is available at the master servers. It can perform 14 | TSIG signatures and it can add a SOA serial number of the updated zone. 15 | If a server already has that serial number it will disregard the message. 16 | 17 | .SH OPTIONS 18 | .TP 19 | \fB-z zone\fR 20 | The zone that is updated. 21 | 22 | .TP 23 | \fB-I address\fR 24 | Source IP to send query from. 25 | 26 | .TP 27 | \fB-h\fR 28 | Show usage and exit 29 | 30 | .TP 31 | \fB-v\fR 32 | Show the version and exit 33 | 34 | .TP 35 | \fB-s serial\fR 36 | Append a SOA record indicating the serial number of the updated zone. 37 | 38 | .TP 39 | \fB-p port\fR 40 | Use port as destination port (default the DNS port 53) for the UDP packets. 41 | 42 | .TP 43 | \fB-y key:data[:algo] \fR 44 | Use the given TSIG key and base64-data, and optionally an algorithm to sign 45 | the NOTIFY. The algorithm defaults to hmac-md5.sig-alg.reg.int. 46 | 47 | .TP 48 | \fB-d\fR 49 | Print verbose debug information. The query that is sent and the query 50 | that is received. 51 | 52 | .TP 53 | \fB-r num\fR 54 | Specify the maximum number of retries before notify gives up trying to 55 | send the UDP packet. 56 | 57 | .SH EXIT CODE 58 | The program exits with a 0 exit code if all servers replied an 59 | acknowledgement to the notify message, and a failure exit code otherwise. 60 | 61 | .SH AUTHOR 62 | Written by the ldns team as an example for ldns usage. 63 | 64 | .SH REPORTING BUGS 65 | Report bugs to . 66 | 67 | .SH COPYRIGHT 68 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 69 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 70 | PURPOSE. 71 | -------------------------------------------------------------------------------- /examples/ldns-nsec3-hash.1: -------------------------------------------------------------------------------- 1 | .TH ldns-nsec3-hash.c 1 "10 Dec 2008" 2 | .SH NAME 3 | ldns-nsec3-hash \- print out the NSEC3 hash for a domain name 4 | .SH SYNOPSIS 5 | .B ldns-nsec3-hash 6 | .IR 7 | 8 | .SH DESCRIPTION 9 | \fBldns-nsec3-hash\fR is used to print out the NSEC3 hash for the given domain name. 10 | 11 | .SH OPTIONS 12 | .TP 13 | \fB-a\fR \fInumber\fR 14 | Use the given algorithm number for the hash calculation. Defaults to 1 (SHA-1). 15 | 16 | .TP 17 | \fB-s\fR \fIsalt\fR 18 | Use the given salt for the hash calculation. Salt value should be in hexadecimal format. 19 | 20 | .TP 21 | \fB-t\fR \fIcount\fR 22 | Use count iterations for the hash calculation. 23 | 24 | 25 | .SH AUTHOR 26 | Written by the ldns team as an example for ldns usage. 27 | 28 | .SH REPORTING BUGS 29 | Report bugs to . 30 | 31 | .SH COPYRIGHT 32 | Copyright (C) 2008 NLnet Labs. This is free software. There is NO 33 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 34 | PURPOSE. 35 | -------------------------------------------------------------------------------- /examples/ldns-resolver.1: -------------------------------------------------------------------------------- 1 | .TH ldns-resolver 1 "27 Apr 2005" 2 | .SH NAME 3 | ldns-resolver \- tries to create a resolver from a resolv.conf file. 4 | .SH SYNOPSIS 5 | .B ldns-resolver 6 | .IR file 7 | 8 | .SH DESCRIPTION 9 | \fBldns-resolver\fR tries to create a resolver from a resolv.conf file. 10 | This is only useful to test the library for robustness with input data. 11 | 12 | .SH OPTIONS 13 | \fBldns-resolver\fR takes a filename of the resolv.conf file as input. 14 | For example \fIldns-resolver /etc/resolv.conf\fR will show if the file can 15 | be parsed successfully. 16 | 17 | .SH AUTHOR 18 | Written by the ldns team as an example for ldns usage. 19 | 20 | .SH REPORTING BUGS 21 | Report bugs to . 22 | 23 | .SH COPYRIGHT 24 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 25 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 26 | PURPOSE. 27 | -------------------------------------------------------------------------------- /examples/ldns-resolver.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ldns-resolver tries to create a resolver structure from /dev/urandom 3 | * this is only useful to test the library for robustness with input data 4 | * 5 | * (c) NLnet Labs 2006 - 2008 6 | * See the file LICENSE for the license 7 | */ 8 | 9 | #include "config.h" 10 | #include "errno.h" 11 | 12 | #include 13 | 14 | int 15 | main(int argc, char **argv) { 16 | 17 | ldns_resolver *r; 18 | int line = 1; 19 | FILE *rand; 20 | ldns_status s; 21 | 22 | if (argc != 2 || strncmp(argv[1], "-h", 3) == 0) { 23 | printf("Usage: ldns-resolver \n"); 24 | printf("Tries to create a stub resolver structure from the given file.\n"); 25 | exit(EXIT_FAILURE); 26 | } 27 | 28 | if (!(rand = fopen(argv[1], "r"))) { 29 | printf("Error opening %s: %s\n", argv[1], strerror(errno)); 30 | exit(EXIT_FAILURE); 31 | } 32 | 33 | printf("Trying to read from %s\n", argv[1]); 34 | s = ldns_resolver_new_frm_fp_l(&r, rand, &line); 35 | if (s != LDNS_STATUS_OK) { 36 | printf("Failed: %s at line %d\n", ldns_get_errorstr_by_id(s), line); 37 | exit(EXIT_FAILURE); 38 | } else { 39 | printf("Success\n"); 40 | ldns_resolver_print(stdout, r); 41 | ldns_resolver_deep_free(r); 42 | } 43 | 44 | fclose(rand); 45 | 46 | return EXIT_SUCCESS; 47 | } 48 | -------------------------------------------------------------------------------- /examples/ldns-revoke.1: -------------------------------------------------------------------------------- 1 | .TH ldns-revoke 1 "23 Jul 2008" 2 | .SH NAME 3 | ldns-revoke \- sets the revoke bit of a DNSKEY 4 | .SH SYNOPSIS 5 | .B ldns-revoke 6 | .IR file 7 | 8 | .SH DESCRIPTION 9 | \fBldns-revoke\fR is used to revoke a public DNSKEY RR. 10 | When run it will read \fIfile\fR with a DNSKEY RR in it, 11 | sets the revoke bit and write back the output to \fIfile\fR . 12 | 13 | .SH OPTIONS 14 | .TP 15 | \fB-n\fR 16 | Write the result to stdout instead of a file 17 | 18 | .SH AUTHOR 19 | Written by the ldns team as an example for ldns usage. 20 | 21 | .SH REPORTING BUGS 22 | Report bugs to . 23 | 24 | .SH COPYRIGHT 25 | Copyright (C) 2008 NLnet Labs. This is free software. There is NO 26 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 27 | PURPOSE. 28 | -------------------------------------------------------------------------------- /examples/ldns-rrsig.1: -------------------------------------------------------------------------------- 1 | .TH ldns-rrsig 1 "27 Apr 2005" 2 | .SH NAME 3 | ldns-rrsig \- print out the inception and expiration dates in human 4 | readable form 5 | .SH SYNOPSIS 6 | .B ldns-rrsig 7 | .IR domain 8 | [ 9 | .IR type 10 | ] 11 | 12 | .SH DESCRIPTION 13 | \fBldns-rrsig\fR is used to print the expiration and inception date of 14 | a RRSIG. The first argument is a domain name. \fBldns-rrsig\fR will 15 | query the authoritative servers for that domain to get a list of RRSIGs. 16 | It will then print out the inception and expiration dates for the RRSIG 17 | covering the SOA record. 18 | .PP 19 | If the second argument \fBtype\fR is given the RRSIG covering that type will be shown. 20 | 21 | .SH AUTHOR 22 | Written by the ldns team as an example for ldns usage. 23 | 24 | .SH REPORTING BUGS 25 | Report bugs to . 26 | 27 | .SH COPYRIGHT 28 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 29 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 30 | PURPOSE. 31 | -------------------------------------------------------------------------------- /examples/ldns-test-edns.1: -------------------------------------------------------------------------------- 1 | .TH ldns-test-edns 1 "14 Dec 2010" 2 | .SH NAME 3 | ldns-test-edns \- test if dns cache supports EDNS and DNSSEC. 4 | .SH SYNOPSIS 5 | .B ldns-test-edns 6 | [ 7 | .IR -i 8 | ] 9 | { 10 | .IR ip 11 | } 12 | .SH DESCRIPTION 13 | \fBldns-test-edns\fR tests a DNS cache and checks if it supports EDNS0 and 14 | DNSSEC types so that it can be used as a dnssec-enabled DNS cache. It sends 15 | two queries to the cache, one for the root key and one for a DS record. 16 | These must succeed, the answer must have EDNS, that type and signatures. 17 | .PP 18 | If the IP address is good for DNSSEC, it is printed with 'OK'. Otherwise 19 | short description is given of the failure. 20 | If OK is given, the cache should be good to use as a cache for a local 21 | configured DNSSEC validator. 22 | .PP 23 | The tool assumes the root is signed and Sweden is signed. 24 | Also, the queries are sent with the CD flag, the tool does not check that the 25 | results are validated, but that they \fBcan\fR be validated. 26 | .SH OPTIONS 27 | \fB-i\fR option enables a mode where the working IP addresses are printed 28 | after another, with no other explanations, and if none work or no IP addresses 29 | are on the input, 'off' is printed. 30 | .PP 31 | \fBldns-test-edns\fR takes one or more IP addresses, it checks them in turn. 32 | IPv4 and IPv6 addresses can be given. The exit value is for the last checked 33 | IP address: 0 is OK, 1 is failure, 2 is some sort of network failure. 34 | .SH AUTHOR 35 | Written by the ldns team as an example for ldns usage. 36 | .SH REPORTING BUGS 37 | Report bugs to . 38 | .SH COPYRIGHT 39 | Copyright (C) 2010 NLnet Labs. This is free software. There is NO 40 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 41 | PURPOSE. 42 | -------------------------------------------------------------------------------- /examples/ldns-update.1: -------------------------------------------------------------------------------- 1 | .TH ldns-update 1 "30 May 2005" 2 | .SH NAME 3 | ldns-update \- send a dynamic update packet 4 | .SH SYNOPSIS 5 | .B ldns-update 6 | .IR name 7 | [ 8 | .IR zone 9 | ] 10 | [ 11 | .IR ip 12 | ] 13 | [ 14 | .IR tsig_name 15 | .IR tsig_alg 16 | .IR tsig_hmac 17 | ] 18 | 19 | .SH DESCRIPTION 20 | \fBldns-update\fR is used to send a dynamic update packet. 21 | 22 | .SH OPTIONS 23 | .TP 24 | \fBname\fR 25 | The domainname to associate with the given \fBip\fR address. 26 | 27 | .TP 28 | \fBzone\fR 29 | When given uses this \fBzone\fR instead of trying to find and process \fBdomain\fR's SOA record. 30 | 31 | .TP 32 | \fBip\fR 33 | Send the update to this IP address. 34 | Or, when the literal text \fBnone\fR is given, remove any previous addresses. 35 | 36 | .TP 37 | \fBtsig_name tsig_alg tsig_hmac\fR 38 | Use TSIG (rfc2845) to authenticate. 39 | 40 | .SH EXAMPLE 41 | ldns-update my.example.org 1.2.3.4 42 | 43 | .SH AUTHOR 44 | Written by Jakob Schlyter and Håkan Olsson, as an addition to the ldns library from NLnet Labs. 45 | 46 | .SH REPORTING BUGS 47 | Report bugs to . 48 | 49 | .SH COPYRIGHT 50 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 51 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 52 | PURPOSE. 53 | -------------------------------------------------------------------------------- /examples/ldns-version.1: -------------------------------------------------------------------------------- 1 | .TH ldns-version 1 "27 Apr 2005" 2 | .SH NAME 3 | ldns-version \- print out the version of the ldns-library and tools on this system 4 | .SH SYNOPSIS 5 | .B ldns-version 6 | 7 | .SH DESCRIPTION 8 | \fBldns-version\fR is used to print out version information of the ldns library and tools 9 | 10 | .SH OPTIONS 11 | \fBldns-version\fR has no options. 12 | 13 | .SH AUTHOR 14 | Written by the ldns team as an example for ldns usage. 15 | 16 | .SH REPORTING BUGS 17 | Report bugs to . 18 | 19 | .SH COPYRIGHT 20 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 21 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 22 | PURPOSE. 23 | -------------------------------------------------------------------------------- /examples/ldns-version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ldns-version shows ldns's version 3 | * 4 | * (c) NLnet Labs, 2005 - 2008 5 | * See the file LICENSE for the license 6 | */ 7 | 8 | #include "config.h" 9 | #include 10 | 11 | int 12 | main(void) 13 | { 14 | printf("%s\n", ldns_version()); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /examples/ldns-walk.1: -------------------------------------------------------------------------------- 1 | .TH ldns-walk 1 "21 Nov 2005" 2 | .SH NAME 3 | ldns-walk \- Retrieve the contents of a DNSSEC signed zone 4 | .SH SYNOPSIS 5 | .B ldns-walk 6 | [ 7 | .IR OPTION 8 | ] 9 | .IR ZONE 10 | 11 | .SH DESCRIPTION 12 | 13 | \fBldns-walk\fR is used to retrieve the contents of a DNSSEC signed zone. 14 | It does this through NSEC-walking (following the chain of NSEC records) 15 | and 'guessing' the next non-existent owner name for each NSEC. 16 | 17 | Note that it might get stuck on some wildcard records when used through a 18 | caching forwarder. This problem can be circumvented by querying the 19 | authoritative nameserver directly (with the @ argument). 20 | 21 | Of course the nameserver that is used must be DNSSEC-aware. 22 | 23 | .SH OPTIONS 24 | .TP 25 | \fB-4\fR 26 | Use only IPv4. 27 | 28 | .TP 29 | \fB-6\fR 30 | Use only IPv6. 31 | 32 | .TP 33 | \fB-f\fR 34 | Do a 'full' zone walk; by default, ldns-walk will only show the names, and types present at those names. If this option is given, all resource records will be printed. 35 | 36 | .TP 37 | \fB-s\fR \fIname\fR 38 | Start the walk with this owner name. Useful when continuing the walk for a 39 | large zone. 40 | 41 | .TP 42 | \fB-v\fR \fIverbosity\fR 43 | Verbosity level [1-5]. 44 | 45 | .TP 46 | \fB@\fR \fInameserver\fR 47 | Send the queries to this nameserver. 48 | 49 | .SH BUGS 50 | The full zone walk function is not complete yet, it does not correctly print delegation records 51 | 52 | .SH AUTHOR 53 | Written by Jelte Jansen as an example for ldns usage. 54 | 55 | .SH REPORTING BUGS 56 | Report bugs to . 57 | 58 | .SH COPYRIGHT 59 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 60 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 61 | PURPOSE. 62 | -------------------------------------------------------------------------------- /examples/ldns-zcat.1: -------------------------------------------------------------------------------- 1 | .TH ldns-zcat 1 "15 Dec 2005" 2 | .SH NAME 3 | ldns-zcat \- reunite (z)split up a zone files 4 | .SH SYNOPSIS 5 | .B ldns-zcat 6 | .IR zonefiles 7 | 8 | .SH DESCRIPTION 9 | .B ldns-zcat 10 | will read in a bunch of (z)split up zonefiles and creates a new larger 11 | zone file. The SOA record in the first part is used as the SOA record 12 | in the generated zone. 13 | .PP 14 | The resulted zone file is printed to standard output. 15 | 16 | .SH OPTIONS 17 | .TP 18 | .B -o ORIGIN 19 | use ORIGIN when reading in the zone 20 | 21 | .TP 22 | .B -v 23 | show the version number and exit 24 | 25 | .SH AUTHOR 26 | Written by the ldns team as an example for ldns usage. 27 | 28 | .SH REPORTING BUGS 29 | Report bugs to . 30 | 31 | .SH COPYRIGHT 32 | Copyright (C) 2005, 2006 NLnet Labs. This is free software. There is NO 33 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 34 | PURPOSE. 35 | -------------------------------------------------------------------------------- /examples/ldns-zsplit.1: -------------------------------------------------------------------------------- 1 | .TH ldns-zsplit 1 "15 Dec 2005" 2 | .SH NAME 3 | ldns-zsplit \- split up a zone file 4 | .SH SYNOPSIS 5 | .B ldns-zsplit 6 | [ 7 | .IR OPTIONS 8 | ] 9 | .IR zonefile 10 | 11 | .SH DESCRIPTION 12 | 13 | .SH OPTIONS 14 | .TP 15 | .B -n NUMBER 16 | Split after NUMBER RRs, \fBldns-zsplit\fR will not split in 17 | the middle of an RRs. 18 | .PP 19 | Each part is saved with a numerical suffix, starting with .000. The 20 | largest suffix is thus .999. 21 | 22 | .TP 23 | .B -o ORIGIN 24 | use ORIGIN as origin when reading the zonefile. 25 | 26 | .TP 27 | .B -z 28 | Sort the zone before splitting. 29 | 30 | .TP 31 | .B -v 32 | Show version number and exit. 33 | 34 | .SH AUTHOR 35 | Written by the ldns team as an example for ldns usage. 36 | 37 | .SH REPORTING BUGS 38 | Report bugs to . 39 | 40 | .SH COPYRIGHT 41 | Copyright (C) 2005, 2006 NLnet Labs. This is free software. There is NO 42 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 43 | PURPOSE. 44 | -------------------------------------------------------------------------------- /examples/ldnsd.1: -------------------------------------------------------------------------------- 1 | .TH ldnsd 1 "27 Apr 2005" 2 | .SH NAME 3 | ldnsd \- simple daemon example code 4 | .SH SYNOPSIS 5 | .B ldnsd 6 | .IR port 7 | .IR zone 8 | .IR zonefile 9 | 10 | .SH DESCRIPTION 11 | \fBldnsd\fR is a simple daemon that answers queries for a zone. 12 | This is NOT a full-fledged authoritative nameserver! 13 | 14 | .SH OPTIONS 15 | \fBldnsd\fR takes a port, zone and zonefile as arguments. 16 | 17 | .SH AUTHOR 18 | Written by the ldns team as an example for ldns usage. 19 | 20 | .SH REPORTING BUGS 21 | Report bugs to . 22 | 23 | .SH COPYRIGHT 24 | Copyright (C) 2005 NLnet Labs. This is free software. There is NO 25 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 26 | PURPOSE. 27 | -------------------------------------------------------------------------------- /examples/nsd-test/Makefile.in: -------------------------------------------------------------------------------- 1 | # Standard installation pathnames 2 | # See the file LICENSE for the license 3 | SHELL = @SHELL@ 4 | VERSION = @PACKAGE_VERSION@ 5 | basesrcdir = $(shell basename `pwd`) 6 | srcdir = @srcdir@ 7 | prefix = @prefix@ 8 | exec_prefix = @exec_prefix@ 9 | bindir = @bindir@ 10 | mandir = @mandir@ 11 | 12 | CC = @CC@ 13 | CFLAGS = @CFLAGS@ -Wall -I. 14 | CPPFLAGS = @CPPFLAGS@ 15 | LDFLAGS = @LDFLAGS@ 16 | LIBS = @LIBS@ 17 | LDNSDIR = @LDNSDIR@ 18 | 19 | COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LIBS) 20 | 21 | LINT = splint 22 | LINTFLAGS = +quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned -Du_char=uint8_t -preproc 23 | 24 | HEADER = config.h 25 | SOURCES = ldns-testns.c nsd-ldnsd.c 26 | 27 | PROGRAMS=$(SOURCES:.c=) 28 | 29 | .PHONY: all clean realclean 30 | 31 | all: $(PROGRAMS) 32 | 33 | all-static: $(PROGRAMS:=-stc) 34 | 35 | %: $(srcdir)/%.c 36 | $(COMPILE) -o $@ $(srcdir)/$@.c 37 | 38 | %-stc: 39 | @# can't mix implicit and static rules 40 | @if [ $(srcdir)/$(@:-stc=).c -nt $(@:-stc=) ] ; then \ 41 | echo "$(CC) $(CPPFLAGS) $(CFLAGS) -lpcap -lcrypto -o $(@:-stc=) $(srcdir)/$(@:-stc=).c $(LDNSDIR)/lib/libldns.a" ; \ 42 | $(CC) $(CPPFLAGS) $(CFLAGS) -lpcap -lcrypto -o $(@:-stc=) $(srcdir)/$(@:-stc=).c $(LDNSDIR)/lib/libldns.a ; \ 43 | fi ; 44 | 45 | lint: 46 | for i in $(SOURCES); do \ 47 | $(LINT) $(LINTFLAGS) -I. -I$(srcdir) $(srcdir)/$$i $(CPPFLAGS); \ 48 | if [ $$? -ne 0 ] ; then exit 1 ; fi ; \ 49 | done 50 | 51 | clean: 52 | rm -f *.o 53 | rm -f $(PROGRAMS) 54 | 55 | realclean: clean 56 | rm -rf autom4te.cache/ 57 | rm -f config.log config.status aclocal.m4 config.h.in configure Makefile 58 | rm -f config.h 59 | 60 | confclean: clean 61 | rm -rf config.log config.status config.h Makefile 62 | -------------------------------------------------------------------------------- /ldns/.c-mode-rc.el: -------------------------------------------------------------------------------- 1 | ;;; Override Emacs c-mode settings. 2 | 3 | (c-set-style "bsd") 4 | (set-variable 'c-basic-offset 8) 5 | (set-variable 'indent-tabs-mode t) 6 | -------------------------------------------------------------------------------- /ldns/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef LDNS_SHA1_H 2 | #define LDNS_SHA1_H 3 | 4 | #include /* uint32_t and friends */ 5 | #include /* size_t and NULL */ 6 | 7 | #if LDNS_BUILD_CONFIG_HAVE_INTTYPES_H 8 | # include 9 | #endif 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define LDNS_SHA1_BLOCK_LENGTH 64 16 | #define LDNS_SHA1_DIGEST_LENGTH 20 17 | 18 | typedef struct { 19 | uint32_t state[5]; 20 | uint64_t count; 21 | unsigned char buffer[LDNS_SHA1_BLOCK_LENGTH]; 22 | } ldns_sha1_ctx; 23 | 24 | void ldns_sha1_init(ldns_sha1_ctx * context); 25 | void ldns_sha1_transform(uint32_t state[5], const unsigned char buffer[LDNS_SHA1_BLOCK_LENGTH]); 26 | void ldns_sha1_update(ldns_sha1_ctx *context, const unsigned char *data, unsigned int len); 27 | void ldns_sha1_final(unsigned char digest[LDNS_SHA1_DIGEST_LENGTH], ldns_sha1_ctx *context); 28 | 29 | /** 30 | * Convenience function to digest a fixed block of data at once. 31 | * 32 | * \param[in] data the data to digest 33 | * \param[in] data_len the length of data in bytes 34 | * \param[out] digest the length of data in bytes 35 | * This pointer MUST have LDNS_SHA1_DIGEST_LENGTH bytes 36 | * available 37 | * \return the SHA1 digest of the given data 38 | */ 39 | unsigned char *ldns_sha1(const unsigned char *data, unsigned int data_len, unsigned char *digest); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* LDNS_SHA1_H */ 46 | -------------------------------------------------------------------------------- /linktest.c: -------------------------------------------------------------------------------- 1 | 2 | #include "ldns/config.h" 3 | #include 4 | 5 | int 6 | main(void) 7 | { 8 | ldns_rr *rr = ldns_rr_new(); 9 | 10 | ldns_rr_free(rr); 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /lua/Makefile.in: -------------------------------------------------------------------------------- 1 | # Standard installation pathnames 2 | # See the file LICENSE for the license 3 | SHELL = @SHELL@ 4 | VERSION = @PACKAGE_VERSION@ 5 | basesrcdir = $(shell basename `pwd`) 6 | srcdir = @srcdir@ 7 | prefix = @prefix@ 8 | exec_prefix = @exec_prefix@ 9 | bindir = @bindir@ 10 | mandir = @mandir@ 11 | 12 | CC = @CC@ 13 | CFLAGS = @CFLAGS@ 14 | LDFLAGS = @LDFLAGS@ 15 | LIBS = @LIBS@ 16 | 17 | LINT = splint 18 | LINTFLAGS = +quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned -Du_char=uint8_t 19 | 20 | COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) 21 | LINK = $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) 22 | 23 | HEADER = config.h 24 | 25 | .PHONY: all clean realclean 26 | 27 | all: lua 28 | 29 | lua: lua-rns 30 | 31 | lua-rns: lua-rns.o 32 | $(LINK) `lua-config --libs` -o $@ $+ 33 | 34 | #lua-rns.o: lua-rns.c 35 | # $(COMPILE) `lua-config --include` -c $< 36 | 37 | ## implicit rule 38 | %.o: %.c $(HEADER) 39 | $(COMPILE) `lua-config --include` -c $< 40 | 41 | clean: 42 | rm -f *.o 43 | rm -f lua-rns 44 | 45 | realclean: clean 46 | rm -rf autom4te.cache/ 47 | rm -f config.log config.status aclocal.m4 config.h.in configure Makefile 48 | rm -f config.h 49 | 50 | lint: 51 | $(LINT) $(LINTFLAGS) -I$(srcdir)/.. lua-rns.c ; \ 52 | if [ $$? -ne 0 ] ; then exit 1 ; fi 53 | -------------------------------------------------------------------------------- /lua/README: -------------------------------------------------------------------------------- 1 | This (for now) an experimental playground. It is only tested on Linux. 2 | -------------------------------------------------------------------------------- /lua/echo.lua: -------------------------------------------------------------------------------- 1 | -- source the lib file with the function 2 | dofile("rns-lib.lua") 3 | 4 | -- echo whatever is received 5 | 6 | -- this function disfigures the packet 7 | function lua_packet_mangle(orig_packet) 8 | -- Dont do anything just mirror 9 | -- local rr1 = record.new_frm_str("www.miek.nl IN A 127.0.0.1") 10 | -- packet.push_rr(orig_packet, LDNS_SECTION_ANSWER, rr1) 11 | return(packet.to_buf(orig_packet)) 12 | end 13 | 14 | rdf_ip = rdf.new_frm_str(LDNS_RDF_TYPE_A, "127.0.0.1") 15 | socket = udp.server_open(rdf_ip, 5353) 16 | if socket == nil then 17 | os.exit(EXIT_FAILURE) 18 | end 19 | 20 | rdf_ip_nameserver = rdf.new_frm_str(LDNS_RDF_TYPE_A, "213.154.224.39") 21 | 22 | while true do 23 | -- read from the socket, this blocks... 24 | wirebuf, sockaddr_from = udp.read(socket) 25 | 26 | -- wrap this in new functions 27 | if wirebuf == nil then 28 | lua_debug("nothing received") 29 | else 30 | -- somebody is writing 31 | wirepkt = buffer.to_pkt(wirebuf) 32 | packet.print(wirepkt) 33 | 34 | wirebuf2 = packet.to_buf(wirepkt) 35 | 36 | -- send it to /our/ nameserver 37 | socket_nameserver = udp.open(rdf_ip_nameserver, 53) 38 | if socket_nameserver == nil then 39 | os.exit(EXIT_FAILURE) 40 | end 41 | 42 | nameserver_bytes = udp.write(socket_nameserver, wirebuf2, rdf_ip_nameserver, 53) 43 | if nameserver_bytes == nil then 44 | lua_debug("ns write error") 45 | end 46 | 47 | nameserver_buf, sockaddr_from_nameserver = udp.read(socket_nameserver) 48 | udp.close(socket_nameserver) 49 | 50 | nameserver_pkt = buffer.to_pkt(nameserver_buf) 51 | packet.print(nameserver_pkt) 52 | 53 | -- make a new buf and write that back to the client 54 | nsbuf2 = lua_packet_mangle(nameserver_pkt) 55 | bytes = lua_udp_write(socket, nsbuf2, sockaddr_from) --this works 56 | 57 | if bytes == nil then 58 | lua_debug("write error") 59 | end 60 | 61 | buffer.free(nsbuf2) 62 | buffer.free(nameserver_buf) 63 | buffer.free(wirebuf2) 64 | buffer.free(wirebuf) 65 | 66 | end 67 | end 68 | udp.close(socket) 69 | -------------------------------------------------------------------------------- /lua/rdf.lua: -------------------------------------------------------------------------------- 1 | -- test rdf stuff 2 | 3 | dofile("rns-lib.lua") 4 | 5 | rdf = l_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, "miek.nl") 6 | l_rdf_print(rdf) 7 | print() 8 | -------------------------------------------------------------------------------- /lua/rns.lua: -------------------------------------------------------------------------------- 1 | -- source the lib file with the function 2 | dofile("rns-lib.lua") 3 | 4 | -- echo whatever is received 5 | 6 | -- this function disfigures the packet 7 | function lua_packet_mangle(orig_packet) 8 | -- MANGLE IT 9 | local rr1 = record.new_frm_str("www.miek.nl IN A 127.0.0.1") 10 | packet.push_rr(orig_packet, LDNS_SECTION_ANSWER, rr1) 11 | return(packet.to_buf(orig_packet)) 12 | end 13 | 14 | rdf_ip = rdf.new_frm_str(LDNS_RDF_TYPE_A, "127.0.0.1") 15 | socket = udp.server_open(rdf_ip, 5353) 16 | if socket == nil then 17 | os.exit(EXIT_FAILURE) 18 | end 19 | 20 | rdf_ip_nameserver = rdf.new_frm_str(LDNS_RDF_TYPE_A, "213.154.224.39") 21 | 22 | while true do 23 | -- read from the socket, this blocks... 24 | wirebuf, sockaddr_from = udp.read(socket) 25 | 26 | -- wrap this in new functions 27 | if wirebuf == nil then 28 | lua_debug("nothing received") 29 | else 30 | -- somebody is writing 31 | wirepkt = buffer.to_pkt(wirebuf) 32 | packet.print(wirepkt) 33 | 34 | wirebuf2 = packet.to_buf(wirepkt) 35 | 36 | -- send it to /our/ nameserver 37 | socket_nameserver = udp.open(rdf_ip_nameserver, 53) 38 | if socket_nameserver == nil then 39 | os.exit(EXIT_FAILURE) 40 | end 41 | 42 | nameserver_bytes = udp.write(socket_nameserver, wirebuf2, rdf_ip_nameserver, 53) 43 | if nameserver_bytes == nil then 44 | lua_debug("ns write error") 45 | end 46 | 47 | nameserver_buf, sockaddr_from_nameserver = udp.read(socket_nameserver) 48 | udp.close(socket_nameserver) 49 | 50 | nameserver_pkt = buffer.to_pkt(nameserver_buf) 51 | packet.print(nameserver_pkt) 52 | 53 | -- make a new buf and write that back to the client 54 | nsbuf2 = lua_packet_mangle(nameserver_pkt) 55 | bytes = lua_udp_write(socket, nsbuf2, sockaddr_from) --this works 56 | 57 | if bytes == nil then 58 | lua_debug("write error") 59 | end 60 | 61 | buffer.free(nsbuf2) 62 | buffer.free(nameserver_buf) 63 | buffer.free(wirebuf2) 64 | buffer.free(wirebuf) 65 | 66 | end 67 | end 68 | udp.close(socket) 69 | -------------------------------------------------------------------------------- /lua/serv.lua: -------------------------------------------------------------------------------- 1 | -- source the lib file with the function 2 | dofile("rns-lib.lua") 3 | 4 | rr1 = record.new_frm_str("www.miek.nl IN A 192.168.1.2", 0, nil) 5 | rr2 = record.new_frm_str("miek.nl IN ns gaap", 0, nil) 6 | rr3 = record.new_frm_str("miek.nl IN ns gaap2", 0, nil) 7 | rr4 = record.new_frm_str("www.atoom.net. IN A 192.168.1.2", 0, nil) 8 | rr5 = record.new_frm_str("www.nlnetlabs.nl IN A 192.168.1.2", 0, nil) 9 | rr6 = record.new_frm_str("www.nlnet.nl IN A 192.168.1.2", 0, nil) 10 | 11 | pkt = packet.new() 12 | pkt = packet.push_rr(pkt, LDNS_SECTION_ANSWER, rr1) 13 | pkt = packet.push_rr(pkt, LDNS_SECTION_ANSWER, rr4) 14 | pkt = packet.push_rr(pkt, LDNS_SECTION_AUTHORITY, rr2) 15 | pkt = packet.push_rr(pkt, LDNS_SECTION_AUTHORITY, rr3) 16 | 17 | ---- Setup a server to listen to UDP -- bit strange to first 18 | -- make a rdf out of it and then continue with the sockaddr struct 19 | rdf_ip = rdf.new_frm_str(LDNS_RDF_TYPE_A, "127.0.0.1") 20 | socket = udp.server_open(rdf_ip, 5353) 21 | if socket == nil then 22 | os.exit(EXIT_FAILURE) 23 | end 24 | 25 | 26 | while true do 27 | -- read from the socket, this blocks... 28 | wirebuf, sockaddr_from = udp.read(socket) 29 | 30 | -- wrap this in new functions 31 | if wirebuf == nil then 32 | lua_debug("nothing received") 33 | else 34 | -- somebody is writing 35 | wirepkt = buffer.to_pkt(wirebuf) 36 | 37 | lua_debug("received from the interface") 38 | 39 | -- next we must send it to our recursive nameserver 40 | -- and pick up the result 41 | -- then we modify the result somewhat and sent it back 42 | -- to the client 43 | 44 | id = packet.id(wirepkt); 45 | packet.print(wirepkt) 46 | 47 | -- set the id on the outgoing packet 48 | packet.set_id(pkt, id) 49 | lua_packet_ancount_incr(pkt, 2) 50 | wirebuf2 = packet.to_buf(pkt) 51 | 52 | -- write back to the client 53 | bytes = lua_udp_write(socket, wirebuf2, sockaddr_from) 54 | if bytes == -1 then 55 | lua_debug("write error") 56 | else 57 | lua_debug("wrote bytes", bytes) 58 | packet.print(pkt) 59 | end 60 | 61 | end 62 | end 63 | udp.close(socket) 64 | -------------------------------------------------------------------------------- /lua/test.lua: -------------------------------------------------------------------------------- 1 | -- source the lib file with the function 2 | dofile("rns-lib.lua") 3 | 4 | -- Now the scary ldns_* stuff 5 | my_rr = record.new_frm_str("www.miek.nl IN A 192.168.1.2") 6 | my_rr2 = record.new_frm_str("www.miek.nl") 7 | my_rr4 = record.new_frm_str("www.atoom.net. IN A 192.168.1.2") 8 | 9 | record.print(my_rr) 10 | record.print(my_rr2) 11 | record.print(my_rr4) 12 | 13 | my_pkt = packet.new(); 14 | 15 | my_pkt = packet.push_rr(my_pkt, LDNS_SECTION_ANSWER, my_rr) 16 | 17 | packet.print(my_pkt) 18 | 19 | my_pkt = packet.push_rr(my_pkt, LDNS_SECTION_ANSWER, my_rr2) 20 | 21 | my_rr3 = packet.get_rr(my_pkt, 0); 22 | record.print(my_rr3) 23 | my_rr3 = packet.get_rr(my_pkt, 1); 24 | record.print(my_rr3) 25 | 26 | packet.print(my_pkt) 27 | my_rr5 = packet.set_rr(my_pkt, my_rr4, 1) 28 | record.print(my_rr5) 29 | 30 | packet.set_id(my_pkt, 1505) 31 | 32 | packet.print(my_pkt) 33 | -------------------------------------------------------------------------------- /lua/test2.lua: -------------------------------------------------------------------------------- 1 | -- source the lib file with the function 2 | dofile("rns-lib.lua") 3 | 4 | my_pkt = packet.new() 5 | 6 | my_rdf = rdf.new_frm_str(LDNS_RDF_TYPE_DNAME, "miek.nl") 7 | if my_rdf == nil then 8 | print("failure") 9 | end 10 | rdf.print(my_rdf) 11 | 12 | my_rr = record.new_frm_str("www.miek.nl in a 192.168.1.1") 13 | record.print(my_rr) 14 | 15 | my_pkt = packet.new() 16 | packet.push_rr(my_pkt, LDNS_SECTION_ANSWER, my_rr) 17 | packet.push_rr(my_pkt, LDNS_SECTION_ANSWER, my_rr) 18 | packet.push_rr(my_pkt, LDNS_SECTION_ANSWER, my_rr) 19 | 20 | lua_record_insert(my_pkt, my_rr, 2) 21 | 22 | packet.print(my_pkt) 23 | -------------------------------------------------------------------------------- /masterdont/Makefile: -------------------------------------------------------------------------------- 1 | LDNSDIR=.. 2 | CC=gcc 3 | CFLAGS=-g3 -W -Wall -Wextra -pedantic -I$(LDNSDIR) 4 | CFLAGS+=-D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ 5 | LFLAGS=-L$(LDNSDIR)/lib -lcrypto 6 | LIBS=-lldns 7 | STATIC=$(LDNSDIR)/lib/libldns.a -lcrypto 8 | 9 | OBJ=main.o zones.o zinfo.o server.o process.o config_file.o 10 | 11 | all: masterdont 12 | 13 | all-static: $(OBJ) 14 | $(CC) -o masterdont $(CFLAGS) $(OBJ) $(STATIC) 15 | 16 | masterdont: $(OBJ) 17 | $(CC) -o masterdont $(CFLAGS) $(OBJ) $(LFLAGS) $(LIBS) 18 | 19 | depend: 20 | $(CC) $(CFLAGS) -MM *.c > makefile.dep 21 | 22 | clean: 23 | rm -f $(OBJ) masterdont 24 | 25 | -include makefile.dep 26 | -------------------------------------------------------------------------------- /masterdont/README: -------------------------------------------------------------------------------- 1 | Masterdont README 2 | 3 | (C) NLnet Labs, 2008. 4 | 5 | License: BSD license 6 | 7 | -------------------------------------------------------------------------------- /masterdont/config.h: -------------------------------------------------------------------------------- 1 | 2 | /* standard includes */ 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /* for networking */ 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* ldns */ 23 | #include "ldns/ldns.h" 24 | 25 | #define DEFAULT_CONFIG "example/masterdont.conf" 26 | 27 | -------------------------------------------------------------------------------- /masterdont/config_file.h: -------------------------------------------------------------------------------- 1 | /* confile_file.h - masterdont config file reading */ 2 | 3 | #ifndef CONFIG_FILE_H 4 | #define CONFIG_FILE_H 5 | struct zones_t; 6 | 7 | #define DEFAULT_PORT 53 /* default is to use the DNS port */ 8 | #define MAX_TCP 200 /* max number concurrent tcp queries */ 9 | #define SERVER_BUFFER_SIZE 65535 /* bytes */ 10 | #define TCP_LISTEN_BACKLOG 15 /* max number of waiting connections */ 11 | #define TCP_PKT_SIZE 16384 /* bytes size max tcp packet */ 12 | 13 | /** a config file that has been read in */ 14 | struct config_file { 15 | /** port number to use */ 16 | int port; 17 | }; 18 | 19 | /** max number of nested include files */ 20 | #define MAX_INCLUDES 100 21 | 22 | /** during config read */ 23 | struct config_read { 24 | /** the cfg file */ 25 | struct config_file* cfg; 26 | /** zone tree */ 27 | struct zones_t* zones; 28 | 29 | /** current include depth */ 30 | int include_depth; 31 | /** stack of include files */ 32 | FILE* fstack[MAX_INCLUDES]; 33 | /** name of include files */ 34 | char* fnames[MAX_INCLUDES]; 35 | /** line number */ 36 | int lineno[MAX_INCLUDES]; 37 | 38 | /** is the temp zone entry filled out? */ 39 | int zone_read; 40 | /** line number where we started reading this zone */ 41 | int zone_linenr; 42 | /** zone entry we are reading */ 43 | char* zone_name; 44 | /** zone dir */ 45 | char* zone_dir; 46 | }; 47 | 48 | /** create structure with defaults */ 49 | struct config_file* config_file_create(void); 50 | 51 | /** delete structure */ 52 | void config_file_delete(struct config_file* cfg); 53 | 54 | /** read in a config file */ 55 | void config_file_read(struct config_file* cfg, const char* fname, 56 | struct zones_t* zones); 57 | 58 | /** during config read, add another zone */ 59 | void config_file_add_zone(struct config_read* cr); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /masterdont/example/example.com.1: -------------------------------------------------------------------------------- 1 | example.com. 345600 IN SOA ns0.example.org. root.example.com. 1 3600 28800 2419200 3600 2 | example.com. 345600 IN NS ns0.example.org. 3 | example.com. 345600 IN NS ns1.example.org. 4 | txt1.example.com. 345600 IN TXT "text record 1" 5 | txt2.example.com. 345600 IN TXT "text record 2" 6 | txt3.example.com. 345600 IN TXT "text record 3" 7 | -------------------------------------------------------------------------------- /masterdont/example/example.com.2: -------------------------------------------------------------------------------- 1 | example.com. 345600 IN SOA ns0.example.org. root.example.com. 2 3600 28800 2419200 3600 2 | -------------------------------------------------------------------------------- /masterdont/example/example.com.3: -------------------------------------------------------------------------------- 1 | example.com. 345600 IN SOA ns0.example.org. root.example.com. 3 3600 28800 2419200 3600 2 | example.com. 3600 IN NS ns2.example.org. 3 | example.com. 3600 IN NS ns4.example.org. 4 | example.com. 3600 IN NS ns23.example.org. 5 | example.com. 3600 IN NS bigserv.example.net. 6 | mail.example.com. 3600 IN AAAA ffff::23 7 | mail.example.com. 3600 IN MX 10 mail.example.com. 8 | mail.example.com. 3600 IN A 192.0.2.11 9 | printer.example.com. 3600 IN AAAA ffff::25 10 | terms.example.com. 3600 IN AAAA ffff::24 11 | terms.example.com. 3600 IN AAAA ffff::26 12 | webmail.example.com. 3600 IN MX 10 mail.example.com. 13 | webmail.example.com. 3600 IN A 192.0.2.10 14 | www.example.com. 3600 IN A 192.0.2.10 15 | -------------------------------------------------------------------------------- /masterdont/example/example.com.5: -------------------------------------------------------------------------------- 1 | example.com. 345600 IN SOA ns0.example.org. root.example.com. 5 3600 28800 2419200 3600 2 | example.com. 3600 IN NS ns2.example.org. 3 | example.com. 3600 IN NS ns4.example.org. 4 | example.com. 3600 IN NS ns23.example.org. 5 | example.com. 3600 IN NS bigserv.example.net. 6 | mail.example.com. 3600 IN AAAA ffff::23 7 | mail.example.com. 3600 IN TXT "if you can find this, all outgoing mail is signed, no, really" 8 | mail.example.com. 3600 IN MX 10 mail.example.com. 9 | mail.example.com. 3600 IN A 192.0.2.11 10 | newservice.example.com. 3600 IN A 192.0.2.123 11 | ooo.example.com. 3600 IN TXT "amazing new protocol here" 12 | terms.example.com. 3600 IN A 192.0.2.24 13 | terms.example.com. 3600 IN A 192.0.2.26 14 | webmail.example.com. 3600 IN MX 20 mail.example.com. 15 | webmail.example.com. 3600 IN A 192.0.2.10 16 | www.example.com. 3600 IN NSEC example.com. A RRSIG NSEC 17 | www.example.com. 3600 IN RRSIG A RSASHA1 3 3600 20060825081644 20060728081644 44537 example.com. rkO1E0zZV+NiEKUrkUEC396ubGOYWML8VbpbWpDcBTwPGP0gGEkva8qt0vE6qlsw3gO4tkT1Ir+TXAWvnRvFtY3bpkNnajhIvV2J+16/p8YtCIxH19IUrAwf1pANMNNtQuFU1CLIVOaXRx8oXRfFY2t+GFYdDqXyjzqgcVU7mww= ;{id = 44537} 18 | www.example.com. 3600 IN RRSIG NSEC RSASHA1 3 3600 20060825081644 20060728081644 44537 example.com. y3AmY5RDR5J4ELdDCGYgvh8sawaxYjGJMch6gxfGPYCu9jqpECkpustTw+GgAnTlLej6iKK/3EfoKUobOVgpIPDqAWNqa8lL8m3P2Kbxp+OXGotSz5atVSlDRei66XwalKhGw9u7EDOLZc/bSbbbxSJa14XwTKA4Tr2Op5KLT/4= ;{id = 44537} 19 | www.example.com. 3600 IN A 192.0.2.10 20 | -------------------------------------------------------------------------------- /masterdont/example/masterdont.conf: -------------------------------------------------------------------------------- 1 | # example config file for Masterdont. 2 | # this is a comment. 3 | 4 | # global server settings. 5 | server: 6 | # port number to use. default 53 (DNS). 7 | port: 10053 8 | 9 | # a number of zone entries follow. 10 | zone: 11 | # domain name of the zone. 12 | name: "example.com" 13 | # directory where data is stored for the zone. 14 | # In the directory files created are named zone.example.com.* 15 | dir: "example" 16 | 17 | #zone: 18 | #name: "example.net" 19 | #dir: "example" 20 | -------------------------------------------------------------------------------- /masterdont/example/zone.example.com.full.1: -------------------------------------------------------------------------------- 1 | example.com. 345600 IN SOA ns0.example.org. root.example.com. 1 3600 28800 2419200 3600 2 | example.com. 345600 IN NS ns0.example.org. 3 | example.com. 345600 IN NS ns1.example.org. 4 | txt1.example.com. 345600 IN TXT "text record 1" 5 | txt2.example.com. 345600 IN TXT "text record 2" 6 | txt3.example.com. 345600 IN TXT "text record 3" 7 | -------------------------------------------------------------------------------- /masterdont/example/zone.example.com.index: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /masterdont/main.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include "config_file.h" 3 | #include "zones.h" 4 | #include "server.h" 5 | 6 | static void 7 | usage(const char* me) 8 | { 9 | printf("usage: %s [options]\n", me); 10 | printf("Hidden master stealth server: serves AXFR, IXFR.\n"); 11 | printf("-h print this information.\n"); 12 | printf("-c set config file to use.\n"); 13 | printf("\n"); 14 | } 15 | 16 | int main(int argc, char* argv[]) 17 | { 18 | const char* config = DEFAULT_CONFIG; 19 | int c; 20 | 21 | while((c=getopt(argc, argv, "c:h")) != -1) 22 | { 23 | switch(c) { 24 | case 'c': 25 | config = optarg; 26 | break; 27 | default: 28 | printf("Unknown option '-%c' (%x).\n", c, c); 29 | case 'h': 30 | usage(argv[0]); 31 | return 1; 32 | } 33 | } 34 | argc -= optind; 35 | argv += optind; 36 | if(argc > 0) { 37 | printf("Too many arguments.\n"); 38 | usage(argv[0]); 39 | return 1; 40 | } 41 | 42 | /* start server */ 43 | while(server_start(config)) { 44 | printf("Masterdont reload\n"); 45 | } 46 | printf("Masterdont stopped\n"); 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /masterdont/process.h: -------------------------------------------------------------------------------- 1 | /* 2 | * process.h, process queries to determine the answer RRs and packets. 3 | */ 4 | 5 | #ifndef PROCESS_H 6 | #define PROCESS_H 7 | 8 | struct socket_service; 9 | struct zones_t; 10 | struct zone_entry_t; 11 | 12 | /** 13 | * Calculate the reply for the query in q. Put answer in packet p. 14 | * P is an empty packet on routine start, with header. 15 | */ 16 | ldns_pkt_rcode process_pkts(struct socket_service* sv, 17 | ldns_pkt* q, ldns_pkt* r, struct zones_t* zones); 18 | 19 | /** 20 | * Process QUERY 21 | */ 22 | ldns_pkt_rcode process_pkt_query(struct socket_service* sv, 23 | ldns_pkt* q, ldns_pkt* r, struct zones_t* zones); 24 | 25 | /** 26 | * Process NOTIFY 27 | */ 28 | ldns_pkt_rcode process_pkt_notify(struct socket_service* sv, 29 | ldns_pkt* q, ldns_pkt* r, struct zones_t* zones); 30 | 31 | /** 32 | * Process SOA queries 33 | * pass correct zone entry. 34 | */ 35 | ldns_pkt_rcode process_pkt_soa(struct socket_service* sv, 36 | ldns_pkt* q, ldns_pkt* r, struct zone_entry_t* entry); 37 | 38 | /** 39 | * Process IXFR 40 | * pass correct zone entry. 41 | */ 42 | ldns_pkt_rcode process_pkt_ixfr(struct socket_service* sv, 43 | ldns_pkt* q, ldns_pkt* r, struct zone_entry_t* entry); 44 | 45 | /** 46 | * Process AXFR 47 | * pass correct zone entry. 48 | */ 49 | ldns_pkt_rcode process_pkt_axfr(struct socket_service* sv, 50 | struct zone_entry_t* entry); 51 | #endif /* PROCESS_H */ 52 | -------------------------------------------------------------------------------- /masterdont/zones.h: -------------------------------------------------------------------------------- 1 | /* 2 | zones.h keep list of zones to handle with backend info. 3 | */ 4 | 5 | #ifndef ZONES_H 6 | #define ZONES_H 7 | struct zinfo_t; 8 | 9 | /** 10 | * zone entry information 11 | */ 12 | struct zone_entry_t { 13 | /** rbtree node info */ 14 | ldns_rbnode_t node; 15 | /** zone name */ 16 | ldns_rdf* zname; 17 | /** zone name in text */ 18 | char* zstr; 19 | /** zone class */ 20 | uint16_t zclass; 21 | /** zone info */ 22 | struct zinfo_t* zinfo; 23 | 24 | /** next in linked list */ 25 | struct zone_entry_t* next; 26 | }; 27 | 28 | /** 29 | * Keep zones information. 30 | */ 31 | struct zones_t { 32 | /** tree of zone_entry, sorted by zname, zclass */ 33 | ldns_rbtree_t* ztree; 34 | }; 35 | 36 | /** 37 | * create new empty zones struct 38 | */ 39 | struct zones_t* zones_create(void); 40 | 41 | /** 42 | * Read all the zone entry storage 43 | */ 44 | void zones_read(struct zones_t* zones); 45 | 46 | /** 47 | * Find zone entry given the name 48 | * or NULL if doesn't exist 49 | */ 50 | struct zone_entry_t* zones_find(struct zones_t* zones, const char* name, 51 | uint16_t fclass); 52 | 53 | /** 54 | * find a zone based on rdf 55 | */ 56 | struct zone_entry_t* zones_find_rdf(struct zones_t* zones, ldns_rdf* name, 57 | uint16_t fclass); 58 | 59 | /** 60 | * Insert new entry for zone name, returns new entry. 61 | * or NULL if out of memory. 62 | */ 63 | struct zone_entry_t* zones_insert(struct zones_t* zones, const char* name, 64 | uint16_t nclass); 65 | 66 | /** 67 | * free a zone entry 68 | */ 69 | void zone_entry_free(struct zone_entry_t* entry); 70 | 71 | /** 72 | * free zones data structure 73 | */ 74 | void zones_free(struct zones_t* zones); 75 | 76 | #endif /* ZONES_H */ 77 | -------------------------------------------------------------------------------- /packaging/ldns-config.1: -------------------------------------------------------------------------------- 1 | .TH ldns-config 1 "22 Sep 2011" 2 | .SH NAME 3 | ldns-config \- show compiler and linker flags for ldns usage. 4 | .SH SYNOPSIS 5 | .B ldns-config 6 | [ 7 | .IR OPTIONS 8 | ] 9 | 10 | .SH DESCRIPTION 11 | When writing programs using ldns, you have to tell the compiler 12 | where to look for include files and what libraries from which location 13 | to link to. \fBldns-config\fR can be used to find out what flags to use 14 | with the C compiler and the linker. 15 | 16 | .SH OPTIONS 17 | .TP 18 | \fB--cflags\fR 19 | Show the C compiler flags needed to compile with ldns 20 | 21 | .TP 22 | \fB--libs\fR 23 | Show the flags to be used to link with ldns 24 | 25 | .TP 26 | \fB--version\fR 27 | Shows the ldns version of the installed ldns library 28 | 29 | .TP 30 | \fB--libversion\fR 31 | Shows version of the binary api of the installed ldns library 32 | 33 | .TP 34 | \fB--help\fR 35 | Show \fBldns-config\fR usage description 36 | 37 | .SH AUTHOR 38 | Written by the ldns team. 39 | 40 | .SH REPORTING BUGS 41 | Report bugs to . 42 | 43 | .SH COPYRIGHT 44 | Copyright (C) 2011 NLnet Labs. This is free software. There is NO 45 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 46 | PURPOSE. 47 | 48 | -------------------------------------------------------------------------------- /packaging/ldns-config.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix="@prefix@" 4 | exec_prefix="@exec_prefix@" 5 | VERSION="@PACKAGE_VERSION@" 6 | CFLAGS="@CFLAGS@" 7 | CPPFLAGS="@CPPFLAGS@ @LIBSSL_CPPFLAGS@" 8 | LDFLAGS="@LDFLAGS@ @LIBSSL_LDFLAGS@" 9 | PYTHON_CPPFLAGS="@PYTHON_CPPFLAGS@" 10 | PYTHON_LDFLAGS="@PYTHON_LDFLAGS@" 11 | LIBS="@LIBS@ @LIBSSL_LIBS@" 12 | LIBDIR="@libdir@" 13 | INCLUDEDIR="@includedir@" 14 | LIBVERSION="@VERSION_INFO@" 15 | 16 | 17 | for arg in $@ 18 | do 19 | if [ $arg = "--cflags" ] 20 | then 21 | echo "-I${INCLUDEDIR}" 22 | fi 23 | if [ $arg = "--python-cflags" ] 24 | then 25 | echo "${PYTHON_CPPFLAGS} -I${INCLUDEDIR}" 26 | fi 27 | if [ $arg = "--libs" ] 28 | then 29 | echo "${LDFLAGS} -L${LIBDIR} ${LIBS} -lldns" 30 | fi 31 | if [ $arg = "--python-libs" ] 32 | then 33 | echo "${LDFLAGS} ${PYTHON_LDFLAGS} -L${LIBDIR} ${LIBS} -lldns" 34 | fi 35 | if [ $arg = "-h" ] || [ $arg = "--help" ] 36 | then 37 | echo "Usage: $0 [--cflags] [--python-cflags] [--libs] [--python-libs] [--version]" 38 | fi 39 | if [ $arg = "--version" ] 40 | then 41 | echo "${VERSION}" 42 | fi 43 | if [ $arg = "--libversion" ] 44 | then 45 | echo "${LIBVERSION}" 46 | fi 47 | done 48 | -------------------------------------------------------------------------------- /packaging/libldns.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: ldns 7 | Description: Library for DNS programming 8 | URL: http://www.nlnetlabs.nl/projects/ldns 9 | Version: @PACKAGE_VERSION@ 10 | Requires: 11 | Libs: -L${libdir} -lldns 12 | Libs.private: @LDFLAGS@ 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /pcat/Makefile.in: -------------------------------------------------------------------------------- 1 | # Standard installation pathnames 2 | # See the file LICENSE for the license 3 | SHELL = @SHELL@ 4 | VERSION = @PACKAGE_VERSION@ 5 | basesrcdir = $(shell basename `pwd`) 6 | srcdir = @srcdir@ 7 | prefix = @prefix@ 8 | exec_prefix = @exec_prefix@ 9 | bindir = @bindir@ 10 | mandir = @mandir@ 11 | 12 | CC = @CC@ 13 | CFLAGS = @CFLAGS@ -Wall -I. 14 | CPPFLAGS = @CPPFLAGS@ 15 | LDFLAGS = @LDFLAGS@ 16 | LIBS = @LIBS@ 17 | LDNSDIR= @LDNSDIR@ 18 | 19 | INSTALL = $(srcdir)/../install-sh 20 | 21 | COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) 22 | LINK = $(CC) $(CFLAGS) $(LDFLAGS) 23 | LIBS_STC = -lpcap $(LDNSDIR)/lib/libldns.a -lcrypto -ldl 24 | 25 | HEADER = config.h 26 | 27 | .PHONY: all clean realclean all-static 28 | 29 | all: p 30 | 31 | all-static: pcat-stc pcat-diff-stc pcat-print-stc 32 | 33 | p: pcat pcat-diff pcat-print 34 | # strip pcat 35 | # strip pcat-diff 36 | # strip pcat-print 37 | 38 | pcat: pcat.o getdelim.o 39 | $(LINK) -o $@ $+ $(LIBS) 40 | 41 | pcat-diff: pcat-diff.o getdelim.o 42 | $(LINK) -o $@ $+ $(LIBS) 43 | 44 | pcat-print: pcat-print.o getdelim.o 45 | $(LINK) -o $@ $+ $(LIBS) 46 | 47 | pcat-stc: pcat.o getdelim.o 48 | $(LINK) -o $(@:-stc=) $+ $(LIBS_STC) 49 | 50 | pcat-diff-stc: pcat-diff.o getdelim.o 51 | $(LINK) -o $(@:-stc=) $+ $(LIBS_STC) 52 | 53 | pcat-print-stc: pcat-print.o getdelim.o 54 | $(LINK) -o $(@:-stc=) $+ $(LIBS_STC) 55 | 56 | clean: 57 | rm -f pcat pcat-diff pcat-print 58 | rm -f pcat.o pcat-diff.o pcat-print.o 59 | 60 | realclean: clean 61 | rm -f configure config.h config.log config.status 62 | 63 | 64 | ## implicit rule 65 | %.o: $(srcdir)/%.c 66 | $(COMPILE) -c $< 67 | -------------------------------------------------------------------------------- /pcat/getdelim.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #ifndef HAVE_GETDELIM 3 | 4 | #define GETDELIM_BUFFER 128 5 | 6 | /* copied from xine-devel */ 7 | size_t 8 | getdelim( char **lineptr, size_t *n, int delimiter, FILE *stream ) 9 | { 10 | char *p; 11 | int c; 12 | size_t len = 0; 13 | 14 | if (!lineptr || !n || (!*lineptr && *n)) 15 | return -1; 16 | 17 | /* allocate initial buffer */ 18 | if (!*lineptr || !*n) { 19 | char *np; 20 | np = realloc( *lineptr, GETDELIM_BUFFER ); 21 | if (!np) 22 | return -1; 23 | *n = GETDELIM_BUFFER; 24 | *lineptr = np; 25 | } 26 | 27 | p = *lineptr; 28 | 29 | /* read characters from stream */ 30 | while ((c = fgetc( stream )) != EOF) { 31 | if (len >= *n) { 32 | char *np = realloc( *lineptr, *n * 2 ); 33 | if (!np) 34 | return -1; 35 | p = np + (p - *lineptr); 36 | *lineptr = np; 37 | *n *= 2; 38 | } 39 | *p++ = (char) c; 40 | len++; 41 | if (delimiter == c) 42 | break; 43 | } 44 | 45 | /* end of file without any bytes read */ 46 | if ((c == EOF) && (len == 0)) 47 | return -1; 48 | 49 | /* trailing "\0" */ 50 | if (len >= *n) { 51 | char *np = realloc( *lineptr, *n + 1 ); 52 | if (!np) 53 | return -1; 54 | p = np + (p - *lineptr); 55 | *lineptr = np; 56 | *n += 1; 57 | } 58 | *p = '\0'; 59 | 60 | return len; 61 | } 62 | 63 | #endif /* !HAVE_GETDELIM */ 64 | -------------------------------------------------------------------------------- /pcat/pcat-print.1: -------------------------------------------------------------------------------- 1 | '\" t 2 | .TH PCAT-PRINT 1 "08 Mar 2006" "pcat utils" 3 | .SH NAME 4 | pcat-print \- reformat hexadecimal packets back to dig-like syntax 5 | .SH SYNOPSIS 6 | .B pcat-printp 7 | [ 8 | .IR \-h 9 | ] 10 | .IR PCAT_STREAM 11 | 12 | .SH DESCRIPTION 13 | \fBpcat-print\fR reads in a pcat file and reformats the hexadecimal 14 | packets back into a dig-like syntax. If a packet cannot be transformed 15 | back into a sane syntax an error is emitted. 16 | 17 | This makes the manual inspection of the packets easier. 18 | 19 | .PP 20 | If no pcat file is given, standard input is read. 21 | 22 | .SH OPTIONS 23 | There are no options. Like \fBpcat-diff\fR this utility always does 24 | what you want. 25 | 26 | .SH OUTPUT FORMAT 27 | \fBpcat-print\fR will output records. 28 | Each record consists of an index and then three packets. 29 | Each packet is separated by a line of '='s. All in all the output looks 30 | like: 31 | 32 | ========================== 33 | ========================== 34 | Index: xxx:yyy 35 | ========================== 36 | query packet 37 | ========================== 38 | first answer/query packet 39 | ========================== 40 | second answer/query packet 41 | ========================== 42 | .PP 43 | For the index: xxx:yyy. xxx is the query ID of the first answer/query and 44 | yyy is the query ID of the second one. These two IDs should match. The query 45 | ID of the query packet is also equal to xxx. 46 | 47 | .SH ALSO SEE 48 | Also see pcat(1) and pcat-diff(1). 49 | 50 | .SH AUTHOR 51 | Written by Miek Gieben for NLnet Labs. 52 | 53 | .SH REPORTING BUGS 54 | Report bugs to . 55 | 56 | .SH COPYRIGHT 57 | Copyright (C) 2005, 2006 NLnet Labs. This is free software. There is NO 58 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 59 | PURPOSE. 60 | .PP 61 | Licensed under the BSD License. 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /pcat/pcat-print.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | 3 | #include "config.h" 4 | 5 | #include 6 | 7 | #define SEQUENCE 1 8 | #define QUERY 2 9 | #define ANSWER1 3 10 | #define ANSWER2 0 11 | #define LINES 4 12 | 13 | #ifndef HAVE_GETDELIM 14 | ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); 15 | #endif 16 | 17 | void 18 | printf_bar(void) 19 | { 20 | fprintf(stdout, "===================================================================\n"); 21 | } 22 | 23 | int 24 | main(int argc, char **argv) 25 | { 26 | ssize_t read; 27 | char *line; 28 | size_t i, j, k, len; 29 | u_char pkt_buf[LDNS_MAX_PACKETLEN]; 30 | ldns_pkt *p; 31 | ldns_status s; 32 | FILE *diff = stdin; 33 | 34 | i = 1; 35 | len = 0; 36 | line = NULL; 37 | 38 | if (argc > 1) { 39 | if (!(diff = fopen(argv[1], "r"))) { 40 | fprintf(stderr, "Cannot open pcat diff file `%s\'\n", argv[1]); 41 | exit(EXIT_FAILURE); 42 | } 43 | } 44 | 45 | while((read = getdelim(&line, &len, '\n', diff)) != -1) { 46 | if (read < 2 || read > LDNS_MAX_PACKETLEN) { 47 | if(read == 1) 48 | fprintf(stdout, "NO ANSWER (line %d)\n", (int)i); 49 | else 50 | fprintf(stdout, "Under- or overflow (%d) - " 51 | "skipping line %d\n", (int)read, (int)i); 52 | i++; 53 | printf_bar(); 54 | continue; 55 | } 56 | 57 | line[read - 1] = '\0'; 58 | switch(i % LINES) { 59 | case SEQUENCE: 60 | printf_bar(); 61 | fprintf(stdout, "Index: %s\n", line); 62 | printf_bar(); 63 | break; 64 | case QUERY: 65 | case ANSWER1: 66 | case ANSWER2: 67 | k = 0; 68 | for(j = 0; j < read - 1; j += 2) { 69 | pkt_buf[k] = 70 | ldns_hexdigit_to_int(line[j]) * 16 + 71 | ldns_hexdigit_to_int(line[j + 1]); 72 | k++; 73 | } 74 | s = ldns_wire2pkt(&p, pkt_buf, k); 75 | fprintf(stdout, "=* %s\n", line); 76 | if (s != LDNS_STATUS_OK) { 77 | fprintf(stdout, "%s\n", ldns_get_errorstr_by_id(s)); 78 | } else { 79 | ldns_pkt_print(stdout, p); 80 | } 81 | printf_bar(); 82 | break; 83 | } 84 | i++; 85 | len = 0; 86 | } 87 | return 0; 88 | } 89 | -------------------------------------------------------------------------------- /pcat/pcat.1: -------------------------------------------------------------------------------- 1 | '\" t 2 | .TH PCAT 1 "08 Mar 2006" "pcat utils" 3 | .SH NAME 4 | pcat \- (re)-send a pcap trace to a nameserver 5 | .SH SYNOPSIS 6 | .B pcat 7 | [ 8 | .IR \-a 9 | IP 10 | ] 11 | [ 12 | .IR \-p 13 | PORT 14 | ] 15 | .IR PCAP_STRACE 16 | 17 | .SH DESCRIPTION 18 | \fBpcat\fR reads in a pcap trace file and re-sends the packet's payload 19 | to a nameserver. It prints each query and the reply to standard output 20 | is a hexadecimal format. 21 | .PP 22 | If no pcap file is given, standard input is read. 23 | 24 | .SH OPTIONS 25 | .TP 26 | .B \-a IP 27 | Use IP as address to send the queries to. 28 | .TP 29 | .B \-p PORT 30 | Use PORT as port number. 31 | 32 | .SH OUTPUT FORMAT 33 | The output of \fBpcat\fR consists "records". Each record has four lines: 34 | .PP 35 | 1. xxx - (decimal) sequence number 36 | 2. hex dump - query in hex, network order 37 | 3. hex dump - answer in hex, network order 38 | 4. empty line 39 | 40 | The reason for the fourth line is that \fBpcat-print\fR can now parse 41 | both \fBpcat\fRs and \fBpcat-diff\fRs output. 42 | .PP 43 | This format is dubbed: \fBpcat\fR. 44 | 45 | .SH ALSO SEE 46 | Also see pcat-print(1) and pcat-diff(1). 47 | 48 | .SH AUTHOR 49 | Written by Miek Gieben for NLnet Labs. 50 | 51 | .SH REPORTING BUGS 52 | Report bugs to . 53 | 54 | .SH COPYRIGHT 55 | Copyright (C) 2005, 2006 NLnet Labs. This is free software. There is NO 56 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 57 | PURPOSE. 58 | .PP 59 | Licensed under the BSD License. 60 | -------------------------------------------------------------------------------- /pcat/todo: -------------------------------------------------------------------------------- 1 | maxpacketlen? We're are dealing with hex so it should prob. be 2 | twice as large? 3 | 4 | ipv6 5 | 6 | tcp packets 7 | 8 | better pcap payload inspection - currently it only works for udp, 9 | ethernet 10 | 11 | a speed setting to send queries faster? 12 | -------------------------------------------------------------------------------- /test/01-compile.tpkg/01-compile.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 01-compile 2 | Version: 1.0 3 | Description: compile ldns 4 | CreationDate: Fri Oct 19 13:09:03 CEST 2005 5 | Maintainer: Miek Gieben 6 | Category: 7 | Component: 8 | Depends: 9 | Pre: 10 | Post: 11 | Test: 01-compile.test 12 | AuxFiles: 13 | Passed: 14 | Failure: 15 | -------------------------------------------------------------------------------- /test/01-compile.tpkg/01-compile.help: -------------------------------------------------------------------------------- 1 | Synopsis: tpkg -a ../../ exe 01-compile.tpkg 2 | -a path: path is where the source lives 3 | as the test is executed in it own subsdir it will 4 | need ../../ is you use a relative path 5 | -------------------------------------------------------------------------------- /test/03-run.tpkg/03-run.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 03-run 2 | Version: 1.0 3 | Description: run drill and see if it works 4 | CreationDate: Tue Nov 1 14:29:37 CET 2005 5 | Maintainer: Miek Gieben 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 03-run.help 10 | Pre: 11 | Post: 12 | Test: 03-run.test 13 | AuxFiles: 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/03-run.tpkg/03-run.help: -------------------------------------------------------------------------------- 1 | synopsis: tpkg -a exe 03-run 2 | -------------------------------------------------------------------------------- /test/03-run.tpkg/03-run.test: -------------------------------------------------------------------------------- 1 | # #-- 03-run.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | # first arg is the build dir 10 | TPKG_BUILD=$1 11 | 12 | cd $TPKG_BUILD 13 | cd drill/ 14 | # this segfaulted once - nothing should be running on this port 15 | LD_LIBRARY_PATH="../.libs:$LD_LIBRARY_PATH" DYLD_LIBRARY_PATH="../.libs:$DYLD_LIBRARY_PATH" ./drill @localhost mx miek.nl -p 5333 16 | fail=$? 17 | if [ $fail -eq 1 ]; then 18 | #success 19 | exit 0; 20 | fi 21 | exit $fail 22 | -------------------------------------------------------------------------------- /test/04-run-normal.tpkg/04-run-normal.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 04-run-normal 2 | Version: 1.0 3 | Description: run drill and don't do anything fancy 4 | CreationDate: Tue Nov 1 14:59:25 CET 2005 5 | Maintainer: Miek Gieben 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 04-run-normal.help 10 | Pre: 11 | Post: 12 | Test: 04-run-normal.test 13 | AuxFiles: 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/04-run-normal.tpkg/04-run-normal.help: -------------------------------------------------------------------------------- 1 | synopsis: tpkg -a exe 04-run-normal 2 | -------------------------------------------------------------------------------- /test/04-run-normal.tpkg/04-run-normal.test: -------------------------------------------------------------------------------- 1 | # #-- 03-run.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | # first arg is the build dir 10 | TPKG_BUILD=$1 11 | 12 | cd $TPKG_BUILD 13 | cd drill/ 14 | LD_LIBRARY_PATH="../.libs:$LD_LIBRARY_PATH" DYLD_LIBRARY_PATH="../.libs:$DYLD_LIBRARY_PATH" ./drill @k.root-servers.net mx miek.nl && \ 15 | LD_LIBRARY_PATH="../.libs:$LD_LIBRARY_PATH" DYLD_LIBRARY_PATH="../.libs:$DYLD_LIBRARY_PATH" ./drill mx miek.nl 16 | if [[ $? -ne 0 ]]; then 17 | exit 1 18 | fi 19 | 20 | LD_LIBRARY_PATH="../.libs:$LD_LIBRARY_PATH" DYLD_LIBRARY_PATH="../.libs:$DYLD_LIBRARY_PATH" ./drill @ mx miek.nl 21 | if [[ $? -ne 1 ]]; then 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /test/05-iana-rr-types.tpkg/._05-iana-rr-types.dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NLnetLabs/ldns/ae1243a7ba8630a60df5e6f128c49fdaaa7e6306/test/05-iana-rr-types.tpkg/._05-iana-rr-types.dir -------------------------------------------------------------------------------- /test/05-iana-rr-types.tpkg/05-iana-rr-types.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 05-iana-rr-types 2 | Version: 1.0 3 | Description: Fetch dns-parameters.xml from iana and check all RR types 4 | CreationDate: wo apr 24 13:49:20 CEST 2013 5 | Maintainer: Willem Toorop 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 05-iana-rr-types.help 10 | Pre: 11 | Post: 12 | Test: 05-iana-rr-types.test 13 | AuxFiles: 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/05-iana-rr-types.tpkg/05-iana-rr-types.help: -------------------------------------------------------------------------------- 1 | synopsis: tpkg -a exe 05-iana-rr-types 2 | -------------------------------------------------------------------------------- /test/05-iana-rr-types.tpkg/05-iana-rr-types.test: -------------------------------------------------------------------------------- 1 | # #-- 03-run.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | # first arg is the build dir 10 | TPKG_BUILD=$1 11 | PARAM_XML="dns-parameters.xml" 12 | PARAM_URL="http://www.iana.org/assignments/dns-parameters/$PARAM_XML" 13 | 14 | if [ -f $PARAM_XML ] 15 | then 16 | mv $PARAM_XML ${PARAM_XML}.aandekant 17 | fi 18 | if which wget 19 | then 20 | wget "$PARAM_URL" 21 | elif ! ( echo quit | ftp "$PARAM_URL" ) 22 | then 23 | echo "Don't have wget or ftp to get $PARAM_URL" 24 | exit -1 25 | fi 26 | 27 | EXIT_STATUS=0 28 | 29 | for TYPE_VAL in `awk '/[^<>]*<\/type>/{ a=$1; getline; b=$1; print a""b }' dns-parameters.xml | sed -e 's///g' -e 's/<\/type>//g' -e 's//:/g' -e 's/<\/value>//g'|egrep -v '^(Unassigned|Private|Reserved)'` 30 | do 31 | TYPE=${TYPE_VAL%:*} 32 | VALUE=${TYPE_VAL#*:} 33 | case "x$TYPE" in 34 | x\*) TYPE="ANY" 35 | ;; 36 | xNSAP-PTR) TYPE="NSAP_PTR" 37 | ;; 38 | esac 39 | if ! grep "LDNS_RR_TYPE_${TYPE} = ${VALUE}" ${TPKG_BUILD}/ldns/rr.h >/dev/null 40 | then 41 | echo "RR type ${TYPE} (value ${VALUE}) not implemented." 42 | EXIT_STATUS=1 43 | fi 44 | done 45 | 46 | exit $EXIT_STATUS 47 | 48 | -------------------------------------------------------------------------------- /test/08-zonereader.tpkg/08-zonereader.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 08-zonereader 2 | Version: 1.0 3 | Description: Check the backward compat. of the zone parser 4 | CreationDate: Mon Jan 2 16:24:38 CET 2006 5 | Maintainer: Jelte Jansen 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 08-zonereader.help 10 | Pre: 11 | Post: 12 | Test: 08-zonereader.test 13 | AuxFiles: 08-zonereader.outputzone 08-zonereader.inputzone 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/08-zonereader.tpkg/08-zonereader.help: -------------------------------------------------------------------------------- 1 | No arguments are used for this test. 2 | 3 | The example tool ldns-read-zone is used to read the zone from 4 | 08-zonereader-inputzone that contains a number of different RRs. The output 5 | is compared to 08-zonereader-outputzone. 6 | 7 | With this test the zone reading functions are checked to see if they have 8 | not regressed. 9 | -------------------------------------------------------------------------------- /test/08-zonereader.tpkg/08-zonereader.test: -------------------------------------------------------------------------------- 1 | # #-- 05-nm.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | LIB=../../lib/ 10 | export LD_LIBRARY_PATH=$LIB:$LD_LIBRARY_PATH 11 | 12 | # get the libdns symbols 13 | ../../examples/ldns-read-zone -b 08-zonereader.inputzone > 08-zonereader.current 14 | 15 | diff 08-zonereader.current 08-zonereader.outputzone 16 | fail=$? 17 | rm -f 08-zonereader.current 18 | 19 | exit $fail 20 | -------------------------------------------------------------------------------- /test/09-doc-check.tpkg/09-doc-check.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 09-doc-check 2 | Version: 1.0 3 | Description: Generate the documentation and check for errors 4 | CreationDate: Mon Jan 9 12:12:32 CET 2006 5 | Maintainer: Miek Gieben 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 09-doc-check.help 10 | Pre: 11 | Post: 12 | Test: 09-doc-check.test 13 | AuxFiles: 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/09-doc-check.tpkg/09-doc-check.help: -------------------------------------------------------------------------------- 1 | No arguments are used for this test. 2 | 3 | Run a make doc and check for errors. 4 | -------------------------------------------------------------------------------- /test/09-doc-check.tpkg/09-doc-check.test: -------------------------------------------------------------------------------- 1 | # #-- 05-nm.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | : > report 10 | echo 0 > exit_code 11 | for target in doc manpage-create-errors manpage-errors 12 | do 13 | ( cd $1 14 | if ! make $target 2>&1 15 | then 16 | echo 1 > exit_code 17 | fi 18 | 19 | ) >make-out 20 | 21 | A=`cat make-out | wc -l` 22 | if [[ $A -gt 1 ]] 23 | then 24 | ( echo "***" 25 | echo "*** make $target" 26 | echo "***" 27 | echo "" 28 | cat make-out 29 | echo "" 30 | 31 | ) >>report 32 | fi 33 | done 34 | 35 | A=`cat report | wc -l` 36 | if [[ $A -gt 0 ]]; then 37 | cat report 38 | fi 39 | exit `cat exit_code` 40 | 41 | -------------------------------------------------------------------------------- /test/10-ldns-compare-zones.tpkg/10-ldns-compare-zones.diffs: -------------------------------------------------------------------------------- 1 | ++_added.justazone.example. 3600 IN TXT "added" 2 | ~+a1.justazone.example. 3600 IN A 192.0.2.1 3 | ~-a1.justazone.example. 3600 IN A 192.0.2.2 4 | ~-a2.justazone.example. 3600 IN A 192.0.2.1 5 | ~+a2.justazone.example. 3600 IN A 192.0.2.2 6 | ~-a3.justazone.example. 3600 IN A 192.0.2.1 7 | ~+a3.justazone.example. 3600 IN A 192.0.2.2 8 | ~-a3.justazone.example. 3600 IN A 203.0.113.1 9 | ~+a3.justazone.example. 3600 IN A 203.0.113.2 10 | ~+delegation1.justazone.example. 3600 IN NS ns2.delegation1.justazone.example. 11 | ++delegation2.justazone.example. 3600 IN NS ns1.delegation2.justazone.example. 12 | --delegation4.justazone.example. 3600 IN NS ns1.delegation3.justazone.example. 13 | ~+grow2to3.justazone.example. 3600 IN TXT "three" 14 | ~-shrink2to1.justazone.example. 3600 IN TXT "two" 15 | ~-shrink3to2.justazone.example. 3600 IN TXT "three" 16 | --zz.justazone.example. 3600 IN TXT "top" 17 | --zz.justazone.example. 3600 IN TXT "zZZZzzz" 18 | +2 -2 ~7 19 | -------------------------------------------------------------------------------- /test/10-ldns-compare-zones.tpkg/10-ldns-compare-zones.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 10-ldns-compare-zones 2 | Version: 1.0 3 | Description: Check ldns-compare-zone behaviour 4 | CreationDate: Wed Oct 6 15:11:39 CEST 2021 5 | Maintainer: Willem Toorop 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 10-ldns-compare-zones.help 10 | Pre: 11 | Post: 12 | Test: 10-ldns-compare-zones.test 13 | AuxFiles: 10-ldns-compare-zones.zone1 10-ldns-compare-zones.zone2 10-ldns-compare-zones.diffs 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/10-ldns-compare-zones.tpkg/10-ldns-compare-zones.help: -------------------------------------------------------------------------------- 1 | No arguments are used for this test. 2 | 3 | The example tool ldns-compare-zone is used to compare two zone files with numerous differences. 4 | 5 | -------------------------------------------------------------------------------- /test/10-ldns-compare-zones.tpkg/10-ldns-compare-zones.test: -------------------------------------------------------------------------------- 1 | # #-- 05-nm.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | LIB=../../lib/ 10 | export LD_LIBRARY_PATH=$LIB:$LD_LIBRARY_PATH 11 | 12 | # get the libdns symbols 13 | ../../examples/ldns-compare-zones -as 10-ldns-compare-zones.zone1 10-ldns-compare-zones.zone2 > 10-ldns-compare-zones.out 14 | 15 | diff 10-ldns-compare-zones.out 10-ldns-compare-zones.diffs 16 | fail=$? 17 | rm -f 10-ldns-compare-zones.out 18 | 19 | exit $fail 20 | -------------------------------------------------------------------------------- /test/10-ldns-compare-zones.tpkg/10-ldns-compare-zones.zone1: -------------------------------------------------------------------------------- 1 | $ORIGIN justazone.example. 2 | 3 | @ SOA @ hostmaster ( 4 | 1 5 | 1800 ; refresh (30 minutes) 6 | 900 ; retry (15 minutes) 7 | 604800 ; expire (1 week) 8 | 86400 ; minimum (1 day) 9 | ) 10 | ; This delegation will grow to 2 records 11 | ; this change was undetected in ldns < 1.7.2 12 | delegation1 NS ns1.delegation1 13 | 14 | delegation3 NS ns1.delegation3 15 | 16 | delegation4 NS ns1.delegation3 17 | delegation5 NS ns1.delegation5 18 | a1 A 192.0.2.2 19 | a2 A 192.0.2.1 20 | a3 A 192.0.2.1 21 | A 198.51.100.1 22 | A 203.0.113.1 23 | shrink3to2 TXT one 24 | TXT two 25 | TXT three 26 | shrink2to1 TXT one 27 | TXT two 28 | grow2to3 TXT one 29 | TXT two 30 | zz TXT top 31 | TXT zZZZzzz 32 | -------------------------------------------------------------------------------- /test/10-ldns-compare-zones.tpkg/10-ldns-compare-zones.zone2: -------------------------------------------------------------------------------- 1 | $ORIGIN justazone.example. 2 | 3 | @ SOA @ hostmaster ( 4 | 1 5 | 1800 ; refresh (30 minutes) 6 | 900 ; retry (15 minutes) 7 | 604800 ; expire (1 week) 8 | 86400 ; minimum (1 day) 9 | ) 10 | ; This delegation will grow to 2 records 11 | ; this change was undetected in ldns < 1.7.2 12 | delegation1 NS ns1.delegation1 13 | NS ns2.delegation1 14 | ; delegation2 is not in zone1 15 | delegation2 NS ns1.delegation2 16 | delegation3 NS ns1.delegation3 17 | 18 | delegation5 NS ns1.delegation5 19 | a1 A 192.0.2.1 20 | a2 A 192.0.2.2 21 | a3 A 192.0.2.2 22 | A 198.51.100.1 23 | A 203.0.113.2 24 | shrink3to2 TXT one 25 | TXT two 26 | shrink2to1 TXT one 27 | grow2to3 TXT one 28 | TXT two 29 | TXT three 30 | _added TXT added 31 | -------------------------------------------------------------------------------- /test/12-unit-tests-dnssec.tpkg/12-unit-tests-dnssec.Makefile.in: -------------------------------------------------------------------------------- 1 | # Standard installation pathnames 2 | # See the file LICENSE for the license 3 | SHELL = @SHELL@ 4 | VERSION = @PACKAGE_VERSION@ 5 | basesrcdir = $(shell basename `pwd`) 6 | srcdir = @srcdir@ 7 | prefix = @prefix@ 8 | exec_prefix = @exec_prefix@ 9 | bindir = @bindir@ 10 | mandir = @mandir@ 11 | datarootdir = @datarootdir@ 12 | 13 | CC = @CC@ 14 | CFLAGS = @CFLAGS@ 15 | CPPFLAGS = @CPPFLAGS@ @LIBSSL_CPPFLAGS@ -I../.. 16 | LDFLAGS = @LDFLAGS@ @LIBSSL_LDFLAGS@ -L../../.libs 17 | LIBS = @LIBS@ @LIBSSL_SSL_LIBS@ -lldns 18 | 19 | # Hmmm gcc 4.6.1 expects $(LIBS) as the last argument 20 | 21 | COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) 22 | LINK = $(CC) $(CFLAGS) $(LDFLAGS) 23 | 24 | HEADER = config.h 25 | TESTS = 12-unit-tests-dnssec 26 | 27 | .PHONY: all clean realclean 28 | %.o: 29 | $(COMPILE) -c $(srcdir)/$*.c 30 | 31 | all: $(TESTS) 32 | 33 | 12-unit-tests-dnssec: 12-unit-tests-dnssec.o 34 | $(LINK) -o $@ $+ $(LIBS) 35 | 36 | clean: 37 | rm -f *.o 38 | rm -f $(TESTS) 39 | rm -f lua-rns 40 | 41 | realclean: clean 42 | rm -rf autom4te.cache/ 43 | rm -f config.log config.status aclocal.m4 config.h.in configure Makefile 44 | rm -f config.h 45 | 46 | confclean: clean 47 | rm -rf config.log config.status config.h Makefile 48 | -------------------------------------------------------------------------------- /test/12-unit-tests-dnssec.tpkg/12-unit-tests-dnssec.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 12-unit-tests-dnssec 2 | Version: 1.0 3 | Description: Run unit tests on dnssec.c 4 | CreationDate: Wed Apr 24 15:48:07 CEST 2013 5 | Maintainer: Jelte Jansen 6 | Category: 7 | Component: 8 | CmdDepends: 9 | Depends: 10 | Help: 12-unit-tests-dnssec.help 11 | Pre: 12-unit-tests-dnssec.pre 12 | Post: 13 | Test: 12-unit-tests-dnssec.test 14 | AuxFiles: 12-unit-tests-dnssec.Makefile.in 12-unit-tests-dnssec.configure.ac 12-unit-tests-dnssec.c 15 | Passed: 16 | Failure: 17 | -------------------------------------------------------------------------------- /test/12-unit-tests-dnssec.tpkg/12-unit-tests-dnssec.help: -------------------------------------------------------------------------------- 1 | TODO :p 2 | Please describe how to use this test. 3 | i.e. tpkg -a ARG exe testname: 4 | ARG is used to ... 5 | -------------------------------------------------------------------------------- /test/12-unit-tests-dnssec.tpkg/12-unit-tests-dnssec.pre: -------------------------------------------------------------------------------- 1 | # #-- 10-older-test.pre--# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | conf=`which autoconf` ||\ 10 | conf=`which autoconf-2.59` ||\ 11 | conf=`which autoconf-2.61` ||\ 12 | conf=`which autoconf259` 13 | 14 | hdr=`which autoheader` ||\ 15 | hdr=`which autoheader-2.59` ||\ 16 | hdr=`which autoheader-2.61` ||\ 17 | hdr=`which autoheader259` 18 | 19 | mk=`which gmake` ||\ 20 | mk=`which make` 21 | 22 | echo "autoconf: $conf" 23 | echo "autoheader: $hdr" 24 | echo "make: $mk" 25 | 26 | if [ ! $mk ] || [ ! $conf ] || [ ! $hdr ] ; then 27 | echo "Error, one or more build tools not found, aborting" 28 | exit 1 29 | fi; 30 | 31 | opts=`../../config.status --config` 32 | echo options: $opts 33 | 34 | #$conf 12-unit-tests-dnssec.configure.ac > configure && \ 35 | #chmod +x configure && \ 36 | #$hdr 12-unit-tests-dnssec.configure.ac &&\ 37 | #eval ./configure --with-ldns=../.. "$opts" && \ 38 | ../../config.status --file 12-unit-tests-dnssec.Makefile 39 | $mk -f 12-unit-tests-dnssec.Makefile 40 | 41 | -------------------------------------------------------------------------------- /test/12-unit-tests-dnssec.tpkg/12-unit-tests-dnssec.test: -------------------------------------------------------------------------------- 1 | # #-- 10-older-test.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | #PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | export LD_LIBRARY_PATH="../../.libs:$LD_LIBRARY_PATH" 10 | export DYLD_LIBRARY_PATH="../../.libs:$DYLD_LIBRARY_PATH" 11 | 12 | # run the test 13 | ./12-unit-tests-dnssec 14 | -------------------------------------------------------------------------------- /test/13-unit-tests-base.tpkg/13-unit-tests-base.Makefile.in: -------------------------------------------------------------------------------- 1 | # Standard installation pathnames 2 | # See the file LICENSE for the license 3 | SHELL = @SHELL@ 4 | VERSION = @PACKAGE_VERSION@ 5 | basesrcdir = $(shell basename `pwd`) 6 | srcdir = @srcdir@ 7 | prefix = @prefix@ 8 | exec_prefix = @exec_prefix@ 9 | bindir = @bindir@ 10 | mandir = @mandir@ 11 | datarootdir = @datarootdir@ 12 | 13 | CC = @CC@ 14 | CFLAGS = @CFLAGS@ 15 | CPPFLAGS = @CPPFLAGS@ @LIBSSL_CPPFLAGS@ -I../.. 16 | LDFLAGS = @LDFLAGS@ @LIBSSL_LDFLAGS@ -L../../.libs 17 | LIBS = @LIBS@ @LIBSSL_SSL_LIBS@ -lldns 18 | 19 | COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) 20 | LINK = $(CC) $(CFLAGS) $(LDFLAGS) 21 | 22 | HEADER = config.h 23 | TESTS = 13-unit-tests-base 24 | 25 | .PHONY: all clean realclean 26 | %.o: 27 | $(COMPILE) -c $(srcdir)/$*.c 28 | 29 | all: $(TESTS) 30 | 31 | 13-unit-tests-base: 13-unit-tests-base.o 32 | $(LINK) -o $@ $+ $(LIBS) 33 | 34 | clean: 35 | rm -f *.o 36 | rm -f $(TESTS) 37 | rm -f lua-rns 38 | 39 | realclean: clean 40 | rm -rf autom4te.cache/ 41 | rm -f config.log config.status aclocal.m4 config.h.in configure Makefile 42 | rm -f config.h 43 | 44 | confclean: clean 45 | rm -rf config.log config.status config.h Makefile 46 | -------------------------------------------------------------------------------- /test/13-unit-tests-base.tpkg/13-unit-tests-base.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 13-unit-tests-base 2 | Version: 1.0 3 | Description: Run unit tests on base 32 / 64 converters and sha1/sha2 functions 4 | CreationDate: Wed Mar 15 10:15:57 CET 2006 5 | Maintainer: Jelte Jansen 6 | Category: 7 | Component: 8 | CmdDepends: 9 | Depends: 10 | Help: 13-unit-tests-base.help 11 | Pre: 13-unit-tests-base.pre 12 | Post: 13 | Test: 13-unit-tests-base.test 14 | AuxFiles: 13-unit-tests-base.Makefile.in 13-unit-tests-base.configure.ac 13-unit-tests-base.c 15 | Passed: 16 | Failure: 17 | -------------------------------------------------------------------------------- /test/13-unit-tests-base.tpkg/13-unit-tests-base.help: -------------------------------------------------------------------------------- 1 | TODO :p 2 | Please describe how to use this test. 3 | i.e. tpkg -a ARG exe testname: 4 | ARG is used to ... 5 | -------------------------------------------------------------------------------- /test/13-unit-tests-base.tpkg/13-unit-tests-base.pre: -------------------------------------------------------------------------------- 1 | # #-- 10-older-test.pre--# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | conf=`which autoconf` ||\ 10 | conf=`which autoconf-2.59` ||\ 11 | conf=`which autoconf-2.61` ||\ 12 | conf=`which autoconf259` 13 | 14 | hdr=`which autoheader` ||\ 15 | hdr=`which autoheader-2.59` ||\ 16 | hdr=`which autoheader-2.61` ||\ 17 | hdr=`which autoheader259` 18 | 19 | mk=`which gmake` ||\ 20 | mk=`which make` 21 | 22 | echo "autoconf: $conf" 23 | echo "autoheader: $hdr" 24 | echo "make: $mk" 25 | 26 | opts=`../../config.status --config` 27 | echo options: $opts 28 | 29 | if [ ! $mk ] || [ ! $conf ] || [ ! $hdr ] ; then 30 | echo "Error, one or more build tools not found, aborting" 31 | exit 1 32 | fi; 33 | 34 | #$conf 13-unit-tests-base.configure.ac > configure && \ 35 | #chmod +x configure && \ 36 | #$hdr 13-unit-tests-base.configure.ac &&\ 37 | #eval ./configure --with-ldns=../../ "$opts" && \ 38 | ../../config.status --file 13-unit-tests-base.Makefile 39 | $mk -f 13-unit-tests-base.Makefile 40 | 41 | -------------------------------------------------------------------------------- /test/13-unit-tests-base.tpkg/13-unit-tests-base.test: -------------------------------------------------------------------------------- 1 | # #-- 10-older-test.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | #PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | export LD_LIBRARY_PATH="../../lib:$LD_LIBRARY_PATH" 10 | export DYLD_LIBRARY_PATH="../../lib:$DYLD_LIBRARY_PATH" 11 | 12 | # run the test 13 | ./13-unit-tests-base 14 | exit $? 15 | -------------------------------------------------------------------------------- /test/14-read-zone.tpkg/14-read-zone.db: -------------------------------------------------------------------------------- 1 | ; 2 | ; BIND data file for miek.nl for internal use 3 | ; 4 | $TTL 1H 5 | @ IN SOA elektron.atoom.net. miekg.atoom.net. ( 6 | 2005060700 ; Serial 7 | 6H ; Refresh 8 | 2H ; Retry 9 | 7D ; Expire 10 | 1H ) ; Negative Cache TTL 11 | 12 | @ IN NS elektron.atoom.net. 13 | @ IN MX 10 elektron.atoom.net. 14 | @ IN A 192.168.1.2 15 | 16 | a IN A 192.168.1.2 17 | www IN CNAME a 18 | ; hallo 19 | 20 | 21 | ; 22 | www in A 127.0.0.1 23 | ; bla 24 | -------------------------------------------------------------------------------- /test/14-read-zone.tpkg/14-read-zone.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 14-read-zone 2 | Version: 1.0 3 | Description: read a zone with comment on the last line 4 | CreationDate: Thu Apr 6 10:50:19 CEST 2006 5 | Maintainer: Miek Gieben 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 14-read-zone.help 10 | Pre: 11 | Post: 12 | Test: 14-read-zone.test 13 | AuxFiles: 14-read-zone.db 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/14-read-zone.tpkg/14-read-zone.help: -------------------------------------------------------------------------------- 1 | No arguments are needed 2 | -------------------------------------------------------------------------------- /test/14-read-zone.tpkg/14-read-zone.test: -------------------------------------------------------------------------------- 1 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 2 | 3 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 4 | 5 | LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH \ 6 | ../../examples/ldns-read-zone 14-read-zone.db 7 | 8 | if [[ $? -eq 0 ]]; then 9 | exit 0 10 | else 11 | exit 1 12 | fi 13 | -------------------------------------------------------------------------------- /test/15-unit-tests-rrtypes.tpkg/15-unit-tests-rrtypes.Makefile.in: -------------------------------------------------------------------------------- 1 | # Standard installation pathnames 2 | # See the file LICENSE for the license 3 | SHELL = @SHELL@ 4 | VERSION = @PACKAGE_VERSION@ 5 | basesrcdir = $(shell basename `pwd`) 6 | srcdir = @srcdir@ 7 | prefix = @prefix@ 8 | exec_prefix = @exec_prefix@ 9 | bindir = @bindir@ 10 | mandir = @mandir@ 11 | datarootdir = @datarootdir@ 12 | 13 | CC = @CC@ 14 | CFLAGS = @CFLAGS@ 15 | CPPFLAGS = @CPPFLAGS@ @LIBSSL_CPPFLAGS@ -I../.. 16 | LDFLAGS = @LDFLAGS@ @LIBSSL_LDFLAGS@ -L../../.libs 17 | LIBS = @LIBS@ @LIBSSL_SSL_LIBS@ -lldns 18 | 19 | COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) 20 | LINK = $(CC) $(CFLAGS) $(LDFLAGS) 21 | 22 | HEADER = config.h 23 | TESTS = 15-unit-tests-rrtypes 24 | 25 | .PHONY: all clean realclean 26 | %.o: 27 | $(COMPILE) -c $(srcdir)/$*.c 28 | 29 | all: $(TESTS) 30 | 31 | 15-unit-tests-rrtypes: 15-unit-tests-rrtypes.o 32 | $(LINK) -o $@ $+ $(LIBS) 33 | 34 | clean: 35 | rm -f *.o 36 | rm -f $(TESTS) 37 | rm -f lua-rns 38 | 39 | realclean: clean 40 | rm -rf autom4te.cache/ 41 | rm -f config.log config.status aclocal.m4 config.h.in configure Makefile 42 | rm -f config.h 43 | 44 | confclean: clean 45 | rm -rf config.log config.status config.h Makefile 46 | -------------------------------------------------------------------------------- /test/15-unit-tests-rrtypes.tpkg/15-unit-tests-rrtypes.c: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | 4 | #include "config.h" 5 | 6 | #include 7 | 8 | static int 9 | err(const ldns_rr_descriptor* desc, const char* why) 10 | { 11 | printf("Type %d %s: %s\n", desc->_type, desc->_name, why); 12 | return 0; 13 | } 14 | 15 | static int 16 | check_desc(const ldns_rr_descriptor* desc, ldns_rr_type type) 17 | { 18 | int i; 19 | int dcount = 0; 20 | if(!desc) { 21 | printf("Null!\n"); 22 | return 0; 23 | } 24 | if(ldns_rr_descriptor_minimum(desc) != desc->_minimum) 25 | return err(desc, "minimum wrong"); 26 | if(desc->_variable == LDNS_RDF_TYPE_NONE && 27 | ldns_rr_descriptor_maximum(desc) != desc->_maximum) 28 | return err(desc, "maximum wrong"); 29 | if(desc->_type != type && !(desc->_type == LDNS_RR_TYPE_NULL 30 | && strncmp(desc->_name, "TYPE", 4)==0)) 31 | return err(desc, "type wrong"); 32 | 33 | /* check wireformat desc */ 34 | for(i=0; i_maximum; i++) { 35 | if(desc->_wireformat[i] != 36 | ldns_rr_descriptor_field_type(desc, i)) 37 | return err(desc, "descriptor field bad"); 38 | if(desc->_wireformat[i] == LDNS_RDF_TYPE_DNAME) 39 | dcount++; 40 | } 41 | if(desc->_dname_count != dcount) { 42 | printf("%s counted %d, stored %d\n", 43 | desc->_name, dcount, desc->_dname_count); 44 | return 0; 45 | } 46 | if(dcount == 0 && desc->_compress != LDNS_RR_NO_COMPRESS) 47 | return err(desc, "compression set but no dnames in format"); 48 | return 1; 49 | } 50 | 51 | static int 52 | check_descriptors(void) 53 | { 54 | ldns_rr_type start = LDNS_RR_TYPE_FIRST; 55 | ldns_rr_type end = LDNS_RDATA_FIELD_DESCRIPTORS_COMMON /* 250 */; 56 | ldns_rr_type i; 57 | for(i=start; i configure && \ 35 | #chmod +x configure && \ 36 | #$hdr 15-unit-tests-rrtypes.configure.ac &&\ 37 | #eval ./configure --with-ldns=../../ "$opts" && \ 38 | ../../config.status --file 15-unit-tests-rrtypes.Makefile 39 | $mk -f 15-unit-tests-rrtypes.Makefile 40 | -------------------------------------------------------------------------------- /test/15-unit-tests-rrtypes.tpkg/15-unit-tests-rrtypes.test: -------------------------------------------------------------------------------- 1 | # #-- 10-older-test.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | #PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | export "LD_LIBRARY_PATH=../../.libs:$LD_LIBRARY_PATH" 10 | export "DYLD_LIBRARY_PATH=../../.libs:$DYLD_LIBRARY_PATH" 11 | 12 | # run the test 13 | ./15-unit-tests-rrtypes 14 | exit $? 15 | -------------------------------------------------------------------------------- /test/16-unit-tests-edns.tpkg/16-unit-tests-edns.Makefile.in: -------------------------------------------------------------------------------- 1 | # Standard installation pathnames 2 | # See the file LICENSE for the license 3 | SHELL = @SHELL@ 4 | VERSION = @PACKAGE_VERSION@ 5 | basesrcdir = $(shell basename `pwd`) 6 | srcdir = @srcdir@ 7 | prefix = @prefix@ 8 | exec_prefix = @exec_prefix@ 9 | bindir = @bindir@ 10 | mandir = @mandir@ 11 | datarootdir = @datarootdir@ 12 | 13 | CC = @CC@ 14 | CFLAGS = @CFLAGS@ 15 | CPPFLAGS = @CPPFLAGS@ @LIBSSL_CPPFLAGS@ -I../.. 16 | LDFLAGS = @LDFLAGS@ @LIBSSL_LDFLAGS@ -L../../.libs 17 | LIBS = @LIBS@ @LIBSSL_SSL_LIBS@ -lldns 18 | 19 | COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) 20 | LINK = $(CC) $(CFLAGS) $(LDFLAGS) 21 | 22 | HEADER = config.h 23 | TESTS = 16-unit-tests-edns 24 | 25 | .PHONY: all clean realclean 26 | %.o: 27 | $(COMPILE) -c $(srcdir)/$*.c 28 | 29 | all: $(TESTS) 30 | 31 | 16-unit-tests-edns: 16-unit-tests-edns.o 32 | $(LINK) -o $@ $+ $(LIBS) 33 | 34 | clean: 35 | rm -f *.o 36 | rm -f $(TESTS) 37 | rm -f lua-rns 38 | 39 | realclean: clean 40 | rm -rf autom4te.cache/ 41 | rm -f config.log config.status aclocal.m4 config.h.in configure Makefile 42 | rm -f config.h 43 | 44 | confclean: clean 45 | rm -rf config.log config.status config.h Makefile 46 | -------------------------------------------------------------------------------- /test/16-unit-tests-edns.tpkg/16-unit-tests-edns.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 16-unit-tests-edns 2 | Version: 1.0 3 | Description: Run EDNS unit tests on base 32 / 64 converters and sha1/sha2 functions 4 | CreationDate: Wed Mar 15 10:15:57 CET 2006 5 | Maintainer: Tom Carpay 6 | Category: 7 | Component: 8 | CmdDepends: 9 | Depends: 10 | Help: 11 | Pre: 16-unit-tests-edns.pre 12 | Post: 13 | Test: 16-unit-tests-edns.test 14 | AuxFiles: 16-unit-tests-edns.Makefile.in 16-unit-tests-edns.configure.ac 16-unit-tests-edns.c 15 | Passed: 16 | Failure: 17 | -------------------------------------------------------------------------------- /test/16-unit-tests-edns.tpkg/16-unit-tests-edns.pre: -------------------------------------------------------------------------------- 1 | # #-- 16-unit-tests-edns.pre--# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | conf=`which autoconf` ||\ 10 | conf=`which autoconf-2.59` ||\ 11 | conf=`which autoconf-2.61` ||\ 12 | conf=`which autoconf259` 13 | 14 | hdr=`which autoheader` ||\ 15 | hdr=`which autoheader-2.59` ||\ 16 | hdr=`which autoheader-2.61` ||\ 17 | hdr=`which autoheader259` 18 | 19 | mk=`which gmake` ||\ 20 | mk=`which make` 21 | 22 | echo "autoconf: $conf" 23 | echo "autoheader: $hdr" 24 | echo "make: $mk" 25 | 26 | opts=`../../config.status --config` 27 | echo options: $opts 28 | 29 | if [ ! $mk ] || [ ! $conf ] || [ ! $hdr ] ; then 30 | echo "Error, one or more build tools not found, aborting" 31 | exit 1 32 | fi; 33 | 34 | ssl=`` 35 | if [[ "$OSTYPE" == "darwin"* && -d "/opt/homebrew/Cellar/openssl@1.1" ]]; then 36 | ssl=/opt/homebrew/Cellar/openssl@1.1/1.1.1n/ 37 | fi; 38 | 39 | #$conf 13-unit-tests-base.configure.ac > configure && \ 40 | #chmod +x configure && \ 41 | #$hdr 13-unit-tests-base.configure.ac &&\ 42 | #eval ./configure --with-ldns=../../ with-ssl=$ssl "$opts" && \ 43 | ../../config.status --file 16-unit-tests-edns.Makefile 44 | $mk -f 16-unit-tests-edns.Makefile 45 | 46 | -------------------------------------------------------------------------------- /test/16-unit-tests-edns.tpkg/16-unit-tests-edns.test: -------------------------------------------------------------------------------- 1 | # #-- 16-unit-tests-edns.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | #PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | export LD_LIBRARY_PATH="../../lib:$LD_LIBRARY_PATH" 10 | export DYLD_LIBRARY_PATH="../../lib:$DYLD_LIBRARY_PATH" 11 | 12 | # run the test 13 | ./16-unit-tests-edns 14 | exit $? 15 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-resolv.conf1: -------------------------------------------------------------------------------- 1 | search jelte.nlnetlabs.nl 2 | nameserver 192.168.8.8 3 | nameserver 192.168.8.21 4 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-resolv.conf2: -------------------------------------------------------------------------------- 1 | domain jelte.nlnetlabs.nl 2 | nameserver 192.168.8.8 3 | nameserver 192.168.8.21 4 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-resolv.conf3: -------------------------------------------------------------------------------- 1 | domain jelte.nlnetlabs.nl 2 | search nlnetlabs.nl 3 | search fluim.net 4 | nameserver 192.168.8.8 5 | nameserver 192.168.8.21 6 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-resolv.conf4: -------------------------------------------------------------------------------- 1 | domain jelte.nlnetlabs.nl 2 | search nlnetlabs.nl 3 | search fluim.net 4 | sortlist 192.168.8.0/255.255.255.0 195.169.215.155 5 | nameserver 192.168.8.8 6 | nameserver 192.168.8.21 7 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-resolv.conf5: -------------------------------------------------------------------------------- 1 | domain jelte.nlnetlabs.nl 2 | options debug 3 | nameserver 192.168.8.8 4 | nameserver 192.168.8.21 5 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-resolv.conf6: -------------------------------------------------------------------------------- 1 | domain jelte.nlnetlabs.nl 2 | options rotate attempts inet6 3 | nameserver 192.168.8.8 4 | nameserver 192.168.8.21 5 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-stub-resolver.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 17-stub-resolver 2 | Version: 1.0 3 | Description: try to create stub resolvers from different resolv.conf files 4 | CreationDate: Fri Jun 30 10:05:09 CEST 2006 5 | Maintainer: Jelte Jansen 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 17-stub-resolver.help 10 | Pre: 11 | Post: 12 | Test: 17-stub-resolver.test 13 | AuxFiles: 17-resolv.conf1 17-resolv.conf2 17-resolv.conf3 17-resolv.conf4 17-resolv.conf5 17-resolv.conf6 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-stub-resolver.help: -------------------------------------------------------------------------------- 1 | No arguments are needed 2 | -------------------------------------------------------------------------------- /test/17-stub-resolver.tpkg/17-stub-resolver.test: -------------------------------------------------------------------------------- 1 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 2 | 3 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 4 | 5 | RESULT=0 6 | 7 | echo "17-resolv.conf1:" 8 | cat 17-resolv.conf1 9 | echo "" 10 | 11 | LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH \ 12 | ../../examples/ldns-resolver 17-resolv.conf1 13 | 14 | if [[ $? -ne 0 ]]; then 15 | RESULT=1 16 | fi 17 | 18 | echo "" 19 | echo "17-resolv.conf2:" 20 | cat 17-resolv.conf2 21 | echo "" 22 | 23 | LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH \ 24 | ../../examples/ldns-resolver 17-resolv.conf2 25 | 26 | if [[ $? -ne 0 ]]; then 27 | RESULT=1 28 | fi 29 | 30 | echo "" 31 | echo "17-resolv.conf3:" 32 | cat 17-resolv.conf3 33 | echo "" 34 | 35 | LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH \ 36 | ../../examples/ldns-resolver 17-resolv.conf3 37 | 38 | if [[ $? -ne 0 ]]; then 39 | RESULT=1 40 | fi 41 | 42 | echo "" 43 | echo "17-resolv.conf4:" 44 | cat 17-resolv.conf4 45 | echo "" 46 | 47 | LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH \ 48 | ../../examples/ldns-resolver 17-resolv.conf4 49 | 50 | if [[ $? -ne 0 ]]; then 51 | RESULT=1 52 | fi 53 | 54 | echo "" 55 | echo "17-resolv.conf5:" 56 | cat 17-resolv.conf5 57 | echo "" 58 | 59 | LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH \ 60 | ../../examples/ldns-resolver 17-resolv.conf5 61 | 62 | if [[ $? -ne 0 ]]; then 63 | RESULT=1 64 | fi 65 | 66 | echo "" 67 | echo "17-resolv.conf6:" 68 | cat 17-resolv.conf6 69 | echo "" 70 | 71 | LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH \ 72 | ../../examples/ldns-resolver 17-resolv.conf6 73 | 74 | if [[ $? -ne 0 ]]; then 75 | RESULT=1 76 | fi 77 | 78 | 79 | exit $RESULT 80 | -------------------------------------------------------------------------------- /test/18-drill-tests1.tpkg/18-drill-tests1.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 18-drill-tests1 2 | Version: 1.0 3 | Description: some basic execution tests of drill with ldns-fake-server (print, chase) 4 | CreationDate: Wed Nov 29 16:16:37 CET 2006 5 | Maintainer: Jelte Jansen 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 18-drill-tests1.help 10 | Pre: 11 | Post: 12 | Test: 18-drill-tests1.test 13 | AuxFiles: test1-server-data test1-answer-output test1-drill-output test2-server-data test2-key 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/18-drill-tests1.tpkg/18-drill-tests1.help: -------------------------------------------------------------------------------- 1 | No arguments are needed 2 | -------------------------------------------------------------------------------- /test/18-drill-tests1.tpkg/test1-answer-output: -------------------------------------------------------------------------------- 1 | ;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2 2 | ;; QUESTION SECTION: 3 | ;; www.kanariepiet.com. IN A 4 | 5 | ;; ANSWER SECTION: 6 | www.kanariepiet.com. 68060 IN A 82.94.237.50 7 | 8 | ;; AUTHORITY SECTION: 9 | kanariepiet.com. 68060 IN NS ns2.hexon-is.nl. 10 | kanariepiet.com. 68060 IN NS ns1.hexon-is.nl. 11 | 12 | ;; ADDITIONAL SECTION: 13 | ns1.hexon-is.nl. 24512 IN A 82.94.237.2 14 | ns2.hexon-is.nl. 24512 IN A 212.204.219.91 15 | 16 | ;; MSG SIZE rcvd: 132 17 | -------------------------------------------------------------------------------- /test/18-drill-tests1.tpkg/test1-drill-output: -------------------------------------------------------------------------------- 1 | ;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 23460 2 | ;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2 3 | ;; QUESTION SECTION: 4 | ;; www.kanariepiet.com. IN A 5 | 6 | ;; ANSWER SECTION: 7 | www.kanariepiet.com. 68060 IN A 82.94.237.50 8 | 9 | ;; AUTHORITY SECTION: 10 | kanariepiet.com. 68060 IN NS ns2.hexon-is.nl. 11 | kanariepiet.com. 68060 IN NS ns1.hexon-is.nl. 12 | 13 | ;; ADDITIONAL SECTION: 14 | ns1.hexon-is.nl. 24512 IN A 82.94.237.2 15 | ns2.hexon-is.nl. 24512 IN A 212.204.219.91 16 | 17 | ;; Query time: 0 msec 18 | ;; WHEN: Thu Jan 1 01:00:00 1970 19 | ;; MSG SIZE rcvd: 222 20 | -------------------------------------------------------------------------------- /test/18-drill-tests1.tpkg/test1-server-data: -------------------------------------------------------------------------------- 1 | ENTRY_BEGIN 2 | ADJUST copy_id 3 | HEX_ANSWER_BEGIN 4 | ; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 5 | ;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 6 | 5b a4 81 80 00 01 00 01 00 02 00 02 03 77 77 77 0b 6b 61 6e ; 1- 20 7 | 61 72 69 65 70 69 65 74 03 63 6f 6d 00 00 01 00 01 03 77 77 ; 21- 40 8 | 77 0b 6b 61 6e 61 72 69 65 70 69 65 74 03 63 6f 6d 00 00 01 ; 41- 60 9 | 00 01 00 01 09 dc 00 04 52 5e ed 32 0b 6b 61 6e 61 72 69 65 ; 61- 80 10 | 70 69 65 74 03 63 6f 6d 00 00 02 00 01 00 01 09 dc 00 11 03 ; 81- 100 11 | 6e 73 32 08 68 65 78 6f 6e 2d 69 73 02 6e 6c 00 0b 6b 61 6e ; 101- 120 12 | 61 72 69 65 70 69 65 74 03 63 6f 6d 00 00 02 00 01 00 01 09 ; 121- 140 13 | dc 00 11 03 6e 73 31 08 68 65 78 6f 6e 2d 69 73 02 6e 6c 00 ; 141- 160 14 | 03 6e 73 31 08 68 65 78 6f 6e 2d 69 73 02 6e 6c 00 00 01 00 ; 161- 180 15 | 01 00 00 5f c0 00 04 52 5e ed 02 03 6e 73 32 08 68 65 78 6f ; 181- 200 16 | 6e 2d 69 73 02 6e 6c 00 00 01 00 01 00 00 5f c0 00 04 d4 cc ; 201- 220 17 | db 5b 18 | HEX_ANSWER_END 19 | ENTRY_END 20 | -------------------------------------------------------------------------------- /test/18-drill-tests1.tpkg/test2-key: -------------------------------------------------------------------------------- 1 | test.jelte.nlnetlabs.nl. 3600 IN DNSKEY 256 3 RSASHA1 AQPSu30bsy0UAdRQIN5RqcUBnXDKgOTL+BOiPDZkwilHgX/CafIrBMfwRmWmpxu6dg6gU5xjplHmhRdOkU/Wjh4d41AfJlS/w6Z5dF5jRj5VXVGElhPQVxdZTyhIpZBeNqZw1VZ2+SoLRdRvmEUfAShr+iRurOppRJVBqB5sfLWldw== ; {id = 26552, size = 1024b} 2 | -------------------------------------------------------------------------------- /test/19-keygen.tpkg/19-keygen.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 19-keygen 2 | Version: 1.0 3 | Description: Check the output of the key generator 4 | CreationDate: Mon Dec 10 13:52:06 CET 2007 5 | Maintainer: Jelte Jansen 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 19-keygen.help 10 | Pre: 11 | Post: 12 | Test: 19-keygen.test 13 | AuxFiles: 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/19-keygen.tpkg/19-keygen.help: -------------------------------------------------------------------------------- 1 | No arguments are used for this test. 2 | 3 | The example tool ldns-read-zone is used to read the zone from 4 | 19-keygen-inputzone that contains a number of different RRs. The output 5 | is compared to 19-keygen-outputzone. 6 | 7 | With this test the zone reading functions are checked to see if they have 8 | not regressed. 9 | -------------------------------------------------------------------------------- /test/20-sign-zone.tpkg/20-sign-zone.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 20-sign-zone 2 | Version: 1.0 3 | Description: sign a zone file and verify it 4 | CreationDate: Tue Feb 10 09:40:53 CET 2009 5 | Maintainer: Jelte 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 20-sign-zone.help 10 | Pre: 11 | Post: 12 | Test: 20-sign-zone.test 13 | AuxFiles: 20-sign-zone.db Kjelte.nlnetlabs.nl.+005+09693.key Kjelte.nlnetlabs.nl.+005+09693.private Kjelte.nlnetlabs.nl.+005+51181.key Kjelte.nlnetlabs.nl.+005+51181.private 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/20-sign-zone.tpkg/20-sign-zone.help: -------------------------------------------------------------------------------- 1 | No arguments are needed 2 | -------------------------------------------------------------------------------- /test/20-sign-zone.tpkg/20-sign-zone.test: -------------------------------------------------------------------------------- 1 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 2 | 3 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 4 | 5 | LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH \ 6 | ../../examples/ldns-signzone -b jelte.nlnetlabs.nl Kjelte.nlnetlabs.nl.+005+09693 7 | 8 | if [[ $? -ne 0 ]]; then 9 | echo "Signer failed" 10 | exit 1 11 | fi 12 | 13 | ../../examples/ldns-verify-zone jelte.nlnetlabs.nl.signed 14 | 15 | if [[ $? -ne 0 ]]; then 16 | echo "Verification failed" 17 | exit 2 18 | fi 19 | exit 0 20 | -------------------------------------------------------------------------------- /test/20-sign-zone.tpkg/Kjelte.nlnetlabs.nl.+005+09693.key: -------------------------------------------------------------------------------- 1 | jelte.nlnetlabs.nl. 3600 IN DNSKEY 256 3 5 AwEAAa1rGRf+7OfCNijf7dQqYhtBMe3MH/tzR5m6zURKmuZ1FhT168wGBglcrnFrcbZsCYakpiuWxAFPA7rdB8i2xCwLdLg8zzim4x+ufaUA8bwrEFzqWPCaJ6eoL2T73PEACYOyq2B9CfHHfg3XuShv6al6APka8sPlXFDdKekTvp2j ;{id = 9693 (zsk), size = 1024b} 2 | -------------------------------------------------------------------------------- /test/20-sign-zone.tpkg/Kjelte.nlnetlabs.nl.+005+09693.private: -------------------------------------------------------------------------------- 1 | Private-key-format: v1.2 2 | Algorithm: 5 (RSASHA1) 3 | Modulus: rWsZF/7s58I2KN/t1CpiG0Ex7cwf+3NHmbrNREqa5nUWFPXrzAYGCVyucWtxtmwJhqSmK5bEAU8Dut0HyLbELAt0uDzPOKbjH659pQDxvCsQXOpY8Jonp6gvZPvc8QAJg7KrYH0J8cd+Dde5KG/pqXoA+Rryw+VcUN0p6RO+naM= 4 | PublicExponent: AQAB 5 | PrivateExponent: kyfaN15/MXq/8pdyfSMp9O6xq5QXX4xHKdA19slIAF9Cya6U1KAX50HaVSxTZfTvcG2vBDX/RQ0DoUGGJW/RrhgKv+awrWHJWmVQGgBPeDAQ3FQwI7augLcI+qXM+S2bmTRx4vv0+aw478U3kA5McrZZ1aXHpkpP++z7Q/Q8W4E= 6 | Prime1: 4INzM4AMUOZSnesIOkqNWiIoFhMgvt/hpAMkaiCjhNSGc93dVr2C7S6NDC0A22BSIdv94R/CurNT09UsPpN8cw== 7 | Prime2: xb03LtU4vC/lpxJLF70Jg1BKypqDdxoTEaALsSHIc6dqNwlbrnJWpvZYkhBywMy6q8/bUUIlmPazXESolJK+EQ== 8 | Exponent1: Iwgfx59pTI5DweRUilPrrm659ofRijcAzEi5O94P5cALorSxvsEfVsb2tzmmcpSa/DGJccE071Df+aO/nZwBxQ== 9 | Exponent2: XJt6Tae0c4YnEvDhVFPHMcWX0X091rjSd22yLBn7TBb7Cp2KX4/S/0zePEIRzDPVtQOa3lqRSys24x6QqUx0UQ== 10 | Coefficient: X8UoYtwkSmc4hcVoXc9y03IFo6Rf8xu4zEL5zQfWk6zGlJHuZFezjYqcQa+K9im/U/5IcdAP/RnYfzLh8H9G1w== 11 | -------------------------------------------------------------------------------- /test/20-sign-zone.tpkg/Kjelte.nlnetlabs.nl.+005+51181.key: -------------------------------------------------------------------------------- 1 | jelte.nlnetlabs.nl. 3600 IN DNSKEY 257 3 5 AwEAAbJmmaN7pQw30zL2TsdhQ+Vl8fxzDrKT/3aquftoHBUgkjHuVdRMr03nMTjxBpWodDrvG/GYG46L2Nws3Ykcdfxglhx60coN+rq7vimJl9E60CYT83xugT1lvoBzGxm6yPzFKb4NT015GwrkqqC1XJA1FmN09SXAPRwI6yk7Ru7ODjBeSRZ3LyVsBL6gMO902FSw8mWKyZZONxxzuyC0WepODghU5qVbHs8/WVdJc4CjKoM3OnRpAxposrhxSmDsavbi7+kR1Cd3wyQEDTY8STaJzEiwfasO2gJJL/FZzsjoHrOf6qYruZyPTBhApmygqSu+aDAlsRRFDEMuU44ZuTU= ;{id = 51181 (ksk), size = 2048b} 2 | -------------------------------------------------------------------------------- /test/20-sign-zone.tpkg/Kjelte.nlnetlabs.nl.+005+51181.private: -------------------------------------------------------------------------------- 1 | Private-key-format: v1.2 2 | Algorithm: 5 (RSASHA1) 3 | Modulus: smaZo3ulDDfTMvZOx2FD5WXx/HMOspP/dqq5+2gcFSCSMe5V1EyvTecxOPEGlah0Ou8b8ZgbjovY3CzdiRx1/GCWHHrRyg36uru+KYmX0TrQJhPzfG6BPWW+gHMbGbrI/MUpvg1PTXkbCuSqoLVckDUWY3T1JcA9HAjrKTtG7s4OMF5JFncvJWwEvqAw73TYVLDyZYrJlk43HHO7ILRZ6k4OCFTmpVsezz9ZV0lzgKMqgzc6dGkDGmiyuHFKYOxq9uLv6RHUJ3fDJAQNNjxJNonMSLB9qw7aAkkv8VnOyOges5/qpiu5nI9MGECmbKCpK75oMCWxFEUMQy5Tjhm5NQ== 4 | PublicExponent: AQAB 5 | PrivateExponent: ln5QuwWR7KWnJ0V6nVzivsBqCzEwQ9rvVTaeX4OqtPPd//rzMn1iINCXyFYi3NrW+eQ9aWeMT4qPbOT4GTMGINmFqA6/rLhwO1gnCblFdb4sWwLXkq9RnO6YbpkrUmAsLndQSD/IFy3Db0QI4Ds+E3SFJ29BYhAyPNUVM5oKs2V9FShbSs0jrBR1Pb9GdCUHiyNheVIaRmpwmhzyyO/Govhy60rN0KildQBG5yOR+gUM0O/ZgLBhzBjgnvocFj6qW1wZsxJSrRweXQ7ISLDabDr81A0rIahCKhph0I4S45W+g+cnFCL0DjwgQ9zBMvbT6EstIIcGaFDSoeTrUHSpAQ== 6 | Prime1: 2kR0TxB0zidXQnvwQ3Itl+fH62x5JdlhREfrvu1tZ55dZlGxCXRw75x9AwOltIYTv6EusXAqLO+gCnP+mS4WPTsm+A5mpneNUVusj9DYG71j01Tp0wVQ+shH3N7QKhYZJ/q8gKRyu9kKpveQA3Rc/Nzo0zjolFi7MvrBKKnSgkE= 7 | Prime2: 0T3Tja6G5M8zZv77Rmv58jEGETU0BMhdRsByKW6bFLd5le2+s8OXCHTCdULxvhK0K8OTO2ki7Q7v68k+g8yMhba0DxW402v9vz3a7ln9gi8kFmqQRnm8Wp6s6iFqiIOOLWDUqBeBLHii/JlOdZnXuL2LtqGZwYcVIG/w5YBM0fU= 8 | Exponent1: Ga80gJlPJXM7sXckLsug0d9Uhz+cgfeymnZcJ3uJBEh+dSvnyVUKdSfVDiW/uh6M9F/jPr4UOHV6P8CmlR/3Pf1X+Ji5O52V450GEWZiB+GhfZzgZxSZEum+ix8tH8a57xpyVDEFz1UbC8rWB5IJ3zefrjtkIxDN9pHLaR2SyAE= 9 | Exponent2: SliDcJYQjAArLW9v7Me02Z8dnsOepgxjSB5c8efA5o2CgAknd0wJwBFsfqm4p2aR6fLlv3hN1pk2Gjs5IS9uxpvyQmHfeA+o62iY/5OuBbGmSui2NrROfoxeuBoDdln4DJuZM9iWJyz+DG6UeCifg56lo9Crhx3uHcZoe8MoiHk= 10 | Coefficient: DH+bYSWwL1ggJHjI6a01ZvWANob3bf3Rbg5umrY7oHFpF3dWgau8rGwi0dxbDqMQOJzx3s9z0r0ZZ8KJr91Xs0c+1NhE2l/eL1j+gqMMDTTJUr9T39cZ/9BzHo81ineV5RlDuQ7P24ISvjYFUj/7zQIWPY7ach1uA0Oh8XW+p1A= 11 | -------------------------------------------------------------------------------- /test/20-sign-zone.tpkg/jelte.nlnetlabs.nl: -------------------------------------------------------------------------------- 1 | ; loosely based on jelte.nlnetlabs.nl. 2 | 3 | jelte.nlnetlabs.nl. 3600 IN SOA ns.jelte.nlnetlabs.nl. jelte.jelte.nlnetlabs.nl. 808 28800 7200 604800 3600 4 | jelte.nlnetlabs.nl. 3600 IN NS ns.jelte.nlnetlabs.nl. 5 | jelte.nlnetlabs.nl. 3600 IN NS ext.ns.whyscream.net. 6 | jelte.nlnetlabs.nl. 3600 IN NS ns-ext.nlnetlabs.nl. 7 | jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 8 | jelte.nlnetlabs.nl. 60 IN MX 10 smtp.jelte.nlnetlabs.nl. 9 | jelte.nlnetlabs.nl. 3600 IN AAAA 2a02:348:55:5250::80 10 | jelte.nlnetlabs.nl. 0 IN TYPE65534 \# 5 0846480001 11 | dnssec.jelte.nlnetlabs.nl. 3600 IN NS ns2.jelte.nlnetlabs.nl. 12 | dnssec.jelte.nlnetlabs.nl. 3600 IN DS 8340 5 1 5733A59841EA708AE9223822124B07B555E17332 13 | dragon.jelte.nlnetlabs.nl. 1234 IN AAAA 2002:c3a9:dd9d:8:219:d1ff:fe81:5c10 14 | git.jelte.nlnetlabs.nl. 3600 IN AAAA 2a02:348:55:5250::80 15 | git.jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 16 | imap.jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 17 | nepmail.jelte.nlnetlabs.nl. 3600 IN MX 10 mirre.nlnetlabs.nl. 18 | ns.jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 19 | ns.jelte.nlnetlabs.nl. 3600 IN AAAA 2a02:348:55:5250::53 20 | ns-ext.jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 21 | ns2.jelte.nlnetlabs.nl. 3600 IN A 195.169.221.157 22 | ns2.jelte.nlnetlabs.nl. 3600 IN AAAA 2002:c3a9:dd9d:1::1 23 | nsec3.jelte.nlnetlabs.nl. 3600 IN NS ns2.jelte.nlnetlabs.nl. 24 | nsec3.jelte.nlnetlabs.nl. 3600 IN DS 21665 7 1 8D5E7DEDC1501A38009882DD1508246EB4A2251C 25 | smtp.jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 26 | svn.jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 27 | talon.jelte.nlnetlabs.nl. 3600 IN A 195.169.221.157 28 | v6.jelte.nlnetlabs.nl. 3600 IN AAAA 2002:c3a9:dd9d:1::1 29 | vps.jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 30 | vpsv6.jelte.nlnetlabs.nl. 3600 IN AAAA 2a02:348:55:5250::1 31 | www.jelte.nlnetlabs.nl. 3600 IN A 178.18.82.80 32 | www.jelte.nlnetlabs.nl. 3600 IN AAAA 2a02:348:55:5250::80 33 | wwwv6.jelte.nlnetlabs.nl. 3600 IN AAAA 2a02:348:55:5250::80 34 | 35 | -------------------------------------------------------------------------------- /test/25-ZONEMD.tpkg/25-ZONEMD.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 25-ZONEMD 2 | Version: 1.0 3 | Description: Check ldns-verify-zone on RFC8976 Appendix A example zones 4 | CreationDate: Wed Jan 20 16:41:56 CET 2021 5 | Maintainer: Willem 6 | Category: 7 | Component: 8 | Depends: 9 | Help: 25-ZONEMD.help 10 | Pre: 11 | Post: 12 | Test: 25-ZONEMD.test 13 | AuxFiles: A.1.Simple-EXAMPLE-Zone A.2.Complex-EXAMPLE-Zone A.3.EXAMPLE-Zone-with-multiple-digests A.4.The-URI.ARPA-Zone A.5.The-ROOT-SERVERS.NET-Zone repeated-ZONEMD-scheme-and-algorithm 14 | Passed: 15 | Failure: 16 | -------------------------------------------------------------------------------- /test/25-ZONEMD.tpkg/25-ZONEMD.help: -------------------------------------------------------------------------------- 1 | No arguments are needed 2 | -------------------------------------------------------------------------------- /test/25-ZONEMD.tpkg/25-ZONEMD.test: -------------------------------------------------------------------------------- 1 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 2 | 3 | export LD_LIBRARY_PATH="../../lib:${LD_LIBRARY_PATH}" 4 | 5 | # These must succeed 6 | # 7 | for ZONE in A.1.Simple-EXAMPLE-Zone \ 8 | A.2.Complex-EXAMPLE-Zone \ 9 | A.3.EXAMPLE-Zone-with-multiple-digests \ 10 | A.4.The-URI.ARPA-Zone \ 11 | A.5.The-ROOT-SERVERS.NET-Zone 12 | do 13 | echo Verifying ${ZONE} 14 | if [ "${ZONE}" = "A.4.The-URI.ARPA-Zone" ] 15 | then 16 | # Allow DNSSEC to fail (ZONEMD has no signature) 17 | # 18 | ../../examples/ldns-verify-zone -ZZZV 4 -t 20181021203928 ${ZONE} 19 | else 20 | ../../examples/ldns-verify-zone -ZV 4 ${ZONE} 21 | fi 22 | if [[ $? -ne 0 ]]; then 23 | echo "ZONE ${ZONE} failed" 24 | exit 1 25 | fi 26 | done 27 | 28 | # These must fail 29 | # 30 | for ZONE in repeated-ZONEMD-scheme-and-algorithm 31 | do 32 | echo Verifying ${ZONE} 33 | ../../examples/ldns-verify-zone -ZV 4 ${ZONE} 34 | 35 | if [[ $? -eq 0 ]]; then 36 | echo "ZONE ${ZONE} validated (which it should not)" 37 | exit 1 38 | fi 39 | done 40 | 41 | 42 | exit 0 43 | -------------------------------------------------------------------------------- /test/25-ZONEMD.tpkg/A.1.Simple-EXAMPLE-Zone: -------------------------------------------------------------------------------- 1 | example. 86400 IN SOA ns1 admin 2018031900 ( 2 | 1800 900 604800 86400 ) 3 | 86400 IN NS ns1 4 | 86400 IN NS ns2 5 | 86400 IN ZONEMD 2018031900 1 1 ( 6 | c68090d90a7aed71 7 | 6bc459f9340e3d7c 8 | 1370d4d24b7e2fc3 9 | a1ddc0b9a87153b9 10 | a9713b3c9ae5cc27 11 | 777f98b8e730044c ) 12 | ns1 3600 IN A 203.0.113.63 13 | ns2 3600 IN AAAA 2001:db8::63 14 | -------------------------------------------------------------------------------- /test/25-ZONEMD.tpkg/A.2.Complex-EXAMPLE-Zone: -------------------------------------------------------------------------------- 1 | example. 86400 IN SOA ns1 admin 2018031900 ( 2 | 1800 900 604800 86400 ) 3 | 86400 IN NS ns1 4 | 86400 IN NS ns2 5 | 86400 IN ZONEMD 2018031900 1 1 ( 6 | 31cefb03814f5062 7 | ad12fa951ba0ef5f 8 | 8da6ae354a415767 9 | 246f7dc932ceb1e7 10 | 42a2108f529db6a3 11 | 3a11c01493de358d ) 12 | ns1 3600 IN A 203.0.113.63 13 | ns2 3600 IN AAAA 2001:db8::63 14 | occluded.sub 7200 IN TXT "I'm occluded but must be digested" 15 | sub 7200 IN NS ns1 16 | duplicate 300 IN TXT "I must be digested just once" 17 | duplicate 300 IN TXT "I must be digested just once" 18 | foo.test. 555 IN TXT "out-of-zone data must be excluded" 19 | non-apex 900 IN ZONEMD 2018031900 1 1 ( 20 | 616c6c6f77656420 21 | 6275742069676e6f 22 | 7265642e20616c6c 23 | 6f77656420627574 24 | 2069676e6f726564 25 | 2e20616c6c6f7765 ) 26 | -------------------------------------------------------------------------------- /test/25-ZONEMD.tpkg/A.3.EXAMPLE-Zone-with-multiple-digests: -------------------------------------------------------------------------------- 1 | example. 86400 IN SOA ns1 admin 2018031900 ( 2 | 1800 900 604800 86400 ) 3 | example. 86400 IN NS ns1.example. 4 | example. 86400 IN NS ns2.example. 5 | example. 86400 IN ZONEMD 2018031900 1 1 ( 6 | 62e6cf51b02e54b9 7 | b5f967d547ce4313 8 | 6792901f9f88e637 9 | 493daaf401c92c27 10 | 9dd10f0edb1c56f8 11 | 080211f8480ee306 ) 12 | example. 86400 IN ZONEMD 2018031900 1 2 ( 13 | 08cfa1115c7b948c 14 | 4163a901270395ea 15 | 226a930cd2cbcf2f 16 | a9a5e6eb85f37c8a 17 | 4e114d884e66f176 18 | eab121cb02db7d65 19 | 2e0cc4827e7a3204 20 | f166b47e5613fd27 ) 21 | example. 86400 IN ZONEMD 2018031900 1 240 ( 22 | e2d523f654b9422a 23 | 96c5a8f44607bbee ) 24 | example. 86400 IN ZONEMD 2018031900 241 1 ( 25 | e1846540e33a9e41 26 | 89792d18d5d131f6 27 | 05fc283e ) 28 | ns1.example. 3600 IN A 203.0.113.63 29 | ns2.example. 86400 IN TXT "This example has multiple digests" 30 | ns2.example. 3600 IN AAAA 2001:db8::63 31 | -------------------------------------------------------------------------------- /test/25-ZONEMD.tpkg/repeated-ZONEMD-scheme-and-algorithm: -------------------------------------------------------------------------------- 1 | example. 86400 IN NS ns.example. 2 | example. 86400 IN SOA ns.example. admin.example. 2018031900 1800 900 604800 86400 3 | example. 86400 IN ZONEMD 2018031900 1 1 8ee54f64ce0d57fd70e1a4811a9ca9e849e2e50cb5 ( 4 | 98edf3ba9c2a58625335c1f966835f0d4338d9f78f 5 | 557227d63bf6 ) 6 | ZONEMD 2018031900 1 1 000000000000000000000000000000000000000000 ( 7 | 000000000000000000000000000000000000000000 8 | 000000000000 ) 9 | ns.example. 3600 IN A 127.0.0.1 10 | -------------------------------------------------------------------------------- /test/26-loc-centimetre.tpkg/26-loc-centimetre.db: -------------------------------------------------------------------------------- 1 | one 12345 IN LOC 12 45 52.333 N 105 40 33.452 W -24m 0.1m 0.1m 0.1m 2 | -------------------------------------------------------------------------------- /test/26-loc-centimetre.tpkg/26-loc-centimetre.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 26-loc-centimetre 2 | Version: 1.0 3 | Description: Verify parsing of centimetres in LOC records. 4 | CreationDate: di 7 sep 2021 10:58:42 CEST 5 | Maintainer: 6 | Category: 7 | Component: 8 | CmdDepends: 9 | Depends: 10 | Help: 26-loc-centimetre.help 11 | Pre: 12 | Post: 13 | Test: 26-loc-centimetre.test 14 | AuxFiles: 15 | Passed: 16 | Failure: 17 | -------------------------------------------------------------------------------- /test/26-loc-centimetre.tpkg/26-loc-centimetre.help: -------------------------------------------------------------------------------- 1 | This requires no arguments. 2 | -------------------------------------------------------------------------------- /test/26-loc-centimetre.tpkg/26-loc-centimetre.test: -------------------------------------------------------------------------------- 1 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 2 | 3 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 4 | 5 | export LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH 6 | 7 | OUTPUT=`../../examples/ldns-read-zone 26-loc-centimetre.db` 8 | 9 | if [[ $? -eq 0 ]]; then 10 | echo $OUTPUT | grep 0.10m 11 | else 12 | exit 1 13 | fi 14 | -------------------------------------------------------------------------------- /test/27-tab-between-cstrings.tpkg/27-tab-between-cstrings.db: -------------------------------------------------------------------------------- 1 | foo 12345 IN HINFO "hohum" "weirdo" 2 | -------------------------------------------------------------------------------- /test/27-tab-between-cstrings.tpkg/27-tab-between-cstrings.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 27-tab-between-cstrings 2 | Version: 1.0 3 | Description: Check for GH 147 regression 4 | CreationDate: Thu Dec 9 12:04:34 EST 2021 5 | Maintainer: 6 | Category: 7 | Component: 8 | CmdDepends: 9 | Depends: 10 | Help: 27-tab-between-cstrings.help 11 | Pre: 12 | Post: 13 | Test: 27-tab-between-cstrings.test 14 | AuxFiles: 15 | Passed: 16 | Failure: 17 | -------------------------------------------------------------------------------- /test/27-tab-between-cstrings.tpkg/27-tab-between-cstrings.help: -------------------------------------------------------------------------------- 1 | This requires no arguments. 2 | -------------------------------------------------------------------------------- /test/27-tab-between-cstrings.tpkg/27-tab-between-cstrings.test: -------------------------------------------------------------------------------- 1 | # #-- 27-tab-between-cstrings.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | 5 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 6 | 7 | export LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH 8 | 9 | OUTPUT=`../../examples/ldns-read-zone 27-tab-between-cstrings.db` 10 | 11 | if [[ $? -eq 0 ]]; then 12 | echo $OUTPUT | grep weirdo 13 | else 14 | exit 1 15 | fi 16 | -------------------------------------------------------------------------------- /test/28-tab-instead-of-space.tpkg/28-tab-instead-of-space.db: -------------------------------------------------------------------------------- 1 | com. 14400 IN NAPTR 100 10 S SIP+D2U "!^.*$!sip:customer-service@example.com!" com. 2 | -------------------------------------------------------------------------------- /test/28-tab-instead-of-space.tpkg/28-tab-instead-of-space.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 28-tab-instead-of-space 2 | Version: 1.0 3 | Description: Check for GH 157 regression 4 | CreationDate: Tue Mar 15 21:01:34 EST 2022 5 | Maintainer: 6 | Category: 7 | Component: 8 | CmdDepends: 9 | Depends: 10 | Help: 28-tab-instead-of-space.help 11 | Pre: 12 | Post: 13 | Test: 28-tab-instead-of-space.test 14 | AuxFiles: 15 | Passed: 16 | Failure: 17 | -------------------------------------------------------------------------------- /test/28-tab-instead-of-space.tpkg/28-tab-instead-of-space.help: -------------------------------------------------------------------------------- 1 | This requires no arguments. 2 | -------------------------------------------------------------------------------- /test/28-tab-instead-of-space.tpkg/28-tab-instead-of-space.test: -------------------------------------------------------------------------------- 1 | # #-- 28-tab-instead-of-space.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | 5 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 6 | 7 | export LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH 8 | 9 | OUTPUT=`../../examples/ldns-read-zone 28-tab-instead-of-space.db` 10 | 11 | if [[ $? -eq 0 ]]; then 12 | echo $OUTPUT | grep customer-service 13 | else 14 | exit 1 15 | fi 16 | -------------------------------------------------------------------------------- /test/29-generic-rdata-tab.tpkg/29-generic-rdata-tab.db: -------------------------------------------------------------------------------- 1 | a.example. CLASS32 TYPE731 \# 6 abcd ( 2 | ef 01 23 45 ) 3 | -------------------------------------------------------------------------------- /test/29-generic-rdata-tab.tpkg/29-generic-rdata-tab.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 29-generic-rdata-tab 2 | Version: 1.0 3 | Description: Check for GH 157 regression 4 | CreationDate: Tue Mar 15 21:01:34 EST 2022 5 | Maintainer: 6 | Category: 7 | Component: 8 | CmdDepends: 9 | Depends: 10 | Help: 29-generic-rdata-tab.help 11 | Pre: 12 | Post: 13 | Test: 29-generic-rdata-tab.test 14 | AuxFiles: 15 | Passed: 16 | Failure: 17 | -------------------------------------------------------------------------------- /test/29-generic-rdata-tab.tpkg/29-generic-rdata-tab.help: -------------------------------------------------------------------------------- 1 | This requires no arguments. 2 | -------------------------------------------------------------------------------- /test/29-generic-rdata-tab.tpkg/29-generic-rdata-tab.test: -------------------------------------------------------------------------------- 1 | # #-- 29-generic-rdata-tab.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | 5 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 6 | 7 | export LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH 8 | 9 | OUTPUT=`../../examples/ldns-read-zone 29-generic-rdata-tab.db` 10 | 11 | if [[ $? -eq 0 ]]; then 12 | echo $OUTPUT | grep CLASS32 13 | else 14 | exit 1 15 | fi 16 | -------------------------------------------------------------------------------- /test/30-load-pyldns.tpkg/30-load-pyldns.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 30-load-pyldns 2 | Version: 1.0 3 | Description: Import pyldns module 4 | CreationDate: Mon Nov 12 14:53:29 CET 2012 5 | Maintainer: Willem Toorop 6 | Category: 7 | Component: 8 | Depends: 9 | Pre: 10 | Post: 11 | Test: 30-load-pyldns.test 12 | AuxFiles: 13 | Passed: 14 | Failure: 15 | -------------------------------------------------------------------------------- /test/30-load-pyldns.tpkg/30-load-pyldns.help: -------------------------------------------------------------------------------- 1 | Synopsis: tpkg -a ../../ exe 30-load-pyldns.tpkg 2 | -a path: path is where the source lives 3 | as the test is executed in it own subsdir it will 4 | need ../../ is you use a relative path 5 | -------------------------------------------------------------------------------- /test/30-load-pyldns.tpkg/30-load-pyldns.test: -------------------------------------------------------------------------------- 1 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 2 | 3 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 4 | 5 | # first arg is the build dir 6 | TPKG_BUILD=$1 7 | 8 | LD_LIBRARY_PATH=$TPKG_BUILD/.libs PYTHONPATH=$TPKG_BUILD/python-site python -c "import ldns" 9 | 10 | -------------------------------------------------------------------------------- /test/31-load-pyldnsx.tpkg/31-load-pyldnsx.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 31-load-pyldnsx 2 | Version: 1.0 3 | Description: Import pyldnsx module 4 | CreationDate: Mon Nov 12 14:56:43 CET 2012 5 | Maintainer: Willem Toorop 6 | Category: 7 | Component: 8 | Depends: 9 | Pre: 10 | Post: 11 | Test: 31-load-pyldnsx.test 12 | AuxFiles: 13 | Passed: 14 | Failure: 15 | -------------------------------------------------------------------------------- /test/31-load-pyldnsx.tpkg/31-load-pyldnsx.help: -------------------------------------------------------------------------------- 1 | Synopsis: tpkg -a ../../ exe 31-load-pyldnsx.tpkg 2 | -a path: path is where the source lives 3 | as the test is executed in it own subsdir it will 4 | need ../../ is you use a relative path 5 | -------------------------------------------------------------------------------- /test/31-load-pyldnsx.tpkg/31-load-pyldnsx.test: -------------------------------------------------------------------------------- 1 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 2 | 3 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 4 | 5 | # first arg is the build dir 6 | TPKG_BUILD=$1 7 | 8 | LD_LIBRARY_PATH=$TPKG_BUILD/.libs PYTHONPATH=$TPKG_BUILD/python-site python -c "import ldnsx" 9 | 10 | -------------------------------------------------------------------------------- /test/32-unbound-regression.tpkg/32-unbound-regression.clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -fr `ls -1a|grep -v ^32-|grep -v '^\.$'|grep -v '^\.\.$'` 4 | 5 | -------------------------------------------------------------------------------- /test/32-unbound-regression.tpkg/32-unbound-regression.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 32-unbound-regression 2 | Version: 1.0 3 | Description: Test unbound compiled against previous ldns with this version 4 | CreationDate: Tue Jun 18 15:45:35 CEST 2013 5 | Maintainer: Willem Toorop 6 | Category: 7 | Component: 8 | Depends: 9 | Pre: 10 | Post: 11 | Test: 32-unbound-regression.test 12 | AuxFiles: 13 | Passed: 14 | Failure: 15 | -------------------------------------------------------------------------------- /test/32-unbound-regression.tpkg/32-unbound-regression.help: -------------------------------------------------------------------------------- 1 | Synopsis: tpkg -a ../../ exe 32-unbound-regression.tpkg 2 | -a path: path is where the source lives 3 | as the test is executed in it own subsdir it will 4 | need ../../ is you use a relative path 5 | -------------------------------------------------------------------------------- /test/60-compile-builddir.tpkg/60-compile-builddir.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 60-compile-builddir 2 | Version: 1.0 3 | Description: compile ldns in a separate build directory 4 | CreationDate: ma 4 jun 2018 12:58:05 CEST 5 | Maintainer: Jelte Jansen 6 | Category: 7 | Component: 8 | Depends: 9 | Pre: 10 | Post: 11 | Test: 60-compile-builddir.test 12 | AuxFiles: 13 | Passed: 14 | Failure: 15 | -------------------------------------------------------------------------------- /test/60-compile-builddir.tpkg/60-compile-builddir.help: -------------------------------------------------------------------------------- 1 | Synopsis: tpkg -a ../../ exe 60-compile-builddir.tpkg 2 | -a path: path is where the source lives 3 | as the test is executed in it own subsdir it will 4 | need ../../ is you use a relative path 5 | -------------------------------------------------------------------------------- /test/999-compile-nossl.tpkg/999-compile-nossl.dsc: -------------------------------------------------------------------------------- 1 | BaseName: 999-compile-nossl 2 | Version: 1.0 3 | Description: compile ldns without openssl 4 | CreationDate: Wed Jan 11 11:51:50 CET 2006 5 | Maintainer: Miek Gieben 6 | Category: 7 | Component: 8 | Depends: 9 | Pre: 10 | Post: 11 | Test: 999-compile-nossl.test 12 | AuxFiles: 13 | Passed: 14 | Failure: 15 | -------------------------------------------------------------------------------- /test/999-compile-nossl.tpkg/999-compile-nossl.help: -------------------------------------------------------------------------------- 1 | Synopsis: tpkg -a ../../ exe 01-compile.tpkg 2 | -a path: path is where the source lives 3 | as the test is executed in it own subsdir it will 4 | need ../../ is you use a relative path 5 | -------------------------------------------------------------------------------- /test/999-compile-nossl.tpkg/999-compile-nossl.test: -------------------------------------------------------------------------------- 1 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 2 | 3 | export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 4 | 5 | # first arg is the build dir 6 | TPKG_BUILD=$1 7 | 8 | cd $TPKG_BUILD 9 | ORIGDIR=`pwd` 10 | 11 | case $OSTYPE in 12 | linux*) 13 | TMP=`mktemp -d` 14 | libtoolize && autoreconf && \ 15 | cd $TMP && \ 16 | $ORIGDIR/configure --without-ssl && \ 17 | make 18 | ;; 19 | freebsd*) 20 | TMP=`mktemp -t /tmp -d` 21 | libtoolize && \ 22 | autoconf259 && autoheader259 && \ 23 | cd $TMP && \ 24 | $ORIGDIR//configure --without-ssl && \ 25 | gmake 26 | ;; 27 | darwin*) 28 | TMP=`mktemp -d` 29 | glibtoolize && \ 30 | autoconf && autoheader && \ 31 | export MACOSX_DEPLOYMENT_TARGET=10.4 && \ 32 | cd $TMP && \ 33 | $ORIGDIR//configure --without-ssl && \ 34 | make 35 | ;; 36 | esac 37 | 38 | cd $ORIGDIR 39 | RES=$? 40 | echo "DIR:" 41 | echo $TMP 42 | rm -rf $TMP 43 | exit $RES 44 | -------------------------------------------------------------------------------- /test/codingstyle.tpkg/codingstyle.dsc: -------------------------------------------------------------------------------- 1 | BaseName: codingstyle 2 | Version: 1.0 3 | Description: Check LDNS CodingStyle 4 | CreationDate: Tue Mar 14 12:58:28 CET 2006 5 | Maintainer: Miek Gieben 6 | Category: 7 | Component: 8 | CmdDepends: 9 | Depends: 10 | Help: codingstyle.help 11 | Pre: 12 | Post: 13 | Test: codingstyle.test 14 | AuxFiles: 15 | Passed: 16 | Failure: 17 | -------------------------------------------------------------------------------- /test/codingstyle.tpkg/codingstyle.help: -------------------------------------------------------------------------------- 1 | No arguments are used for this test 2 | -------------------------------------------------------------------------------- /test/codingstyle.tpkg/codingstyle.test: -------------------------------------------------------------------------------- 1 | # #-- codingstyle.test --# 2 | # source the master var file when it's there 3 | [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4 | # use .tpkg.var.test for in test variable passing 5 | [ -f .tpkg.var.test ] && source .tpkg.var.test 6 | # svnserve resets the path, you may need to adjust it, like this: 7 | PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. 8 | 9 | L=90 10 | OPT="-ncs -sai -nut -ce -nfca -nlp -ncdb -br -ts08 -i8 -nbad" 11 | 12 | LC_OSTYPE=$(echo $OSTYPE | tr 'A-Z' 'a-z') 13 | 14 | st=0 15 | for i in ../../*.c; do 16 | 17 | case $i in 18 | "../../util.c" | "../../host2str.c" | "../../resolver.c") 19 | continue;; 20 | "../../error.c" | "../../rr.c" | "../../str2host.c") 21 | continue;; 22 | "../../keys.c" | "../../linktest.c" | "../../dnssec.c") 23 | continue;; 24 | "../../packet.c" | "../../parse.c") 25 | continue;; 26 | esac 27 | 28 | case $LC_OSTYPE in 29 | linux*) 30 | diff -w -u $i <(cat $i | indent -l$L $OPT) | grep ^--- 31 | ;; 32 | *bsd*) 33 | diff -w -u $i <(cat $i | gindent -l$L $OPT)| grep ^--- 34 | ;; 35 | darwin*) 36 | echo "Warning: Codingstyle not checked on osx" 37 | exit 0 38 | ;; 39 | solaris*) 40 | echo "Warning: Codingstyle not checked on solaris" 41 | exit 0 42 | ;; 43 | esac 44 | 45 | if [[ $? -eq 1 ]]; then 46 | st=1 47 | fi 48 | done 49 | if [[ $st -eq 0 ]]; then 50 | exit 1 51 | fi 52 | exit 0 53 | -------------------------------------------------------------------------------- /test/f: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # get all the functions from ldns 4 | 5 | FILES="buffer.h error.h host2str.h keys.h packet.h rdata.h rr_functions.h str2host.h update.h wire2host.h 6 | common.h dname.h dnssec.h higher.h host2wire.h net.h parse.h resolver.h 7 | rr.h tsig.h util.h zone.h" 8 | 9 | # we need two grep ldns_ ... 10 | for i in $FILES; do 11 | cpp -I.. "../ldns/$i" | grep -E '.*? .*?\(.*' | grep ldns_ | \ 12 | awk '{ print $2 }' | sed 's/^\*//' | sed 's/(.*$//' | grep ldns_ 13 | done 14 | -------------------------------------------------------------------------------- /test/m: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | grep -v -E '^#' ../doc/function_manpages | sed 's/, /\n/g' | sed 's/|.*$//' | sort | uniq 4 | -------------------------------------------------------------------------------- /test/test_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # do ldns tests 4 | cd test || { echo "Must be executed from srcdir"; exit -1; } 5 | . common.sh 6 | 7 | # find tpkg 8 | if [ -z "$TPKG" ] || [ ! -x "$TPKG" ] 9 | then 10 | if [ -x tpkg/tpkg ] ; then TPKG="$(pwd)/tpkg/tpkg" 11 | elif [ -x test/tpkg/tpkg ] ; then TPKG="$(pwd)/test/tpkg/tpkg" 12 | elif command -v tpkg > /dev/null; then TPKG="$(command -v tpkg)" 13 | else 14 | TPKG=$1 15 | if [ -z "$TPKG" ] 16 | then 17 | TPKG=$HOME/repos/tpkg/tpkg 18 | echo Did not find tpkg program! 19 | exit -1 20 | fi 21 | fi 22 | fi 23 | 24 | is_freebsd=$(uname -s 2>&1 | grep -i -c 'freebsd') 25 | test_tool_avail "dig" 26 | 27 | echo start the test at "$(date)" in "$(pwd)" 28 | [ "$1" = "clean" ] || [ "$2" = "clean" ] && $TPKG clean 29 | $TPKG -a ../.. fake 01-compile.tpkg 30 | 31 | # Works only on FreeBSD really 32 | if [[ "$is_freebsd" -eq 0 ]]; then 33 | $TPKG -a ../.. fake 02-lint.tpkg 34 | fi 35 | 36 | $TPKG -a ../.. fake 07-compile-examples.tpkg 37 | $TPKG -a ../.. fake 16-compile-builddir.tpkg 38 | $TPKG -a ../.. fake 30-load-pyldns.tpkg 39 | $TPKG -a ../.. fake 31-load-pyldnsx.tpkg 40 | $TPKG -a ../.. fake 32-unbound-regression.tpkg 41 | $TPKG -a ../.. fake 999-compile-nossl.tpkg 42 | command -v indent || $TPKG -a ../.. fake codingstyle.tpkg 43 | grep -q '^#define HAVE_SSL ' ../ldns/config.h || ( 44 | $TPKG -a ../.. fake 19-keygen.tpkg 45 | $TPKG -a ../.. fake 20-sign-zone.tpkg 46 | $TPKG -a ../.. fake 25-ZONEMD.tpkg 47 | ) 48 | 49 | failed=0 50 | for tests in *.tpkg 51 | do 52 | COMMAND="$TPKG -a ../.. exe $(basename "$tests")" 53 | echo "$COMMAND" 54 | $COMMAND 55 | if [ $? -ne 0 ]; then ((failed=failed+1)); fi 56 | done 57 | echo finished the test at "$(date)" in "$(pwd)" 58 | $TPKG report 59 | cd .. 60 | 61 | exit $failed 62 | -------------------------------------------------------------------------------- /test/test_ci.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BUILD_DIR=$(pwd) 4 | echo "PATH=$PATH" > "$BUILD_DIR/test/.tpkg.var.master" 5 | 6 | if git log HEAD^..HEAD | grep -q 'git:TEST [0-9][0-9]*' 7 | then 8 | ONLY_TEST=$(git log HEAD^..HEAD | grep 'git:TEST [0-9][0-9]*' | sed 's/^.*git:TEST \([0-9][0-9]*\).*$/\1/g') 9 | else 10 | ONLY_TEST="" 11 | fi 12 | 13 | if git log HEAD^..HEAD | grep -q 'git:REGRESSION' 14 | then 15 | NO_REGRESSION=0 16 | else 17 | NO_REGRESSION=1 18 | fi 19 | 20 | if [ -z "$TPKG" ] || [ ! -x "$TPKG" ] 21 | then 22 | if [ -x tpkg/tpkg ] ; then TPKG="$(pwd)/tpkg/tpkg" 23 | elif [ -x test/tpkg/tpkg ] ; then TPKG="$(pwd)/test/tpkg/tpkg" 24 | elif command -v tpkg > /dev/null; then TPKG="$(command -v tpkg)" 25 | else 26 | echo Did not find tpkg program! 27 | exit 255 # Shell can only return 0-255 28 | fi 29 | fi 30 | 31 | # RUN THE TESTS 32 | for tests in "$BUILD_DIR"/test/*.tpkg 33 | do 34 | TESTFN="$(basename "$tests")" 35 | TESTNR=${TESTFN%-*} 36 | [ -n "$ONLY_TEST" ] && [ x"$ONLY_TEST" != x"$TESTNR" ] && continue 37 | case "$TESTNR" in 38 | [3-5][0-9]*) [ $NO_REGRESSION = 1 ] && continue 39 | ;; 40 | esac 41 | case $TESTNR in 42 | 02) # splint doesn't work on linux 43 | [ "x$(uname -s)" = "xLinux" ] && continue 44 | ;; 45 | 32) # No backwards compatibility regression testing 46 | # when .so had major version bump. 47 | chmod +x "$BUILD_DIR/packaging/ldns-config" 48 | BINAPI=$("$BUILD_DIR/packaging/ldns-config" --libversion) 49 | [ "x${BINAPI#*.}" = "x0.0" ] && continue 50 | esac 51 | $TPKG -b "$BUILD_DIR/test" -a "$BUILD_DIR" exe "$TESTFN" 52 | done 53 | 54 | cd test || { echo "Where is the test directory?"; exit 1; } 55 | exec $TPKG -n -1 r 56 | -------------------------------------------------------------------------------- /test/testbed/do-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | TPKG=/home/jeltejan/repos/tpkg/tpkg 3 | 4 | NEED_SPLINT='00-lint.tpkg' 5 | NEED_DOXYGEN='01-doc.tpkg' 6 | 7 | cd testdata; 8 | for test in `ls *.tpkg`; do 9 | SKIP=0 10 | if echo $NEED_SPLINT | grep $test >/dev/null; then 11 | if test ! -x "`command -v splint`"; then 12 | SKIP=1; 13 | fi 14 | fi 15 | if echo $NEED_DOXYGEN | grep $test >/dev/null; then 16 | if test ! -x "`command -v doxygen`"; then 17 | SKIP=1; 18 | fi 19 | fi 20 | if test $SKIP -eq 0; then 21 | echo $test 22 | $TPKG -a ../.. exe $test 23 | else 24 | echo "skip $test" 25 | fi 26 | done 27 | -------------------------------------------------------------------------------- /test/testbed/testbed.txt: -------------------------------------------------------------------------------- 1 | Testbed.sh help page. 2 | 3 | Testbed helps in running the test packages (using tpkg(1)) on several systems. 4 | The script is specially written for unbound (edit it to change to different 5 | software). It is licensed BSD. 6 | 7 | The hosts to run on are listed in host_file.. You need to have 8 | public-key authorized ssh access to these systems (or type your password lots 9 | and lots of times). The host_file describes the directories and environment 10 | of each host. You need only user-level access to the host. 11 | 12 | The host_file is very restrictive in formatting. Comments are lines starting 13 | with the # mark. The entries must be separated by tabs. Please list the 14 | hostnamedescriptioncheckoutdirvariables 15 | 16 | hostname: network hostname to ssh to. 17 | desc: pretty text to describe the machine architecture. 18 | checkoutdir: directory on the remote host where a svn checkout is present. 19 | variables: zero or more variables separated by spaces. BLA=value BAR=val. 20 | 21 | Only important variable for unbound is the LDNS= variable that if present 22 | forces --with-ldns= to be passed to ./configure. In case LDNS is not 23 | installed on the system itself, but present somewhere else. 24 | 25 | *** Running the testbed 26 | 27 | Run by executing the script. It will take all the hosts from the file in 28 | turn and update the svn directory there, possible autoreconf if necessary, 29 | possibly ./configure if necessary, make the executables. 30 | Then it will run the testcode/do-tests script. This script should execute 31 | the tests that this host is capable of running. 32 | 33 | in testdata/testbed.log has a line-by-line log. See your make errors here. 34 | in testdata/testbed.report has only the tpkg reports. Summary. 35 | 36 | -------------------------------------------------------------------------------- /test/testbed/unitmain.c: -------------------------------------------------------------------------------- 1 | /* 2 | * testcode/unitmain.c - unit test main program for unbound. 3 | * 4 | * Copyright (c) 2007, NLnet Labs. All rights reserved. 5 | * 6 | * See LICENSE for the license. 7 | * 8 | */ 9 | /** 10 | * \file 11 | * Unit test main program. Calls all the other unit tests. 12 | * Exits with code 1 on a failure. 0 if all unit tests are successful. 13 | */ 14 | 15 | #include "config.h" 16 | 17 | /** 18 | * Main unit test program. Setup, teardown and report errors. 19 | * @param argc: arg count. 20 | * @param argv: array of command line arguments. 21 | */ 22 | int main(int argc, char* argv[]) 23 | { 24 | if(argc != 1) { 25 | printf("usage: %s\n", argv[0]); 26 | printf("\tperforms unit tests.\n"); 27 | return 1; 28 | } 29 | printf("Start of %s unit test.\n", PACKAGE_STRING); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /test/testdata/host_file.template: -------------------------------------------------------------------------------- 1 | # list of hosts and options for each. You need keyed ssh access to each. 2 | # It must be one tab delimited only. Very strict syntax. 3 | # hostname description directory variables 4 | linux.example.com Linux Fedora Core i386 src/unbound/trunk 5 | solaris.example.com Solaris 10 sparc64 nsd_trunk LDNS=/var/local/ldns 6 | --------------------------------------------------------------------------------