Compare commits
22 Commits
6741f8cac2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
9d06151ed2
|
|||
|
63ee2aa82b
|
|||
|
49acea31ac
|
|||
|
6b855a5b29
|
|||
|
9d57b8f858
|
|||
|
6d9ba77568
|
|||
|
9c5b00433f
|
|||
|
e241f6ffeb
|
|||
|
188334c850
|
|||
|
6ea4e72e8a
|
|||
|
56c7fcd617
|
|||
|
c9f8a8237d
|
|||
|
bda99dbf5f
|
|||
|
08f36a7a50
|
|||
|
94ebacd84d
|
|||
|
6f86987901
|
|||
|
910ce1b098
|
|||
|
8f5f8df0aa
|
|||
|
7729ea62b3
|
|||
|
fca523f013
|
|||
|
4482f85ded
|
|||
|
cd598cce47
|
11
README.md
11
README.md
@@ -116,3 +116,14 @@ This will allow you to create a wordpress site without using a licence key using
|
||||
```
|
||||
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.
@@ -51,6 +51,7 @@ async def listworkers(ctx):
|
||||
await ctx.response.send_message(f"Error listing workers\n" + r.text,ephemeral=True)
|
||||
else:
|
||||
await ctx.response.send_message("You do not have permission to use this command",ephemeral=True)
|
||||
update_bot_status()
|
||||
|
||||
@tree.command(name="licence", description="Gets a licence key")
|
||||
async def license(ctx):
|
||||
@@ -70,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:
|
||||
@@ -84,7 +93,7 @@ async def createsite(ctx, domain: str, licence: str = None):
|
||||
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:
|
||||
@@ -95,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'])
|
||||
|
||||
@@ -104,6 +113,7 @@ async def createsite(ctx, domain: str, licence: str = None):
|
||||
await ctx.response.send_message(f"Error creating site\n" + json['error'])
|
||||
else:
|
||||
await ctx.response.send_message(f"Error creating site\n" + r.text)
|
||||
update_bot_status()
|
||||
|
||||
|
||||
@tree.command(name="siteinfo", description="Get info about a WordPress site")
|
||||
@@ -129,12 +139,26 @@ async def check_site_ready(domain):
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_site_count():
|
||||
r = requests.get(f"http://{Master_IP}:{Master_Port}/site-count")
|
||||
if r.status_code == 200:
|
||||
return r.text
|
||||
else:
|
||||
return "Error getting site count\n" + r.text
|
||||
|
||||
def update_bot_status():
|
||||
site_count = get_site_count()
|
||||
client.loop.create_task(client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="over " + site_count + " wordpress sites")))
|
||||
|
||||
# When the bot is ready
|
||||
@client.event
|
||||
async def on_ready():
|
||||
global ADMINID
|
||||
ADMINID = client.application.owner.id
|
||||
await tree.sync()
|
||||
await client.loop.create_task(client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="over HNSHosting wordpress")))
|
||||
|
||||
# Get the number of sites
|
||||
site_count = get_site_count()
|
||||
await client.loop.create_task(client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="over " + site_count + " wordpress sites")))
|
||||
|
||||
client.run(TOKEN)
|
||||
@@ -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')
|
||||
@@ -308,7 +277,14 @@ def stripeapi():
|
||||
return jsonify({'success': 'false'})
|
||||
|
||||
if event.type == 'payment_intent.succeeded':
|
||||
# Only for payments for licences
|
||||
payment_intent = event.data.object
|
||||
if payment_intent['amount'] != 1000:
|
||||
return jsonify({'success': 'true'})
|
||||
|
||||
if payment_intent['description'] != "Subscription creation":
|
||||
return jsonify({'success': 'true'})
|
||||
|
||||
# Get email
|
||||
email = payment_intent['receipt_email']
|
||||
# Create licence key
|
||||
@@ -531,19 +507,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,9 +531,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<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')
|
||||
|
||||
@@ -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;
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user