From 08f36a7a50ad6ebbb42e78b0e4d0f780a110642e Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 20 Sep 2023 22:01:01 +1000 Subject: [PATCH 01/12] worker: Update wp script to use named volume for db --- worker/wp.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/worker/wp.sh b/worker/wp.sh index 04855d5..c0cc7f0 100644 --- a/worker/wp.sh +++ b/worker/wp.sh @@ -43,6 +43,8 @@ services: MYSQL_DATABASE: WordPressDatabase MYSQL_USER: WordPressUser MYSQL_PASSWORD: $MYSQL_PASSWORD + volumes: + - mysql:/var/lib/mysql wordpress: depends_on: - ${DOMAIN}db From bda99dbf5f727ee9051a2ece5e24d536ec67e250 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 20 Sep 2023 22:11:58 +1000 Subject: [PATCH 02/12] main: Updated status page style --- master/main.py | 8 ++++---- master/templates/success.html | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/master/main.py b/master/main.py index 96575b9..9d60a94 100644 --- a/master/main.py +++ b/master/main.py @@ -537,13 +537,13 @@ def success(): domain = request.args.get('domain') domain = domain.lower() if not site_exists(domain): - return render_template('success.html', message="Error: Domain does not exist\nPlease contact support") + return render_template('success.html', title="Your site is installing.
Please wait...",message="") if 'status' not in request.args: # Get worker worker = site_worker(domain) if worker == None: - return render_template('success.html', message="Error: Domain does not exist\nPlease contact support") + return render_template('success.html', title="Your site is installing.
Please wait...",message="Error: Domain does not exist
Please contact support") # Get worker ip ip = workerIP_PRIV(worker) @@ -554,9 +554,9 @@ def success(): if "tlsa" in json: tlsa = json['tlsa'] - return render_template('success.html', message="Success\nDomain: " + domain + "\nIP: " + publicIP + "\nTLSA: " + tlsa + "\nMake sure to add the TLSA record to `_443._tcp." + domain + "` or `*." + domain + "`") + return render_template('success.html', title="Your site is ready!",message="Success
Domain: " + domain + "
IP: " + publicIP + "
TLSA: " + tlsa + "
Make sure to add the TLSA record to `_443._tcp." + domain + "` or `*." + domain + "`") else: - return render_template('success.html', message="Success\nDomain: " + domain + "\nIP: " + publicIP + "\nTLSA: Pending\nNo TLSA record found") + return render_template('success.html', title="Your site is installing.
Please wait...",message="Domain: " + domain + "
IP: " + publicIP + "
TLSA: Pending
No TLSA record found") elif request.args.get('status') == 'creating': return render_template('success.html') diff --git a/master/templates/success.html b/master/templates/success.html index f2cb7f3..0c1d19d 100644 --- a/master/templates/success.html +++ b/master/templates/success.html @@ -35,9 +35,9 @@

Success

-

Your site is installing.
Please wait...

+

{{title| safe}}

-

{{message}}

+

{{message | safe}}

From c9f8a8237d2a1a364adcdb9ac546ada7de8345db Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 20 Sep 2023 22:21:00 +1000 Subject: [PATCH 03/12] main: Add code block for tlsa info --- master/main.py | 2 +- worker/main.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/master/main.py b/master/main.py index 9d60a94..49608e7 100644 --- a/master/main.py +++ b/master/main.py @@ -554,7 +554,7 @@ def success(): if "tlsa" in json: tlsa = json['tlsa'] - return render_template('success.html', title="Your site is ready!",message="Success
Domain: " + domain + "
IP: " + publicIP + "
TLSA: " + tlsa + "
Make sure to add the TLSA record to `_443._tcp." + domain + "` or `*." + domain + "`") + return render_template('success.html', title="Your site is ready!",message="Success
Domain: " + domain + "
IP: " + publicIP + "
TLSA: " + tlsa + "
Make sure to add the TLSA record to _443._tcp." + domain + " or *." + domain + "") else: return render_template('success.html', title="Your site is installing.
Please wait...",message="Domain: " + domain + "
IP: " + publicIP + "
TLSA: Pending
No TLSA record found") diff --git a/worker/main.py b/worker/main.py index cdb9c62..f9c1140 100644 --- a/worker/main.py +++ b/worker/main.py @@ -44,8 +44,8 @@ def tlsa(): 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'}) + except FileNotFoundError as e: + return jsonify({'error': 'TLSA record not found', 'success': 'false', 'ex': str(e)}) # Remove newlines tlsa = tlsa[0].strip('\n') From 56c7fcd617752f8041c63377565eaf5be36c4453 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 20 Sep 2023 22:26:34 +1000 Subject: [PATCH 04/12] main: Use the success page for info page --- master/main.py | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/master/main.py b/master/main.py index 49608e7..ede59ba 100644 --- a/master/main.py +++ b/master/main.py @@ -233,37 +233,6 @@ def site_status(): else: return jsonify({'success': 'false', 'domain': domain, 'ip': publicIP, 'tlsa': 'none','error': 'No TLSA record found'}) - -@app.route('/info') -def site_status_human(): - domain = request.args.get('domain') - domain = domain.lower() - if domain == None: - return "

Invalid domain

" - - # Check if domain exists - if not site_exists(domain): - return "

Domain does not exist

" - - # Get worker - worker = site_worker(domain) - if worker == None: - return "

Domain does not exist

" - - # Get worker ip - ip = workerIP_PRIV(worker) - - # Get TLSA record - resp=requests.get("http://"+ip + ":5000/tlsa?domain=" + domain,timeout=2) - json = resp.json() - publicIP = workerIP(worker) - - if "tlsa" in json: - tlsa = json['tlsa'] - return "

Domain: " + domain + "


IP: " + publicIP + "


TLSA: " + tlsa + "


Make sure to add the TLSA record to `_443._tcp." + domain + "` or `*." + domain + "`

" - else: - return "

Domain: " + domain + "


IP: " + publicIP + "


TLSA: none


No TLSA record found

" - @app.route('/tlsa', methods=['GET']) def tlsa(): domain = request.args.get('domain') @@ -561,7 +530,10 @@ def success(): elif request.args.get('status') == 'creating': return render_template('success.html') - +@app.route('/info') +def info(): + success() + @app.route('/site-count') def site_count_route(): return str(get_sites_count()) @@ -648,7 +620,7 @@ def admin(): if not site.__contains__(':'): continue domain = site.split(':')[0] - html += "

Domain: " + domain + " | Worker: " + site.split(':')[1].strip('\n') + " | Info

" + html += "

Domain: " + domain + " | Worker: " + site.split(':')[1].strip('\n') + " | Info

" html += "

" # Form to add worker From 6ea4e72e8a2280ff76e3b2f1d06369ed59d304fd Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 20 Sep 2023 22:29:27 +1000 Subject: [PATCH 05/12] main: Add style to tlsa --- master/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/master/main.py b/master/main.py index ede59ba..a3cbbff 100644 --- a/master/main.py +++ b/master/main.py @@ -523,9 +523,9 @@ def success(): if "tlsa" in json: tlsa = json['tlsa'] - return render_template('success.html', title="Your site is ready!",message="Success
Domain: " + domain + "
IP: " + publicIP + "
TLSA: " + tlsa + "
Make sure to add the TLSA record to _443._tcp." + domain + " or *." + domain + "") + return render_template('success.html', title="Your site is ready!",message="Success
Domain: " + domain + "
IP: " + publicIP + "
TLSA: " + tlsa + "
Make sure to add the TLSA record to _443._tcp." + domain + " or *." + domain + "") else: - return render_template('success.html', title="Your site is installing.
Please wait...",message="Domain: " + domain + "
IP: " + publicIP + "
TLSA: Pending
No TLSA record found") + return render_template('success.html', title="Your site is installing.
Please wait...",message="Domain: " + domain + "
IP: " + publicIP + "
TLSA: Pending
No TLSA record found") elif request.args.get('status') == 'creating': return render_template('success.html') From 188334c8508fe689389fe3659af7c860e9c6f9ac Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 20 Sep 2023 22:32:14 +1000 Subject: [PATCH 06/12] main: Updated refresh script --- master/templates/assets/js/status_update.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/master/templates/assets/js/status_update.js b/master/templates/assets/js/status_update.js index 0738dca..9f6509a 100644 --- a/master/templates/assets/js/status_update.js +++ b/master/templates/assets/js/status_update.js @@ -1,10 +1,12 @@ -// Refresh page without status arg - -// Wait 10 seconds +// Wait for 10 seconds setTimeout(function() { - // Refresh page - // Get domain from param + // Get the 'domain' parameter from the current URL + var urlParams = new URLSearchParams(window.location.search); var domain = urlParams.get('domain'); - window.location = "https://hnshosting.au/success?domain=" + domain; -}, 10000); \ No newline at end of file + // Construct the new URL with the 'domain' parameter + var newURL = "https://hnshosting.au/info?domain=" + domain; + + // Redirect to the new URL + window.location.href = newURL; +}, 10000); From e241f6ffeb1514adff3d971daa483e056e610401 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 20 Sep 2023 22:33:09 +1000 Subject: [PATCH 07/12] main: Add return to info page --- master/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/main.py b/master/main.py index a3cbbff..c159d9a 100644 --- a/master/main.py +++ b/master/main.py @@ -532,7 +532,7 @@ def success(): @app.route('/info') def info(): - success() + return success() @app.route('/site-count') def site_count_route(): From 9c5b00433feec15650640557ac37ca4768dc9e68 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 21 Sep 2023 11:32:34 +1000 Subject: [PATCH 08/12] bot: Adding a few catches to the bot --- discord-bot/bot.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/discord-bot/bot.py b/discord-bot/bot.py index cf7fa15..6293b17 100644 --- a/discord-bot/bot.py +++ b/discord-bot/bot.py @@ -71,6 +71,14 @@ async def license(ctx): @tree.command(name="createsite", description="Create a new WordPress site") async def createsite(ctx, domain: str, licence: str = None): + # Verify domain is valid + if domain == None: + await ctx.response.send_message("You must specify a domain",ephemeral=True) + return + if "http://" in domain or "https://" in domain: + await ctx.response.send_message("You must specify a domain without http:// or https://",ephemeral=True) + return + if FREE_LICENCE == True: # If free licences are enabled then auto generate a licence r = requests.post(f"http://{Master_IP}:{Master_Port}/add-licence",headers={"key":os.getenv('LICENCE_KEY')}) if r.status_code == 200: @@ -80,12 +88,12 @@ async def createsite(ctx, domain: str, licence: str = None): else: await ctx.response.send_message(f"Error getting license\n" + json['error']) return - + r = requests.post(f"http://{Master_IP}:{Master_Port}/new-site?domain={domain}",headers={"key":licence}) if r.status_code == 200: json = r.json() if json['success'] == "true": - await ctx.response.send_message(f"Site {domain} creating...\nI'll send you a message when it's ready") + await ctx.response.send_message(f"Site https://{domain} creating...\nI'll send you a message when it's ready") ready = False while ready == False: @@ -96,7 +104,7 @@ async def createsite(ctx, domain: str, licence: str = None): r = requests.get(f"http://{Master_IP}:{Master_Port}/site-info?domain={domain}") json = r.json() if json['success'] == "true": - await ctx.user.send(f"Site {domain} is ready!\nHere is the site info for {json['domain']}\nA: `{json['ip']}`\nTLSA: `{json['tlsa']}`\nMake sure you put the TLSA in either `_443._tcp.{domain}` or `*.{domain}`") + await ctx.user.send(f"Site https://{domain} is ready!\nHere is the site info for {json['domain']}\nA: `{json['ip']}`\nTLSA: `{json['tlsa']}`\nMake sure you put the TLSA in either `_443._tcp.{domain}` or `*.{domain}`") else: await ctx.user.send(f"Error getting site info\n" + json['error']) From 6d9ba77568f1f4d322a5ee707233d53ae31d5b9d Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Mon, 25 Sep 2023 15:07:56 +1000 Subject: [PATCH 09/12] main: Fix return for info page --- master/main.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/master/main.py b/master/main.py index c159d9a..7d70eed 100644 --- a/master/main.py +++ b/master/main.py @@ -500,6 +500,7 @@ def register_post(): return redirect('/success?domain=' + domain + '&status=creating') @app.route('/success') +@app.route('/info') def success(): if 'domain' not in request.args: return redirect('/') @@ -529,10 +530,7 @@ def success(): elif request.args.get('status') == 'creating': return render_template('success.html') - -@app.route('/info') -def info(): - return success() + @app.route('/site-count') def site_count_route(): From 9d57b8f85888f032b183c576eb95e29dc643bd45 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Mon, 25 Sep 2023 15:14:16 +1000 Subject: [PATCH 10/12] main: Update admin page --- master/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/main.py b/master/main.py index 7d70eed..c695878 100644 --- a/master/main.py +++ b/master/main.py @@ -618,7 +618,7 @@ def admin(): if not site.__contains__(':'): continue domain = site.split(':')[0] - html += "

Domain: " + domain + " | Worker: " + site.split(':')[1].strip('\n') + " | Info

" + html += "

Domain: " + domain + " | Worker: " + site.split(':')[1].strip('\n') + " | Info

" html += "

" # Form to add worker From 6b855a5b29f98426a4f651fd49e0dfd8d74c6fa2 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Mon, 23 Oct 2023 15:42:38 +1100 Subject: [PATCH 11/12] fix: Fix wordpress rewrites for hip2 --- worker/wp.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/worker/wp.sh b/worker/wp.sh index c0cc7f0..2a3e7b3 100644 --- a/worker/wp.sh +++ b/worker/wp.sh @@ -89,6 +89,12 @@ printf "server { sub_filter_once on; } + location = /.well-known/wallets/HNS { + proxy_pass $URL; + proxy_set_header Host \$http_host; + rewrite ^(.*)$ \$1/ break; + } + listen 443 ssl; ssl_certificate /etc/ssl/$DOMAIN.crt; From 49acea31ac2a2fe05c56f9978b3784f1d81bd705 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Mon, 23 Oct 2023 15:46:16 +1100 Subject: [PATCH 12/12] feat: Add instructions for enabling HIP2 on WordPress site This commit adds detailed instructions for enabling HIP2 on a WordPress site. It includes steps to download, upload, and activate the HIP2 plugin, as well as setting the HNS wallet address and testing the functionality. --- README.md | 13 ++++++++++++- assets/hns-wallet-plugin.zip | Bin 0 -> 1168 bytes 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 assets/hns-wallet-plugin.zip diff --git a/README.md b/README.md index def6909..ee42c56 100644 --- a/README.md +++ b/README.md @@ -115,4 +115,15 @@ Enable the free mode by setting the following environment variable. This will allow you to create a wordpress site without using a licence key using the /createsite command. ``` FREE_MODE: true -``` \ No newline at end of file +``` + + +## Hip2 +HIP2 allows sending HNS to a domain. +To enable HIP2 on your wordpress site you should + +1. Download the [HIP2 plugin](https://git.woodburn.au/nathanwoodburn/hnshosting-wp/raw/branch/main/assets/hns-wallet-plugin.zip) +2. Upload the plugin to your wordpress site +3. Activate the plugin +4. Go to the settings page and enter your HNS wallet address +5. Ensure it works by settings the permalink to post name and saving \ No newline at end of file diff --git a/assets/hns-wallet-plugin.zip b/assets/hns-wallet-plugin.zip new file mode 100644 index 0000000000000000000000000000000000000000..fab70cbae9425480d6279192ed0fae0c4d4a0e22 GIT binary patch literal 1168 zcmWIWW@Zs#00D#A@Nh5#N(cezjJ#sq^2D5+)Dqo-oYM5nJpBN$dL{-A22G&)!uXvF z3z!)g9&<1-sAE-+VS-*kM#0ul@BG^q0{dQv^RO@naUIXz;c&`{9`vvwyDD3Z1Zr>)p<1W5)R&uK5oh zFK7SZWU*W}{c4!9SEr3)inSTo6^R&DihNb!h*&tW!UqE}pQ} z;}zRE6}c$ybj>Sgra35-A3N3cSHYVlXKmWS_>kFZSFXM(EqI=z`IYxsnzxd{3Y}?w z-48;ASPq`*ypztl)FATpyv(TVw9I9)%RjRIk!G-4qS4m%V*dW~Dl_i*Ez)%H5&4qY z_I0Oi!tyZdS5w1Qy?7M+L8c<+(h`Bi?3?2%)x_Ty7(IO7_bPUq>a8Qf|8GCNBeSor zc?-Yf-t3ZDQ94f9m!57+x)UVp&b}wm%=YNc7>_{1iJ>7o9AEBH2u|^R?Dk~-3Uf97 zD^Y6KB;HTirN6erVTzC0W|IxaRrGGF=$+-<5!W|&m#0RSPhVBxj^iuXfM!VXeE6Q4 zpxrUkG1lhfJA3;-KTB_<+kb0wyRTdE@!xHG zmYuTQdG+@3RhrZKT|NgnndsjTEAs2{JRBt~su%a{lWXk0$T<@Il}(=(KJ*uO#yrpr(A$LbSt7%@OAQee(UIS?iv#FW4g5e|+NaHvcna@h>J!)j4|frR2iZ z-z#Fjye>TBFAli%qU&+=#NkFZb9e0cu%RHHA)ib|WFoyp1h zv&*S}N3!JoUPXx|F9k2GQT(&w{_H$g-kRTMN)0Sj?Czyj$NII1=&0|}zInc@(JXxZ z@(*n5Kgb7oGcwsT