Base resolver implementation. Provides 'resolve' method which is called by DNSHandler with the decode request (DNSRecord instance) and returns a DNSRecord instance as reply. In most cases you should be able to create a custom resolver by just replacing the
| 93 | from dnslib import DNSRecord,DNSError,QTYPE,RCODE,RR |
| 94 | |
| 95 | class BaseResolver(object): |
| 96 | """ |
| 97 | Base resolver implementation. Provides 'resolve' method which is |
| 98 | called by DNSHandler with the decode request (DNSRecord instance) |
| 99 | and returns a DNSRecord instance as reply. |
| 100 | |
| 101 | In most cases you should be able to create a custom resolver by |
| 102 | just replacing the resolve method with appropriate resolver code for |
| 103 | application (see fixedresolver/zoneresolver/shellresolver for |
| 104 | examples) |
| 105 | |
| 106 | Note that a single instance is used by all DNSHandler instances so |
| 107 | need to consider blocking & thread safety. |
| 108 | """ |
| 109 | def resolve(self,request,handler): |
| 110 | """ |
| 111 | Example resolver - respond to all requests with NXDOMAIN |
| 112 | """ |
| 113 | reply = request.reply() |
| 114 | reply.header.rcode = getattr(RCODE,'NXDOMAIN') |
| 115 | return reply |
| 116 | |
| 117 | class DNSHandler(socketserver.BaseRequestHandler): |
| 118 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected