main: Added api to return the sites info
All checks were successful
Build Docker / Build Bot (push) Successful in 21s
Build Docker / Build Master (push) Successful in 26s

This commit is contained in:
Nathan Woodburn 2023-08-24 14:19:03 +10:00
parent e1aa30058e
commit a626248564
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -179,6 +179,39 @@ def list_workers():
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'])
def tlsa():
domain = request.args.get('domain')