Skip to content

Commit

Permalink
Support ALIAS, *._something and foo.#bar#
Browse files Browse the repository at this point in the history
  • Loading branch information
tvlooy committed Jan 9, 2024
1 parent 7d8f17a commit 2f32718
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Command/Dns/GetRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function processResponse(array $response)
case 'CNAME':
case 'SOA':
case 'CAA':
case 'ALIAS':
$rec = new $className($record->id, $record->record_name, $record->ttl, $record->content);

break;
Expand Down
1 change: 1 addition & 0 deletions src/Command/Dns/ListRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function processResponse(array $response)
case 'CNAME':
case 'SOA':
case 'CAA':
case 'ALIAS':
$rec = new $className(
$record->id,
$record->record_name,
Expand Down
4 changes: 2 additions & 2 deletions src/Structure/Dns/AbstractDnsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ protected function validateHostname(string $hostname, bool $allowOrigin = true):
if ($allowOrigin && in_array($hostname, ['', '@', '*'])) {
return $hostname;
} else {
// remove leading underscores or wildcards from labels, as we consider them valid, then send through filter_var
$filtered = preg_replace('(^\*\.|^_|\._)', '', $hostname);
// remove special characters from labels, as we consider them valid, then send through filter_var
$filtered = preg_replace('(^\*\._|^\*\.|^_|\._|\#)', '', $hostname);
$filtered = filter_var($filtered, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);

// did the check pass and did we removed leading underscores? if so, use original value;
Expand Down
33 changes: 33 additions & 0 deletions src/Structure/Dns/DnsALIASRecord.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace TomCan\CombellApi\Structure\Dns;

class DnsALIASRecord extends AbstractDnsRecord
{
private $content;

public function __construct(string $id = '', string $hostname = '', int $ttl = 3600, string $content = '')
{
parent::__construct($id, 'ALIAS', $hostname, $ttl);
$this->setContent($content);
}

public function getContent(): string
{
return $this->content;
}

private function setContent(string $content): void
{
$this->content = $content;
}

public function getObject(): \stdClass
{
$obj = parent::getObject();
$obj->content = $this->getContent();

return $obj;
}
}

0 comments on commit 2f32718

Please sign in to comment.