瀏覽代碼

Remove Gemini references

Miraty 3 年之前
父節點
當前提交
dedce71154
共有 9 個文件被更改,包括 22 次插入272 次删除
  1. 1 52
      README.md
  2. 0 89
      ht/gemini-domain.php
  3. 0 103
      ht/gemini-onion.php
  4. 6 4
      ht/http-onion.php
  5. 7 5
      ht/https-domain.php
  6. 0 8
      ht/index.php
  7. 7 4
      inc/const.inc.php
  8. 0 6
      inc/pages.inc.php
  9. 1 1
      index.php

+ 1 - 52
README.md

@@ -8,55 +8,4 @@ This PHP Web interface allow it's users to manage 3 services, that can be used t
 
 * A domain registry
 * A nameserver
-* An hypertext service, that allow a directory containing hypertext documents to be accessed with the choice of the protocol and the routing method :
-* HTTP(S) or Gemini
-* DNS access or Onion (the Tor's system)
-
-
-On the client:
-```
-$ ssh-keygen -a 100 -t ed25519
-```
-
-## Nginx mimetypes association
-
-```
-text/plain            txt;
-text/gemini           gmi;
-text/markdown         md;
-text/html             html;
-text/css              css;
-text/xml              xml;
-text/csv              csv;
-text/javascript       js;
-
-application/xhtml+xml xhtml;
-application/atom+xml  atom;
-application/rss+xml   rss;
-
-application/json      json;
-application/gzip      gz;
-application/zip       zip;
-application/epub+zip  epub;
-application/pdf       pdf;
-
-font/woff             woff;
-font/woff2            woff2;
-
-image/png             png;
-image/tiff            tif tiff;
-image/gif             gif;
-image/jpeg            jpeg jpg;
-image/svg+xml         svg svgz;
-image/webp            webp;
-
-audio/mpeg            mp3;
-audio/ogg             ogg oga opus spx;
-audio/webm            weba;
-audio/flac            flac;
-
-video/webm            webm;
-video/mp4             mp4;
-video/ogg             ogv;
-
-```
+* An HTTP service

+ 0 - 89
ht/gemini-domain.php

@@ -1,89 +0,0 @@
-<?php require "../top.inc.php"; ?>
-
-<p>
-	Ajouter un domaine sur un dossier de site<br>
-	Le domaine doit pointer vers ces adresses IP :
-	<br>IPv4 : <code><?= IPV4_ADDRESS ?></code>
-	<br>IPv6 : <code><?= IPV6_ADDRESS ?></code>
-</p>
-
-<form method="post">
-	<label for="domain">Domaine sur lequel répondre</label><br>
-	<input required="" placeholder="capsule.<?= DOMAIN_EXAMPLE ?>" id="domain" name="domain" type="text"><br>
-	<label for="dir">Dossier ciblé</label><br>
-	<select required="" name="dir" id="dir">
-		<option value="" disabled="" selected="">---</option>
-
-		<?php
-
-		$fsDirs = listFsDirs($_SESSION['username']);
-		$dbUsedDirs = listDbDirs($_SESSION['username'], "dns", "gemini");
-		$i = 0;
-		$j = 0;
-		$alreadyEnabledDirs = NULL;
-		$notYetEnabledDirs = NULL;
-		if ($fsDirs) {
-			foreach ($fsDirs as $fsDir) {
-				if ($dbUsedDirs AND in_array($fsDir, $dbUsedDirs)) {
-					$alreadyEnabledDirs[$i] = $fsDir;
-					$i++;
-				} else {
-					$notYetEnabledDirs[$j] = $fsDir;
-					$j++;
-				}
-			}
-
-			if (!is_null($notYetEnabledDirs)) {
-				foreach ($notYetEnabledDirs as $dir) {
-					echo "<option value='" . $dir . "'>" . $dir . "</option>";
-				}
-			}
-
-			if (!is_null($alreadyEnabledDirs)) {
-				foreach ($alreadyEnabledDirs as $dir) {
-					echo "<option disabled='' value='" . $dir . "'>" . $dir . "</option>";
-				}
-			}
-		}
-		?>
-	</select>
-	<br>
-	<input value="Valider" type="submit">
-</form>
-
-<?php
-
-if (isset($_POST['domain']) AND isset($_POST['dir']) AND isset($_SESSION['username'])) {
-
-	antiCSRF();
-
-	checkDomainFormat($_POST['domain']);
-
-	if (!in_array($_POST['dir'], $notYetEnabledDirs))
-		exit("ERROR : Wrong value for dir");
-
-	addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "gemini");
-
-	// Generate tls keys
-	exec(SUDO_PATH . " " . MANIVER_PATH . " gemini-new-certificate " . $_POST['domain']);
-
-	// Add to Twins configuration
-	$conf = "
-	" . $_POST['domain'] . ":
-		cert: " . TWINS_PATH . "/tls/" . $_POST['domain'] . ".crt
-		key: " . TWINS_PATH . "/tls/" . $_POST['domain'] . ".key
-		paths:
-			-
-				path: /
-				root: " . HT_PATH . "/" . $_SESSION['username'] . "/ht/" . $_POST['dir'];
-	file_put_contents(TWINS_PATH . "/twins.conf", $conf, FILE_APPEND);
-
-	// Reload Twins daemon
-	exec(SUDO_PATH . " " . MANIVER_PATH . " reload-twins");
-
-	echo "Accès par domaine ajouté sur ce dossier !";
-}
-
-?>
-
-<?php require "../bottom.inc.php"; ?>

