summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-09-30 00:02:48 +0000
committerLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-09-30 00:02:48 +0000
commite3e5402155786931fffd78e71bb2a7324a677ff0 (patch)
tree0a98f8edb5244cb92e74a551d48146ebb22136d8
parent52e12905e5b39e5a39999dcebf02e91615e99ef8 (diff)
downloadantispammeta-e3e5402155786931fffd78e71bb2a7324a677ff0.tar.bz2
antispammeta-e3e5402155786931fffd78e71bb2a7324a677ff0.tar.xz
antispammeta-e3e5402155786931fffd78e71bb2a7324a677ff0.tar.zst
Remove invasive logging functionality
This removes the ;nicks and ;explain commands. Actionlogs and alertlogs are untouched for now. Cf. T8 for motivation.
-rw-r--r--lib/ASM/Commander.pm65
-rw-r--r--lib/ASM/DB.pm130
-rw-r--r--lib/ASM/Event.pm8
-rw-r--r--lib/ASM/Log.pm17
4 files changed, 0 insertions, 220 deletions
diff --git a/lib/ASM/Commander.pm b/lib/ASM/Commander.pm
index aa83b83..91fa311 100644
--- a/lib/ASM/Commander.pm
+++ b/lib/ASM/Commander.pm
@@ -144,12 +144,6 @@ my $cmdtbl = {
'^;falsematch\b' => {
'flag' => 's',
'cmd' => \&cmd_falsematch },
- '^;nicks (?<nick>\S+)\s*$' => {
- 'flag' => 's',
- 'cmd' => \&cmd_nicks },
- '^;explain (?<nick1>\S+)\s+(?<nick2>\S+)\s*$' => {
- 'flag' => 's',
- 'cmd' => \&cmd_explain },
'^;version$' => {
'cmd' => \&cmd_version },
};
@@ -360,9 +354,6 @@ sub cmd_sql {
}
my $dbh = $::db->{DBH};
- if ($+{db} eq 'log') {
- $dbh = $::db->{DBH_LOG};
- }
$::db->raw($conn, $event->{to}->[0], $dbh, $+{string});
}
@@ -1048,62 +1039,6 @@ sub cmd_falsematch {
$conn->privmsg($event->replyto, 'To whitelist false matches for the impersonation check, have someone with the "a" flag run ";restrict nick LegitimateNickGoesHere +nonickbl_impersonate". Contact ilbelkyr if this issue reoccurs.');
}
-sub cmd_nicks {
- my ($conn, $event) = @_;
- my $nick = $+{nick};
- if (!defined $::db) {
- $conn->privmsg($event->replyto, "I am set to run without a database, fool.");
- return;
- }
- my $DB = $::db->{DBH_LOG};
- my $doit = sprintf ("select distinct nick from joins as v1
- inner join (
- select distinct host from joins where nick=%s
- and host not like %s
- and host <> %s
- ) as v2
- on v1.host = v2.host
- where v1.nick not like %s
- ",
- $DB->quote($nick),
- $DB->quote('gateway/%/session'),
- $DB->quote('127.0.0.1'),
- $DB->quote('guest%')
- );
- my $result = $DB->selectcol_arrayref( $doit );
- $conn->privmsg($event->replyto, "Results for $nick: " . ASM::Util->commaAndify(sort @$result));
-}
-
-sub cmd_explain { # all hosts associated with two given nicks
- my ($conn, $event) = @_;
- my $nick1 = $+{nick1};
- my $nick2 = $+{nick2};
- my $header = sprintf ("Hosts for %s and %s: ", $nick1, $nick2);
- if (!defined $::db) {
- $conn->privmsg($event->replyto, "I am set to run without a database, fool.");
- return;
- }
- my $DB = $::db->{DBH_LOG};
- my $result = $DB->selectcol_arrayref (
- sprintf ("
- select distinct t1.host from joins as t1
- inner join (
- select host from joins
- where
- nick=%s and
- host not like %s and
- host <> %s) as t2
- on t1.host=t2.host and
- t1.nick=%s",
- $DB->quote($nick1),
- $DB->quote('%/session'),
- $DB->quote('127.0.0.1'),
- $DB->quote($nick2)
- )
- );
- $conn->privmsg($event->replyto, $header . ASM::Util->commaAndify(sort @$result));
-}
-
sub cmd_version {
my ($conn, $event) = @_;
$conn->privmsg($event->replyto, $::version);
diff --git a/lib/ASM/DB.pm b/lib/ASM/DB.pm
index bf56a8a..b8c7b63 100644
--- a/lib/ASM/DB.pm
+++ b/lib/ASM/DB.pm
@@ -12,9 +12,7 @@ sub new {
my ($db, $host, $port, $user, $pass, $table, $actiontable, $dblog) = @_;
my $self = {};
$self->{DBH} = DBI->connect("DBI:mysql:database=$db;host=$host;port=$port", $user, $pass);
- $self->{DBH_LOG} = DBI->connect("DBI:mysql:database=$dblog;host=$host;port=$port", $user, $pass);
$self->{DBH}->{mysql_auto_reconnect} = 1;
- $self->{DBH_LOG}->{mysql_auto_reconnect} = 1;
$self->{TABLE} = $table;
$self->{ACTIONTABLE} = $actiontable;
bless($self);
@@ -172,134 +170,6 @@ sub actionlog
# };
}
-
-#FIXME: This function is shit. Also, it doesn't work like I want it to with mode.
-sub logg
-{
- my $self = shift;
- my ($event) = @_;
- my $dbh = $self->{DBH_LOG};
- my $table = $event->{type};
- my $nick = lc $event->{nick};
- my $victim;
- $table = 'action' if ($table eq 'caction');
- $table = 'privmsg' if ($table eq 'public');
- return if (($table eq 'action') or ($table eq 'privmsg')); #Disabling logging of privmsg stuffs to mysql. no point.
- my $realtable = $table;
- $realtable = 'joins' if $realtable eq 'join'; #mysql doesn't like a table named join
- my $string = 'INSERT INTO `' . $realtable . '` (';
-## begin saner code for this function
- if ($table eq 'quit') {
- $string = 'INSERT INTO `quit` (nick, user, host, geco, ip, account, content1) VALUES (' .
- $dbh->quote($event->{nick}) . ',' . $dbh->quote($event->{user}) . ',' .
- $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{$nick}->{gecos}) . ',';
- my $ip = ASM::Util->getNickIP($nick, $event->{host});
- if (defined($ip)) { $ip = $dbh->quote($ip); } else { $ip = 'NULL'; }
- my $account = $::sn{$nick}->{account};
- if (!defined($account) or ($account eq '0') or ($account eq '*')) {
- $account = 'NULL';
- } else {
- $account = $dbh->quote($account);
- }
- $string = $string . $ip . ',' . $account . ',' . $dbh->quote($event->{args}->[0]) . ');';
- $dbh->do($string);
- ASM::Util->dprint($string, 'mysql');
- return;
- } elsif ($table eq 'part') {
- $string = 'INSERT INTO `part` (channel, nick, user, host, geco, ip, account, content1) VALUES (' .
- $dbh->quote($event->{to}->[0]) . ',' .
- $dbh->quote($event->{nick}) . ',' . $dbh->quote($event->{user}) . ',' .
- $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{$nick}->{gecos}) . ',';
- my $ip = ASM::Util->getNickIP($nick, $event->{host});
- if (defined($ip)) { $ip = $dbh->quote($ip); } else { $ip = 'NULL'; }
- my $account = $::sn{$nick}->{account};
- if (!defined($account) or ($account eq '0') or ($account eq '*')) {
- $account = 'NULL';
- } else {
- $account = $dbh->quote($account);
- }
- $string = $string . $ip . ',' . $account . ',' . $dbh->quote($event->{args}->[0]) . ');';
- $dbh->do($string);
- ASM::Util->dprint($string, 'mysql');
- return;
- } elsif ($table eq 'kick') {
- $victim = lc $event->{to}->[0];
- $string = 'INSERT INTO `kick` (channel, nick, user, host, geco, ip, account, ' .
- 'victim_nick, victim_user, victim_host, victim_geco, victim_ip, victim_account, content1) VALUES (' .
- $dbh->quote($event->{args}->[0]) . ',' .
- $dbh->quote($event->{nick}) . ',' . $dbh->quote($event->{user}) . ',' .
- $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{$nick}->{gecos}) . ',';
- my $ip = ASM::Util->getNickIP($nick);
- if (defined($ip)) { $ip = $dbh->quote($ip); } else { $ip = 'NULL'; }
- my $account = $::sn{$nick}->{account};
- if (($account eq '0') or ($account eq '*')) { $account = 'NULL'; } else { $account = $dbh->quote($account); }
- $string = $string . $ip . ',' . $account;
- $string = $string . ', ' . $dbh->quote($event->{to}->[0]);
- $string = $string . ', ' . $dbh->quote($::sn{$victim}->{user});
- $string = $string . ', ' . $dbh->quote($::sn{$victim}->{host});
- $string = $string . ', ' . $dbh->quote($::sn{$victim}->{gecos});
- my $vic_ip = ASM::Util->getNickIP($victim);
- if (defined($vic_ip)) { $vic_ip = $dbh->quote($vic_ip); } else { $vic_ip = 'NULL'; }
- my $vic_account = $::sn{$victim}->{account};
- if (($vic_account eq '0') or ($vic_account eq '*')) { $vic_account = 'NULL'; } else { $vic_account = $dbh->quote($vic_account); }
- $string = $string . ', ' . $vic_ip . ',' . $vic_account . ',' . $dbh->quote($event->{args}->[1]) . ');';
- $dbh->do($string);
- ASM::Util->dprint($string, 'mysql');
- return;
- }
-## end saner code for this function
- if (($table ne 'nick') && ($table ne 'quit')) {
- $string = $string . 'channel, ';
- }
- $string = $string . 'nick, user, host, geco';
- if (($table ne 'join') && ($table ne 'kick')) {
- $string = $string . ', content1';
- }
- if ($table eq 'mode') {
- $string = $string . ', content2';
- }
- if ($table eq 'kick') {
- $string = $string . ', victim_nick, victim_user, victim_host, victim_geco, content1';
- }
- if ($table eq 'join') {
- $string .= ', account';
- }
- $string = $string . ') VALUES (';
- if (($table ne 'nick') && ($table ne 'quit') && ($table ne 'kick')) {
- $string = $string . $dbh->quote($event->{to}->[0]) . ", ";
- }
- if ($table eq 'kick') {
- $string = $string . $dbh->quote($event->{args}->[0]) . ", ";
- }
- my $geco = $::sn{$nick}->{gecos};
- $string = $string . $dbh->quote($event->{nick}) . ", " . $dbh->quote($event->{user}) . ", " .
- $dbh->quote($event->{host}) . ", " . $dbh->quote($geco);
- if (($table ne 'join') && ($table ne 'kick')) {
- $string = $string. ', ' . $dbh->quote($event->{args}->[0]);
- }
- if ($table eq 'kick') {
- $string = $string . ', ' . $dbh->quote($event->{to}->[0]);
- $string = $string . ', ' . $dbh->quote($::sn{$victim}->{user});
- $string = $string . ', ' . $dbh->quote($::sn{$victim}->{host});
- $string = $string . ', ' . $dbh->quote($::sn{$victim}->{gecos});
- $string = $string . ', ' . $dbh->quote($event->{args}->[1]);
- }
- if ($table eq 'mode') {
- $string = $string . ', ' . $dbh->quote($event->{args}->[1]);
- }
- if ($table eq 'join') {
- my $account = $::sn{$nick}->{account};
- if (!defined($account) or ($account eq '0') or ($account eq '*')) {
- $account = 'NULL';
- } else {
- $account = $dbh->quote($account);
- }
- $string .= ', ' . $account;
- }
- $string = $string . ');';
- ASM::Util->dprint($string, 'mysql');
- $dbh->do($string);
-}
sub query
{
diff --git a/lib/ASM/Event.pm b/lib/ASM/Event.pm
index b8b4d6c..fac5c06 100644
--- a/lib/ASM/Event.pm
+++ b/lib/ASM/Event.pm
@@ -214,7 +214,6 @@ sub on_join {
$::sn{$nick}->{host} = $event->{host};
$::sn{$nick}->{account} = lc $event->{args}->[0];
push @{$::sa{$::sn{$nick}->{account}}}, $nick;
- $::db->logg($event) if defined $::db;
}
sub on_part
@@ -222,7 +221,6 @@ sub on_part
my ($conn, $event) = @_;
my $nick = lc $event->{nick};
my $chan = lc $event->{to}->[0];
- $::db->logg( $event ) if defined $::db;
# Ignore channels that are +s and not monitored
if (defined $::db and $event->{args}->[0] =~ /^requested by/ and (not ((grep { /^s$/ } @{$::sc{$chan}{modes}} ) && ($::channels->{channel}->{$chan}->{monitor} eq "no"))) ) {
my $idx = $::db->actionlog( $event);
@@ -265,7 +263,6 @@ sub on_public
my ($conn, $event) = @_;
my $chan = lc $event->{to}[0];
$chan =~ s/^[+@]//;
- $::db->logg( $event ) if defined $::db;
$::sc{$chan}{users}{lc $event->{nick}}{msgtime} = time;
}
@@ -273,7 +270,6 @@ sub on_notice
{
my ($conn, $event) = @_;
return if ( $event->{to}->[0] eq '$*' ); # if this is a global notice FUCK THAT SHIT
- $::db->logg( $event ) if defined $::db;
}
sub on_errnickinuse
@@ -307,7 +303,6 @@ sub on_quit
# Ignore channels that are +s and not monitored
my @actionlog_channels = grep { not ((grep { /^s$/ } @{$::sc{$_}{modes}}) && ($::channels->{channel}->{$_}->{monitor} eq "no")) } @channels;
$::log->sqlIncident( join(',', @actionlog_channels), $idx ) if $idx;
- $::db->logg( $event );
}
if (
($event->{args}->[0] eq "*.net *.split") && #special, netsplit situation
@@ -384,7 +379,6 @@ sub irc_topic {
$::sc{$chan}{topic}{time} = time;
$::sc{$chan}{topic}{by} = $event->{from};
}
- $::db->logg( $event ) if defined $::db;
}
}
@@ -414,7 +408,6 @@ sub on_nick {
}
$::sn{$newnick} = $::sn{$oldnick} if ($oldnick ne $newnick);
- $::db->logg( $event ) if defined $::db;
@{$::sa{$::sn{$oldnick}{account}}} = grep { $_ ne $oldnick } @{$::sa{$::sn{$oldnick}{account}}};
push @{$::sa{$::sn{$newnick}{account}}}, $newnick;
delete( $::sn{$oldnick}) if ($oldnick ne $newnick);
@@ -430,7 +423,6 @@ sub on_kick {
}
my $chan = lc $event->{args}->[0];
if (defined $::db) {
- $::db->logg( $event );
# Ignore channels that are +s and not monitored
if ( not ((grep { /^s$/ } @{$::sc{$chan}{modes}}) && ($::channels->{channel}->{$chan}->{monitor} eq "no")) ) {
my $idx = $::db->actionlog($event);
diff --git a/lib/ASM/Log.pm b/lib/ASM/Log.pm
index adeb4f2..46bda4c 100644
--- a/lib/ASM/Log.pm
+++ b/lib/ASM/Log.pm
@@ -108,23 +108,6 @@ sub logg
}
push @backlog, $line;
$self->{backlog}->{$chan} = \@backlog;
- if (open(FH, $path)) { # or die "Can't open $path: $!";
- print FH $line;
- ASM::Util->dprint($line, 'logger');
- close(FH);
- } else {
- print "COULDN'T PRINT TO $path - $line";
- }
- my $spy;
- my $nick = lc $event->{nick};
- if (defined($::spy{$chan})) {
- $spy = $::spy{$chan};
- } elsif (defined($::spy{$nick})) {
- $spy = $::spy{$nick};
- }
- if (defined($spy)) {
- say $spy "$chan: $nostamp";
- }
}
}