mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
Store server IPs in one form (no brackets, short lower-case IPv6) and write each address in the form its context needs: - URLs and host:port (Sentinel, database URLs, SFTP backup download, DNS servers, SMTP, webhook base URLs, links, health checks) get brackets through formatHostForUrl(). - Traefik Host() rules use the address without brackets, so IPv6 domains no longer return 404; saved labels are fixed at deploy. Caddy keeps the brackets. - SSH keeps the plain address. - Hetzner gives an IPv6 /64 network; IPv6-only servers now get the server address (prefix::1) instead of the unusable prefix::64. - sslip labels, registry image names with an IPv6 host, the API domain list, allowlist matching and duplicate checks handle IPv6. A migration normalizes stored IPv6 server addresses, repairs Hetzner servers saved as ::64 that are not reachable, and adds brackets to saved Sentinel URLs.
65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Support\SmtpTransportFactory;
|
|
use Illuminate\Config\Repository;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
class ConfigurationRepository
|
|
{
|
|
private Repository $config;
|
|
|
|
public function __construct(Repository $config)
|
|
{
|
|
$this->config = $config;
|
|
}
|
|
|
|
public function updateMailConfig($settings): void
|
|
{
|
|
$from = mail_from_identity($settings);
|
|
|
|
if ($settings->resend_enabled) {
|
|
$this->config->set('mail.default', 'resend');
|
|
$this->applyMailFrom($from);
|
|
$this->config->set('resend.api_key', $settings->resend_api_key);
|
|
|
|
return;
|
|
}
|
|
|
|
if ($settings->smtp_enabled) {
|
|
$mailerOptions = SmtpTransportFactory::mailerOptions($settings);
|
|
$localDomain = $settings->smtp_ehlo_domain
|
|
?? $this->config->get('mail.mailers.smtp.local_domain');
|
|
|
|
$this->config->set('mail.default', 'smtp');
|
|
$this->applyMailFrom($from);
|
|
$this->config->set('mail.mailers.smtp', [
|
|
'transport' => 'smtp',
|
|
'scheme' => $mailerOptions['scheme'],
|
|
'host' => filled($settings->smtp_host) ? formatHostForUrl($settings->smtp_host) : $settings->smtp_host,
|
|
'port' => $settings->smtp_port,
|
|
'encryption' => $mailerOptions['encryption'],
|
|
'username' => $settings->smtp_username,
|
|
'password' => $settings->smtp_password,
|
|
'timeout' => $settings->smtp_timeout,
|
|
'local_domain' => $localDomain,
|
|
'auto_tls' => $mailerOptions['auto_tls'],
|
|
]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param array{address: string, name: string} $from
|
|
*/
|
|
private function applyMailFrom(array $from): void
|
|
{
|
|
$this->config->set('mail.from.address', $from['address']);
|
|
$this->config->set('mail.from.name', $from['name']);
|
|
|
|
if (app()->bound('mail.manager')) {
|
|
Mail::purge();
|
|
}
|
|
}
|
|
}
|