Browse Source

Add SSHFP form in ns/

Miraty 4 years ago
parent
commit
14999f1ee0
4 changed files with 74 additions and 17 deletions
  1. 3 0
      inc/pages.inc.php
  2. 5 5
      ns/index.php
  3. 4 12
      ns/mx.php
  4. 62 0
      ns/sshfp.php

+ 3 - 0
inc/pages.inc.php

@@ -31,6 +31,9 @@ switch (SERVICE) {
       case "mx":
         $page['title'] = "Enregistrement MX";
       break;
+      case "sshfp":
+        $page['title'] = "Enregistrement SSHFP";
+      break;
       case "zone":
         $page['title'] = "Ajouter une zone";
       break;

+ 5 - 5
ns/index.php

@@ -13,7 +13,7 @@
   <dd>
     Indiquer le serveur de noms d'une zone
   </dd>
-  <dt><a class="nsButton" href="ip">Enregistrements A ou AAAA</a></dt>
+  <dt><a class="nsButton" href="ip">Enregistrements A et AAAA</a></dt>
   <dd>
     Indiquer l'adresse IP d'un domaine
   </dd>
@@ -33,6 +33,10 @@
   <dd>
     Indiquer le serveur mail pour un domaine
   </dd>
+  <dt><a class="nsButton" href="sshfp">Enregistrement <abbr title="Secure SHell FingerPrint">SSHFP</abbr></a></dt>
+  <dd>
+    Indiquer les empreintes de clés <abbr title="Secure SHell">SSH</abbr> d'un domaine
+  </dd>
   <!--
   <dt><a class="nsButton" href="tlsa">Enregistrement <abbr title="Transport Layer Security Association">TLSA</abbr></a></dt>
   <dd>
@@ -42,10 +46,6 @@
   <dd>
     Indiquer la localisation physique d'un domaine
   </dd>
-  <dt><a class="nsButton" href="sshfp">Enregistrement <abbr title="Secure SHell FingerPrint">SSHFP</abbr></a></dt>
-  <dd>
-    Indiquer les empreintes de clés <abbr title="Secure SHell">SSH</abbr> d'un domaine
-  </dd>
   <dt><a class="nsButton" href="cname">Enregistrement <abbr title="Canonical NAME">CNAME</abbr></a></dt>
   <dd>
     Définir un domaine comme étant l'alias d'un autre

+ 4 - 12
ns/mx.php

@@ -14,7 +14,7 @@
 
   <label for="host">Hôte</label>
   <br>
-  <input id="host" minlenght="1" maxlength="128" placeholder="mail.exemple." name="host" type="text">
+  <input id="host" placeholder="mail.exemple." name="host" type="text">
 
   <br>
   <input value="Valider" type="submit">
@@ -24,9 +24,7 @@
 
 if (nsCommonRequirements()
     AND isset($_POST['priority'])
-    AND isset($_POST['weight'])
-    AND isset($_POST['port'])
-    AND isset($_POST['target'])
+    AND isset($_POST['host'])
   ) {
 
   $values = nsParseCommonRequirements();
@@ -34,16 +32,10 @@ if (nsCommonRequirements()
   if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 255))
     exit("ERROR: Wrong value for priority");
 
-  if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 255))
-    exit("ERROR: Wrong value for weight");
-
-  if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
-    exit("ERROR: Wrong value for port");
-
-  checkAbsoluteDomainFormat($_POST['target']);
+  checkAbsoluteDomainFormat($_POST['host']);
 
   exec(KNOTC_PATH . " zone-begin " . $_POST['zone']);
-  exec(KNOTC_PATH . " zone-" . $values['action'] . "set " . $_POST['zone'] . " " . $_POST['domain'] . " " . $values['ttl'] . " IN MX " . $_POST['priority'] . " " . $_POST['weight'] . " " . $_POST['port'] . " " . $_POST['target']);
+  exec(KNOTC_PATH . " zone-" . $values['action'] . "set " . $_POST['zone'] . " " . $_POST['domain'] . " " . $values['ttl'] . " IN MX " . $_POST['priority'] . " " . $_POST['host']);
   exec(KNOTC_PATH . " zone-commit " . $_POST['zone']);
   echo "Enregistrement ajouté";
 }

+ 62 - 0
ns/sshfp.php

@@ -0,0 +1,62 @@
+<?php include "../top.inc.php"; ?>
+
+<form method="post">
+
+  <?php require "../inc/form/form.ns.inc.php"; ?>
+
+  <br>
+
+  <label for="algo">Algorithme</label>
+  <br>
+  <select required="" name="algo" id="algo">
+    <option value="1">1 (RSA)</option>
+    <option value="2" disabled="">2 (DSA)</option>
+    <option value="3">3 (ECDSA)</option>
+    <option value="4" selected="">4 (ED25519)</option>
+  </select>
+
+  <br>
+
+  <label for="type">Type de hash</label>
+  <br>
+  <select required="" name="type" id="type">
+    <option value="1" disabled="">1 (SHA-1)</option>
+    <option value="2" selected="">2 (SHA-256)</option>
+  </select>
+  <br>
+
+  <label for="fp">Empreinte</label>
+  <br>
+  <input required="" id="fp" size="65" minlenght="64" maxlength="64" placeholder="26e6bbb4796c4fb78632e737d31a8acaba43c3a92d9c047031f04e9b70826e1d" name="fp" type="text">
+
+  <br>
+  <input value="Valider" type="submit">
+</form>
+
+<?php
+
+if (nsCommonRequirements()
+    AND isset($_POST['algo'])
+    AND isset($_POST['fp'])
+  ) {
+
+  $values = nsParseCommonRequirements();
+
+  if (!($_POST['algo'] === 1 OR $_POST['algo'] === 3 OR $_POST['algo'] === 4))
+    exit("ERROR: Wrong value for algo");
+
+  if (!($_POST['type'] === 2))
+    exit("ERROR: Wrong value for type");
+
+  if (!(preg_match("/^[a-z0-9]{64}$/", $_POST['fp'])))
+    exit("ERROR: Wrong value for fp");
+
+  exec(KNOTC_PATH . " zone-begin " . $_POST['zone']);
+  exec(KNOTC_PATH . " zone-" . $values['action'] . "set " . $_POST['zone'] . " " . $_POST['domain'] . " " . $values['ttl'] . " IN SSHFP " . $_POST['algo'] . " " . $_POST['type'] . " " . $_POST['fp']);
+  exec(KNOTC_PATH . " zone-commit " . $_POST['zone']);
+  echo "Enregistrement ajouté";
+}
+
+?>
+
+<?php include "../bottom.inc.php"; ?>