本文整理汇总了Python中dnslib.server.DNSServer方法的典型用法代码示例。如果您正苦于以下问题:Python server.DNSServer方法的具体用法?Python server.DNSServer怎么用?Python server.DNSServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dnslib.server
的用法示例。
在下文中一共展示了server.DNSServer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from dnslib import server [as 别名]
# 或者: from dnslib.server import DNSServer [as 别名]
def main():
zone = '''
*.{dnsdomain}. IN NS {ns1domain}.
*.{dnsdomain}. IN NS {ns2domain}.
*.{dnsdomain}. IN A {serverip}
{dnsdomain}. IN A {serverip}
'''.format(
dnsdomain=settings.DNS_DOMAIN, ns1domain=settings.NS1_DOMAIN,
ns2domain=settings.NS2_DOMAIN, serverip=settings.SERVER_IP)
resolver = ZoneResolver(zone, True)
logger = MysqlLogger()
print("Starting Zone Resolver (%s:%d) [%s]" % ("*", 53, "UDP"))
udp_server = DNSServer(resolver,
port=53,
address='',
logger=logger)
udp_server.start()
示例2: main
# 需要导入模块: from dnslib import server [as 别名]
# 或者: from dnslib.server import DNSServer [as 别名]
def main():
global pkt_handler
global dns_server
signal.signal(signal.SIGTERM, exit_handler)
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(levelname)-7s - %(threadName)-12s (%(module)-6s.%(funcName)s:%(lineno)d) - %(message)s')
if DEBUG:
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
dns_logger = LocalDNSLogger()
pkt_handler = PacketHandler()
resolver = BeaconResolver()
dns_server = DNSServer(resolver, port=PORT, address=ADDR, logger=dns_logger)
dns_server.start_thread()
ui = MainMenu()
ui.cmdloop()
logging.warning("After cmdloop initialized. Code shouldn't get here so long as MainMenu is running.")
while dns_server.isAlive():
time.sleep(1)
示例3: start
# 需要导入模块: from dnslib import server [as 别名]
# 或者: from dnslib.server import DNSServer [as 别名]
def start(self):
if not self.server:
print(" * Starting DNS server on {}:53".format(self.default_ip))
try:
self.server = DNSServer(self.resolver, port=53, address=self.default_ip)
self.server.start_thread()
except Exception as e:
print(" * ERROR: Unable to bind to port 53. DNS server could not start: {}".format(e))
示例4: run_dns_proxy
# 需要导入模块: from dnslib import server [as 别名]
# 或者: from dnslib.server import DNSServer [as 别名]
def run_dns_proxy(self):
resolver = HTTPSResolver()
logger = DNSLogger()
server = DNSServer(resolver,
port=DNS_PORT,
address='localhost',
logger=logger)
server.start_thread()
while self.is_running:
# this just keeps the thing alive...
time.sleep(5)
server.stop()