summaryrefslogtreecommitdiffstats
path: root/scripts/cap_sasl.pl
diff options
context:
space:
mode:
authorMantas Mikulėnas2015-12-04 19:11:05 +0200
committerMantas Mikulėnas2015-12-04 19:11:05 +0200
commit58ca3f7cf3cc10d8d5716904e9350ff67a584816 (patch)
tree838e68b85ba6e12d4c66e605daa147207a9745fd /scripts/cap_sasl.pl
parent8ed021da54e70c912899c1a16926654b8ff1f7a4 (diff)
downloadscripts.irssi.org-58ca3f7cf3cc10d8d5716904e9350ff67a584816.tar.bz2
cap_sasl 1.11
Diffstat (limited to 'scripts/cap_sasl.pl')
-rw-r--r--scripts/cap_sasl.pl40
1 files changed, 23 insertions, 17 deletions
diff --git a/scripts/cap_sasl.pl b/scripts/cap_sasl.pl
index 7c1fba2..7a0b742 100644
--- a/scripts/cap_sasl.pl
+++ b/scripts/cap_sasl.pl
@@ -4,14 +4,14 @@ use MIME::Base64;
use vars qw($VERSION %IRSSI);
use constant CHALLENGE_SIZE => 32;
-$VERSION = "1.10";
+$VERSION = "1.11";
%IRSSI = (
- authors => 'Michael Tharp (gxti), Jilles Tjoelker (jilles), Mantas Mikulėnas (grawity)',
- contact => 'grawity@gmail.com',
- name => 'cap_sasl.pl',
- description => 'Implements SASL authentication and enables CAP "multi-prefix"',
- license => 'GPLv2',
- url => 'http://ircv3.atheme.org/extensions/sasl-3.1',
+ authors => 'Michael Tharp (gxti), Jilles Tjoelker (jilles), Mantas Mikulėnas (grawity)',
+ contact => 'grawity@gmail.com',
+ name => 'cap_sasl.pl',
+ description => 'Implements SASL authentication and enables CAP "multi-prefix"',
+ license => 'GPLv2',
+ url => 'http://ircv3.atheme.org/extensions/sasl-3.1',
);
my %sasl_auth = ();
@@ -314,7 +314,7 @@ if (eval {require Crypt::PK::ECC}) {
}
};
- sub cmd_sasl_keygen {
+ Irssi::command_bind("sasl keygen" => sub {
my ($data, $server, $witem) = @_;
my $print = $server
@@ -362,8 +362,7 @@ if (eval {require Crypt::PK::ECC}) {
}
my $cmdchar = substr(Irssi::settings_get_str("cmdchars"), 0, 1);
- my $cmd = "msg NickServ SET PROPERTY pubkey $pub";
- # TODO: change to 'SET PUBKEY' when freenode gets support for that
+ my $cmd = "msg NickServ SET PUBKEY $pub";
if ($server) {
$print->("SASL: updating your Irssi settings...");
@@ -379,9 +378,9 @@ if (eval {require Crypt::PK::ECC}) {
$print->("SASL: submit your pubkey to $net:");
$print->("%P".$cmdchar.$cmd);
}
- }
+ });
- sub cmd_sasl_pubkey {
+ Irssi::command_bind("sasl pubkey" => sub {
my ($data, $server, $witem) = @_;
my $arg = $server ? $server->{tag} : $data;
@@ -420,11 +419,18 @@ if (eval {require Crypt::PK::ECC}) {
my $pub = encode_base64($pk->export_key_raw("public_compressed"), "");
Irssi::print("SASL: loaded keyfile '$f'");
Irssi::print("SASL: your pubkey is $pub");
- }
-
- Irssi::command_bind('sasl keygen', \&cmd_sasl_keygen);
- Irssi::command_bind('sasl pubkey', \&cmd_sasl_pubkey);
-};
+ });
+} else {
+ Irssi::command_bind("sasl keygen" => sub {
+ Irssi::print("SASL: cannot '/sasl keygen' as the Perl 'CryptX' module is missing",
+ MSGLEVEL_CLIENTERROR);
+ });
+
+ Irssi::command_bind("sasl pubkey" => sub {
+ Irssi::print("SASL: cannot '/sasl pubkey' as the Perl 'CryptX' module is missing",
+ MSGLEVEL_CLIENTERROR);
+ });
+}
cmd_sasl_load();