Zone definitions
Usage
This class is able to read and parse the content of zone file by doing:
>>> import ldns
>>> zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN)
>>> print zone.soa()
example. 600 IN SOA example. admin.example. 2008022501 28800 7200 604800 18000
>>> print zone.rrs()
example. 600 IN MX 10 mail.example.
example. 600 IN NS ns1.example.
example. 600 IN NS ns2.example.
example. 600 IN A 192.168.1.1
The zone.txt file contains the following records:
$ORIGIN example.
$TTL 600
example. IN SOA example. admin.example. (
2008022501 ; serial
28800 ; refresh (8 hours)
7200 ; retry (2 hours)
604800 ; expire (1 week)
18000 ; minimum (5 hours)
)
@ IN MX 10 mail.example.
@ IN NS ns1
@ IN NS ns2
@ IN A 192.168.1.1
Retrieve all resource records from the zone that are glue records.
The resulting list does are pointer references to the zone’s data.
Due to the current zone implementation (as a list of rr’s), this function is extremely slow. Another (probably better) way to do this is to use an ldns_dnssec_zone structure and the mark_glue function
Returns: | (ldns_rr_list *) the rr_list with the glue |
---|
Creates a new zone object from given file pointer
Parameters: |
|
---|---|
Returns: | zone instance or None. If an instance can’t be created and raiseException is True, an exception occurs. |
Create a new zone from a file, keep track of the line numbering
Parameters: |
|
---|---|
Returns: |
|
Prints the data in the zone to the given file stream (in presentation format).
push an single rr to a zone structure.
This function use pointer copying, so the rr_list structure inside z is modified!
Parameters: | rr – the rr to add |
---|---|
Returns: | (bool) a true on succes otherwise falsed |
push an rrlist to a zone structure.
This function use pointer copying, so the rr_list structure inside z is modified!
Parameters: | list – the list to add |
---|---|
Returns: | (bool) a true on succes otherwise falsed |
Returns the number of resource records in the zone, NOT counting the SOA record.
Returns: | (size_t) the number of rr’s in the zone |
---|
Get a list of a zone’s content.
Note that the SOA isn’t included in this list. You need to get the with ldns_zone_soa.
Returns: | (ldns_rr_list *) the rrs from this zone |
---|
Set the zone’s contents.
Parameters: | rrlist – the rrlist to use |
---|
Set the zone’s soa record.
Parameters: | soa – the soa to set |
---|
Signs the zone, and returns a newly allocated signed zone.
Parameters: | key_list – list of keys to sign with |
---|---|
Returns: | (ldns_zone *) signed zone |
Signs the zone with NSEC3, and returns a newly allocated signed zone.
Parameters: |
|
---|---|
Returns: | (ldns_zone *) signed zone |
Return the soa record of a zone.
Returns: | (ldns_rr *) the soa record in the zone |
---|
Sort the rrs in a zone, with the current impl.
this is slow