diff options
Diffstat (limited to 'project2/proj2_s4498062/dns_client.py')
-rw-r--r-- | project2/proj2_s4498062/dns_client.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/project2/proj2_s4498062/dns_client.py b/project2/proj2_s4498062/dns_client.py index b15d566..0f5e50f 100644 --- a/project2/proj2_s4498062/dns_client.py +++ b/project2/proj2_s4498062/dns_client.py @@ -7,22 +7,29 @@ A simple example of a client using the DNS resolver. import dns.resolver -if __name__ == "__main__": + +def main(): + """DNS client""" # Parse arguments import argparse parser = argparse.ArgumentParser(description="DNS Client") parser.add_argument("hostname", help="hostname to resolve") - parser.add_argument("-c", "--caching", action="store_true", - help="Enable caching") - parser.add_argument("-t", "--ttl", metavar="time", type=int, default=0, - help="TTL value of cached entries") + parser.add_argument( + "-c", "--caching", action="store_true", + help="Enable caching") + parser.add_argument( + "-t", "--ttl", metavar="time", type=int, default=0, + help="TTL value of cached entries") args = parser.parse_args() - + # Resolve hostname resolver = dns.resolver.Resolver(args.caching, args.ttl) hostname, aliases, addresses = resolver.gethostbyname(args.hostname) - + # Print output - print(hostname) - print(aliases) - print(addresses) + print hostname + print aliases + print addresses + +if __name__ == "__main__": + main() |