dns-resolver / app.py
CultriX's picture
Update app.py
36c6acd verified
raw
history blame contribute delete
829 Bytes
import gradio as gr
import dns.resolver
supported_types = [
'A', 'AAAA', 'CAA', 'CNAME', 'DS', 'DNSKEY', 'MX',
'NS', 'NSEC', 'NSEC3', 'RRSIG', 'SOA', 'TXT'
]
def dns_lookup(domain, record_type):
resolver = dns.resolver.Resolver()
try:
answers = resolver.resolve(domain, record_type)
records = [str(rdata) for rdata in answers]
return '\n'.join(records)
except Exception as e:
return f"Error: {e}"
iface = gr.Interface(
fn=dns_lookup,
inputs=[
gr.Textbox(lines=1, placeholder="example.com", label="Domain Name"),
gr.Dropdown(choices=supported_types, value='A', label="Record Type")
],
outputs=gr.Textbox(),
title="DNS Resolver",
description="Enter a domain name and select a DNS record type to perform a DNS lookup."
)
iface.launch()