mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-07 10:05:50 +00:00
When the tests-connreset.py module was initially implemented in commit
5c17919019
, the dispatch code did not
properly apply the idle timeout to TCP connections. This allowed the
check in that test module to reset the TCP connection after 5 seconds as
named did not attempt to tear the connection down earlier than that.
However, as the dispatch code was improved, the idle timeout started
being enforced for TCP dispatches; the exact value it is set to in the
current code depends on a given server's SRTT, but it defaults to about
1.2 seconds for responsive servers. This means that the code paths
triggered by the "dispatch" system test are now different than the ones
it was originally supposed to trigger because it is now named itself
that shuts the TCP connection down cleanly before the ans3 server gets a
chance to reset it.
Account for the above by lowering the amount of time after which the
ans3 server in the "dispatch" system test resets TCP connections to just
1 second, so that the test actually does what its name implies.
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
# 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
|
|
|
|
from isctest.asyncserver import (
|
|
AsyncDnsServer,
|
|
ConnectionReset,
|
|
DnsProtocol,
|
|
DnsResponseSend,
|
|
QueryContext,
|
|
ResponseAction,
|
|
ResponseHandler,
|
|
)
|
|
|
|
|
|
class TruncateOnUdpHandler(ResponseHandler):
|
|
async def get_responses(
|
|
self, qctx: QueryContext
|
|
) -> AsyncGenerator[ResponseAction, None]:
|
|
assert qctx.protocol == DnsProtocol.UDP, "This server only supports UDP"
|
|
qctx.response.set_rcode(dns.rcode.NOERROR)
|
|
qctx.response.flags |= dns.flags.TC
|
|
yield DnsResponseSend(qctx.response)
|
|
|
|
|
|
def main() -> None:
|
|
server = AsyncDnsServer()
|
|
server.install_connection_handler(ConnectionReset(delay=1.0))
|
|
server.install_response_handler(TruncateOnUdpHandler())
|
|
server.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|