commit f039763e19b82fdd2a36fde0b0c4af118211ddf4 from: Izzy Blacklock date: Tue Aug 08 17:20:30 2023 UTC rebranded and removed irc specific stuff from botnow commit - 26e212c59a608d949d8fbd33aa41b0357b452221 commit + f039763e19b82fdd2a36fde0b0c4af118211ddf4 blob - d7a45c1ec048a41f46881a14e853247f9b6f81c0 blob + 87f37ddfb4ad05db8b3015fc376edc2eeabae6e4 --- lib/IRCNOW/Acct/DNS.pm +++ lib/IRCNOW/Acct/DNS.pm @@ -1,4 +1,4 @@ -package BotNow::DNS; +package IRCNOW::Acct::DNS; use strict; use warnings; @@ -6,7 +6,6 @@ use OpenBSD::Pledge; use OpenBSD::Unveil; use lib qw(./lib); use IRCNOW::IO qw(readarray writefile appendfile); -use IRCNOW::IO::IRC; use File::Copy qw(copy); my %conf = %main::conf; @@ -24,13 +23,6 @@ my $hostnameif = $conf{hostnameif}; if (host($hostname) =~ /(\d+\.){3,}\d+/) { $ip4 = $&; } -IRCNOW::IO::IRC::cbind("msg", "-", "setrdns", \&msetrdns); -IRCNOW::IO::IRC::cbind("msg", "-", "delrdns", \&mdelrdns); -IRCNOW::IO::IRC::cbind("msg", "-", "setdns", \&msetdns); -IRCNOW::IO::IRC::cbind("msg", "-", "deldns", \&mdeldns); -IRCNOW::IO::IRC::cbind("msg", "-", "host", \&mhost); -IRCNOW::IO::IRC::cbind("msg", "-", "nextdns", \&mnextdns); -IRCNOW::IO::IRC::cbind("msg", "-", "readip6s", \&mreadip6s); sub init { unveil("$zonedir", "rwc") or die "Unable to unveil $!"; @@ -39,91 +31,6 @@ sub init { unveil("$hostnameif", "rwc") or die "Unable to unveil $!"; } -# !setrdns 2001:bd8:: username.example.com -sub msetrdns { - my ($bot, $nick, $host, $hand, $text) = @_; - if (! (IRCNOW::IO::IRC::isstaff($bot, $nick))) { return; } - if ($text =~ /^([0-9A-Fa-f:\.]{3,})\s+([-0-9A-Za-z\.]+)$/) { - my ($ip, $hostname) = ($1, $2); - if (setrdns($ip, $ip6subnet, $hostname)) { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :$hostname set to $ip"); - } else { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :ERROR: failed to set rDNS"); - } - } -} - -# !delrdns 2001:bd8:: -sub mdelrdns { - my ($bot, $nick, $host, $hand, $text) = @_; - if (! (IRCNOW::IO::IRC::isstaff($bot, $nick))) { return; } - if ($text =~ /^([0-9A-Fa-f:\.]{3,})$/) { - my ($ip) = ($1); - if (delrdns($ip, $ip6subnet)) { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :$ip rDNS deleted"); - } else { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :ERROR: failed to set rDNS"); - } - } -} -# !setdns username 1.2.3.4 -sub msetdns { - my ($bot, $nick, $host, $hand, $text) = @_; - if (! (IRCNOW::IO::IRC::isstaff($bot, $nick))) { return; } - if ($text =~ /^([-0-9A-Za-z\.]+)\s+([0-9A-Fa-f:\.]+)/) { - my ($name, $value) = ($1, $2); - if ($value =~ /:/ and setdns($name, $hostname, "AAAA", $value)) { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :$name.$hostname AAAA set to $value"); - } elsif (setdns($name, $hostname, "A", $value)) { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :$name.$hostname A set to $value"); - } else { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :ERROR: failed to set DNS"); - } - } -} - -# !deldns username -sub mdeldns { - my ($bot, $nick, $host, $hand, $text) = @_; - if (! (IRCNOW::IO::IRC::isstaff($bot, $nick))) { return; } - if ($text =~ /^([-0-9A-Za-z\.]+)$/) { - my ($name) = ($1); - if (setdns($name, $hostname)) { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :$text deleted"); - } else { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :ERROR: failed to delete DNS records"); - } - } -} - -# !host username -sub mhost { - my ($bot, $nick, $host, $hand, $text) = @_; - if (! (IRCNOW::IO::IRC::isstaff($bot, $nick))) { return; } - if ($text =~ /^([-0-9A-Za-z:\.]{3,})/) { - my ($hostname) = ($1); - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :".host($hostname)); - } -} - -# !nextdns username -sub mnextdns { - my ($bot, $nick, $host, $hand, $text) = @_; - if (! (IRCNOW::IO::IRC::isstaff($bot, $nick))) { return; } - if ($text =~ /^([-0-9a-zA-Z]+)/) { - IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :$text set to ".nextdns($text)); - } -} - -# !readip6s -sub mreadip6s { - my ($bot, $nick, $host, $hand, $text) = @_; - if (! (IRCNOW::IO::IRC::isstaff($bot, $nick))) { return; } - foreach my $line (readip6s($hostnameif)) { - print "$line\n" - } -} - # Return list of ipv6 addresses from filename sub readip6s { my ($filename) = @_;