Obsolete
/
dnsmanagerv1
Archived
3
0
Fork 0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
dnsmanagerv1/lib/util.pm

32 lines
626 B
Perl
Raw Normal View History

package util;
use v5.10;
use configuration ':all';
use YAML::XS;
use Exporter 'import';
# what we want to export eventually
our @EXPORT_OK = qw/is_domain_name is_valid_tld/;
# bundle of exports (tags)
our %EXPORT_TAGS = ( all => [qw/is_domain_name is_valid_tld/] );
# TODO we can check if dn matches our domain name
sub is_domain_name {
my ($dn) = @_;
my $ndd = qr/^
([a-zA-Z0-9]+[a-zA-Z0-9-]*[a-zA-Z0-9]*[.])*
[a-zA-Z0-9]+[a-zA-Z0-9-]*[a-zA-Z0-9]([.])?
$/x;
return $dn =~ $ndd;
}
sub is_valid_tld {
my ($tld) = @_;
my $cfg = get_cfg;
grep { $_ eq $tld } @{$$cfg{tld}};
}
1;