From d50f130b0ec0a1d413265ea856f7de38f46710bd Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 17 Aug 2023 13:48:08 +1000 Subject: [PATCH] worker: tlsa bug fixes --- worker/main.py | 11 ++++++++--- worker/wp.sh | 5 ----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/worker/main.py b/worker/main.py index e739c80..25c7a33 100644 --- a/worker/main.py +++ b/worker/main.py @@ -38,9 +38,14 @@ def tlsa(): domain = request.args.get('domain') if domain == None: return jsonify({'error': 'Invalid domain', 'success': 'false'}) - script = 'bash tlsa.sh ' + domain - # Get output from script - tlsa = os.popen(script).read() + + tlsa = None + try: + tlsa_file = open('wordpress-'+domain+'/tlsa.txt', 'r') + tlsa = tlsa_file.readlines() + tlsa_file.close() + except FileNotFoundError: + return jsonify({'error': 'TLSA record not found', 'success': 'false'}) return jsonify({'domain': domain, 'tlsa': tlsa}) diff --git a/worker/wp.sh b/worker/wp.sh index 5ee82d9..6563699 100644 --- a/worker/wp.sh +++ b/worker/wp.sh @@ -9,7 +9,6 @@ # [port offset] is the offset you want to use for the port numbers. # This is used if you want to run multiple instances of WordPress on the same server. (e.g. 0, 1, 2, 3, etc.) - # Variables # Set the domain name @@ -74,9 +73,6 @@ volumes: # Start the containers docker-compose up -d -# Create the NGINX -sudo apt install nginx -y - URL="http://localhost:$WORDPRESS_PORT" # Setup NGINX config @@ -118,7 +114,6 @@ echo "Add this TLSA Record to your DNS:" echo -n "3 1 1 " && openssl x509 -in cert.crt -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | xxd -p -u -c 32 # Save TLSA to file -echo "Add this TLSA Record to your DNS:" > tlsa.txt echo -n "3 1 1 " >> tlsa.txt echo -n "" && openssl x509 -in cert.crt -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | xxd -p -u -c 32 >> tlsa.txt