-
Notifications
You must be signed in to change notification settings - Fork 0
/
dnsserver
executable file
·40 lines (35 loc) · 1.29 KB
/
dnsserver
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
# dnsserver - Contains script to run a DNSServer locally
# +-----------+
# | Imports |
# +-----------+
import argparse
from src.cdnresolver import *
# +-------------+
# | Constants |
# +-------------+
ANYWHERE = '0.0.0.0'
# +-----------------+
# | Main Function |
# +-----------------+
if __name__ == "__main__":
# Parse arguments
parser = argparse.ArgumentParser(description='DNS server')
parser.add_argument('-p', '--port',
dest="port", type=int, required=True,
help="The port to bind to")
parser.add_argument('-n', '--name',
dest="name", type=str, required=True,
help="The CDN-specific name to translate to an IP")
parser.add_argument('-v', '--verbose',
dest='verbose', action='store_true', default=False,
help='Runs the server in verbose mode')
args = parser.parse_args()
# Start a DNSServer with given arguments, and CDNResolver
resolver = CDNResolver(name=args.name)
logger = DNSLogger('request,reply,truncated,error', False)
server = DNSServer(resolver,
port=args.port,
address=ANYWHERE,
logger=logger)
server.start()