From 5835cef7cacee4ae0044a27b9a45f87a62726dd1 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Wed, 5 Jul 2023 11:02:13 -0700 Subject: [PATCH] add dns checks for vhosts --- panel/classes/Panel/Vhost/Vhosts.php | 22 +++++++- panel/ui/vhost/vhosts-vhost.html | 75 +++++++++++++++++++--------- 2 files changed, 72 insertions(+), 25 deletions(-) diff --git a/panel/classes/Panel/Vhost/Vhosts.php b/panel/classes/Panel/Vhost/Vhosts.php index 212e264..c7d3774 100644 --- a/panel/classes/Panel/Vhost/Vhosts.php +++ b/panel/classes/Panel/Vhost/Vhosts.php @@ -37,6 +37,24 @@ class Vhosts extends \Panel\Vhost { $cert_array['alternative'] = $alternative; $f3->set('cert_array', $cert_array); } + } else { + /* no cert, get dns info */ + $dnsinfo = array(); + $dnsinfo['server_addr'] = $_SERVER['SERVER_ADDR']; + # A record + $dnsinfo['a']['color'] = "red"; + if ($certdomain_dns = dns_get_record("$vhost", DNS_A)) { + if ($certdomain_dns[0]['ip'] == $dnsinfo['server_addr']) { + $dnsinfo['a']['status'] = "Verified"; + $dnsinfo['a']['color'] = "black"; + $dnsinfo['verified_count']++; + } else { + $dnsinfo['a']['status'] = "Update"; + } + } else { + $dnsinfo['a']['status'] = "Create"; + } + $f3->set('dnsinfo', $dnsinfo); } /* get user info */ $username = $vhost_array[0]['username']; @@ -66,12 +84,12 @@ class Vhosts extends \Panel\Vhost { if ($f3->exists('PARAMS.vhost')) { - $vhost_array = $f3->get('vhost_array'); + // $vhost_array = $f3->get('vhost_array'); /* convert data for frontend display */ // nothing to convert - $f3->set('vhost_array', $vhost_array); + // $f3->set('vhost_array', $vhost_array); $vhost = $f3->get('PARAMS.vhost'); $f3->set('page_header', "Details for $vhost"); diff --git a/panel/ui/vhost/vhosts-vhost.html b/panel/ui/vhost/vhosts-vhost.html index a62981e..e42b00c 100644 --- a/panel/ui/vhost/vhosts-vhost.html +++ b/panel/ui/vhost/vhosts-vhost.html @@ -34,32 +34,61 @@ -

- - - - - - - - - - - - - - - -
CertificateExpirationSecured HostnamesAction
{{ @cert_array.common }}{{ @cert_array.end }}{{ @cert_array.alternative | raw }}Delete
-
- -Add Security Certificate - + +

+ + + + + + + + + + + + + +
CertificateExpirationSecured HostnamesAction
{{ @cert_array.common }}{{ @cert_array.end }}{{ @cert_array.alternative | raw }}Delete
+

+
+ +
+ + + You need a Security Certificate. Click Here to add one now. + + + You need a Security Certificate for {{ @vhost_array.virtualhost }}. +
+ Before you can add one you must make the DNS change listed below. Once that's completed come back here and this message will change to an option to create a Security Certificate. +
+ Note that after you add DNS records it can take some time for the changes to propagate and show up here. +

+ + + + + + + +
{{ @dnsinfo.a.status }} A Record for {{ @vhost_array.virtualhost }}
Type:A
Host:{{ @vhost_array.virtualhost }}
Value:{{ @dnsinfo.server_addr }}
TTL:3600 (or default)
This should be the only A record for {{ @vhost_array.virtualhost }}.
+

+ + + + + + + +
Verify CNAME Record for www.{{ @vhost_array.virtualhost }}
Type:CNAME
Host:www.{{ @vhost_array.virtualhost }}
Value:{{ @vhost_array.virtualhost }}
TTL:3600 (or default)
This should be the only record for www.{{ @vhost_array.virtualhost }}.
Note this admin did not check for this record, it may already exist.
+
+
+
+
-

-
Remote Access
Protocol:SFTP (SSH File Transfer Protocol)