-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
65 lines (45 loc) · 1.41 KB
/
index.py
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
import os
import requests
from flask import Flask, jsonify, json
from werkzeug.exceptions import HTTPException
from MNetwork import MRoute, MPing, MDns
app = Flask(__name__)
@app.route('/dns/query/<name>')
def DNSQuery(name):
return jsonify(MDns.Dns(name).Query())
@app.route('/dns/check/<name>')
def DNSCheck(name):
return jsonify(MDns.Dns(name).SpoofCheck())
@app.route('/route/trace/<ip>')
def RouteTrace(ip):
return jsonify(MRoute.Trace(ip).ICMP())
@app.route('/route/trace/<ip>/<port>')
def TCPRouteTrace(ip, port):
return jsonify(MRoute.Trace(ip, port=int(port)).TCP())
@app.route('/ping/icmp/<ip>')
def ICMPing(ip):
return jsonify(MPing.Ping(ip).ICMP())
@app.route('/ping/tcp/<ip>/<port>')
def TCPing(ip, port):
return jsonify(MPing.Ping(ip, port=int(port)).TCP())
@app.route('/hello')
def Hello():
return jsonify(requests.get('https://ip.mili.one/').text)
@app.errorhandler(HTTPException)
def handle_exception(e):
response = e.get_response()
response.data = json.dumps({
"code": e.code,
"name": e.name,
"description": e.description,
})
response.content_type = "application/json"
return response
if __name__ == '__main__':
print('Welcome to Eris API')
HOST = os.environ.get('SERVER_HOST', '0.0.0.0')
try:
PORT = int(os.environ.get('SERVER_PORT', '2025'))
except ValueError:
PORT = 2025
app.run(HOST, PORT)