feat(yeswiki-installer) : allow no ip v6
This commit is contained in:
parent
30c9718ad4
commit
6ecb34cee5
2 changed files with 25 additions and 11 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require 'vendor/autoload.php';
|
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))) {
|
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.'".');
|
throw new Exception('not valid domain : "'.$domain.'".');
|
||||||
|
@ -17,12 +17,14 @@ function checkDNS($domain, $withWww = false)
|
||||||
if ($currentip[0]['ip'] !== $_SERVER['ip4']) {
|
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']);
|
throw new Exception('the current ip v4 address of '.$domain.' is '.$currentip[0]['ip'].'. it should be '.$_SERVER['ip4']);
|
||||||
}
|
}
|
||||||
|
if (!$noip6) {
|
||||||
if (empty($currentip[0]['ipv6'])) {
|
if (empty($currentip[0]['ipv6'])) {
|
||||||
throw new Exception('the domain '.$domain.' has no ip v6 in DNS record.');
|
throw new Exception('the domain '.$domain.' has no ip v6 in DNS record.');
|
||||||
}
|
}
|
||||||
if ($currentip[1]['ipv6'] !== $_SERVER['ip6']) {
|
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']);
|
throw new Exception('the current ip v6 address of '.$domain.' is '.$currentip[1]['ipv6'].'. it should be '.$_SERVER['ip6']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($withWww) {
|
if ($withWww) {
|
||||||
$dnsentries = dns_get_record('www.'.$domain, DNS_A + DNS_AAAA + DNS_CNAME);
|
$dnsentries = dns_get_record('www.'.$domain, DNS_A + DNS_AAAA + DNS_CNAME);
|
||||||
$foundCnameEntry = false;
|
$foundCnameEntry = false;
|
||||||
|
@ -35,13 +37,18 @@ function checkDNS($domain, $withWww = false)
|
||||||
if ($row['host'] == 'www.'.$domain && $row['type']=='A' && $row['ip'] == $_SERVER['ip4']) {
|
if ($row['host'] == 'www.'.$domain && $row['type']=='A' && $row['ip'] == $_SERVER['ip4']) {
|
||||||
$foundIp4 = true;
|
$foundIp4 = true;
|
||||||
}
|
}
|
||||||
|
if (!$noip6) {
|
||||||
if ($row['host'] == 'www.'.$domain && $row['type']=='AAAA' && $row['ipv6'] == $_SERVER['ip6']) {
|
if ($row['host'] == 'www.'.$domain && $row['type']=='AAAA' && $row['ipv6'] == $_SERVER['ip6']) {
|
||||||
$foundIp6 = true;
|
$foundIp6 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!$foundCnameEntry) {
|
if (!$foundCnameEntry) {
|
||||||
if (!$foundIp4 && !$foundIp6) {
|
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'].' and a AAAA entry to '.$_SERVER['ip6'].'.');
|
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'].'.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,12 @@ if (0 == posix_getuid()) {
|
||||||
'description' => 'No SSL certificate and no DNS check',
|
'description' => 'No SSL certificate and no DNS check',
|
||||||
'noValue' => true,
|
'noValue' => true,
|
||||||
],
|
],
|
||||||
|
'noip6' => [
|
||||||
|
'prefix' => 'noip6',
|
||||||
|
'longPrefix' => 'no-ip-v6',
|
||||||
|
'description' => 'No ip v6 DNS check',
|
||||||
|
'noValue' => true,
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
$climate->arguments->parse();
|
$climate->arguments->parse();
|
||||||
$domain = $climate->arguments->get('domain');
|
$domain = $climate->arguments->get('domain');
|
||||||
|
@ -71,11 +77,12 @@ if (0 == posix_getuid()) {
|
||||||
$type = $climate->arguments->get('type');
|
$type = $climate->arguments->get('type');
|
||||||
$confirm = $climate->arguments->get('confirm');
|
$confirm = $climate->arguments->get('confirm');
|
||||||
$nossl = $climate->arguments->get('nossl');
|
$nossl = $climate->arguments->get('nossl');
|
||||||
|
$noip6 = $climate->arguments->get('noip6');
|
||||||
$herseUser = $climate->arguments->get('herseuser');
|
$herseUser = $climate->arguments->get('herseuser');
|
||||||
$hersePass = $climate->arguments->get('hersepass');
|
$hersePass = $climate->arguments->get('hersepass');
|
||||||
$isFullDomain = !preg_match('/.'.$_SERVER['maindomain'].'$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0);
|
$isFullDomain = !preg_match('/.'.$_SERVER['maindomain'].'$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0);
|
||||||
if (!$nossl) {
|
if (!$nossl) {
|
||||||
checkDNS($domain, $isFullDomain);
|
checkDNS($domain, $isFullDomain, $noip6);
|
||||||
}
|
}
|
||||||
checkIfInstalled($domain);
|
checkIfInstalled($domain);
|
||||||
$needHerse = checkHerse($herseUser, $hersePass);
|
$needHerse = checkHerse($herseUser, $hersePass);
|
||||||
|
|
Loading…
Add table
Reference in a new issue