+ 0 - 103
ht/gemini-onion.php

@@ -1,103 +0,0 @@
-<?php require "../top.inc.php"; ?>
-<p>
-	Ajouter un accès en .onion sur un dossier
-</p>
-
-<form method="post">
-	<label for="dir">Dossier ciblé</label><br>
-	<select required="" name="dir" id="dir">
-		<option value="" disabled="" selected="">---</option>
-
-		<?php
-
-		$fsDirs = listFsDirs($_SESSION['username']);
-		$dbUsedDirs = listDbDirs($_SESSION['username'], "onion", "gemini");
-		$i = 0;
-		$j = 0;
-		$alreadyEnabledDirs = NULL;
-		$notYetEnabledDirs = NULL;
-		if ($fsDirs) {
-			foreach ($fsDirs as $fsDir) {
-				if ($dbUsedDirs AND in_array($fsDir, $dbUsedDirs)) {
-					$alreadyEnabledDirs[$i] = $fsDir;
-					$i++;
-				} else {
-					$notYetEnabledDirs[$j] = $fsDir;
-					$j++;
-				}
-			}
-
-			if (!is_null($notYetEnabledDirs)) {
-				foreach ($notYetEnabledDirs as $dir) {
-					echo "<option value='" . $dir . "'>" . $dir . "</option>";
-				}
-			}
-
-			if (!is_null($alreadyEnabledDirs)) {
-				foreach ($alreadyEnabledDirs as $dir) {
-					echo "<option disabled='' value='" . $dir . "'>" . $dir . "</option>";
-				}
-			}
-		}
-		?>
-	</select>
-	<br>
-	<input value="Valider" type="submit">
-</form>
-
-<?php
-
-if (isset($_POST['dir']) AND isset($_SESSION['username'])) {
-
-	antiCSRF();
-
-	if (!in_array($_POST['dir'], $notYetEnabledDirs))
-		exit("ERROR : Wrong value for dir");
-
-	// Generate a .onion address
-	$torConf = file_get_contents(TOR_CONFIG_PATH);
-	$torConf = $torConf . "\nHiddenServiceDir " . TOR_KEYS_PATH . "/" . $_POST['dir'] . "/\nHiddenServicePort 1965 [::1]:1965";
-	file_put_contents(TOR_CONFIG_PATH, $torConf);
-
-	exec(SUDO_PATH . " " . MANIVER_PATH . " reload-tor", $output);
-	addNiverLog("Tor reloaded by " . $_SESSION['username'], $output);
-
-	// Copy generated address to a location readable by PHP
-	exec(SUDO_PATH . " " . MANIVER_PATH . " export-tor " . $_SESSION['username'] . " " . $_POST['dir'], $output);
-	addNiverLog("Tor data exported by " . $_SESSION['username'], $output);
-
-	// Wait
-	sleep(1);
-
-	// Get the address generated by Tor
-	$onion = file_get_contents(HT_PATH . "/" . $_SESSION['username'] . "/ht/" . $_POST['dir'] . "/hostname");
-	$onion = str_replace(array("\r", "\n"), "", $onion);
-
-	// Store it in the database
-	addSite($_SESSION['username'], $_POST['dir'], $onion, "onion", "gemini");
-
-	// Generate tls keys
-	exec(SUDO_PATH . " " . MANIVER_PATH . " gemini-new-certificate " . $onion);
-
-	// Add to Twins configuration
-	$conf = "
-	" . $onion . ":
-		cert: " . TWINS_PATH . "/tls/" . $onion . ".crt
-		key: " . TWINS_PATH . "/tls/" . $onion . ".key
-		paths:
-			-
-				path: /
-				root: " . HT_PATH . "/" . $_SESSION['username'] . "/ht/" . $_POST['dir'];
-	file_put_contents(TWINS_PATH . "/twins.conf", $conf, FILE_APPEND);
-
-	// Reload Twins daemon
-	exec(SUDO_PATH . " " . MANIVER_PATH . " reload-twins");
-
-	// Tell the user their site address
-	echo "<p>L'adresse de votre capsule Onion Gemini est : <br><a href='gemini://" . $onion . "'<code>gemini://" . $onion . "</code></a></p>";
-
-}
-
-?>
-
-<?php require "../bottom.inc.php"; ?>

