Ajout de la gestion des sous-domaine IPv6
ToDo: Pouvoir avoir un domaine simultanément IPv4 et IPv6
This commit is contained in:
parent
a1837727a5
commit
33cb13286b
|
@ -131,6 +131,13 @@ for($i=0;$i<$r["nsub"];$i++) {
|
|||
<label for="ip"><?php __("IP redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_ip" id="sub_ip" value="<?php ehe($sub_ip); ?>" size="16" /> <small><?php __("(enter an IPv4 address, for example 192.168.1.2)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input type="radio" id="ipv6" class="inc" name="type" value="<?php echo $dom->type_ipv6; ?>" <?php cbox($type==$dom->type_ipv6); ?> onclick="document.main.sub_ip.focus();" />
|
||||
<label for="ipv6"><?php __("IPv6 redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_ipv6" id="sub_ipv6" value="<?php ehe($sub_ipv6); ?>" size="32" /> <small><?php __("(enter an IPv6 address, for example 2001:0910::)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
<? } ?>
|
||||
<tr>
|
||||
<td><input type="radio" id="webmail" class="inc" name="type" value="<?php echo $dom->type_webmail; ?>" <?php cbox($type==$dom->type_webmail); ?>/>
|
||||
|
|
|
@ -36,6 +36,7 @@ $fields = array (
|
|||
"sub_local" => array ("request", "string", "/"),
|
||||
"sub_url" => array ("request", "string", "http://"),
|
||||
"sub_ip" => array ("request", "string", ""),
|
||||
"sub_ipv6" => array ("request", "string", ""),
|
||||
"action" => array ("request", "string", "add"),
|
||||
);
|
||||
getFields($fields);
|
||||
|
@ -52,6 +53,9 @@ switch ($type) {
|
|||
case $dom->type_ip:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_ip);
|
||||
break;
|
||||
case $dom->type_ipv6:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_ipv6);
|
||||
break;
|
||||
case $dom->type_webmail:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,"");
|
||||
break;
|
||||
|
|
|
@ -37,6 +37,7 @@ $fields = array (
|
|||
"sub_local" => array ("request", "string", "/"),
|
||||
"sub_url" => array ("request", "string", "http://"),
|
||||
"sub_ip" => array ("request", "string", ""),
|
||||
"sub_ipv6" => array ("request", "string", ""),
|
||||
"action" => array ("request", "string", "add"),
|
||||
);
|
||||
getFields($fields);
|
||||
|
@ -62,6 +63,9 @@ switch ($type) {
|
|||
case $dom->type_url:
|
||||
$sub_url=$r["dest"];
|
||||
break;
|
||||
case $dom->type_ipv6:
|
||||
$sub_ipv6=$r["dest"];
|
||||
break;
|
||||
case $dom->type_ip:
|
||||
$sub_ip=$r["dest"];
|
||||
break;
|
||||
|
@ -106,10 +110,18 @@ $dom->unlock();
|
|||
<label for="url"><?php __("URL redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_url" id="sub_url" value="<?php ehe($sub_url); ?>" size="50" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input type="radio" id="ip" class="inc" name="type" value="<?php echo $dom->type_ip; ?>" <?php cbox($type==$dom->type_ip); ?> onclick="document.main.sub_ip.focus();" />
|
||||
<label for="ip"><?php __("IP redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_ip" id="sub_ip" value="<?php ehe($sub_ip); ?>" size="16" /> <small><?php __("(enter an IPv4 address, for example 192.168.1.2)"); ?></small></td>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><input type="radio" id="ipv6" class="inc" name="type" value="<?php echo $dom->type_ipv6; ?>" <?php cbox($type==$dom->type_ipv6); ?> onclick="document.main.sub_ipv6.focus();" />
|
||||
<label for="ipv6"><?php __("IPv6 redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_ipv6" id="sub_ipv6" value="<?php ehe($sub_ipv6); ?>" size="16" /> <small><?php __("(enter an IPv6 address, for example 2001:0910::0)"); ?></small></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="radio" id="webmail" class="inc" name="type" value="<?php echo $dom->type_webmail; ?>" <?php cbox($r["type"]==$dom->type_webmail); ?> />
|
||||
|
|
|
@ -124,6 +124,15 @@ function checkip($ip) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Check that $ip is a correct ipv6 ip */
|
||||
function checkipv6($ip) {
|
||||
// return true or false whether the ip is correctly formatted
|
||||
$pattern =
|
||||
'/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/';
|
||||
|
||||
return preg_match( $pattern, $ip ) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* Check a login mail */
|
||||
function checkloginmail($mail) {
|
||||
if (!preg_match("/^[a-zA-Z0-9_\.:\+\-]*[a-zA-Z0-9_]$/",$mail)) {
|
||||
|
|
|
@ -70,6 +70,7 @@ class m_dom {
|
|||
var $type_url = "1";
|
||||
var $type_ip = "2";
|
||||
var $type_webmail = "3";
|
||||
var $type_ipv6 = "4";
|
||||
|
||||
var $action_insert = "0";
|
||||
var $action_update= "1";
|
||||
|
@ -700,6 +701,12 @@ class m_dom {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if ($type==4) { // IPv6
|
||||
if (!checkipv6($dest)) {
|
||||
$err->raise("dom",19);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($type==1) { // URL
|
||||
if (!checkurl($dest)) {
|
||||
$err->raise("dom",20);
|
||||
|
|
|
@ -105,8 +105,13 @@ change_host_ip() {
|
|||
if [ -z "$host" ]; then
|
||||
host="@"
|
||||
fi
|
||||
if [ "$host_type" = "$TYPE_IPV6" ]; then
|
||||
a_line="$host IN AAAA $ip"
|
||||
pattern="^$host[[:space:]]*IN[[:space:]]*AAAA[[:space:]]*.*\$"
|
||||
else
|
||||
a_line="$host IN A $ip"
|
||||
pattern="^$host[[:space:]]*IN[[:space:]]*A[[:space:]]*.*\$"
|
||||
fi
|
||||
if [ ! -f "$zone_file" ]; then
|
||||
echo "Should change $host.$domain, but can't find $zone_file."
|
||||
return 1
|
||||
|
@ -143,6 +148,8 @@ add_host() {
|
|||
|
||||
if [ "$host_type" = "$TYPE_IP" ]; then
|
||||
ip="$value"
|
||||
elif [ "$host_type" = "$TYPE_IPV6" ]; then
|
||||
ip="$value"
|
||||
else
|
||||
ip="$PUBLIC_IP"
|
||||
if [ "$host_type" != "$TYPE_WEBMAIL" ]; then
|
||||
|
@ -211,7 +218,7 @@ delete_host() {
|
|||
|
||||
if [ -f "$ZONES_DIR/$domain" ] ; then
|
||||
cp -a -f "$ZONES_DIR/$domain" "$ZONES_DIR/$domain.$$"
|
||||
sed -e "/^$escaped_host[[:space:]]*IN[[:space:]]*A[[:space:]]/d" \
|
||||
sed -e "/^$escaped_host[[:space:]]*IN[[:space:]]*\(AAAA\|A\)[[:space:]]/d" \
|
||||
< "$ZONES_DIR/$domain" > "$ZONES_DIR/$domain.$$"
|
||||
mv "$ZONES_DIR/$domain.$$" "$ZONES_DIR/$domain"
|
||||
increment_serial "$domain"
|
||||
|
|
|
@ -53,6 +53,7 @@ TYPE_LOCAL=0
|
|||
TYPE_URL=1
|
||||
TYPE_IP=2
|
||||
TYPE_WEBMAIL=3
|
||||
TYPE_IPV6=4
|
||||
YES=1
|
||||
|
||||
if [ `id -u` -ne 0 ]; then
|
||||
|
|
Loading…
Reference in New Issue