diff --git a/utils.inc.php b/utils.inc.php index 28ea934..70747ca 100644 --- a/utils.inc.php +++ b/utils.inc.php @@ -2,7 +2,7 @@ require 'vendor/autoload.php'; -function checkDNS($domain, $withWww = false) +function checkDNS($domain, $withWww = false, $noip6 = false) { if (!preg_match('/(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)/', strtolower($domain))) { throw new Exception('not valid domain : "'.$domain.'".'); @@ -17,11 +17,13 @@ function checkDNS($domain, $withWww = false) if ($currentip[0]['ip'] !== $_SERVER['ip4']) { throw new Exception('the current ip v4 address of '.$domain.' is '.$currentip[0]['ip'].'. it should be '.$_SERVER['ip4']); } - if (empty($currentip[0]['ipv6'])) { - throw new Exception('the domain '.$domain.' has no ip v6 in DNS record.'); - } - if ($currentip[1]['ipv6'] !== $_SERVER['ip6']) { - throw new Exception('the current ip v6 address of '.$domain.' is '.$currentip[1]['ipv6'].'. it should be '.$_SERVER['ip6']); + if (!$noip6) { + if (empty($currentip[0]['ipv6'])) { + throw new Exception('the domain '.$domain.' has no ip v6 in DNS record.'); + } + if ($currentip[1]['ipv6'] !== $_SERVER['ip6']) { + throw new Exception('the current ip v6 address of '.$domain.' is '.$currentip[1]['ipv6'].'. it should be '.$_SERVER['ip6']); + } } if ($withWww) { $dnsentries = dns_get_record('www.'.$domain, DNS_A + DNS_AAAA + DNS_CNAME); @@ -35,13 +37,18 @@ function checkDNS($domain, $withWww = false) if ($row['host'] == 'www.'.$domain && $row['type']=='A' && $row['ip'] == $_SERVER['ip4']) { $foundIp4 = true; } - if ($row['host'] == 'www.'.$domain && $row['type']=='AAAA' && $row['ipv6'] == $_SERVER['ip6']) { - $foundIp6 = true; + if (!$noip6) { + if ($row['host'] == 'www.'.$domain && $row['type']=='AAAA' && $row['ipv6'] == $_SERVER['ip6']) { + $foundIp6 = true; + } } } if (!$foundCnameEntry) { - if (!$foundIp4 && !$foundIp6) { - throw new Exception('the domain www.'.$domain.' was not found in DNS record as a CNAME targeting '.$domain."\n".' or A entry to '.$_SERVER['ip4'].' and a AAAA entry to '.$_SERVER['ip6'].'.'); + if (!$foundIp4) { + throw new Exception('the domain www.'.$domain.' was not found in DNS record as a CNAME targeting '.$domain."\n".' or A entry to '.$_SERVER['ip4']); + } + if (!$noip6 && !$foundIp6) { + throw new Exception('the domain www.'.$domain.' was not found in DNS record as a CNAME targeting '.$domain."\n".' or AAAA entry to '.$_SERVER['ip6'].'.'); } } } diff --git a/yeswiki-installer.php b/yeswiki-installer.php index a34fc69..b42367b 100755 --- a/yeswiki-installer.php +++ b/yeswiki-installer.php @@ -62,6 +62,12 @@ if (0 == posix_getuid()) { 'description' => 'No SSL certificate and no DNS check', 'noValue' => true, ], + 'noip6' => [ + 'prefix' => 'noip6', + 'longPrefix' => 'no-ip-v6', + 'description' => 'No ip v6 DNS check', + 'noValue' => true, + ], ]); $climate->arguments->parse(); $domain = $climate->arguments->get('domain'); @@ -71,11 +77,12 @@ if (0 == posix_getuid()) { $type = $climate->arguments->get('type'); $confirm = $climate->arguments->get('confirm'); $nossl = $climate->arguments->get('nossl'); + $noip6 = $climate->arguments->get('noip6'); $herseUser = $climate->arguments->get('herseuser'); $hersePass = $climate->arguments->get('hersepass'); $isFullDomain = !preg_match('/.'.$_SERVER['maindomain'].'$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0); if (!$nossl) { - checkDNS($domain, $isFullDomain); + checkDNS($domain, $isFullDomain, $noip6); } checkIfInstalled($domain); $needHerse = checkHerse($herseUser, $hersePass);