main: Added api to return the sites info
This commit is contained in:
parent
e1aa30058e
commit
a626248564
@ -179,6 +179,39 @@ def list_workers():
|
|||||||
|
|
||||||
return jsonify({'success': 'true', 'workers': worker_list})
|
return jsonify({'success': 'true', 'workers': worker_list})
|
||||||
|
|
||||||
|
@app.route('/site-info', methods=['GET'])
|
||||||
|
def site_status():
|
||||||
|
domain = request.args.get('domain')
|
||||||
|
if domain == None:
|
||||||
|
return jsonify({'error': 'Invalid domain', 'success': 'false'})
|
||||||
|
|
||||||
|
# Check if domain exists
|
||||||
|
if not site_exists(domain):
|
||||||
|
return jsonify({'error': 'Domain does not exist', 'success': 'false'})
|
||||||
|
|
||||||
|
# Get worker
|
||||||
|
worker = site_worker(domain)
|
||||||
|
if worker == None:
|
||||||
|
return jsonify({'error': 'Domain does not exist', 'success': 'false'})
|
||||||
|
|
||||||
|
# Get worker ip
|
||||||
|
ip = workerIP(worker)
|
||||||
|
|
||||||
|
# Get TLSA record
|
||||||
|
resp=requests.get("http://"+ip + ":5000/tlsa?domain=" + domain,timeout=2)
|
||||||
|
json = resp.json()
|
||||||
|
|
||||||
|
if "tlsa" in json:
|
||||||
|
tlsa = json['tlsa']
|
||||||
|
else:
|
||||||
|
tlsa = "none"
|
||||||
|
|
||||||
|
# Return status
|
||||||
|
|
||||||
|
|
||||||
|
return jsonify({'success': 'true', 'domain': domain, 'ip': ip, 'tlsa': tlsa})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/tlsa', methods=['GET'])
|
@app.route('/tlsa', methods=['GET'])
|
||||||
def tlsa():
|
def tlsa():
|
||||||
domain = request.args.get('domain')
|
domain = request.args.get('domain')
|
||||||
|
Loading…
Reference in New Issue
Block a user