Skip to content
Snippets Groups Projects
Verified Commit fc99b20f authored by Grigorii Demidov's avatar Grigorii Demidov Committed by Tomas Krizek
Browse files

scenario: possibility to ignore selected queries was added

parent f011d004
No related merge requests found
......@@ -4,7 +4,7 @@
" au BufRead,BufNewFile *.rpl set filetype=deckard
" au BufRead,BufNewFile *.stc set foldmethod=syntax
syntax keyword Keyword MATCH STEP ADJUST MANDATORY RAW
syntax keyword Keyword MATCH STEP ADJUST MANDATORY RAW IGNORE
syntax keyword Structure CONFIG_END
syntax keyword Function CHECK_ANSWER QUERY TIME_PASSES
......
......@@ -37,12 +37,13 @@ let adjust_option = "copy_id" | "copy_query" | "raw_id"
let reply_option = "QR" | "TC" | "AA" | "AD" | "RD" | "RA" | "CD" | "DO" | "NOERROR" | "FORMERR" | "SERVFAIL" | "NXDOMAIN" | "NOTIMP" | "REFUSED" | "YXDOMAIN" | "YXRRSET" | "NXRRSET" | "NOTAUTH" | "NOTZONE" | "BADVERS" | "BADSIG" | "BADKEY" | "BADTIME" | "BADMODE" | "BADNAME" | "BADALG" | "BADTRUNC" | "BADCOOKIE"
let step_option = "REPLY" | "QUERY" | "CHECK_ANSWER" | "CHECK_OUT_QUERY" | /TIME_PASSES[ \t]+ELAPSE/
let ignore = [del_str "IGNORE" . label "ignore" . value "true" . comment_or_eol]
let mandatory = [del_str "MANDATORY" . label "mandatory" . value "true" . comment_or_eol]
let tsig = [del_str "TSIG" . label "tsig" . space . [label "keyname" . store word] . space . [label "secret" . store word] . comment_or_eol]
let match = (mandatory | tsig)* . [ label "match_present" . value "true" . del_str "MATCH" ] . [space . label "match" . store match_option ]+ . comment_or_eol
let adjust = (mandatory | tsig)* . del_str "ADJUST" . [space . label "adjust" . store adjust_option ]+ . comment_or_eol
let reply = (mandatory | tsig)* . del ("REPLY" | "FLAGS") "REPLY" . [space . label "reply" . store reply_option ]+ . comment_or_eol
let match = (ignore | mandatory | tsig)* . [ label "match_present" . value "true" . del_str "MATCH" ] . [space . label "match" . store match_option ]+ . comment_or_eol
let adjust = (ignore | mandatory | tsig)* . del_str "ADJUST" . [space . label "adjust" . store adjust_option ]+ . comment_or_eol
let reply = (ignore | mandatory | tsig)* . del ("REPLY" | "FLAGS") "REPLY" . [space . label "reply" . store reply_option ]+ . comment_or_eol
let question = [label "record" . domain . tab . (class . tab)? . type . comment_or_eol ]
......
......@@ -173,6 +173,12 @@ class Entry:
except (KeyError, IndexError):
self.mandatory = None
# IGNORE
try:
self.ignore = list(node.match("/ignore"))[0]
except (KeyError, IndexError):
self.ignore = None
# TSIG
self.process_tsig()
......@@ -395,6 +401,8 @@ class Entry:
return self.raw_data
def reply(self, query):
if self.ignore:
return None, True
if self.is_raw_data_entry:
return self._adjust_raw_reply(query), True
return self._adjust_reply(query), False
......@@ -788,7 +796,7 @@ class Scenario:
return candidate.reply(query)
except (IndexError, ValueError):
pass
return None, True
return None, False
def play(self, paddr):
""" Play given scenario. """
......
......@@ -91,15 +91,16 @@ class TestServer:
if query is None:
return False
log.debug('server %s received query from %s: %s', server_addr, client_addr, query)
response, is_raw_data = self.scenario.reply(query, server_addr)
response, second = self.scenario.reply(query, server_addr)
if response:
is_raw_data = second
if not is_raw_data:
data_to_wire = response.to_wire(max_size=65535)
log.debug('response: %s', response)
else:
data_to_wire = response
log.debug('raw response not printed')
else:
elif not second:
response = dns.message.make_response(query)
response.set_rcode(dns.rcode.SERVFAIL)
data_to_wire = response.to_wire()
......@@ -108,6 +109,10 @@ class TestServer:
'server %s has no response for question %s, answering with SERVFAIL',
server_addr,
'; '.join([str(rr) for rr in query.question]))
else:
# Just ignore
log.debug('ignoring')
return True
scenario.sendto_msg(client, data_to_wire, client_addr)
return True
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment