--- /dev/null
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+from typing import AsyncGenerator
+
+import dns.opcode
+import dns.rcode
+
+from isctest.asyncserver import (
+ AsyncDnsServer,
+ DnsResponseSend,
+ ResponseHandler,
+ QueryContext,
+)
+
+
+class ReplyUpdateHandler(ResponseHandler):
+ async def get_responses(
+ self, qctx: QueryContext
+ ) -> AsyncGenerator[DnsResponseSend, None]:
+ qctx.response.set_opcode(dns.opcode.UPDATE)
+ yield DnsResponseSend(qctx.response)
+
+
+def main() -> None:
+ server = AsyncDnsServer(default_aa=True, default_rcode=dns.rcode.NOERROR)
+ server.install_response_handler(ReplyUpdateHandler())
+ server.run()
+
+
+if __name__ == "__main__":
+ main()
from typing import AsyncGenerator
-import dns.opcode
+import dns
import dns.rcode
from isctest.asyncserver import (
AsyncDnsServer,
+ CloseConnection,
DnsResponseSend,
- ResponseHandler,
+ DomainHandler,
+ IgnoreAllQueries,
QueryContext,
+ ResponseAction,
+ ResponseDrop,
)
-class ReplyUpdateHandler(ResponseHandler):
+class SilentHandler(DomainHandler, IgnoreAllQueries):
+ """Handler that doesn't respond."""
+
+ domains = ["silent.example"]
+
+
+class CloseHandler(DomainHandler):
+ """Handler that doesn't respond and closes TCP connection."""
+
+ domains = ["close.example"]
+
+ async def get_responses(
+ self, qctx: QueryContext
+ ) -> AsyncGenerator[ResponseAction, None]:
+ yield CloseConnection()
+
+
+class SilentThenServfailHandler(DomainHandler):
+ """Handler that drops one query and response to the next one with SERVFAIL."""
+
+ domains = ["silent-then-servfail.example"]
+ counter = 0
+
async def get_responses(
self, qctx: QueryContext
- ) -> AsyncGenerator[DnsResponseSend, None]:
- qctx.response.set_opcode(dns.opcode.UPDATE)
- yield DnsResponseSend(qctx.response)
+ ) -> AsyncGenerator[ResponseAction, None]:
+ if self.counter % 2 == 0:
+ yield ResponseDrop()
+ else:
+ qctx.response.set_rcode(dns.rcode.SERVFAIL)
+ yield DnsResponseSend(qctx.response, authoritative=False)
+ self.counter += 1
def main() -> None:
- server = AsyncDnsServer(default_aa=True, default_rcode=dns.rcode.NOERROR)
- server.install_response_handler(ReplyUpdateHandler())
+ server = AsyncDnsServer()
+ server.install_response_handlers(
+ [
+ CloseHandler(),
+ SilentHandler(),
+ SilentThenServfailHandler(),
+ ]
+ )
server.run()
+++ /dev/null
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# SPDX-License-Identifier: MPL-2.0
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-from typing import AsyncGenerator
-
-import dns
-import dns.rcode
-
-from isctest.asyncserver import (
- AsyncDnsServer,
- CloseConnection,
- DnsResponseSend,
- DomainHandler,
- IgnoreAllQueries,
- QueryContext,
- ResponseAction,
- ResponseDrop,
-)
-
-
-class SilentHandler(DomainHandler, IgnoreAllQueries):
- """Handler that doesn't respond."""
-
- domains = ["silent.example"]
-
-
-class CloseHandler(DomainHandler):
- """Handler that doesn't respond and closes TCP connection."""
-
- domains = ["close.example"]
-
- async def get_responses(
- self, qctx: QueryContext
- ) -> AsyncGenerator[ResponseAction, None]:
- yield CloseConnection()
-
-
-class SilentThenServfailHandler(DomainHandler):
- """Handler that drops one query and response to the next one with SERVFAIL."""
-
- domains = ["silent-then-servfail.example"]
- counter = 0
-
- async def get_responses(
- self, qctx: QueryContext
- ) -> AsyncGenerator[ResponseAction, None]:
- if self.counter % 2 == 0:
- yield ResponseDrop()
- else:
- qctx.response.set_rcode(dns.rcode.SERVFAIL)
- yield DnsResponseSend(qctx.response, authoritative=False)
- self.counter += 1
-
-
-def main() -> None:
- server = AsyncDnsServer()
- server.install_response_handlers(
- [
- CloseHandler(),
- SilentHandler(),
- SilentThenServfailHandler(),
- ]
- )
- server.run()
-
-
-if __name__ == "__main__":
- main()
n=$((n + 1))
echo_i "check nslookup handles UPDATE response ($n)"
ret=0
-"$NSLOOKUP" -q=CNAME -timeout=1 "-port=$PORT" foo.bar 10.53.0.7 >nslookup.out.test$n 2>&1 && ret=1
+"$NSLOOKUP" -q=CNAME -timeout=1 "-port=$PORT" foo.bar 10.53.0.6 >nslookup.out.test$n 2>&1 && ret=1
grep "Opcode mismatch" nslookup.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "check host handles UPDATE response ($n)"
ret=0
-"$HOST" -W 1 -t CNAME -p $PORT foo.bar 10.53.0.7 >host.out.test$n 2>&1 && ret=1
+"$HOST" -W 1 -t CNAME -p $PORT foo.bar 10.53.0.6 >host.out.test$n 2>&1 && ret=1
grep "Opcode mismatch" host.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
ret=0
res=0
$NSUPDATE <<EOF >nsupdate.out.test$n 2>&1 || res=$?
-server 10.53.0.7 ${PORT}
+server 10.53.0.6 ${PORT}
add x.example.com 300 in a 1.2.3.4
send
EOF
n=$((n + 1))
echo_i "check dig handles UPDATE response ($n)"
ret=0
- dig_with_opts @10.53.0.7 +tries=1 +timeout=1 cname foo.bar >dig.out.test$n 2>&1 && ret=1
+ dig_with_opts @10.53.0.6 +tries=1 +timeout=1 cname foo.bar >dig.out.test$n 2>&1 && ret=1
grep "Opcode mismatch" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "check that dig handles UDP timeout followed by a SERVFAIL correctly ($n)"
ret=0
- dig_with_opts +timeout=1 +nofail @10.53.0.8 silent-then-servfail.example >dig.out.test$n 2>&1 || ret=1
+ dig_with_opts +timeout=1 +nofail @10.53.0.7 silent-then-servfail.example >dig.out.test$n 2>&1 || ret=1
grep -F "status: SERVFAIL" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "check that dig handles TCP timeout followed by a SERVFAIL correctly ($n)"
ret=0
- dig_with_opts +timeout=1 +nofail +tcp @10.53.0.8 silent-then-servfail.example >dig.out.test$n 2>&1 || ret=1
+ dig_with_opts +timeout=1 +nofail +tcp @10.53.0.7 silent-then-servfail.example >dig.out.test$n 2>&1 || ret=1
grep -F "status: SERVFAIL" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "check that dig tries the next server after a TCP socket read error ($n)"
ret=0
- dig_with_opts +tcp @10.53.0.8 @10.53.0.3 close.example >dig.out.test$n 2>&1 || ret=1
+ dig_with_opts +tcp @10.53.0.7 @10.53.0.3 close.example >dig.out.test$n 2>&1 || ret=1
grep -F "status: NOERROR" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "check that dig tries the next server after UDP socket read timeouts ($n)"
ret=0
- dig_with_opts +timeout=1 @10.53.0.8 @10.53.0.3 silent.example >dig.out.test$n 2>&1 || ret=1
+ dig_with_opts +timeout=1 @10.53.0.7 @10.53.0.3 silent.example >dig.out.test$n 2>&1 || ret=1
grep -F "status: NOERROR" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "check that dig tries the next server after TCP socket read timeouts ($n)"
ret=0
- dig_with_opts +timeout=1 +tcp @10.53.0.8 @10.53.0.3 silent.example >dig.out.test$n 2>&1 || ret=1
+ dig_with_opts +timeout=1 +tcp @10.53.0.7 @10.53.0.3 silent.example >dig.out.test$n 2>&1 || ret=1
grep -F "status: NOERROR" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "check that dig correctly refuses to use a server with a IPv4 mapped IPv6 address after failing with a regular IP address ($n)"
ret=0
- dig_with_opts @10.53.0.8 @::ffff:10.53.0.8 silent.example >dig.out.test$n 2>&1 || ret=1
+ dig_with_opts @10.53.0.7 @::ffff:10.53.0.7 silent.example >dig.out.test$n 2>&1 || ret=1
grep -F ";; Skipping mapped address" dig.out.test$n >/dev/null || ret=1
grep -F ";; No acceptable nameservers" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi