Complete public hosting operations for Coulobre 0.9
This commit is contained in:
1 parent
a033d85d1f
commit
9e66510f7c
41 files changed
+2042
-44
No files matched your search
@@ -9,7 +9,7 @@ from threading import Thread
|
||||
from urllib.parse import parse_qs
|
||||
|
||||
from .cli import number
|
||||
from .config import InstallError, parse_plan, port
|
||||
from .config import REMOTE_MODES, InstallError, parse_plan, port
|
||||
from .engine import Installer
|
||||
|
||||
COOKIE = "coulobre_installer"
|
||||
@@ -19,6 +19,7 @@ FORM = """<form method="post" action="/review">
|
||||
<label>Hostname<input name="hostname" autocomplete="off" required></label>
|
||||
<label>Access<select name="access">
|
||||
<option value="tls">HTTPS on this server</option>
|
||||
<option value="acme">HTTPS with Let's Encrypt</option>
|
||||
<option value="proxy">Trusted external HTTPS proxy</option></select></label>
|
||||
<label>Panel certificate path<input name="certificate"></label>
|
||||
<label>Panel private key path<input name="key"></label>
|
||||
@@ -45,21 +46,33 @@ border-radius:.3rem;padding:.75rem 1.1rem;font:inherit} summary{cursor:pointer}
|
||||
def role_form(name):
|
||||
title = name.upper() if name == "dns" else "Mail"
|
||||
local = (
|
||||
'<label>Mail hostname<input name="mail_local_host"></label>'
|
||||
'<label>Mail certificate path<input name="mail_certificate"></label>'
|
||||
'<label>Mail private key path<input name="mail_key"></label>'
|
||||
"<label>Public mail hostname"
|
||||
'<input name="mail_local_host"></label>'
|
||||
'<label>Mail TLS<select name="mail_tls">'
|
||||
'<option value="provided">Existing certificate</option>'
|
||||
'<option value="acme">Let's Encrypt</option></select></label>'
|
||||
"<label>Certificate path on the mail host"
|
||||
'<input name="mail_certificate"></label>'
|
||||
"<label>Private key path on the mail host"
|
||||
'<input name="mail_key"></label>'
|
||||
if name == "mail"
|
||||
else ""
|
||||
)
|
||||
return f"""<fieldset><legend>{title}</legend>
|
||||
<label>Role<select name="{name}_mode"><option value="off">Disabled</option>
|
||||
<option value="local">Local service</option>
|
||||
<option value="remote">Separate Coulobre node</option></select></label>
|
||||
<option value="remote">Connect an existing Coulobre node</option>
|
||||
<option value="remote-install">Install and connect a Coulobre node</option>
|
||||
</select></label>
|
||||
{local}
|
||||
<details><summary>Separate node settings</summary>
|
||||
<label>SSH hostname or address<input name="{name}_host"></label>
|
||||
<label>SSH port<input name="{name}_port" type="number" value="22"></label>
|
||||
<label>Verified SSH host public key file<input name="{name}_host_key"></label>
|
||||
<label>SSH administrator username for installation
|
||||
<input name="{name}_ssh_user"></label>
|
||||
<label>SSH administrator key file for installation
|
||||
<input name="{name}_ssh_identity"></label>
|
||||
</details></fieldset>"""
|
||||
|
||||
|
||||
@@ -89,7 +102,7 @@ def form_plan(fields):
|
||||
for name in ("dns", "mail"):
|
||||
mode = fields.get(f"{name}_mode", "off")
|
||||
target = data[name] = {"mode": mode}
|
||||
if mode == "remote":
|
||||
if mode in REMOTE_MODES:
|
||||
target.update(
|
||||
host=fields.get(f"{name}_host", ""),
|
||||
host_key=fields.get(f"{name}_host_key", ""),
|
||||
@@ -97,12 +110,20 @@ def form_plan(fields):
|
||||
fields.get(f"{name}_port") or "22", f"the {name} node"
|
||||
),
|
||||
)
|
||||
elif name == "mail" and mode == "local":
|
||||
target.update(
|
||||
host=fields.get("mail_local_host", ""),
|
||||
certificate=fields.get("mail_certificate", ""),
|
||||
key=fields.get("mail_key", ""),
|
||||
)
|
||||
if mode == "remote-install":
|
||||
target.update(
|
||||
ssh_user=fields.get(f"{name}_ssh_user", ""),
|
||||
ssh_identity=fields.get(f"{name}_ssh_identity", ""),
|
||||
)
|
||||
if name == "mail" and mode in {"local", "remote-install"}:
|
||||
field = "host" if mode == "local" else "mail_hostname"
|
||||
target[field] = fields.get("mail_local_host", "")
|
||||
target["tls"] = fields.get("mail_tls", "provided")
|
||||
if target["tls"] == "provided":
|
||||
target.update(
|
||||
certificate=fields.get("mail_certificate", ""),
|
||||
key=fields.get("mail_key", ""),
|
||||
)
|
||||
return parse_plan(data)
|
||||
|
||||
|
||||
@@ -236,7 +257,7 @@ class WizardHandler(BaseHTTPRequestHandler):
|
||||
data = parse_qs(
|
||||
self.rfile.read(size).decode("utf-8"),
|
||||
keep_blank_values=True,
|
||||
max_num_fields=25,
|
||||
max_num_fields=32,
|
||||
errors="strict",
|
||||
)
|
||||
if any(len(values) != 1 for values in data.values()):
|
||||
|
||||
Reference in new issue
Block a user