From 55b8d6e356a9bd72b56b701d1a0352e56417358c Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Fri, 27 Sep 2024 16:44:36 +0300 Subject: [PATCH] update --- .../Resources/EmailDomainResource.php | 2 +- .../Email/App/Http/Livewire/DkimSetup.php | 50 +++++++++++++++++++ .../App/Providers/EmailServiceProvider.php | 4 ++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/web/Modules/Email/App/Filament/Resources/EmailDomainResource.php b/web/Modules/Email/App/Filament/Resources/EmailDomainResource.php index 9b9a2f3..a38aecf 100644 --- a/web/Modules/Email/App/Filament/Resources/EmailDomainResource.php +++ b/web/Modules/Email/App/Filament/Resources/EmailDomainResource.php @@ -52,7 +52,7 @@ class EmailDomainResource extends Resource ->label('DKIM Setup') ->form(function (Domain $record) { return [ - Forms\Components\Livewire::make(DkimSetup::class, [ + Forms\Components\Livewire::make('email::dkim-setup', [ 'domain' => $record->domain, ]), ]; diff --git a/web/Modules/Email/App/Http/Livewire/DkimSetup.php b/web/Modules/Email/App/Http/Livewire/DkimSetup.php index c2c41b2..d127938 100644 --- a/web/Modules/Email/App/Http/Livewire/DkimSetup.php +++ b/web/Modules/Email/App/Http/Livewire/DkimSetup.php @@ -18,6 +18,56 @@ class DkimSetup extends Component ]); } + public function verify() + { + $getMainDomain = ''; + $parseDomain = explode('.', $this->domain); + if (count($parseDomain) > 2) { + $getMainDomain = $parseDomain[1] . '.' . $parseDomain[2]; + } else { + $getMainDomain = $this->domain; + } + + $checks = []; + $checkOne = shell_exec('dig @1.1.1.1 +short MX '.$getMainDomain); + $checkOnePass = false; + if (str_contains($checkOne, '10 '.$this->domain)) { + $checkOnePass = true; + } + $checks[] = [ + 'check' => 'MX', + 'pass' => $checkOnePass, + 'result'=>$checkOne + ]; + + $checkTwo = shell_exec('dig @1.1.1.1 +short A '.$this->domain); + $checkTwo = trim($checkTwo); + $getIpOfDomain = gethostbyname($this->domain); + $checkTwoPass = false; + if ($checkTwo == $getIpOfDomain) { + $checkTwoPass = true; + } + $checks[] = [ + 'check'=>'IP', + 'pass'=>$checkTwoPass, + 'result'=>$checkTwo + ]; + + $checkThree = shell_exec('dig @1.1.1.1 +short -x ' . $getIpOfDomain); + $checkThree = trim($checkThree); + $checkTreePass = false; + if ($checkThree == $this->domain) { + $checkTreePass = true; + } + $checks[] = [ + 'check'=>'Reverse DNS', + 'pass'=>$checkTreePass, + 'result'=>$checkThree + ]; + + return $checks; + } + public function secure() { $output = DkimDomainSetup::run($this->domain); diff --git a/web/Modules/Email/App/Providers/EmailServiceProvider.php b/web/Modules/Email/App/Providers/EmailServiceProvider.php index f1958c2..9fe38da 100644 --- a/web/Modules/Email/App/Providers/EmailServiceProvider.php +++ b/web/Modules/Email/App/Providers/EmailServiceProvider.php @@ -5,7 +5,9 @@ namespace Modules\Email\App\Providers; use BladeUI\Icons\Factory; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Livewire\Livewire; use Modules\Email\App\Console\SetupEmailServer; +use Modules\Email\App\Http\Livewire\DkimSetup; class EmailServiceProvider extends ServiceProvider { @@ -40,6 +42,8 @@ class EmailServiceProvider extends ServiceProvider }); $this->app->register(RouteServiceProvider::class); + + Livewire::component('email::dkim-setup', DkimSetup::class); } /**