2018-05-15 20:26:46 +08:00
|
|
|
import hashlib
|
|
|
|
import binascii
|
|
|
|
import copy
|
|
|
|
import flask_restful
|
2018-05-15 21:42:51 +08:00
|
|
|
from pthreport import PassTheHashReport, Machine, get_report_html
|
2018-05-15 20:26:46 +08:00
|
|
|
|
|
|
|
from cc.auth import jwt_required
|
|
|
|
from cc.services.edge import EdgeService
|
|
|
|
from cc.services.node import NodeService
|
|
|
|
from cc.database import mongo
|
|
|
|
|
|
|
|
class PthMap(flask_restful.Resource):
|
|
|
|
@jwt_required()
|
|
|
|
def get(self, **kw):
|
2018-05-15 21:29:02 +08:00
|
|
|
pth = PassTheHashReport()
|
|
|
|
|
|
|
|
v = copy.deepcopy(pth.vertices)
|
|
|
|
e = copy.deepcopy(pth.edges)
|
|
|
|
|
2018-05-15 20:26:46 +08:00
|
|
|
return \
|
|
|
|
{
|
2018-05-15 21:42:51 +08:00
|
|
|
"graph": {
|
|
|
|
"nodes": [{"id": x, "label": Machine(x).GetIp()} for x in v],
|
|
|
|
"edges": [{"id": str(s) + str(t), "from": s, "to": t, "label": label} for s, t, label in e]
|
|
|
|
},
|
|
|
|
|
|
|
|
"report_html": get_report_html()
|
2018-05-15 20:26:46 +08:00
|
|
|
}
|
2018-05-15 21:42:51 +08:00
|
|
|
|