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')