Compare commits

..

No commits in common. "63ee2aa82b29baf47275f6af6b21fdc3749d1dfb" and "94ebacd84dbaa2fe7b002eeeff1b0aadfb3e5bb4" have entirely different histories.

8 changed files with 52 additions and 51 deletions

View File

@ -115,15 +115,4 @@ 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
```

Binary file not shown.

View File

@ -71,14 +71,6 @@ 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:
@ -88,12 +80,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 https://{domain} creating...\nI'll send you a message when it's ready")
await ctx.response.send_message(f"Site {domain} creating...\nI'll send you a message when it's ready")
ready = False
while ready == False:
@ -104,7 +96,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 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}`")
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}`")
else:
await ctx.user.send(f"Error getting site info\n" + json['error'])

View File

@ -233,6 +233,37 @@ 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')
@ -500,20 +531,19 @@ 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', title="Your site is installing.<br>Please wait...",message="")
return render_template('success.html', message="Error: Domain does not exist\nPlease contact support")
if 'status' not in request.args:
# Get worker
worker = site_worker(domain)
if worker == None:
return render_template('success.html', title="Your site is installing.<br>Please wait...",message="Error: Domain does not exist<br>Please contact support")
return render_template('success.html', message="Error: Domain does not exist\nPlease contact support")
# Get worker ip
ip = workerIP_PRIV(worker)
@ -524,14 +554,14 @@ def success():
if "tlsa" in json:
tlsa = json['tlsa']
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>")
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 + "`")
else:
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")
return render_template('success.html', message="Success\nDomain: " + domain + "\nIP: " + publicIP + "\nTLSA: Pending\nNo 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())

View File

@ -1,12 +1,10 @@
// Wait for 10 seconds
// Refresh page without status arg
// Wait 10 seconds
setTimeout(function() {
// Get the 'domain' parameter from the current URL
var urlParams = new URLSearchParams(window.location.search);
// Refresh page
// Get domain from param
var domain = urlParams.get('domain');
// 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);
window.location = "https://hnshosting.au/success?domain=" + domain;
}, 10000);

View File

@ -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">{{title| safe}}</h1>
<h1 class="fw-bold">Your site is installing.<br>Please wait...</h1>
</div>
<p class="text-center">{{message | safe}}</p>
<p class="text-center">{{message}}</p>
</div>
</div>
</div>

View File

@ -44,8 +44,8 @@ def tlsa():
tlsa_file = open('wordpress-'+domain+'/tlsa.txt', 'r')
tlsa = tlsa_file.readlines()
tlsa_file.close()
except FileNotFoundError as e:
return jsonify({'error': 'TLSA record not found', 'success': 'false', 'ex': str(e)})
except FileNotFoundError:
return jsonify({'error': 'TLSA record not found', 'success': 'false'})
# Remove newlines
tlsa = tlsa[0].strip('\n')

View File

@ -43,8 +43,6 @@ services:
MYSQL_DATABASE: WordPressDatabase
MYSQL_USER: WordPressUser
MYSQL_PASSWORD: $MYSQL_PASSWORD
volumes:
- mysql:/var/lib/mysql
wordpress:
depends_on:
- ${DOMAIN}db
@ -89,12 +87,6 @@ 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;