From a626248564d04ed7c214877d0d40ee9f91ec53b2 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 24 Aug 2023 14:19:03 +1000 Subject: [PATCH] main: Added api to return the sites info --- master/main.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/master/main.py b/master/main.py index c3c8c9a..9367bc4 100644 --- a/master/main.py +++ b/master/main.py @@ -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')