+ 6 - 4
ht/http-onion.php

@@ -56,7 +56,7 @@ if (isset($_POST['dir']) AND isset($_SESSION['username'])) {
 
 	// Generate a .onion address
 	$torConf = file_get_contents(TOR_CONFIG_PATH);
-	$torConf = $torConf . "\nHiddenServiceDir " . TOR_KEYS_PATH . "/" . $_POST['dir'] . "/\nHiddenServicePort 80 [::1]:80";
+	$torConf = $torConf . "\nHiddenServiceDir " . TOR_KEYS_PATH . "/" . $_POST['dir'] . "/\nHiddenServicePort 80 [::1]:" . INTERNAL_ONION_HTTP_PORT;
 	file_put_contents(TOR_CONFIG_PATH, $torConf);
 
 	exec(SUDO_PATH . " " . MANIVER_PATH . " reload-tor", $output);
@@ -78,9 +78,11 @@ if (isset($_POST['dir']) AND isset($_SESSION['username'])) {
 
 	// Add it to Nginx
 	$nginxConf = file_get_contents(NIVER_TEMPLATE_PATH . "/nginx/onion.template");
-	$nginxConf = preg_replace("#DOMAIN#", $onion, $nginxConf);
-	$nginxConf = preg_replace("#DIR#", $_POST['dir'], $nginxConf);
-	$nginxConf = preg_replace("#USER#", $_SESSION['username'], $nginxConf);
+	$nginxConf = str_replace("{{INTERNAL_ONION_HTTP_PORT}}", INTERNAL_ONION_HTTP_PORT, $nginxConf);
+	$nginxConf = str_replace("{{DOMAIN}}", $onion, $nginxConf);
+	$nginxConf = str_replace("{{HT_PATH}}", HT_PATH, $nginxConf);
+	$nginxConf = str_replace("{{USERNAME}}", $_SESSION['username'], $nginxConf);
+	$nginxConf = str_replace("{{DIR}}", $_POST['dir'], $nginxConf);
 	file_put_contents(NGINX_CONFIG_PATH . "/" . $_POST['dir'] . ".conf", $nginxConf);
 
 	// Reload Nginx

+ 7 - 5
ht/https-domain.php

@@ -65,11 +65,13 @@ if (isset($_POST['domain']) AND isset($_POST['dir']) AND isset($_SESSION['userna
 
 	addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http");
 
-	$conf = file_get_contents(NIVER_TEMPLATE_PATH . "/nginx/dns.template");
-	$conf = preg_replace("#DOMAIN#", $_POST['domain'], $conf);
-	$conf = preg_replace("#DIR#", $_POST['dir'], $conf);
-	$conf = preg_replace("#USER#", $_SESSION['username'], $conf);
-	file_put_contents(NGINX_CONFIG_PATH . "/" . $_POST['domain'] . ".conf", $conf);
+	$nginxConf = file_get_contents(NIVER_TEMPLATE_PATH . "/nginx/dns.template");
+	$nginxConf = str_replace("{{HTTPS_PORT}}", HTTPS_PORT, $nginxConf);
+	$nginxConf = str_replace("{{DOMAIN}}", $_POST['domain'], $nginxConf);
+	$nginxConf = str_replace("{{HT_PATH}}", HT_PATH, $nginxConf);
+	$nginxConf = str_replace("{{USERNAME}}", $_SESSION['username'], $nginxConf);
+	$nginxConf = str_replace("{{DIR}}", $_POST['dir'], $nginxConf);
+	file_put_contents(NGINX_CONFIG_PATH . "/" . $_POST['domain'] . ".conf", $nginxConf);
 
 	// Reload Nginx
 	exec(SUDO_PATH . " " . MANIVER_PATH . " reload-nginx");

+ 0 - 8
ht/index.php

@@ -13,14 +13,6 @@
 	<dd>
 		Un site HTML, accessible directement, par un nom de domaine
 	</dd>
-	<dt><a class="htButton" href="gemini-onion">Accès Gemini en Onion</a></dt>
-	<dd>
-		Une capsule Gemini, accessible par Tor, avec une adresse en .onion
-	</dd>
-	<dt><a class="htButton" href="gemini-domain">Accès Gemini par DNS</a></dt>
-	<dd>
-		Une capsule Gemini, accessible directement, par un nom de domaine
-	</dd>
 	<dt><a class="htButton" href="le">Let's Encrypt</a></dt>
 	<dd>
 		Installer un certificat Let's Encrypt sur un domaine

+ 7 - 4
inc/const.inc.php

@@ -5,15 +5,18 @@ if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false)
 // --- Constants definitions ---
 
 // Public IP adresses (shown on the interface)
-define("IPV4_ADDRESS", "127.0.0.1");
 define("IPV6_ADDRESS", "::1");
+define("IPV4_ADDRESS", "127.0.0.1");
+
+define("HTTPS_PORT", "42443");
+define("INTERNAL_ONION_HTTP_PORT", "9080");
 
 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
 define("IPV6_EXAMPLE", "2001:db8::3"); // See RFC3849: IPv6 Address Prefix Reserved for Documentation
+define("IPV4_EXAMPLE", "203.0.113.42"); // See RFC5737: IPv4 Address Blocks Reserved for Documentation
 define("DOMAIN_EXAMPLE", "example"); // From RFC2606: Reserved Top Level DNS Names > 2. TLDs for Testing, & Documentation Examples
 
 // Custom Niver paths
@@ -22,7 +25,7 @@ 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'));
 define("DB_PATH", ROOT_PATH . "/db/niver.db"); // Niver's SQLite database
-define("NIVER_TEMPLATE_PATH", "/usr/local/share/niver"); // Templates directory (skel, nginx, knot...)
+define("NIVER_TEMPLATE_PATH", "/usr/local/share/niver"); // Templates directory (nginx, knot...)
 define("MANIVER_PATH", "/usr/local/bin/maniver"); // Executable file
 define("HT_PATH", "/srv/ht"); // The mountpoint of the hypertext storage partition (that will be accessed over SFTP)
 // Nginx
@@ -31,7 +34,7 @@ define("NGINX_CONFIG_PATH", "/etc/nginx/ht"); // Nginx configuration directory
 define("TOR_CONFIG_PATH", "/etc/tor/instances/niver/torrc"); // Tor configuration file
 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
+define("KNOT_ZONES_PATH", "/srv/ns"); // Knot zones directory
 // 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");

+ 0 - 6
inc/pages.inc.php

@@ -91,12 +91,6 @@ switch (SERVICE) {
 			case "mkdir":
 				$page['title'] = "Créer un dossier de site";
 			break;
-			case "gemini-onion":
-				$page['title'] = "Accès Gemini en Onion";
-			break;
-			case "gemini-domain":
-				$page['title'] = "Accès Gemini par domaine";
-			break;
 			case "http-onion":
 				$page['title'] = "Accès HTTP en Onion";
 			break;

+ 1 - 1
index.php

@@ -11,7 +11,7 @@
 	</dd>
 	<dt><a class="htButton" href="ht/">Hypertexte</a></dt>
 	<dd>
-		Mettre en ligne son site statique sur un espace <abbr title="SSH File Transfert Protocol">SFTP</abbr>, et le faire répondre en <abbr title="HyperText Transfert Protocol">HTTP</abbr> ou Gemini par le DNS ou Tor
+		Mettre en ligne son site statique sur un espace <abbr title="SSH File Transfert Protocol">SFTP</abbr>, et le faire répondre en <abbr title="HyperText Transfert Protocol">HTTP</abbr> par DNS ou Tor
 	</dd>
 	<dt><a class="authButton" href="auth/">Authentification</a></dt>
 	<dd>