Home | History | Annotate | Line # | Download | only in ans4
      1 # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      2 #
      3 # SPDX-License-Identifier: MPL-2.0
      4 #
      5 # This Source Code Form is subject to the terms of the Mozilla Public
      6 # License, v. 2.0.  If a copy of the MPL was not distributed with this
      7 # file, you can obtain one at https://mozilla.org/MPL/2.0/.
      8 #
      9 # See the COPYRIGHT file distributed with this work for additional
     10 # information regarding copyright ownership.
     11 
     12 """Custom authoritative server (ans4) for the dnssec_py suite.
     13 
     14 Per-domain response handlers live one-per-module in sibling *_ans.py files
     15 (e.g. rrsig_labels_signer_ans.py); this loader installs each into a single
     16 AsyncDnsServer.  Keeping each domain's crafted-response logic in its own
     17 file bounds its scope as the server accrues unrelated domains.
     18 """
     19 
     20 from dnssec_py.ans4 import noqname_mismatch, rrsig_labels_signer_ans, sibling_ds_ans
     21 from isctest.asyncserver import AsyncDnsServer
     22 
     23 
     24 def main() -> None:
     25     server = AsyncDnsServer()
     26 
     27     server.install_response_handler(sibling_ds_ans.SiblingDsInjectionHandler())
     28     if noqname_mismatch.PEM_PATH.exists():
     29         server.install_response_handlers(noqname_mismatch.RuntimeCheckHandler())
     30     if rrsig_labels_signer_ans.PEM_PATH.exists():
     31         server.install_response_handler(rrsig_labels_signer_ans.AttackerZoneHandler())
     32 
     33     server.run()
     34 
     35 
     36 if __name__ == "__main__":
     37     main()
     38