61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
from flask import Flask, request
|
|
from flask_restful import Resource, Api
|
|
|
|
app = Flask(__name__)
|
|
api = Api(app)
|
|
|
|
|
|
class WhoIS():
|
|
def __init__(self, domain):
|
|
self.domain = domain
|
|
self.registrant = {'name': 'Test Case', 'email': 'tcase@test.com',
|
|
'eligibilitytype': 'Company', 'eligibilityid': '123456789'}
|
|
self.nameservers = ['ns1.dommain.tld', 'ns2.domain.tld']
|
|
|
|
|
|
class DNS():
|
|
def __init__(self, domain):
|
|
self.getARecords()
|
|
self.getAAAARecords()
|
|
self.getMXRecords()
|
|
self.getTXTRecords()
|
|
self.getNSRecords()
|
|
|
|
def getARecords(self):
|
|
self.a = '1.2.3.4'
|
|
|
|
def getAAAARecords(self):
|
|
self.aaaa = '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
|
|
|
|
def getMXRecords(self):
|
|
self.mx = {'mail.domain.tld': 10}
|
|
|
|
def getTXTRecords(self):
|
|
self.txt = 'v=spf1 +a +mx +include:spf.hostingplatform.net.au'
|
|
|
|
def getNSRecords(self):
|
|
self.ns = ['ns1.domain.tld', 'ns2.domain.tld']
|
|
|
|
|
|
class Domain():
|
|
def __init__(self, domain):
|
|
self.domain = domain
|
|
self.whois = WhoIS(domain).__dict__
|
|
self.dns = DNS(domain).__dict__
|
|
|
|
|
|
class DNSLookup(Resource):
|
|
def get(self, domain=None):
|
|
if domain == None:
|
|
return [{'message': 'Please specify a domain name'}, 'error']
|
|
else:
|
|
ret = Domain(domain)
|
|
status = 'success'
|
|
return [ret.__dict__, status]
|
|
|
|
|
|
api.add_resource(DNSLookup, '/', '/<string:domain>')
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True, host='0.0.0.0')
|