Skip to content

Commit

Permalink
better alias checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Idrinth authored Feb 23, 2023
1 parent 7fc4c2f commit 003a24f
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/VirtualHostGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ private function buildHostList(\PDOStatement $statement, array &$virtualhosts, s
if (gethostbyname($vhost . '.') !== $ip) {
continue;
}
if (gethostbyname('www.' . $vhost . '.') !== $ip) {
continue;
}
if (!$this->certificate($vhost, $row['admin'])) {
continue;
}
if (!$this->certificate("www.$vhost", $row['admin'])) {
continue;
$aliases = [];
echo " Handling Alias www.$vhost\n";
if (gethostbyname("www.$vhost.") !== $ip && $this->certificate("www.$vhost", $row['admin'])) {
$aliases[] = "www.$vhost";
}
$aliases = ["www.$vhost"];
$stmt = $this->database->prepare('SELECT virtualhost_domain_alias.subdomain,domain.domain,domain.admin '
. 'FROM virtualhost_domain_alias '
. 'INNER JOIN domain ON domain.aid=virtualhost_domain_alias.domain '
Expand All @@ -60,14 +58,13 @@ private function buildHostList(\PDOStatement $statement, array &$virtualhosts, s
foreach ($stmt->fetchAll() as $alias) {
$domain = trim($alias['subdomain'] . '.' . $alias['domain'], '.');
echo " Handling Alias $domain\n";
if (!$this->certificate($domain, $alias['admin'])) {
continue;
if (gethostbyname("$domain.") !== $ip && $this->certificate($domain, $alias['admin'])) {
$aliases[] = $domain;
}
if (!$this->certificate("www.$domain", $alias['admin'])) {
continue;
echo " Handling Alias www.$domain\n";
if (gethostbyname("www.$domain.") !== $ip && $this->certificate("www.$domain", $alias['admin'])) {
$aliases[] = "www.$domain";
}
$aliases[] = $domain;
$aliases[] = "www.$domain";
}
$virtualhosts[] = [
'domain' => $vhost,
Expand Down

0 comments on commit 003a24f

Please sign in to comment.