From ea99201a5a0e820819cf7332e21c6623fa43a939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Sun, 19 Feb 2023 01:35:02 +0100 Subject: [PATCH] fix lookup correctly --- src/VirtualHostGenerator.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/VirtualHostGenerator.php b/src/VirtualHostGenerator.php index 3bdf43b..c945958 100644 --- a/src/VirtualHostGenerator.php +++ b/src/VirtualHostGenerator.php @@ -39,13 +39,16 @@ private function buildHostList(\PDOStatement $statement, array &$virtualhosts, s foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) { $vhost = trim($row['name'] . '.' . $row['domain'], '.'); echo "Handling $vhost\n"; - if (gethostbyname($vhost) !== $ip) { + if (gethostbyname($vhost . '.') !== $ip) { + continue; + } + if (gethostbyname('www.' . $vhost . '.') !== $ip) { continue; } - if (!$this->certificate($vhost . '.', $row['admin'])) { + if (!$this->certificate($vhost, $row['admin'])) { continue; } - if (!$this->certificate("www.$vhost.", $row['admin'])) { + if (!$this->certificate("www.$vhost", $row['admin'])) { continue; } $virtualhosts[] = [