Hopefully finished work on adding, removing, getting and setting ptrs.

This commit is contained in:
Maff 2014-02-09 09:22:23 +00:00
parent f01bb0c1b6
commit f9ea0a8c19
1 changed files with 22 additions and 4 deletions

View File

@ -129,7 +129,25 @@ sub write_zone {
print ZONE Net::DNS::ZoneParse::writezone @_;
close ZONE or nicedie "Seemingly failed to close $zone$zone_ext, cowardly quitting here.";
}
sub get_rdns {
sub del_ptr {
#I'm so sorry
my $rec = shift;
sub is_match {
my ($rr,$rec) = @_;
return 1 unless $rr->name eq $rec;
return 0;
}
write_zone $rec,grep {&is_match(($_,$rec))} @_;
}
sub add_ptr {
my ($ip,$fqdn) = @_;
my ($rec,$zone) = get_arpa $ip;
my @z = get_zone_array $ip;
my $new_rr = Net::DNS::RR->new("$rec.$zone. 3600 IN PTR $fqdn");
push @z,$new_rr;
write_zone $zone,@z;
}
sub get_ptr {
my $ip = shift;
return unless does_record_exist $ip;
my ($rec,$zone) = get_arpa $ip;
@ -140,7 +158,7 @@ sub get_rdns {
}
return;
}
sub set_rdns {
sub set_ptr {
my ($ip,$fqdn) = @_;
my ($record,$zone) = get_arpa $ip;
my @z = get_zone_array $ip;
@ -194,7 +212,7 @@ for(does_zone_exist $ip) {
nicedie "Authoritative zone for IP $ip exists but we can't write to it. Please check the permissions on the zonefile for $tz." when 0;
}
#if(!defined $domain and $reset) {
# set_rdns $ip,$def_rdns or nicedie "Failed to set rDNS for $ip to '$def_rdns'!";
# set_ptr $ip,$def_rdns or nicedie "Failed to set rDNS for $ip to '$def_rdns'!";
#}
#do_sync $ip if (($made_modifications and !$nosync) or $fsync);
set_rdns $ip,$domain;
add_ptr $ip, $domain;