|
@@ -16,16 +16,24 @@ if (processForm()) {
|
|
|
|
|
|
$remoteAaaaRecords = dns_get_record($_POST['domain'], DNS_AAAA);
|
|
|
if (is_array($remoteAaaaRecords) !== true)
|
|
|
- output(403, 'Ce domaine n\'existe pas.');
|
|
|
+ output(500, 'Erreur lors de la récupération de l\'enregistrement AAAA.');
|
|
|
if (equalArrays([CONF['ht']['ipv6_address']], array_column($remoteAaaaRecords, 'ipv6')) !== true)
|
|
|
output(403, 'Ce domaine doit avoir pour unique enregistrement AAAA <code>' . CONF['ht']['ipv6_address'] . '</code>.');
|
|
|
|
|
|
$remoteARecords = dns_get_record($_POST['domain'], DNS_A);
|
|
|
if (is_array($remoteARecords) !== true)
|
|
|
- output(403, 'Ce domaine n\'existe pas.');
|
|
|
+ output(500, 'Erreur lors de la récupération de l\'enregistrement A.');
|
|
|
if (equalArrays([CONF['ht']['ipv4_address']], array_column($remoteARecords, 'ip')) !== true)
|
|
|
output(403, 'Ce domaine doit avoir pour unique enregistrement A <code>' . CONF['ht']['ipv4_address'] . '</code>.');
|
|
|
|
|
|
+ $remoteTXTRecords = dns_get_record($_POST['domain'], DNS_TXT);
|
|
|
+ if (is_array($remoteTXTRecords) !== true)
|
|
|
+ output(500, 'Erreur lors de la récupération de l\'enregistrement TXT.');
|
|
|
+ if (preg_match('/\nauth-owner=([0-9a-f]{8})-([0-9a-f]{32})\n/', "\n" . implode("\n", array_column($remoteTXTRecords, 'txt')) . "\n", $matches) !== 1)
|
|
|
+ output(403, 'Aucun enregistrement TXT au format correct trouvé.');
|
|
|
+
|
|
|
+ checkAuthToken($matches[1], $matches[2]);
|
|
|
+
|
|
|
rateLimit();
|
|
|
|
|
|
addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http");
|
|
@@ -57,6 +65,8 @@ if (processForm()) {
|
|
|
output(200, 'Accès HTTP par domaine ajouté sur ce dossier !');
|
|
|
}
|
|
|
|
|
|
+$proof = getAuthToken();
|
|
|
+
|
|
|
?>
|
|
|
|
|
|
<p>
|
|
@@ -64,19 +74,24 @@ if (processForm()) {
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
|
- Le domaine doit contenir ces enregistrements :
|
|
|
- <dl>
|
|
|
- <dt><code>AAAA</code></dt>
|
|
|
- <dd>
|
|
|
- <code><?= CONF['ht']['ipv6_address'] ?></code>
|
|
|
- </dd>
|
|
|
- <dt><code>A</code></dt>
|
|
|
- <dd>
|
|
|
- <code><?= CONF['ht']['ipv4_address'] ?></code>
|
|
|
- </dd>
|
|
|
- </dl>
|
|
|
+ La présence des enregistrements ci-après sera vérifiée lors du traitement de ce formulaire.
|
|
|
</p>
|
|
|
|
|
|
+<dl>
|
|
|
+ <dt><code>AAAA</code></dt>
|
|
|
+ <dd>
|
|
|
+ <code><?= CONF['ht']['ipv6_address'] ?></code>
|
|
|
+ </dd>
|
|
|
+ <dt><code>A</code></dt>
|
|
|
+ <dd>
|
|
|
+ <code><?= CONF['ht']['ipv4_address'] ?></code>
|
|
|
+ </dd>
|
|
|
+ <dt><code>TXT</code></dt>
|
|
|
+ <dd>
|
|
|
+ <code>auth-owner=<?= $proof ?></code>
|
|
|
+ </dd>
|
|
|
+</dl>
|
|
|
+
|
|
|
<form method="post">
|
|
|
<label for="domain">Domaine sur lequel répondre</label><br>
|
|
|
<input required="" placeholder="site.<?= PLACEHOLDER_DOMAIN ?>" id="domain" name="domain" type="text"><br>
|