Local container deployment
This commit is contained in:
parent
a744c3ad98
commit
5e73c9fea9
9 changed files with 32 additions and 243 deletions
|
@ -2,9 +2,9 @@
|
|||
if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false)
|
||||
exit("This file is meant to be included.");
|
||||
|
||||
function addNiverLog($message, $outputLines, $returnCode) {
|
||||
function addNiverLog($message, $outputLines, $returnCode = false) {
|
||||
$logs = "\n" . date("Y-m-d H:i:s") . " " . $message . "\n";
|
||||
if (isset($returnCode))
|
||||
if ($returnCode !== false)
|
||||
$logs = $logs . "Return code: " . $returnCode . "\n";
|
||||
else
|
||||
$logs = $logs . "No return code logged\n";
|
||||
|
|
|
@ -50,7 +50,7 @@ function antiCSRF() {
|
|||
if (!isset($_SERVER['HTTP_SEC_FETCH_SITE']) AND !isset($_SERVER['HTTP_ORIGIN']))
|
||||
exit("ERROR: Browser sent neither Sec-Fetch-Site nor Origin HTTP headers, so anti-CSRF verification can't be done.");
|
||||
|
||||
if (isset($_SERVER['HTTP_ORIGIN']) AND $_SERVER['HTTP_ORIGIN'] !== "https://niver.4.niv.re")
|
||||
if (isset($_SERVER['HTTP_ORIGIN']) AND $_SERVER['HTTP_ORIGIN'] !== ORIGIN)
|
||||
exit("ERROR: Anti-CSRF verification failed");
|
||||
|
||||
if (isset($_SERVER['HTTP_SEC_FETCH_SITE']) AND $_SERVER['HTTP_SEC_FETCH_SITE'] !== "same-origin")
|
||||
|
|
|
@ -5,8 +5,11 @@ if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false)
|
|||
// --- Constants definitions ---
|
||||
|
||||
// Public IP adresses (shown on the interface)
|
||||
define("IPV4_ADDRESS", "82.66.61.19");
|
||||
define("IPV6_ADDRESS", "2a01:e0a:15c:2e40:acab:3:3:3");
|
||||
define("IPV4_ADDRESS", "127.0.0.1");
|
||||
define("IPV6_ADDRESS", "::1");
|
||||
|
||||
define("ORIGIN", "https://niver.test:42443");
|
||||
define("REGISTRY", "niver.test.");
|
||||
|
||||
// Example IP adresses (for placeholders)
|
||||
define("IPV4_EXAMPLE", "203.0.113.42"); // See RFC5737: IPv4 Address Blocks Reserved for Documentation
|
||||
|
@ -14,7 +17,7 @@ define("IPV6_EXAMPLE", "2001:db8::3"); // See RFC3849: IPv6 Address Prefix Reser
|
|||
define("DOMAIN_EXAMPLE", "example"); // From RFC2606: Reserved Top Level DNS Names > 2. TLDs for Testing, & Documentation Examples
|
||||
|
||||
// Custom Niver paths
|
||||
define("PREFIX", "/motrig"); // Prefix in URL, if any
|
||||
define("PREFIX", ""); // Prefix in URL, if any
|
||||
define("ROOT_PATH", "/var/www/niver" . PREFIX); // Niver's directory
|
||||
define("SERVICE", substr(dirname($_SERVER['PHP_SELF']), strlen(PREFIX) + 1));
|
||||
define("PAGE", basename($_SERVER['PHP_SELF'], '.php'));
|
||||
|
@ -29,8 +32,6 @@ define("TOR_CONFIG_PATH", "/etc/tor/instances/niver/torrc"); // Tor configuratio
|
|||
define("TOR_KEYS_PATH", "/var/lib/tor-instances/niver/keys"); // Tor keys directory
|
||||
// Knot
|
||||
define("KNOT_ZONES_PATH", "/var/lib/knot/zones"); // Knot zones directory
|
||||
// Twins
|
||||
define("TWINS_PATH", "/var/local/twins"); // Twins directory containing configuration and TLS certificates
|
||||
// Executable files (you can get the full path of a command with $ which <command>)
|
||||
define("KNOTC_PATH", "/usr/sbin/knotc");
|
||||
define("KEYMGR_PATH", "/usr/sbin/keymgr");
|
||||
|
@ -64,115 +65,11 @@ define("THEME", array(
|
|||
'lightHtColor' => "#FFFF00",
|
||||
'lightAuthColor' => "#00FF00",
|
||||
|
||||
//The old theme for both dark and light themes
|
||||
/*'htColor' => "#FF0000",
|
||||
'regColor' => "#DA03E5",
|
||||
'authColor' => "#00FF00",
|
||||
'nsColor' => "#00A5A5",*/
|
||||
|
||||
'lightColor' => '#FFFFFF',
|
||||
'darkColor' => '#000000',
|
||||
));
|
||||
|
||||
// Public suffixes
|
||||
define("SUFFIXES", array(
|
||||
"4.niv.re.",
|
||||
|
||||
"asso.4.niv.re.",
|
||||
"org.4.niv.re.",
|
||||
"perso.4.niv.re.",
|
||||
"blog.4.niv.re.",
|
||||
"me.4.niv.re.",
|
||||
|
||||
"edu.4.niv.re.",
|
||||
"info.4.niv.re.",
|
||||
"wiki.4.niv.re.",
|
||||
"sci.4.niv.re.",
|
||||
|
||||
"pol.4.niv.re.",
|
||||
"libre.4.niv.re.",
|
||||
"fem.4.niv.re.",
|
||||
"eco.4.niv.re.",
|
||||
"veg.4.niv.re.",
|
||||
"bio.4.niv.re.",
|
||||
"anar.4.niv.re.",
|
||||
"ancom.4.niv.re.",
|
||||
"acab.4.niv.re.",
|
||||
"handi.4.niv.re.",
|
||||
|
||||
"queer.4.niv.re.",
|
||||
"gay.4.niv.re.",
|
||||
"enby.4.niv.re.",
|
||||
"trans.4.niv.re.",
|
||||
|
||||
"net.4.niv.re.",
|
||||
"tech.4.niv.re.",
|
||||
"io.4.niv.re.",
|
||||
"sec.4.niv.re.",
|
||||
"cyber.4.niv.re.",
|
||||
"dev.4.niv.re.",
|
||||
"geek.4.niv.re.",
|
||||
"fs.4.niv.re.",
|
||||
"ht.4.niv.re.",
|
||||
"hyper.4.niv.re.",
|
||||
"git.4.niv.re.",
|
||||
"forge.4.niv.re.",
|
||||
"code.4.niv.re.",
|
||||
"lab.4.niv.re.",
|
||||
"labs.4.niv.re.",
|
||||
"gemini.4.niv.re.",
|
||||
"gmi.4.niv.re.",
|
||||
"gemlog.4.niv.re.",
|
||||
"mail.4.niv.re.",
|
||||
"ynh.4.niv.re.",
|
||||
"yuno.4.niv.re.",
|
||||
"sys.4.niv.re.",
|
||||
|
||||
"fed.4.niv.re.",
|
||||
"fedi.4.niv.re.",
|
||||
"soc.4.niv.re.",
|
||||
"masto.4.niv.re.",
|
||||
"plero.4.niv.re.",
|
||||
"pix.4.niv.re.",
|
||||
"mobi.4.niv.re.",
|
||||
|
||||
"art.4.niv.re.",
|
||||
"music.4.niv.re.",
|
||||
"video.4.niv.re.",
|
||||
"draw.4.niv.re.",
|
||||
"audio.4.niv.re.",
|
||||
"ink.4.niv.re.",
|
||||
|
||||
"na.4.niv.re.",
|
||||
"psy.4.niv.re.",
|
||||
"neuro.4.niv.re.",
|
||||
"auti.4.niv.re.",
|
||||
"plur.4.niv.re.",
|
||||
|
||||
"blue.4.niv.re.",
|
||||
"red.4.niv.re.",
|
||||
"pink.4.niv.re.",
|
||||
"green.4.niv.re.",
|
||||
"black.4.niv.re.",
|
||||
|
||||
"city.4.niv.re.",
|
||||
"town.4.niv.re.",
|
||||
"cafe.4.niv.re.",
|
||||
"home.4.niv.re.",
|
||||
"forum.4.niv.re.",
|
||||
|
||||
"dream.4.niv.re.",
|
||||
"space.4.niv.re.",
|
||||
"forest.4.niv.re.",
|
||||
"rain.4.niv.re.",
|
||||
"snow.4.niv.re.",
|
||||
"sun.4.niv.re.",
|
||||
"earth.4.niv.re.",
|
||||
"world.4.niv.re.",
|
||||
"soft.4.niv.re.",
|
||||
"cute.4.niv.re.",
|
||||
"cutie.4.niv.re.",
|
||||
"fun.4.niv.re.",
|
||||
"play.4.niv.re.",
|
||||
"game.4.niv.re.",
|
||||
REGISTRY,
|
||||
));
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<div>
|
||||
<label for="ttl-value">Valeur</label>
|
||||
<br>
|
||||
<input required="" id="ttl-value" list="ttls" name="ttl-value" size="6" type="number" min="1" max="432000" value="3600" placeholder="3600">
|
||||
<input required="" id="ttl-value" list="ttls" name="ttl-value" size="6" type="number" min="1" max="432000" value="10800" placeholder="10800">
|
||||
<datalist id="ttls">
|
||||
<option value="900">
|
||||
<option value="1800">
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php require "top.inc.php"; ?>
|
||||
|
||||
<dl>
|
||||
<dt><a class="regButton" href="reg/">Registre 4.niv.re.</a></dt>
|
||||
<dt><a class="regButton" href="reg/">Registre <code><?= REGISTRY ?></code></a></dt>
|
||||
<dd>
|
||||
Demander l'attribution d'un sous-domaine de <code>4.niv.re.</code>
|
||||
Demander l'attribution d'un sous-domaine de <code><?= REGISTRY ?></code>
|
||||
</dd>
|
||||
<dt><a class="nsButton" href="ns/">Serveurs de noms</a></dt>
|
||||
<dd>
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
<dl>
|
||||
<dt><a class="regButton" href="register">Enregistrer un nouveau domaine</a></dt>
|
||||
<dd>
|
||||
Prendre possession d'un sous-domaine de 4.niv.re.
|
||||
Prendre possession d'un sous-domaine de <code><?= REGISTRY ?></code>
|
||||
</dd>
|
||||
<dt><a class="regButton" href="ns">Enregistrement <abbr title="Name Server">NS</abbr></a></dt>
|
||||
<dd>
|
||||
Indiquer les serveurs de noms de son sous-domaine de 4.niv.re.
|
||||
Indiquer les serveurs de noms de son sous-domaine de <code><?= REGISTRY ?></code>
|
||||
</dd>
|
||||
<dt><a class="regButton" href="ds">Enregistrement <abbr title="Delegation Signer">DS</abbr></a></dt>
|
||||
<dd>
|
||||
|
@ -15,7 +15,7 @@
|
|||
</dd>
|
||||
<dt><a class="regButton" href="glue">Glue Record</a></dt>
|
||||
<dd>
|
||||
Indiquer les IP de ses serveurs de noms de son sous-domaine de 4.niv.re. dont les adresses se trouvent sur ce même sous-domaine
|
||||
Indiquer les IP de ses serveurs de noms de son sous-domaine de <code><?= REGISTRY ?></code> dont les adresses se trouvent sur ce même sous-domaine
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
|
18
reg/ns.php
18
reg/ns.php
|
@ -45,10 +45,20 @@ if (isset($_POST['domain']) AND isset($_POST['action']) AND isset($_POST['ns'])
|
|||
|
||||
$suffix = regGetUpperDomain($_POST['domain']);
|
||||
|
||||
exec(KNOTC_PATH . " zone-begin " . $suffix);
|
||||
exec(KNOTC_PATH . " zone-" . $action . "set " . $suffix . " " . $_POST['domain'] . " 86400 NS " . $_POST['ns']);
|
||||
exec(KNOTC_PATH . " zone-commit " . $suffix);
|
||||
echo "Enregistrement NS ajouté";
|
||||
exec(KNOTC_PATH . " zone-begin " . $suffix, $output);
|
||||
exec(KNOTC_PATH . " zone-" . $action . "set " . $suffix . " " . $_POST['domain'] . " 86400 IN NS " . $_POST['ns'], $output);
|
||||
exec(KNOTC_PATH . " zone-commit " . $suffix, $output);
|
||||
foreach ($output as $line) {
|
||||
if ($line !== "OK") {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
if ($error) {
|
||||
appendLog($output);
|
||||
echo "An ERROR occured!";
|
||||
} else {
|
||||
echo "Modification effectuée avec succès";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
114
reg/register.php
114
reg/register.php
|
@ -16,119 +16,7 @@ Ce domaine doit être composé uniquement d'au moins 4 lettres latines non accen
|
|||
<label for="suffix">Suffixe</label>
|
||||
<br>
|
||||
<select required="" id="suffix" name="suffix">
|
||||
<option selected="" value="4.niv.re.">.4.niv.re.</option>
|
||||
<optgroup label="Organisations">
|
||||
<option value="asso.4.niv.re.">.asso.4.niv.re.</option>
|
||||
<option value="org.4.niv.re.">.org.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Personnels">
|
||||
<option value="perso.4.niv.re.">.perso.4.niv.re.</option>
|
||||
<option value="blog.4.niv.re.">.blog.4.niv.re.</option>
|
||||
<option value="me.4.niv.re.">.me.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Connaissance">
|
||||
<option value="edu.4.niv.re.">.edu.4.niv.re.</option>
|
||||
<option value="info.4.niv.re.">.info.4.niv.re.</option>
|
||||
<option value="wiki.4.niv.re.">.wiki.4.niv.re.</option>
|
||||
<option value="sci.4.niv.re.">.sci.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Politique">
|
||||
<option value="pol.4.niv.re.">.pol.4.niv.re.</option>
|
||||
<option value="libre.4.niv.re.">.libre.4.niv.re.</option>
|
||||
<option value="fem.4.niv.re.">.fem.4.niv.re.</option>
|
||||
<option value="eco.4.niv.re.">.eco.4.niv.re.</option>
|
||||
<option value="veg.4.niv.re.">.veg.4.niv.re.</option>
|
||||
<option value="bio.4.niv.re.">.bio.4.niv.re.</option>
|
||||
<option value="anar.4.niv.re.">.anar.4.niv.re.</option>
|
||||
<option value="ancom.4.niv.re.">.ancom.4.niv.re.</option>
|
||||
<option value="acab.4.niv.re.">.acab.4.niv.re.</option>
|
||||
<option value="handi.4.niv.re.">.handi.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="LGBT+">
|
||||
<option value="queer.4.niv.re.">.queer.4.niv.re.</option>
|
||||
<option value="gay.4.niv.re.">.gay.4.niv.re.</option>
|
||||
<option value="enby.4.niv.re.">.enby.4.niv.re.</option>
|
||||
<option value="trans.4.niv.re.">.trans.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Technologie">
|
||||
<option value="net.4.niv.re.">.net.4.niv.re.</option>
|
||||
<option value="tech.4.niv.re.">.tech.4.niv.re.</option>
|
||||
<option value="io.4.niv.re.">.io.4.niv.re.</option>
|
||||
<option value="sec.4.niv.re.">.sec.4.niv.re.</option>
|
||||
<option value="cyber.4.niv.re.">.cyber.4.niv.re.</option>
|
||||
<option value="dev.4.niv.re.">.dev.4.niv.re.</option>
|
||||
<option value="geek.4.niv.re.">.geek.4.niv.re.</option>
|
||||
<option value="fs.4.niv.re.">.fs.4.niv.re.</option>
|
||||
<option value="ht.4.niv.re.">.ht.4.niv.re.</option>
|
||||
<option value="hyper.4.niv.re.">.hyper.4.niv.re.</option>
|
||||
<option value="git.4.niv.re.">.git.4.niv.re.</option>
|
||||
<option value="forge.4.niv.re.">.forge.4.niv.re.</option>
|
||||
<option value="code.4.niv.re.">.code.4.niv.re.</option>
|
||||
<option value="lab.4.niv.re.">.lab.4.niv.re.</option>
|
||||
<option value="labs.4.niv.re.">.labs.4.niv.re.</option>
|
||||
<option value="gemini.4.niv.re.">.gemini.4.niv.re.</option>
|
||||
<option value="gmi.4.niv.re.">.gmi.4.niv.re.</option>
|
||||
<option value="gemlog.4.niv.re.">.gemlog.4.niv.re.</option>
|
||||
<option value="mail.4.niv.re.">.mail.4.niv.re.</option>
|
||||
<option value="ynh.4.niv.re.">.ynh.4.niv.re.</option>
|
||||
<option value="yuno.4.niv.re.">.yuno.4.niv.re.</option>
|
||||
<option value="sys.4.niv.re.">.sys.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Fédiverse">
|
||||
<option value="fed.4.niv.re.">.fed.4.niv.re.</option>
|
||||
<option value="fedi.4.niv.re.">.fedi.4.niv.re.</option>
|
||||
<option value="soc.4.niv.re.">.soc.4.niv.re.</option>
|
||||
<option value="masto.4.niv.re.">.masto.4.niv.re.</option>
|
||||
<option value="plero.4.niv.re.">.plero.4.niv.re.</option>
|
||||
<option value="pix.4.niv.re.">.pix.4.niv.re.</option>
|
||||
<option value="mobi.4.niv.re.">.mobi.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Arts">
|
||||
<option value="art.4.niv.re.">.art.4.niv.re.</option>
|
||||
<option value="music.4.niv.re.">.music.4.niv.re.</option>
|
||||
<option value="video.4.niv.re.">.video.4.niv.re.</option>
|
||||
<option value="draw.4.niv.re.">.draw.4.niv.re.</option>
|
||||
<option value="audio.4.niv.re.">.audio.4.niv.re.</option>
|
||||
<option value="ink.4.niv.re.">.ink.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Neurodiversité">
|
||||
<option value="na.4.niv.re.">.na.4.niv.re.</option>
|
||||
<option value="psy.4.niv.re.">.psy.4.niv.re.</option>
|
||||
<option value="neuro.4.niv.re.">.neuro.4.niv.re.</option>
|
||||
<option value="auti.4.niv.re.">.auti.4.niv.re.</option>
|
||||
<option value="plur.4.niv.re.">.plur.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Couleurs">
|
||||
<option value="blue.4.niv.re.">.blue.4.niv.re.</option>
|
||||
<option value="red.4.niv.re.">.red.4.niv.re.</option>
|
||||
<option value="pink.4.niv.re.">.pink.4.niv.re.</option>
|
||||
<option value="green.4.niv.re.">.green.4.niv.re.</option>
|
||||
<option value="black.4.niv.re.">.black.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Communauté">
|
||||
<option value="city.4.niv.re.">.city.4.niv.re.</option>
|
||||
<option value="town.4.niv.re.">.town.4.niv.re.</option>
|
||||
<option value="cafe.4.niv.re.">.cafe.4.niv.re.</option>
|
||||
<option value="home.4.niv.re.">.home.4.niv.re.</option>
|
||||
<option value="forum.4.niv.re.">.forum.4.niv.re.</option>
|
||||
</optgroup>
|
||||
<optgroup label="Divers">
|
||||
<option value="dream.4.niv.re.">.dream.4.niv.re.</option>
|
||||
<option value="space.4.niv.re.">.space.4.niv.re.</option>
|
||||
<option value="forest.4.niv.re.">.forest.4.niv.re.</option>
|
||||
<option value="rain.4.niv.re.">.rain.4.niv.re.</option>
|
||||
<option value="snow.4.niv.re.">.snow.4.niv.re.</option>
|
||||
<option value="sun.4.niv.re.">.sun.4.niv.re.</option>
|
||||
<option value="earth.4.niv.re.">.earth.4.niv.re.</option>
|
||||
<option value="world.4.niv.re.">.world.4.niv.re.</option>
|
||||
<option value="soft.4.niv.re.">.soft.4.niv.re.</option>
|
||||
<option value="cute.4.niv.re.">.cute.4.niv.re.</option>
|
||||
<option value="cutie.4.niv.re.">.cutie.4.niv.re.</option>
|
||||
<option value="fun.4.niv.re.">.fun.4.niv.re.</option>
|
||||
<option value="play.4.niv.re.">.play.4.niv.re.</option>
|
||||
<option value="game.4.niv.re.">.game.4.niv.re.</option>
|
||||
</optgroup>
|
||||
|
||||
<option selected="" value="<?= REGISTRY ?>">.<?= REGISTRY ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
|
@ -18,7 +18,7 @@ require "inc/pages.inc.php";
|
|||
if (
|
||||
isset($_COOKIE['niver']) // Resume session
|
||||
OR
|
||||
(SERVICE === "auth"
|
||||
(SERVICE === "auth" // Create new session
|
||||
AND PAGE === "login"
|
||||
AND isset($_POST['username']))
|
||||
) {
|
||||
|
@ -38,12 +38,6 @@ if (
|
|||
]);
|
||||
}
|
||||
|
||||
// Redirect to the login page if not logged in
|
||||
if (SERVICE != "auth" AND !isset($_SESSION['username'])) {
|
||||
header('Location: ' . PREFIX . '/auth/login?redir=' . SERVICE . "/" . PAGE, true, 302);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Remove .php from URL (if any)
|
||||
if (substr($_SERVER['REQUEST_URI'], -4) == ".php") {
|
||||
header("Location: " . PREFIX . "/" . SERVICE . "/" . PAGE, true, 301); // 301 Moved Permanently
|
||||
|
|
Loading…
Add table
Reference in a new issue