Merge branch 'develop' into main
This commit is contained in:
commit
63ee2aa82b
13
README.md
13
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
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
## 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
|
BIN
assets/hns-wallet-plugin.zip
Normal file
BIN
assets/hns-wallet-plugin.zip
Normal file
Binary file not shown.
@ -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'])
|
||||
|
||||
|
@ -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 "<h1>Invalid domain</h1>"
|
||||
|
||||
# Check if domain exists
|
||||
if not site_exists(domain):
|
||||
return "<h1>Domain does not exist</h1>"
|
||||
|
||||
# Get worker
|
||||
worker = site_worker(domain)
|
||||
if worker == None:
|
||||
return "<h1>Domain does not exist</h1>"
|
||||
|
||||
# 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 "<h1>Domain: " + domain + "</h1><br><p>IP: " + publicIP + "</p><br><p>TLSA: " + tlsa + "</p><br><p>Make sure to add the TLSA record to `_443._tcp." + domain + "` or `*." + domain + "`</p>"
|
||||
else:
|
||||
return "<h1>Domain: " + domain + "</h1><br><p>IP: " + publicIP + "</p><br><p>TLSA: none</p><br><p>No TLSA record found</p>"
|
||||
|
||||
@app.route('/tlsa', methods=['GET'])
|
||||
def tlsa():
|
||||
domain = request.args.get('domain')
|
||||
@ -531,19 +500,20 @@ 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('/')
|
||||
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.<br>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.<br>Please wait...",message="Error: Domain does not exist<br>Please contact support")
|
||||
# Get worker ip
|
||||
ip = workerIP_PRIV(worker)
|
||||
|
||||
@ -554,14 +524,14 @@ 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<br>Domain: <code>" + domain + "</code><br>IP: <code>" + publicIP + "</code><br>TLSA: <code>" + tlsa + "</code><br>Make sure to add the TLSA record to <code>_443._tcp." + domain + "</code> or <code>*." + domain + "</code>")
|
||||
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.<br>Please wait...",message="Domain: <code>" + domain + "</code><br>IP: <code>" + publicIP + "</code><br>TLSA: Pending<br>No TLSA record found")
|
||||
|
||||
elif request.args.get('status') == 'creating':
|
||||
return render_template('success.html')
|
||||
|
||||
|
||||
|
||||
|
||||
@app.route('/site-count')
|
||||
def site_count_route():
|
||||
return str(get_sites_count())
|
||||
|
@ -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);
|
||||
// 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);
|
||||
|
@ -35,9 +35,9 @@
|
||||
<div class="col-md-8 col-xl-6 text-center text-md-start mx-auto">
|
||||
<div class="text-center">
|
||||
<p class="fw-bold text-success mb-2">Success</p>
|
||||
<h1 class="fw-bold">Your site is installing.<br>Please wait...</h1>
|
||||
<h1 class="fw-bold">{{title| safe}}</h1>
|
||||
</div>
|
||||
<p class="text-center">{{message}}</p>
|
||||
<p class="text-center">{{message | safe}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
@ -87,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;
|
||||
|
Loading…
Reference in New Issue
Block a user