IPv6-support für DynDNS
Bernd Wurst

Bernd Wurst commited on 2018-05-14 07:37:12
Zeige 5 geänderte Dateien mit 22 Einfügungen und 3 Löschungen.

... ...
@@ -124,6 +124,7 @@ output('<h4>Neuen DNS-Record anlegen</h4>
124 124
 
125 125
 <ul>
126 126
 <li>'.internal_link('dns_record_edit', 'DynDNS (Hostname für einen DynDNS-Account setzen)', 'id=new&type=dyndns&domain='.$domain->id).'</li>
127
+<li>'.internal_link('dns_record_edit', 'DynDNS/AAAA (Hostname für einen DynDNS-Account setzen, als IPv6-Adresse)', 'id=new&type=dyndns_aaaa&domain='.$domain->id).'</li>
127 128
 <li>'.internal_link('dns_record_edit', 'A (normaler Hostname/normale Subdomain)', 'id=new&type=a&domain='.$domain->id).'</li>
128 129
 <li>'.internal_link('dns_record_edit', 'MX (Posteingangsserver)', 'id=new&type=mx&domain='.$domain->id).'</li>
129 130
 </ul>
... ...
@@ -40,6 +40,12 @@ if (isset($_REQUEST['type']) && $_REQUEST['type'] == "dyndns")
40 40
   $_REQUEST['type'] = 'a';
41 41
   $dyndns = true;
42 42
 }
43
+if (isset($_REQUEST['type']) && $_REQUEST['type'] == "dyndns_aaaa")
44
+{
45
+  $_REQUEST['type'] = 'aaaa';
46
+  $dyndns = true;
47
+}
48
+
43 49
 
44 50
 $new = false;
45 51
 if ($_REQUEST['id'] == 'new')
... ...
@@ -31,7 +31,11 @@ if (!isset($_REQUEST['id']))
31 31
 $id = (int) $_REQUEST['id'];
32 32
 $dyndns = get_dyndns_account($id);
33 33
 
34
-  $record = blank_dns_record('a');
34
+  $type = 'a';
35
+  if ($_REQUEST['type'] == 'aaaa') {
36
+      $type = 'aaaa';
37
+  }
38
+  $record = blank_dns_record($type);
35 39
   // Sicherheitsprüfungen passieren im Backend
36 40
   
37 41
   $record['hostname'] = $_REQUEST['hostname'];
... ...
@@ -44,7 +44,8 @@ if ($records) {
44 44
 <ul>
45 45
 ';
46 46
   foreach ($records AS $record) {
47
-    $output .= '  <li>'.$record['fqdn'].' '.internal_link('dyndns_hostname_delete', icon_delete(), 'id='.$record['id']).'</li>';
47
+    $type = strtoupper($record['type']).' / '.($record['type'] == 'a' ? 'IPv4' : 'IPv6');
48
+    $output .= '  <li>'.$record['fqdn'].' ('.$type.') '.internal_link('dyndns_hostname_delete', icon_delete(), 'id='.$record['id']).'</li>';
48 49
   }
49 50
   $output .= '</ul>';
50 51
 }
... ...
@@ -52,7 +53,9 @@ if ($records) {
52 53
 
53 54
 output('<h4>Neuen Hostname festlegen</h4>');
54 55
 
55
-$form = '<p><label for="hostname">Neuer Hostname: </label></td><td><input type="text" name="hostname" id="hostname" value="'.$dyndns['handle'].'" />&#160;.&#160;'.html_select('domain', $available_domains).' <input type="submit" value="Speichern"/></p>';
56
+$form = '<p><label for="hostname">Neuer Hostname: </label> <input type="text" name="hostname" id="hostname" value="'.$dyndns['handle'].'" />&#160;.&#160;'.html_select('domain', $available_domains).' </p>
57
+<p>Typ: <select name="type"><option value="a" selected="selected">A / IPv4</option><option value="aaaa">AAAA / IPv6</option></select></p>
58
+<p><input type="submit" value="Speichern"/></p>';
56 59
 
57 60
 
58 61
 output(html_form('dyndns_hostname_add', 'dyndns_hostname_add', 'id='.$dyndns['id'], $form));
... ...
@@ -250,10 +250,15 @@ function save_dns_record($id, $record)
250 250
       }
251 251
       break;
252 252
     case 'aaaa':
253
+      if ($record['dyndns']) {
254
+          get_dyndns_account( $record['dyndns'] );
255
+          $record['ip'] = NULL;
256
+      } else {
253 257
           $record['dyndns'] = NULL;
254 258
           verify_input_ipv6($record['ip']);
255 259
           $record['data'] = NULL;
256 260
           $record['spec'] = NULL;
261
+      }
257 262
       break;
258 263
     case 'mx':
259 264
       $record['dyndns'] = NULL;
260 265