improves checkWebmail
This commit is contained in:
parent
2e1f1ac8b1
commit
91ea53275e
|
@ -1745,7 +1745,7 @@ class CLIController
|
||||||
$quiet = $this->configController->getConfig(configKey: 'quiet');
|
$quiet = $this->configController->getConfig(configKey: 'quiet');
|
||||||
$verbose = $this->configController->getConfig(configKey: 'verbose');
|
$verbose = $this->configController->getConfig(configKey: 'verbose');
|
||||||
|
|
||||||
if (empty($this->arguments[1])) {
|
if (empty($this->arguments[1])) {
|
||||||
if (!$quiet) {
|
if (!$quiet) {
|
||||||
echo COLOR_DEFAULT . 'You need to supply a domain name.' . PHP_EOL;
|
echo COLOR_DEFAULT . 'You need to supply a domain name.' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
@ -1755,7 +1755,7 @@ class CLIController
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$quiet) {
|
if (!$quiet) {
|
||||||
echo COLOR_DEFAULT . 'Checking domain ' . COLOR_YELLOW . $domainName . COLOR_DEFAULT . PHP_EOL;
|
echo COLOR_DEFAULT . 'Checking domain ' . COLOR_YELLOW . $domainName . COLOR_DEFAULT . '.' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$domain = $this->domainRepository->findByName(name: $domainName)) {
|
if (!$domain = $this->domainRepository->findByName(name: $domainName)) {
|
||||||
|
@ -1780,8 +1780,8 @@ class CLIController
|
||||||
$webmailDomain = 'webmail.' . $domainName;
|
$webmailDomain = 'webmail.' . $domainName;
|
||||||
|
|
||||||
if (!empty($panel->getAAAA())) {
|
if (!empty($panel->getAAAA())) {
|
||||||
if ($verbose) {
|
if (!$quiet && $verbose) {
|
||||||
echo 'Check using IPv6: ' . COLOR_YELLOW . $panel->getAaaa() . COLOR_DEFAULT . PHP_EOL;
|
echo 'Check using IPv6: ' . COLOR_YELLOW . $panel->getAaaa() . '.' . COLOR_DEFAULT . PHP_EOL;
|
||||||
}
|
}
|
||||||
$result = $this->apiController->sendCommand(
|
$result = $this->apiController->sendCommand(
|
||||||
requestType: 'GET',
|
requestType: 'GET',
|
||||||
|
@ -1791,7 +1791,7 @@ class CLIController
|
||||||
command: 'domains/name/' . $webmailDomain,
|
command: 'domains/name/' . $webmailDomain,
|
||||||
serverType: 'panel');
|
serverType: 'panel');
|
||||||
} else {
|
} else {
|
||||||
if ($verbose) {
|
if (!$quiet && $verbose) {
|
||||||
echo 'Check using IPv4: ' . COLOR_YELLOW . $panel->getA() . COLOR_DEFAULT . PHP_EOL;
|
echo 'Check using IPv4: ' . COLOR_YELLOW . $panel->getA() . COLOR_DEFAULT . PHP_EOL;
|
||||||
}
|
}
|
||||||
$result = $this->apiController->sendCommand(
|
$result = $this->apiController->sendCommand(
|
||||||
|
@ -1800,24 +1800,70 @@ class CLIController
|
||||||
versionIP: 4,
|
versionIP: 4,
|
||||||
apiKey: $decryptedKey,
|
apiKey: $decryptedKey,
|
||||||
command: 'domains/name/' . $webmailDomain,
|
command: 'domains/name/' . $webmailDomain,
|
||||||
serverType: 'panel' );
|
serverType: 'panel');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result['header'] === 404) {
|
if ($result['header'] === 404) {
|
||||||
if (!$quiet) {
|
if (!$quiet) {
|
||||||
echo 'The domain ' . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . ' doesn\'t exist.' . PHP_EOL;
|
echo 'The domain ' . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . " doesn't exist." . PHP_EOL;
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
if(!$quiet) {
|
if (!$quiet) {
|
||||||
echo 'Found ' . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . '.' . PHP_EOL;
|
echo 'Found ' . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . '.' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($v4 = dns_get_record(hostname: $webmailDomain, type: DNS_A)[0]) {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo "Found IPv4 entry: " . COLOR_YELLOW . $v4['ip'] . COLOR_DEFAULT . '.' .PHP_EOL;
|
||||||
|
}
|
||||||
|
$v4Test = $this->apiController->fileGetContents(url: $webmailDomain, versionIP: 4);
|
||||||
|
|
||||||
|
if ($v4Test['error']) {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo 'There was an error: ' . COLOR_YELLOW . $v4Test['errorMessage'] . COLOR_DEFAULT . '.';
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo 'Successfully connected to webserver via ' . COLOR_YELLOW . 'IPv4' . COLOR_DEFAULT . '.' . PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo "Found no IPv4 entry for " . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($v6 = dns_get_record(hostname: $webmailDomain, type: DNS_AAAA)[0]) {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo "Found IPv6 entry: " . COLOR_YELLOW . $v6['ipv6'] . COLOR_DEFAULT . '.' . PHP_EOL;
|
||||||
|
}
|
||||||
|
$v6Test = $this->apiController->fileGetContents(url: $webmailDomain, versionIP: 6);
|
||||||
|
|
||||||
|
if ($v6Test['error']) {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo 'There was an error: ' . COLOR_YELLOW . $v6Test['errorMessage'] . COLOR_DEFAULT . '.';
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo 'Successfully connected to webserver via ' . COLOR_YELLOW . 'IPv6' . COLOR_DEFAULT . '.' . PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo "Found no IPv6 entry for " . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . '.' . PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO check that at least IPv4 or IP6 exists?
|
||||||
|
|
||||||
|
|
||||||
$domainData = json_decode(json: $result['data']);
|
$domainData = json_decode(json: $result['data']);
|
||||||
$apacheData = $domainData->apache;
|
$apacheData = $domainData->apache;
|
||||||
|
|
||||||
$httpDirectives = $apacheData->http_directives;
|
|
||||||
$httpsDirectives = $apacheData->https_directives . PHP_EOL;
|
$httpsDirectives = $apacheData->https_directives . PHP_EOL;
|
||||||
|
|
||||||
if (!str_contains(haystack: $httpsDirectives, needle: '# bindAPI - webmailer')) {
|
if (!str_contains(haystack: $httpsDirectives, needle: '# bindAPI - webmailer')) {
|
||||||
|
@ -1825,25 +1871,54 @@ class CLIController
|
||||||
echo 'Generated config is missing.' . PHP_EOL;
|
echo 'Generated config is missing.' . PHP_EOL;
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
|
} else {
|
||||||
|
if (!$quiet) {
|
||||||
|
echo 'Generated config is valid.' . PHP_EOL;
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function webmailCreate()
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function webmailCreate(): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
/*
|
||||||
$webmailConfig = '# bindAPI - webmailer' . PHP_EOL;
|
$webmailConfig = '# bindAPI - webmailer' . PHP_EOL;
|
||||||
$webmailConfig .= 'SSLProxyEngine On' . PHP_EOL;
|
$webmailConfig .= 'SSLProxyEngine On' . PHP_EOL;
|
||||||
$webmailConfig .= 'ProxyPass /.well-known/ !' . PHP_EOL;
|
$webmailConfig .= 'ProxyPass /.well-known/ !' . PHP_EOL;
|
||||||
$webmailConfig .= 'ProxyPass "/" "https://' . $panel->getName() . '/webmail/"' . PHP_EOL;
|
$webmailConfig .= 'ProxyPass "/" "https://webmail' . $panel->getName() . '"' . PHP_EOL;
|
||||||
$webmailConfig .= '## bindAPI - webmailer' . PHP_EOL;
|
$webmailConfig .= '## bindAPI - webmailer' . PHP_EOL;
|
||||||
|
|
||||||
echo $webmailConfig;
|
echo $webmailConfig;
|
||||||
|
|
||||||
//$httpsDirectives += $w
|
//$httpsDirectives += $w
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkMail(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checksVersion(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private function dynDnyUpdate(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private function dynDnsDelete(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private function webmailDelete(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue