Enhance DNS discovery, validation & transfers
Add comprehensive DNS management and input validation, plus safer transfer and logging behavior. - Add CronHelper utilities for cron scripts and unify logging/formatting. - Improve InputValidator: sanitizeDomainInput and validateRootDomain (handles multi-level TLDs) and use throughout domain import/create flows to reject subdomains. - DomainController: refactor DNS refresh to support quick/deep discovery (background deep scans), add endpoints to discover, add/delete/bulk-delete DNS records, import BIND zone files, enrich IP metadata via enrichIpDetails, and strengthen bulk import/reporting messages. - DnsRecord model: add source column handling (discovered/manual/imported), avoid auto-deleting manual/imported records, and add helpers for deleting, bulk deleting, manual adding and importing zone records. - Tag, NotificationGroup and Domain transfer logic: unlink groups when ownership changes, remove tags that belong to other users, add audit logging via Logger and improved bulk transfer reporting. TagController/View: show transferable users for admins and skip global tags on transfer. - Notification channels (Discord, Mattermost, etc.) and EmailHelper: allow explicit subjects and improve payload fields based on notification type. - Add new migration 029_add_dns_record_source.sql and wire it into the installer; update migrations detection. - Add new views/partials for confirm/import/transfer modals, update various domain/group/tag templates, and update cron scripts and routes for discovery. These changes preserve manual/imported DNS records, improve root-domain validation, enable background deep discovery, and add better logging/audit trails for transfers and imports.
This commit is contained in:
@@ -52,10 +52,11 @@ class DiscordChannel implements NotificationChannelInterface
|
||||
|
||||
private function createEmbed(string $message, array $data): array
|
||||
{
|
||||
$title = $data['subject'] ?? '🔔 Domain Monitor Alert';
|
||||
$color = $this->getColorByDaysLeft($data['days_left'] ?? null);
|
||||
|
||||
$embed = [
|
||||
'title' => '🔔 Domain Expiration Alert',
|
||||
'title' => $title,
|
||||
'description' => $message,
|
||||
'color' => $color,
|
||||
'timestamp' => date('c'),
|
||||
@@ -65,23 +66,22 @@ class DiscordChannel implements NotificationChannelInterface
|
||||
];
|
||||
|
||||
if (isset($data['domain'])) {
|
||||
$embed['fields'] = [
|
||||
[
|
||||
'name' => 'Domain',
|
||||
'value' => $data['domain'],
|
||||
'inline' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Days Left',
|
||||
'value' => (string) ($data['days_left'] ?? 'N/A'),
|
||||
'inline' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Expiration Date',
|
||||
'value' => $data['expiration_date'] ?? 'N/A',
|
||||
'inline' => true
|
||||
]
|
||||
$fields = [
|
||||
['name' => 'Domain', 'value' => $data['domain'], 'inline' => true]
|
||||
];
|
||||
|
||||
// Only add expiration fields for domain expiration alerts
|
||||
if (array_key_exists('days_left', $data) || array_key_exists('expiration_date', $data)) {
|
||||
$fields[] = ['name' => 'Days Left', 'value' => (string) ($data['days_left'] ?? 'N/A'), 'inline' => true];
|
||||
$fields[] = ['name' => 'Expiration Date', 'value' => $data['expiration_date'] ?? 'N/A', 'inline' => true];
|
||||
} elseif (isset($data['hostname']) && $data['hostname'] !== $data['domain']) {
|
||||
$fields[] = ['name' => 'Hostname', 'value' => $data['hostname'], 'inline' => true];
|
||||
}
|
||||
if (isset($data['new_status'])) {
|
||||
$fields[] = ['name' => 'Status', 'value' => $data['new_status'], 'inline' => true];
|
||||
}
|
||||
|
||||
$embed['fields'] = $fields;
|
||||
}
|
||||
|
||||
return $embed;
|
||||
|
||||
@@ -31,34 +31,30 @@ class MattermostChannel implements NotificationChannelInterface
|
||||
// Add attachments for richer formatting if domain data is available
|
||||
if (isset($data['domain'])) {
|
||||
$color = $this->getColorByDaysLeft($data['days_left'] ?? null);
|
||||
|
||||
$title = $data['subject'] ?? '🔔 Domain Monitor Alert';
|
||||
|
||||
$fields = [
|
||||
['short' => true, 'title' => 'Domain', 'value' => $data['domain']]
|
||||
];
|
||||
|
||||
// Only add expiration fields for domain expiration alerts
|
||||
if (array_key_exists('days_left', $data) || array_key_exists('expiration_date', $data)) {
|
||||
$fields[] = ['short' => true, 'title' => 'Days Left', 'value' => (string) ($data['days_left'] ?? 'N/A')];
|
||||
$fields[] = ['short' => true, 'title' => 'Expiration Date', 'value' => $data['expiration_date'] ?? 'N/A'];
|
||||
$fields[] = ['short' => true, 'title' => 'Registrar', 'value' => $data['registrar'] ?? 'N/A'];
|
||||
} elseif (isset($data['hostname']) && $data['hostname'] !== $data['domain']) {
|
||||
$fields[] = ['short' => true, 'title' => 'Hostname', 'value' => $data['hostname']];
|
||||
}
|
||||
if (isset($data['new_status'])) {
|
||||
$fields[] = ['short' => true, 'title' => 'Status', 'value' => $data['new_status']];
|
||||
}
|
||||
|
||||
$payload['attachments'] = [
|
||||
[
|
||||
'color' => $color,
|
||||
'title' => '🔔 Domain Expiration Alert',
|
||||
'title' => $title,
|
||||
'text' => $message,
|
||||
'fields' => [
|
||||
[
|
||||
'short' => true,
|
||||
'title' => 'Domain',
|
||||
'value' => $data['domain']
|
||||
],
|
||||
[
|
||||
'short' => true,
|
||||
'title' => 'Days Left',
|
||||
'value' => $data['days_left'] ?? 'N/A'
|
||||
],
|
||||
[
|
||||
'short' => true,
|
||||
'title' => 'Expiration Date',
|
||||
'value' => $data['expiration_date'] ?? 'N/A'
|
||||
],
|
||||
[
|
||||
'short' => true,
|
||||
'title' => 'Registrar',
|
||||
'value' => $data['registrar'] ?? 'N/A'
|
||||
]
|
||||
],
|
||||
'fields' => $fields,
|
||||
'footer' => 'Domain Monitor',
|
||||
'ts' => time()
|
||||
]
|
||||
|
||||
@@ -40,8 +40,10 @@ class PushoverChannel implements NotificationChannelInterface
|
||||
'priority' => $priority,
|
||||
];
|
||||
|
||||
// Optional: Add title
|
||||
if (isset($data['domain'])) {
|
||||
// Optional: Add title - use subject when provided (DNS, SSL, etc.)
|
||||
if (!empty($data['subject'])) {
|
||||
$payload['title'] = $data['subject'];
|
||||
} elseif (isset($data['domain'])) {
|
||||
$payload['title'] = '🔔 Domain Expiration Alert: ' . $data['domain'];
|
||||
} else {
|
||||
$payload['title'] = '🔔 Domain Monitor Notification';
|
||||
|
||||
@@ -53,12 +53,14 @@ class SlackChannel implements NotificationChannelInterface
|
||||
|
||||
private function createBlocks(string $message, array $data): array
|
||||
{
|
||||
$headerText = $data['subject'] ?? '🔔 Domain Monitor Alert';
|
||||
|
||||
$blocks = [
|
||||
[
|
||||
'type' => 'header',
|
||||
'text' => [
|
||||
'type' => 'plain_text',
|
||||
'text' => '🔔 Domain Expiration Alert'
|
||||
'text' => $headerText
|
||||
]
|
||||
],
|
||||
[
|
||||
@@ -71,26 +73,25 @@ class SlackChannel implements NotificationChannelInterface
|
||||
];
|
||||
|
||||
if (isset($data['domain'])) {
|
||||
$fields = [
|
||||
['type' => 'mrkdwn', 'text' => "*Domain:*\n{$data['domain']}"]
|
||||
];
|
||||
|
||||
// Only add expiration fields for domain expiration alerts
|
||||
if (array_key_exists('days_left', $data) || array_key_exists('expiration_date', $data)) {
|
||||
$fields[] = ['type' => 'mrkdwn', 'text' => "*Days Left:*\n" . ($data['days_left'] ?? 'N/A')];
|
||||
$fields[] = ['type' => 'mrkdwn', 'text' => "*Expiration:*\n" . ($data['expiration_date'] ?? 'N/A')];
|
||||
$fields[] = ['type' => 'mrkdwn', 'text' => "*Registrar:*\n" . ($data['registrar'] ?? 'N/A')];
|
||||
} elseif (isset($data['hostname']) && $data['hostname'] !== $data['domain']) {
|
||||
$fields[] = ['type' => 'mrkdwn', 'text' => "*Hostname:*\n{$data['hostname']}"];
|
||||
}
|
||||
if (isset($data['new_status'])) {
|
||||
$fields[] = ['type' => 'mrkdwn', 'text' => "*Status:*\n{$data['new_status']}"];
|
||||
}
|
||||
|
||||
$blocks[] = [
|
||||
'type' => 'section',
|
||||
'fields' => [
|
||||
[
|
||||
'type' => 'mrkdwn',
|
||||
'text' => "*Domain:*\n{$data['domain']}"
|
||||
],
|
||||
[
|
||||
'type' => 'mrkdwn',
|
||||
'text' => "*Days Left:*\n{$data['days_left']}"
|
||||
],
|
||||
[
|
||||
'type' => 'mrkdwn',
|
||||
'text' => "*Expiration:*\n{$data['expiration_date']}"
|
||||
],
|
||||
[
|
||||
'type' => 'mrkdwn',
|
||||
'text' => "*Registrar:*\n{$data['registrar']}"
|
||||
]
|
||||
]
|
||||
'fields' => $fields
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class WebhookChannel implements NotificationChannelInterface
|
||||
private function buildGenericPayload(string $message, array $data): array
|
||||
{
|
||||
return [
|
||||
'event' => 'domain_expiration_alert',
|
||||
'event' => 'domain_monitor_alert',
|
||||
'message' => $message,
|
||||
'data' => $data,
|
||||
'sent_at' => date('c')
|
||||
|
||||
Reference in New Issue
Block a user