commit - 2a82acd0d20f1fc7f958327aa94108dca12dab55
commit + 7ce84f65840e798d163b2760cd72d71fda4c082e
blob - 55a19e68ec7f0ca1a317cae696d50dc342aa5336
blob + 849c46713219b11040ac3e891ee4c4ce3cbcf7ce
--- lib/BotNow/BNC.pm
+++ lib/BotNow/BNC.pm
my $username = $1;
if (BotNow::SQLite::selectrows("bnc", "username", $username)) {
my $email = BotNow::SQLite::get("bnc", "username", $username, "email");
- my $password = Hash::newpass();
+ my $password = BotNow::Hash::newpass();
main::putserv($bot,"privmsg *controlpanel :set Password $username $password");
main::putserv($bot, "PRIVMSG *blockuser :unblock $username");
mailbncApproved($username,$email,$password);
main::putserv($bot, "PRIVMSG $nick :Wrong captcha. To get a new captcha, type !bnc <username> <email>");
return;
}
- my $pass = Hash::newpass();
+ my $pass = BotNow::Hash::newpass();
chomp(my $encrypted = `encrypt $pass`);
my $username = BotNow::SQLite::get("bnc", "ircid", $ircid, "username");
my $email = BotNow::SQLite::get("bnc", "ircid", $ircid, "email");
my $hashirc = BotNow::SQLite::get("irc", "id", $ircid, "hashid");
my $bindhost = "$username.$hostname";
BotNow::SQLite::set("bnc", "ircid", $ircid, "password", $encrypted);
- if (DNS::nextdns($username)) {
+ if (BotNow::DNS::nextdns($username)) {
sleep(2);
createbnc($bot, $username, $pass, $bindhost);
if ($approval eq "true") {
sub createclone {
my ($bot) = @_;
my $socket = $bot->{sock};
- my $password = Hash::newpass();
+ my $password = BotNow::Hash::newpass();
my $msg = <<"EOF";
adduser cloneuser $password
set Nick cloneuser cloneuser
$conf{localnet}
IRCNow Federation
EOF
- main::mail($mailfrom, $email, $mailname, "Your $conf{localnet} Bouncer", $body);
+ IRCNOW::IO::mail($mailfrom, $email, $mailname, "Your $conf{localnet} Bouncer", $body);
}
sub mailbncPending {
$conf{localnet}
IRCNow Federation
EOF
- main::mail($mailfrom, $email, $mailname, "Confirm $conf{localnet} Bouncer", $body);
+ IRCNOW::IO::mail($mailfrom, $email, $mailname, "Confirm $conf{localnet} Bouncer", $body);
}
sub mtaillog {
blob - 48e016f8a436f386d522aaa725c3ff7e62dca254
blob + 2cee5193d1821c0d1d63f8ca6a14f35c5766baea
--- lib/BotNow/Mail.pm
+++ lib/BotNow/Mail.pm
use OpenBSD::Unveil;
use lib qw(./lib);
use IRCNOW::IO qw(readarray writefile);
-
+use BotNow::Hash;
use File::Copy qw(copy);
use MIME::Base64;
use Digest::SHA qw(sha256_hex);
return;
} elsif (main::isstaff($bot, $nick) && $text =~ /^delete\s+([[:ascii:]]+)/) {
my $username = $1;
- if (SQLite::deleterows("mail", "username", $username)) {
+ if (BotNow::SQLite::deleterows("mail", "username", $username)) {
deletemail($username);
foreach my $chan (@teamchans) {
main::putserv($bot, "PRIVMSG $chan :$username email deleted");
return;
}
### Check duplicate hostmasks ###
- my @rows = SQLite::selectrows("irc", "hostmask", $hostmask);
+ my @rows = BotNow::SQLite::selectrows("irc", "hostmask", $hostmask);
foreach my $row (@rows) {
- my $password = SQLite::get("mail", "ircid", $row->{id}, "password");
+ my $password = BotNow::SQLite::get("mail", "ircid", $row->{id}, "password");
if (defined($password)) {
main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
return;
if ($text =~ /^captcha\s+([[:alnum:]]+)/) {
my $text = $1;
# TODO avoid using host mask because cloaking can cause problems
- my $ircid = SQLite::id("irc", "nick", $nick, $expires);
- my $captcha = SQLite::get("mail", "ircid", $ircid, "captcha");
+ my $ircid = BotNow::SQLite::id("irc", "nick", $nick, $expires);
+ my $captcha = BotNow::SQLite::get("mail", "ircid", $ircid, "captcha");
if ($text ne $captcha) {
main::putserv($bot, "PRIVMSG $nick :Wrong captcha. To get a new captcha, type !mail <username> <email>");
return;
}
- my $pass = Hash::newpass();
+ my $pass = BotNot::Hash::newpass();
chomp(my $encrypted = `encrypt $pass`);
- my $username = SQLite::get("mail", "ircid", $ircid, "username");
- my $email = SQLite::get("mail", "ircid", $ircid, "email");
- my $hashirc = SQLite::get("irc", "id", $ircid, "hashid");
- SQLite::set("mail", "ircid", $ircid, "password", $encrypted);
+ my $username = BotNow::SQLite::get("mail", "ircid", $ircid, "username");
+ my $email = BotNow::SQLite::get("mail", "ircid", $ircid, "email");
+ my $hashirc = BotNow::SQLite::get("irc", "id", $ircid, "hashid");
+ BotNow::SQLite::set("mail", "ircid", $ircid, "password", $encrypted);
sleep(2);
createmail($pass, $username);
main::putserv($bot, "PRIVMSG $nick :Check your email!");
return;
} elsif ($text =~ /^([[:alnum:]]+)\s+([[:ascii:]]+)/) {
my ($username, $email) = ($1, $2);
- my @userrows = SQLite::selectrows("mail", "username", $username);
+ my @userrows = BotNow::SQLite::selectrows("mail", "username", $username);
foreach my $row (@userrows) {
- my $password = SQLite::get("mail", "ircid", $row->{id}, "password");
+ my $password = BotNow::SQLite::get("mail", "ircid", $row->{id}, "password");
if (defined($password)) {
main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
return;
}
}
- my @emailrows = SQLite::selectrows("mail", "email", $email);
+ my @emailrows = BotNow::SQLite::selectrows("mail", "email", $email);
foreach my $row (@userrows) {
- my $password = SQLite::get("mail", "ircid", $row->{id}, "password");
+ my $password = BotNow::SQLite::get("mail", "ircid", $row->{id}, "password");
if (defined($password)) {
main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
return;
my $captcha = int(rand(999));
my $ircid = int(rand(9223372036854775807));
my $hashid = sha256_hex("$ircid");
- SQLite::set("irc", "id", $ircid, "localtime", time());
- SQLite::set("irc", "id", $ircid, "hashid", sha256_hex($ircid));
- SQLite::set("irc", "id", $ircid, "date", main::date());
- SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
- SQLite::set("irc", "id", $ircid, "nick", $nick);
- SQLite::set("mail", "ircid", $ircid, "username", $username);
- SQLite::set("mail", "ircid", $ircid, "email", $email);
- SQLite::set("mail", "ircid", $ircid, "captcha", $captcha);
- SQLite::set("mail", "ircid", $ircid, "hashid", $hashid);
+ BotNow::SQLite::set("irc", "id", $ircid, "localtime", time());
+ BotNow::SQLite::set("irc", "id", $ircid, "hashid", sha256_hex($ircid));
+ BotNow::SQLite::set("irc", "id", $ircid, "date", IRCNOW::IO::data());
+ BotNow::SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
+ BotNow::SQLite::set("irc", "id", $ircid, "nick", $nick);
+ BotNow::SQLite::set("mail", "ircid", $ircid, "username", $username);
+ BotNow::SQLite::set("mail", "ircid", $ircid, "email", $email);
+ BotNow::SQLite::set("mail", "ircid", $ircid, "captcha", $captcha);
+ BotNow::SQLite::set("mail", "ircid", $ircid, "hashid", $hashid);
main::whois($bot->{sock}, $nick);
main::ctcp($bot->{sock}, $nick);
main::putserv($bot, "PRIVMSG $nick :".`figlet $captcha`);
IRCNow
EOF
- main::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
+ IRCNOW::IO::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
}
blob - 9b9558224d98a5b8ea25c5a25027ac4a584b1e09
blob + d0635f8de487aacb83c0d4a8d28ca9b93691aadf
--- lib/BotNow/SQLite.pm
+++ lib/BotNow/SQLite.pm
use OpenBSD::Pledge;
use OpenBSD::Unveil;
use lib qw(./lib);
-use IRCNOW::IO qw(readstr);
+use IRCNOW::IO qw(readstr :DEBUG);
use Data::Dumper;
use DBI;
$dbh->do($s);
}
}
- main::debug(ALL, "connected to $dbpath");
+ debug(ALL, "connected to $dbpath");
return defined($dbh);
}
if (!defined($dbh)) { connectdb(); }
my $rows = $dbh->do("INSERT INTO $table ($keys) values ($vals)");
if ($rows) {
- main::debug(ALL, "INSERT INTO $table ($keys) values ($vals)");
+ debug(ALL, "INSERT INTO $table ($keys) values ($vals)");
} else {
- main::debug(ERRORS, "ERRORS: Failed INSERT INTO $table ($keys) values ($vals)");
+ debug(ERRORS, "ERRORS: Failed INSERT INTO $table ($keys) values ($vals)");
}
return $rows;
}
if (!defined($dbh)) { connectdb(); }
my $rows = $dbh->do("UPDATE $table SET $key = ? where $idkey = ?", undef, $val, $idval);
if ($rows) {
- main::debug(ALL, "UPDATE $table SET $key = $val where $idkey = $idval");
+ debug(ALL, "UPDATE $table SET $key = $val where $idkey = $idval");
} else {
- main::debug(ERRORS, "ERRORS: Failed UPDATE $table SET $key = $val where $idkey = $idval");
+ debug(ERRORS, "ERRORS: Failed UPDATE $table SET $key = $val where $idkey = $idval");
}
return $rows;
}
if (!defined($dbh)) { connectdb(); }
my $rows = $dbh->do("DELETE FROM $table WHERE $key = ?", undef, $val);
if ($rows) {
- main::debug(ALL, "DELETE FROM $table WHERE $key = $val");
+ debug(ALL, "DELETE FROM $table WHERE $key = $val");
} else {
- main::debug(ERRORS, "ERRORS: Failed DELETE FROM $table WHERE $key = $val");
+ debug(ERRORS, "ERRORS: Failed DELETE FROM $table WHERE $key = $val");
}
return $rows;
}
if (my $row = $sth->fetchrow_hashref) {
my $val = $row->{$key};
if (!defined($val)) { $val = "undefined"; }
- main::debug(ALL, "get: $table $key => $val where $idkey = $idval");
+ debug(ALL, "get: $table $key => $val where $idkey = $idval");
return $row->{$key};
} else {
- main::debug(ERRORS, "ERRORS: $table $key undefined where $idkey = $idval");
+ debug(ERRORS, "ERRORS: $table $key undefined where $idkey = $idval");
return;
}
}
sub set {
my ($table, $idkey, $idval, $key, $val) = @_;
if (defined(get($table, $idkey, $idval, $idkey))) {
- main::debug(ALL, "set: update");
+ debug(ALL, "set: update");
return updaterow($table, $idkey, $idval, $key, $val) > 0;
} else {
- main::debug(ALL, "set: insert");
+ debug(ALL, "set: insert");
return insertrow($table, "$idkey,$key", "\"$idval\",\"$val\"") > 0;
}
}
}
}
if (abs(time() - $maxrow->{localtime}) <= $expires) {
- main::debug(ALL, "id: $maxrow->{id} where $key = $val at $expires");
+ debug(ALL, "id: $maxrow->{id} where $key = $val at $expires");
return $maxrow->{id};
} else {
- main::debug(ERRORS, "no id found");
+ debug(ERRORS, "no id found");
return;
}
}
blob - 5e7a3a9e2720a5370a8fd078f15ff727d6f8c4bc
blob + fc9c7f68334fbf37df0bdade7e009c8cb8be410a
--- lib/BotNow/Shell.pm
+++ lib/BotNow/Shell.pm
use Digest::SHA qw(sha256_hex);
use lib './lib';
-use IRCNOW::IO qw(:FILEIO);
-require "BotNow::SQLite";
-require "BotNow::Hash";
+use IRCNOW::IO qw(:FILEIO :DEBUG);
+use BotNow::SQLite;
+use BotNow::Hash;
use Data::Dumper;
return;
} elsif (main::isstaff($bot, $nick) && $text =~ /^delete\s+([[:ascii:]]+)/) {
my $username = $1;
- if (SQLite::deleterows("shell", "username", $username)) {
+ if (BotNow::SQLite::deleterows("shell", "username", $username)) {
# TODO delete shell
deleteshell($username);
foreach my $chan (@teamchans) {
return;
}
### TODO: Check duplicate emails ###
- my @rows = SQLite::selectrows("irc", "nick", $nick);
+ my @rows = BotNow::SQLite::selectrows("irc", "nick", $nick);
foreach my $row (@rows) {
- my $password = SQLite::get("shell", "ircid", $row->{id}, "password");
+ my $password = BotNow::SQLite::get("shell", "ircid", $row->{id}, "password");
if (defined($password)) {
main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
return;
}
if ($text =~ /^captcha\s+([[:alnum:]]+)/) {
my $text = $1;
- my $ircid = SQLite::id("irc", "nick", $nick, $expires);
+ my $ircid = BotNow::SQLite::id("irc", "nick", $nick, $expires);
if (!defined($ircid)) { die "undefined ircid"; }
- my $captcha = SQLite::get("shell", "ircid", $ircid, "captcha");
+ my $captcha = BotNow::SQLite::get("shell", "ircid", $ircid, "captcha");
if ($text ne $captcha) {
main::putserv($bot, "PRIVMSG $nick :Wrong captcha. To get a new captcha, type !shell <username> <email>");
return;
}
- my $pass = Hash::newpass();
+ my $pass = BotNow::Hash::newpass();
chomp(my $encrypted = `encrypt $pass`);
- my $username = SQLite::get("shell", "ircid", $ircid, "username");
- my $email = SQLite::get("shell", "ircid", $ircid, "email");
- my $version = SQLite::get("shell", "ircid", $ircid, "version");
+ my $username = BotNow::SQLite::get("shell", "ircid", $ircid, "username");
+ my $email = BotNow::SQLite::get("shell", "ircid", $ircid, "email");
+ my $version = BotNow::SQLite::get("shell", "ircid", $ircid, "version");
my $bindhost = "$username.$hostname";
- SQLite::set("shell", "ircid", $ircid, "password", $encrypted);
+ BotNow::SQLite::set("shell", "ircid", $ircid, "password", $encrypted);
if (DNS::nextdns($username)) {
sleep(2);
createshell($username, $pass, $bindhost);
# my $captcha = join'', map +(0..9,'a'..'z','A'..'Z')[rand(10+26*2)], 1..4;
my $captcha = int(rand(999));
my $ircid = int(rand(2147483647));
- SQLite::set("irc", "id", $ircid, "localtime", time());
- SQLite::set("irc", "id", $ircid, "date", main::date());
- SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
- SQLite::set("irc", "id", $ircid, "nick", $nick);
- SQLite::set("shell", "ircid", $ircid, "username", $username);
- SQLite::set("shell", "ircid", $ircid, "email", $email);
- SQLite::set("shell", "ircid", $ircid, "captcha", $captcha);
+ BotNow::SQLite::set("irc", "id", $ircid, "localtime", time());
+ BotNow::SQLite::set("irc", "id", $ircid, "date", BotNow::IO::date());
+ BotNow::SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
+ BotNow::SQLite::set("irc", "id", $ircid, "nick", $nick);
+ BotNow::SQLite::set("shell", "ircid", $ircid, "username", $username);
+ BotNow::SQLite::set("shell", "ircid", $ircid, "email", $email);
+ BotNow::SQLite::set("shell", "ircid", $ircid, "captcha", $captcha);
main::whois($bot->{sock}, $nick);
main::ctcp($bot->{sock}, $nick);
main::putserv($bot, "PRIVMSG $nick :".`figlet $captcha`);
IRCNow
EOF
- main::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
+ BotNow::IO::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
}
$newconf = "$`$&\n\t$block$'";
} else {
$newconf = $relaydconf;
- main::debug(ERRORS, "ERROR: regex can't match tls { keypair \$username.$hostname }");
+ debug(ERRORS, "ERROR: regex can't match tls { keypair \$username.$hostname }");
}
writefile($relaydconfpath, $newconf);
}
blob - 55a663ffe2734c35459040f3f564428abb69af3a
blob + a4458d218b90f0eb6900a88a8106198c9b7cc12e
--- lib/BotNow/VPN.pm
+++ lib/BotNow/VPN.pm
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
-require "DNS.pm";
-require "SQLite.pm";
+use lib qw(./lib);
+use IRCNOW::IO qw(:DEBUG readarray);
+use BotNow::DNS;
+use BotNow::SQLite;
my %conf = %main::conf;
my $chans = $conf{chans};
}
return;
}
- my @rows = SQLite::selectrows("irc", "nick", $nick);
+ my @rows = BotNow::SQLite::selectrows("irc", "nick", $nick);
foreach my $row (@rows) {
- my $password = SQLite::get("vpn", "ircid", $row->{id}, "password");
+ my $password = BotNow::SQLite::get("vpn", "ircid", $row->{id}, "password");
if (defined($password)) {
main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
return;
}
if ($text =~ /^captcha\s+([[:alnum:]]+)/) {
my $text = $1;
- my $ircid = SQLite::id("irc", "nick", $nick, $expires);
+ my $ircid = BotNow::SQLite::id("irc", "nick", $nick, $expires);
if (!defined($ircid)) { die "undefined ircid"; }
- my $captcha = SQLite::get("vpn", "ircid", $ircid, "captcha");
+ my $captcha = BotNow::SQLite::get("vpn", "ircid", $ircid, "captcha");
if ($text ne $captcha) {
main::putserv($bot, "PRIVMSG $nick :Wrong captcha. To get a new captcha, type !vpn <username> <email>");
return;
}
my $pass = Hash::newpass();
chomp(my $encrypted = `encrypt $pass`);
- my $username = SQLite::get("vpn", "ircid", $ircid, "username");
- my $email = SQLite::get("vpn", "ircid", $ircid, "email");
- my $version = SQLite::get("vpn", "ircid", $ircid, "version");
- SQLite::set("vpn", "ircid", $ircid, "password", $encrypted);
+ my $username = BotNow::SQLite::get("vpn", "ircid", $ircid, "username");
+ my $email = BotNow::SQLite::get("vpn", "ircid", $ircid, "email");
+ my $version = BotNow::SQLite::get("vpn", "ircid", $ircid, "version");
+ BotNow::SQLite::set("vpn", "ircid", $ircid, "password", $encrypted);
createvpn($username, $pass);
foreach my $chan (@teamchans) {
my $captcha = int(rand(999));
my $ircid = int(rand(2147483647));
- SQLite::set("irc", "id", $ircid, "localtime", time());
- SQLite::set("irc", "id", $ircid, "date", main::date());
- SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
- SQLite::set("irc", "id", $ircid, "nick", $nick);
- SQLite::set("vpn", "ircid", $ircid, "username", $username);
- SQLite::set("vpn", "ircid", $ircid, "email", $email);
- SQLite::set("vpn", "ircid", $ircid, "captcha", $captcha);
+ BotNow::SQLite::set("irc", "id", $ircid, "localtime", time());
+ BotNow::SQLite::set("irc", "id", $ircid, "date", BotNow::IO::date());
+ BotNow::SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
+ BotNow::SQLite::set("irc", "id", $ircid, "nick", $nick);
+ BotNow::SQLite::set("vpn", "ircid", $ircid, "username", $username);
+ BotNow::SQLite::set("vpn", "ircid", $ircid, "email", $email);
+ BotNow::SQLite::set("vpn", "ircid", $ircid, "captcha", $captcha);
main::whois($bot->{sock}, $nick);
main::ctcp($bot->{sock}, $nick);
main::putserv($bot, "PRIVMSG $nick :".`figlet $captcha`);
}
sub col {
my ($filename) = @_;
- my @rows = main::readarray($filename);
+ my @rows = readarray($filename);
my @results;
foreach my $row (@rows) {
if ($row =~ /^user (.*?) /) {