1#
2# psybnc like oidentd support for irssi
3#
4# requirements:
5# - oidentd (running)
6# - your user needs "spoof" permissions in the /etc/oidentd.conf
7#   looks like:
8#   "user youruser {
9#        default {
10#            allow spoof;
11#        }
12#   }"
13#
14#  if you want to spoof local user you need:
15#  "allow spoof_all;"
16#
17# - this script works like psybnc oidentd support.
18#   that means it writes ~/.ispoof and ~/.oidentd.conf
19#   these files have to be writeable.
20#
21# usage:
22# - just run the script.
23#
24# configuration:
25# - the script uses the active "username" field for the connect.
26#   you can alter it global via "/set user_name"
27#   or per ircnet with "/ircnet add -user ident somenet"
28#
29# how it works:
30# on connect it writes ~/.ispoof and ~/.oidentd.conf
31# you CAN have RACE CONDITIONS HERE.
32# so delay your connects a bit.
33#
34use strict;
35use warnings;
36use Irssi qw ( signal_add  );
37use IO::File;
38
39use vars qw ( $VERSION %IRSSI );
40
41$VERSION = "0.0.3";
42%IRSSI = (
43    authors     => 'darix',
44    contact     => 'darix@irssi.org',
45    name        => 'oidenty',
46    description => 'oidentd support for irssi',
47    license     => 'BSD License',
48    url         => 'http://www.irssi.de'
49);
50
51signal_add 'server looking' => sub {
52    my ( $server ) = @_;
53
54    my $fh = new IO::File "$ENV{'HOME'}/.ispoof", "w";
55    if ( $fh ) {
56        $fh->print ( "$server->{'username'}" );
57        undef $fh;
58    }
59    else {
60        print ( CRAP "cant open $ENV{'HOME'}/.ispoof for writing. $!" );
61    }
62
63    $fh = new IO::File "$ENV{'HOME'}/.oidentd.conf", "w";
64    if ( $fh ) {
65        $fh->print ( "global { reply \"$server->{'username'}\" }" );
66        undef $fh;
67    }
68    else {
69        print ( CRAP "cant open $ENV{'HOME'}/.oidentd.conf for writing. $!" );
70    }
71
72};
73
74print (CRAP "loaded $IRSSI{'name'} v$VERSION by $IRSSI{'authors'} <$IRSSI{'contact'}>. use it at \cBYOUR OWN RISK\cB");
75print (CRAP "$IRSSI{'description'}");
76