]>
git.saurik.com Git - apple/network_cmds.git/blob - unbound/libunbound/python/doc/examples/example6-1.py
0f405448c5137be4e6dbcddf9c90e0b48303f7d4
2 from unbound
import ub_ctx
,ub_strerror
,RR_TYPE_A
,RR_CLASS_IN
5 ctx
.resolvconf("/etc/resolv.conf")
7 status
, result
= ctx
.resolve("test.record.xxx", RR_TYPE_A
, RR_CLASS_IN
)
8 if status
== 0 and result
.havedata
:
9 print "Result:", result
.data
.address_list
11 print "No record found"
13 #define new local zone
14 status
= ctx
.zone_add("xxx.","static")
15 if (status
!= 0): print "Error zone_add:",status
, ub_strerror(status
)
18 status
= ctx
.data_add("test.record.xxx. IN A 1.2.3.4")
19 if (status
!= 0): print "Error data_add:",status
, ub_strerror(status
)
21 #lookup for an A record
22 status
, result
= ctx
.resolve("test.record.xxx", RR_TYPE_A
, RR_CLASS_IN
)
23 if status
== 0 and result
.havedata
:
24 print "Result:", result
.data
.as_address_list()
26 print "No record found"