-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI-ProtocolTest.py
More file actions
79 lines (65 loc) · 2.21 KB
/
API-ProtocolTest.py
File metadata and controls
79 lines (65 loc) · 2.21 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from flask import Flask, jsonify
from flask_restful import Api, Resource, reqparse
from protocolsTest import *
from dnsRecordTest import *
from blacklisLookup import *
app = Flask(__name__)
api = Api(app)
class Imap(Resource):
def post(self):
parser = reqparse.RequestParser()
parser.add_argument("user")
parser.add_argument("password")
parser.add_argument("server")
args = parser.parse_args()
imap = protocolsTest()
imap = imap.imapTest(args["user"], args["password"], args["server"])
return jsonify(
email=args["user"],
response=imap
)
class Pop(Resource):
def post(self):
parser = reqparse.RequestParser()
parser.add_argument("user")
parser.add_argument("password")
parser.add_argument("server")
args = parser.parse_args()
pop = protocolsTest()
pop = pop.popTest(args["user"], args["password"], args["server"])
return jsonify(
email=args["user"],
response=pop
)
class Smtp(Resource):
def post(self):
parser = reqparse.RequestParser()
parser.add_argument("user")
parser.add_argument("password")
parser.add_argument("recipient")
parser.add_argument("server")
args = parser.parse_args()
smtp = protocolsTest()
smtp = smtp.smtpTest(args["user"], args["password"], args["recipient"], args["server"])
return jsonify(
email_from=args["user"],
email_to=args["recipeint"],
response=smtp
)
class Dns(Resource):
def get(self, record, dnstype):
dns = dnsRecordTest()
dns = dns.getRecord(record,dnstype)
return jsonify(dns)
class Blacklist(Resource):
def get(self, record):
blacklist = blacklistLookup()
blacklist = blacklist.setLookupParam(record)
return jsonify(blacklist)
api.add_resource(Imap, "/imap")
api.add_resource(Pop, "/pop")
api.add_resource(Smtp, "/smtp")
api.add_resource(Dns, "/dns/<string:record>/<string:dnstype>")
api.add_resource(Blacklist, "/blacklist/<string:record>")
#app.run(ssl_context='adhoc')
app.run(debug=True,host='0.0.0.0', port=80)