html/oidenty.pl
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 #
34
35 use vars qw ( $VERSION %IRSSI );
36
37 $VERSION = "0.0.2";
38 %IRSSI = (
39 authors => 'darix',
40 contact => 'darix@irssi.org',
41 name => 'oidenty',
42 description => 'oidentd support for irssi',
43 license => 'BSD License',
44 url => 'http://www.irssi.de'
45 );
46 #
47 use strict;
48 use warnings;
49
50 use Irssi qw ( signal_add );
51 use IO::File;
52
53 signal_add 'server looking' => sub {
54 my ( $server ) = @_;
55
56 my $fh = new IO::File "$ENV{'HOME'}/.ispoof", "w";
57 if ( $fh ) {
58 $fh->print ( "$server->{'username'}" );
59 undef $fh;
60 }
61 else {
62 print ( CRAP "cant open $ENV{'HOME'}/.ispoof for writing. $!" );
63 }
64
65 $fh = new IO::File "$ENV{'HOME'}/.oidentd.conf", "w";
66 if ( $fh ) {
67 $fh->print ( "global { reply \"$server->{'username'}\" }" );
68 undef $fh;
69 }
70 else {
71 print ( CRAP "cant open $ENV{'HOME'}/.oidentd.conf for writing. $!" );
72 }
73
74 };
75
76 print (CRAP "loaded $IRSSI{'name'} v$VERSION by $IRSSI{'authors'} <$IRSSI{'contact'}>. use it at \cBYOUR OWN RISK\cB");
77 print (CRAP "$IRSSI{'description'}");