From: Jari Matilainen Date: Tue, 31 Oct 2017 14:05:00 +0000 (+0100) Subject: close socket on access from unapproved sources, add /help identd X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=7de388ca37af858b86654ddd49fce6f3536348c8;p=irssi-scripts.irssi.org.git close socket on access from unapproved sources, add /help identd --- diff --git a/scripts/identd.pl b/scripts/identd.pl index d283e57..a1ac236 100644 --- a/scripts/identd.pl +++ b/scripts/identd.pl @@ -1,19 +1,3 @@ -# identd_resolve_mode has three possible modes for identd generation: -# 1. !random -# a random string will be created containing [a-z0-9] -# 2. !username -# $ENV{USER} will be used -# 3. freeform -# any other text will be used as is -# -# The identd will be truncated to identd_length characters before the response is sent -# -# For the script to work, the defined port, identd_port, has to be accessible from the -# internet. Make sure it is portforwarded in the router or firewall, or otherwise -# visible to the irc servers you are connecting to. -# -# Beware that on *nix a non-privileged user can't bind to ports below 1024. - use strict; use warnings; use Irssi; @@ -42,6 +26,36 @@ my $verbose = 0; sub VERBOSE { $verbose }; +sub cmd_help { + my ($args, $server, $witem) = @_; + if($args =~ /^identd\b/i) { + Irssi::print ( <peerhost); # or whatever address my $peer = gethostbyaddr($iaddr, AF_INET) // $sock->peerhost; Irssi::print("Identd - handling connection from $peer") if VERBOSE; -# return unless exists $connectrec->{$peer}; + unless(exists $connectrec->{$peer}) { + Irssi::print("Identd - $peer not found in access list"); + close $sock; + return; + } my $username; my $username_mode = fc(Irssi::settings_get_str('identd_resolve_mode')); @@ -123,6 +141,8 @@ Irssi::settings_add_int('identd', 'identd_port', 8113); Irssi::settings_add_int('identd', 'identd_length', 10); Irssi::settings_add_bool('identd', 'identd_verbose', 0); +Irssi::command_bind_first('help', 'cmd_help'); + Irssi::signal_add_first('server looking', 'sig_server_connecting'); Irssi::signal_add_last('event connected', 'sig_event_connected'); Irssi::signal_add_last('server connect failed', 'sig_event_connected');