-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b78ce62
commit 5fc7029
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
/** | ||
* DNS Email DMARC check. | ||
* | ||
* @package tool_emailutils | ||
* @author Brendan Heywood <[email protected]> | ||
* @copyright Catalyst IT 2024 | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* | ||
*/ | ||
|
||
namespace tool_emailutils\check; | ||
use core\check\check; | ||
use core\check\result; | ||
use tool_emailutils\dns_util; | ||
|
||
/** | ||
* DNS Email DKIM check. | ||
* | ||
* @package tool_emailutils | ||
* @author Brendan Heywood <[email protected]> | ||
* @copyright Catalyst IT 2024 | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class dnsdmarc extends check { | ||
|
||
/** | ||
* A link to a place to action this | ||
* | ||
* @return \action_link|null | ||
*/ | ||
public function get_action_link(): ?\action_link { | ||
return new \action_link( | ||
new \moodle_url('/admin/tool/emailutils/dkim.php'), | ||
get_string('dkimmanager', 'tool_emailutils')); | ||
} | ||
|
||
/** | ||
* Get Result. | ||
* | ||
* @return result | ||
*/ | ||
public function get_result() : result { | ||
global $DB, $CFG; | ||
|
||
$url = new \moodle_url($CFG->wwwroot); | ||
$domain = $url->get_host(); | ||
|
||
$details = ''; | ||
$status = result::INFO; | ||
$summary = ''; | ||
|
||
$dns = new dns_util(); | ||
|
||
$noreply = $dns->get_noreply(); | ||
$details .= "<p>No reply email: <code>$noreply</code></p>"; | ||
|
||
$noreplydomain = $dns->get_noreply_domain(); | ||
$details .= "<p>Start looking in domain: <code>$noreplydomain</code></p>"; | ||
|
||
[$dmarcdomain, $dmarc] = $dns->get_dmarc_dns_record(); | ||
|
||
if (empty($dmarc)) { | ||
$details .= "<p>DMARC record is missing</p>"; | ||
$status = result::ERROR; | ||
$summary = "DMARC DNS record missing"; | ||
} else { | ||
$details .= "<p>DMARC record found on domain <code>$dmarcdomain</code><br><code>$dmarc</code></p>"; | ||
$status = result::OK; | ||
$summary = "DMARC record exists"; | ||
} | ||
|
||
|
||
return new result($status, $summary, $details); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters