MCPcopy Index your code
hub / github.com/ddserver/ddserver / answer_a

Function answer_a

ddserver/recursor/__main__.py:154–180  ·  view source on GitHub ↗

Handle A records

(query,
             db,
             config)

Source from the content-addressed store, hash-verified

152@require(db='ddserver.db:Database',
153 config='ddserver.config:Config')
154def answer_a(query,
155 db,
156 config):
157 """ Handle A records
158 """
159
160 with db.cursor() as cur:
161 cur.execute('''
162 SELECT
163 `host`.`hostname` AS `hostname`,
164 `suffix`.`name` AS `suffix`,
165 `host`.`address` AS `address`
166 FROM `hosts` AS `host`
167 LEFT JOIN `suffixes` AS `suffix`
168 ON ( `suffix`.`id` = `host`.`suffix_id` )
169 WHERE `host`.`address` IS NOT NULL
170 AND CONCAT(`host`.`hostname`, '.', `suffix`.`name`) = %(name)s
171 ''', {'name': query.qname})
172 host = cur.fetchone()
173
174 if host:
175 send(formatter.DATA, qname=query.qname,
176 qclass=query.qclass,
177 qtype='A',
178 ttl=config.dns.ttl,
179 id=query.id,
180 content=host['address'])
181
182
183def answer(query):

Callers 1

answerFunction · 0.85

Calls 2

sendFunction · 0.85
cursorMethod · 0.80

Tested by

no test coverage detected