2023-10-25 15:50:33 +02:00
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2023 Afnic
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#
|
|
|
|
|
2023-10-25 15:50:23 +02:00
|
|
|
package Email::SpoofingDemo::API::Recipient;
|
|
|
|
|
|
|
|
use Dancer2;
|
|
|
|
|
|
|
|
use Email::SpoofingDemo::PostfixConfig qw(spf_dkim_dmarc_status
|
|
|
|
set_spf_dkim_dmarc_status);
|
|
|
|
|
|
|
|
our $VERSION = '0.1';
|
|
|
|
|
|
|
|
get '/' => sub { return "Welcome"; };
|
|
|
|
|
|
|
|
get '/status' => sub {
|
|
|
|
my $status = spf_dkim_dmarc_status();
|
|
|
|
my %result = map {
|
|
|
|
$_ => ($status->{$_} ? 'enabled' : 'disabled')
|
|
|
|
} (keys %$status);
|
|
|
|
return \%result;
|
|
|
|
};
|
|
|
|
|
|
|
|
put '/status' => sub {
|
|
|
|
my $spf_enabled = body_parameters->get('spf');
|
|
|
|
my $dkim_enabled = body_parameters->get('dkim');
|
|
|
|
my $dmarc_enabled = body_parameters->get('dmarc');
|
|
|
|
|
|
|
|
unless (defined $spf_enabled
|
|
|
|
and defined $dkim_enabled
|
|
|
|
and defined $dmarc_enabled) {
|
|
|
|
status 400;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_spf_dkim_dmarc_status(
|
|
|
|
$spf_enabled eq 'enabled',
|
|
|
|
$dkim_enabled eq 'enabled',
|
|
|
|
$dmarc_enabled eq 'enabled'
|
|
|
|
);
|
|
|
|
return "OK";
|
|
|
|
};
|
|
|
|
|
|
|
|
any qr{.*} => sub { status 'not_found'; return "Invalid route" };
|
|
|
|
|
|
|
|
dance;
|
|
|
|
|
|
|
|
true;
|