Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-announce-list@python.org Delivered-To: python-announce-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'author:': 0.03; 'receives': 0.04; 'encoding': 0.05; 'url:bitbucket': 0.05; 'subject:Python': 0.06; 'diff': 0.07; 'fixes': 0.07; 'subject:ANN': 0.07; 'subject:support': 0.07; 'string': 0.09; '0.1': 0.09; 'below).': 0.09; 'formatting': 0.09; 'logic': 0.09; 'objects)': 0.09; 'objects,': 0.09; 'rewrite': 0.09; 'text"': 0.09; 'url:github': 0.09; '--------': 0.10; 'python': 0.11; '2.7': 0.14; 'changes': 0.15; '"some': 0.16; "'''": 0.16; '(note:': 0.16; '-------': 0.16; '0.2': 0.16; '0.3': 0.16; '0.6': 0.16; '1.0.0': 0.16; 'bitbucket': 0.16; 'bsd': 0.16; 'bugs.': 0.16; 'cases)': 0.16; 'cli': 0.16; 'dig': 0.16; 'format:': 0.16; 'license:': 0.16; 'object)': 0.16; 'outputs': 0.16; 'query,': 0.16; 'sections:': 0.16; 'skip:q 30': 0.16; 'subclasses': 0.16; 'subclassing': 0.16; 'subject:library': 0.16; 'to:addr:python-announce-list': 0.16; 'tuple': 0.16; 'unpacked': 0.16; 'www': 0.16; 'fix': 0.17; 'thanks,': 0.17; 'library': 0.18; 'module': 0.19; 'implementing': 0.19; 'received:10.0.1': 0.19; 'skip:a 60': 0.19; 'stefan': 0.19; 'examples': 0.20; '(the': 0.22; '>>>': 0.22; 'example': 0.22; '(in': 0.22; 'handles': 0.22; 'shell': 0.22; 'tests': 0.22; 'creating': 0.23; 'id:': 0.23; 'error': 0.23; 'bytes': 0.24; 'entries': 0.24; 'format,': 0.24; 'merge': 0.24; 'parse': 0.24; 'proxy': 0.24; 'earlier': 0.24; 'fairly': 0.24; 'header': 0.24; 'initial': 0.24; 'paul': 0.24; 'question': 0.24; 'script': 0.25; '(see': 0.26; 'compare': 0.26; 'equivalent': 0.26; 'handling': 0.26; 'tracker': 0.26; '----------': 0.26; 'post': 0.26; 'subject:/': 0.26; 'defined': 0.27; 'received:74.125.82.174': 0.27; 'testing': 0.29; 'fixed': 0.29; '(this': 0.29; 'patch': 0.29; 'raise': 0.29; 'errors': 0.30; 'specified': 0.30; 'included': 0.31; 'requests': 0.31; 'container': 0.31; 'minor': 0.31; 'produces': 0.31; 'skip:q 20': 0.31; 'txt': 0.31; 'file': 0.32; 'class': 0.32; 'run': 0.32; 'text': 0.33; 'url:python': 0.33; 'cases': 0.33; 'framework': 0.33; 'implemented': 0.33; 'skip:d 20': 0.34; 'received:74.125.82': 0.34; 'subject: (': 0.35; 'subject:with': 0.35; 'basic': 0.35; 'classes': 0.35; 'created': 0.35; 'skip:s 30': 0.35; 'objects': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'version': 0.36; '2.6': 0.36; 'more': 0.64; 'reply': 0.66; 'sample': 0.67; 'url:0': 0.67; 'between': 0.67; 'response.': 0.68; 'improvements': 0.68; 'status:': 0.68; 'containing': 0.69; 'default': 0.69; 'skip:r 30': 0.69; 'therefore': 0.72; 'records': 0.73; '0.8': 0.84; 'answer:': 0.84; 'to/from': 0.84; 'email addr:gmail.com)': 0.91; 'responses': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version; bh=HEvt3LRMQks0LKw7qVTvg6s7R0pn5bLXbewMdlya0W4=; b=cAo38xTw/rgic+RYvqrVBdoIjEYboTFZ/SgP5hWrLc+02qlYLt/81oJkYojIG8XfAz CsRCBpR76nZARxfJ4hTXNTs57ieZg/28vMZiIvj6rMnQT7bAAGsvkK2D+yvWxgu+6fLx JPfztelwje/wnWMKDRMFLv+hs8OcLmPxX7OyT06PU/1Da9HGfk9H5nfl6QgJcygWaB4y Ua028ebKpJPEJAicfyegIvTPqQVOrounJ2E2xBnsoQJFLV5nQ3yrfBbEiCJ26Gl6X2cs lOHQ5HyHj0BqicyX1ZTmxk+9Wb/8zSjBFLtUAY0nyyRr5pKWZa4enY2hNRBL/V0ZeZeq NXvQ== X-Received: by 10.180.7.227 with SMTP id m3mr15651609wia.59.1399295497674; Mon, 05 May 2014 06:11:37 -0700 (PDT) From: Paul Chakravarti Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: ANN: dnslib-0.9.0 - DNS library for Python (with Py2/3 support) Date: Mon, 5 May 2014 14:11:30 +0100 To: python-announce-list@python.org Mime-Version: 1.0 (Apple Message framework v1283) X-Mailer: Apple Mail (2.1283) X-Mailman-Approved-At: Thu, 08 May 2014 11:18:35 +0200 X-BeenThere: python-announce-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: Announcement-only list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Approved: python-announce-list@python.org Newsgroups: comp.lang.python.announce Message-ID: Lines: 365 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399540717 news.xs4all.nl 2857 [2001:888:2000:d::a6]:33361 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python.announce:1274 Hello, I have just uploaded a new version of 'dnslib' to PyPi: https://pypi.python.org/pypi/dnslib/0.9.0=20 'dnslib' is a simple but very flexible library for encoding & decoding DNS data and creating custom DNS resolvers for=20 Python 2/3. This is the first version that supports Python 3.2+ (and 2.7) and also includes a large number of fixes and additional functionality. (README included below). This is a major release - please submit any issues to the=20 BitBucket issue tracker (https://bitbucket.org/paulc/dnslib). Thanks, PaulC =20 dnslib ------ A library to encode/decode DNS wire-format packets supporting both=20 Python 2.7 and Python 3.2+. The library provides: * Support for encoding/decoding DNS packets between wire format, python objects, and Zone/DiG textual representation (dnslib.dns) * A server framework allowing the simple creation of custom DNS=20 resolvers (dnslib.server) and a number of example servers=20 created using this frameowork * A number of utilities for testing (dnslib.client, dnslib.proxy, dnslib.intercept) Python 3 support was added in Version 0.9.0 which represented a fairly major update to the library - the key changes include: * Python 2.7/3.2+ support (the last version supporting Python 2.6=20 or earlier was version 0.8.3) * Support for encoding/decoding resource records in 'Zone' (BIND)=20 file format=20 * Support for encoding/decoding backets in 'DiG' format * Server framework allowing (in most cases) custom resolvers to be created by just subclassing the DNSResolver class and=20 overringing the 'resolve' method * A lot of fixes to error detection/handling which should make=20 the library much more robust to invalid/unsupported data. The library should now either return a valid DNSRecord instance or raise DNSError (tested via fuzzing) * Improved utilities (dnslib.client, dnslib.proxy, dnslib.intercept) * Improvements to encoding/decoding tests including the ability to generate test data automatically in test_decode.py (comparing outputs against DiG) * Ability to compare and diff DNSRecords This is a large release and despite the testing there therefore are = likely to be some bugs. Once the 0.9 release is sufficiently stable I would = expect to release as 1.0.0 (and stabilise th api) The key DNS packet handling classes are in dnslib.dns and map to the=20 standard DNS packet sections: * DNSRecord - container for DNS packet. Contains: - DNSHeader=20 - Question section containing zero or more DNSQuestion objects=20= - Answer section containing zero or more RR objects=20 - Authority section containing zero or more RR objects=20 - Additional section containing zero or more RR objects=20 * DNS RRs (resource records) contain an RR header and an RD object) * Specific RD types are implemented as subclasses of RD * DNS labels are represented by a DNSLabel class - in most cases this handles conversion to/from textual representation however does support arbitatry labels via a tuple of bytes objects) Version 0.9 of the library was a major rewrite to support Python 3.2+=20 (retaining support for Python 2.7+). As part of the Py3 changes a=20 number of other significant changes were intrtoduced: - Much better error handling (packet decoding errors should be=20 caught and DNSError raised) Usage: ------ To decode a DNS packet: >>> packet =3D = binascii.unhexlify(b'd5ad818000010005000000000377777706676f6f676c6503636f6= d0000010001c00c0005000100000005000803777777016cc010c02c0001000100000005000= 442f95b68c02c0001000100000005000442f95b63c02c0001000100000005000442f95b67c= 02c0001000100000005000442f95b93') >>> d =3D DNSRecord.parse(packet) >>> d The default text representation of the DNSRecord is in zone file format: >>> print(d) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54701 ;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.google.com. IN A ;; ANSWER SECTION: www.google.com. 5 IN CNAME www.l.google.com. www.l.google.com. 5 IN A 66.249.91.104 www.l.google.com. 5 IN A 66.249.91.99 www.l.google.com. 5 IN A 66.249.91.103 www.l.google.com. 5 IN A 66.249.91.147 To create a DNS Request Packet: >>> d =3D DNSRecord.question("google.com") (This is equivalent to: d =3D DNSRecord(q=3DDNSQuestion("google.com") ) >>> d >>> str(DNSRecord.parse(d.pack())) =3D=3D str(d) True >>> print(d) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: ... ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;google.com. IN A >>> d =3D DNSRecord.question("google.com","MX") (This is equivalent to: d =3D = DNSRecord(q=3DDNSQuestion("google.com",QTYPE.MX) ) >>> str(DNSRecord.parse(d.pack())) =3D=3D str(d) True >>> print(d) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: ... ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;google.com. IN MX To create a DNS Response Packet: >>> d =3D DNSRecord(DNSHeader(qr=3D1,aa=3D1,ra=3D1), ... q=3DDNSQuestion("abc.com"), ... a=3DRR("abc.com",rdata=3DA("1.2.3.4"))) >>> d >>> str(DNSRecord.parse(d.pack())) =3D=3D str(d) True >>> print(d) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: ... ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;abc.com. IN A ;; ANSWER SECTION: abc.com. 0 IN A 1.2.3.4 It is also possible to create RRs from a string in zone file format >>> RR.fromZone("abc.com IN A 1.2.3.4") [] (Note: this produces a list of RRs which should be unpacked if being passed to add_answer/add_auth/add_ar etc) >>> q =3D DNSRecord.question("abc.com") >>> a =3D q.reply() >>> a.add_answer(*RR.fromZone("abc.com 60 A 1.2.3.4")) >>> print(a) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: ... ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;abc.com. IN A ;; ANSWER SECTION: abc.com. 60 IN A 1.2.3.4 The zone file can contain multiple entries and supports most of the = normal format defined in RFC1035 (specifically not $INCLUDE) >>> z =3D ''' ... $TTL 300 ... $ORIGIN abc.com ... ... @ IN MX 10 mail.abc.com. ... www IN A 1.2.3.4 ... IN TXT "Some Text" ... mail IN CNAME www.abc.com. ... ''' >>> for rr in RR.fromZone(textwrap.dedent(z)): ... print(rr) abc.com. 300 IN MX 10 mail.abc.com. www.abc.com. 300 IN A 1.2.3.4 www.abc.com. 300 IN TXT "Some Text" mail.abc.com. 300 IN CNAME www.abc.com. To create a skeleton reply to a DNS query: >>> q =3D DNSRecord(q=3DDNSQuestion("abc.com",QTYPE.ANY))=20 >>> a =3D q.reply() >>> a.add_answer(RR("abc.com",QTYPE.A,rdata=3DA("1.2.3.4"),ttl=3D60)) >>> str(DNSRecord.parse(a.pack())) =3D=3D str(a) True >>> print(a) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: ... ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;abc.com. IN ANY ;; ANSWER SECTION: abc.com. 60 IN A 1.2.3.4 Add additional RRs: >>> a.add_answer(RR("xxx.abc.com",QTYPE.A,rdata=3DA("1.2.3.4"))) >>> = a.add_answer(RR("xxx.abc.com",QTYPE.AAAA,rdata=3DAAAA("1234:5678::1"))) >>> str(DNSRecord.parse(a.pack())) =3D=3D str(a) True >>> print(a) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: ... ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;abc.com. IN ANY ;; ANSWER SECTION: abc.com. 60 IN A 1.2.3.4 xxx.abc.com. 0 IN A 1.2.3.4 xxx.abc.com. 0 IN AAAA 1234:5678::1 It is also possible to create a reply from a string in zone file format: >>> q =3D DNSRecord(q=3DDNSQuestion("abc.com",QTYPE.ANY))=20 >>> a =3D q.replyZone("abc.com 60 IN CNAME xxx.abc.com") >>> print(a) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: ... ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;abc.com. IN ANY ;; ANSWER SECTION: abc.com. 60 IN CNAME xxx.abc.com. >>> str(DNSRecord.parse(a.pack())) =3D=3D str(a) True >>> q =3D DNSRecord(q=3DDNSQuestion("abc.com",QTYPE.ANY))=20 >>> a =3D q.replyZone(textwrap.dedent(z)) >>> print(a) ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: ... ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;abc.com. IN ANY ;; ANSWER SECTION: abc.com. 300 IN MX 10 mail.abc.com. www.abc.com. 300 IN A 1.2.3.4 www.abc.com. 300 IN TXT "Some Text" mail.abc.com. 300 IN CNAME www.abc.com. The library also includes a simple framework for generating custom DNS resolvers in dnslib.server (see module docs). In post cases this just=20 requires implementing a custom 'resolve' method which receives a = question=20 object and returns a response. A number of sample resolvers are provided as examples (see CLI --help): dnslib.fixedresolver - Respond to all requests with fixed = response dnslib.zoneresolver - Respond from Zone file=20 dnslib.shellresolver - Call shell script to generate response The library includes a number of client utilities which can be run = using: DiG like client library=20 # python -m dnslib.client --help =20 DNS Proxy Server # python -m dnslib.proxy --help Intercepting DNS Proxy Server (replace proxy responses for specified = domains) # python -m dnslib.intercept --help Changelog: ---------- * 0.1 2010-09-19 Initial Release * 0.2 2010-09-22 Minor fixes * 0.3 2010-10-02 Add DNSLabel class to support arbitrary = labels (embedded '.') * 0.4 2012-02-26 Merge with dbslib-circuits * 0.5 2012-09-13 Add support for RFC2136 DDNS updates Patch provided by Wesley Shields = - thanks * 0.6 2012-10-20 Basic AAAA support * 0.7 2012-10-20 Add initial EDNS0 support (untested) * 0.8 2012-11-04 Add support for NAPTR, Authority RR and = additional RR Patch provided by Stefan Andersson = (https://bitbucket.org/norox) - thanks * 0.8.1 2012-11-05 Added NAPTR test case and fixed logic error Patch provided by Stefan Andersson = (https://bitbucket.org/norox) - thanks * 0.8.2 2012-11-11 Patch to fix IPv6 formatting Patch provided by Torbj=F6rn L=F6nnemark = (https://bitbucket.org/tobbezz) - thanks * 0.8.3 2013-04-27 Don't parse rdata if rdlength is 0 Patch provided by Wesley Shields = - thanks * 0.9.0 2014-05-05 Major update including Py3 support (see = docs) License: -------- * BSD Author: ------- * Paul Chakravarti (paul.chakravarti@gmail.com) Master Repository/Issues: ------------------------- * https://bitbucket.org/paulc/dnslib (Cloned on GitHub: https://github.com/paulchakravarti/dnslib)