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 12import os 13from typing import Optional 14 15import dns.query 16import dns.message 17 18 19QUERY_TIMEOUT = 10 20 21 22def udp( 23 message: dns.message.Message, ip: str, port: Optional[int] = None 24) -> dns.message.Message: 25 if port is None: 26 port = int(os.environ["PORT"]) 27 return dns.query.udp(message, ip, QUERY_TIMEOUT, port=port) 28 29 30def tcp( 31 message: dns.message.Message, ip: str, port: Optional[int] = None 32) -> dns.message.Message: 33 if port is None: 34 port = int(os.environ["PORT"]) 35 return dns.query.tcp(message, ip, QUERY_TIMEOUT, port=port) 36