File: ldns-mx2.py

package info (click to toggle)
ldns 1.8.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,864 kB
  • sloc: ansic: 46,986; python: 7,675; sh: 4,229; perl: 2,186; makefile: 1,231; xml: 518
file content (19 lines) | stat: -rwxr-xr-x 562 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python
#
# MX is a small program that prints out the mx records for a particular domain
#
import ldns

resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")

pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN)
if (pkt) and (pkt.answer()):

    for rr in pkt.answer().rrs():
        if (rr.get_type() != ldns.LDNS_RR_TYPE_MX):
            continue

        rdf = rr.owner()
        print(rdf," ",rr.ttl()," ",rr.get_class_str()," ",rr.get_type_str()," ", end=" ")
        print(" ".join(str(rdf) for rdf in rr.rdfs()))