1#!/usr/local/bin/perl -w 2# dcc_ip.pl v0.5 - Copyright (c) ak5 2004 3# License: Public Domain :-) 4# 5# this scripts gets the current IP before sending a dcc.. 6# useful, if you connect through a BNC f.e. 7# just load it and it will do it's job if dcc_ip_interface is set correct. 8# 9 10# This means: If you are connecting through a router: 11# /set dcc_ip_interface router 12# (NOT the IP of your router, just the word "router". 13# 14# If you're on dialup or something other and you see your external 15# IP address listed in 'ifconfig's output, 16# /set dcc_ip_interface <interface> 17# (for example ppp0) 18# 19# requires: /sbin/ifconfig ;) If you have a router, you need lynx also. 20# 21########## 22 23use strict; 24use Irssi; 25use vars qw($VERSION %IRSSI); 26 $VERSION = '0.5'; 27 %IRSSI = ( 28 authors => 'ak5', 29 contact => 'meister@hq.kroenk.remove-this-because-of-spam.de', 30 name => 'dcc_ip', 31 description => 'This script sets dcc_own_ip when starting a DCC send or chat.'. 32 'set dcc_ip_interface to your external interface, f.e. ppp0.'. 33 'If you are connecting though a router, set it to "router"', 34 license => 'Public Domain', 35 url => 'http://hq.kroenk.de/?gnu/irssi', 36 source => 'http://hq.kroenk.de/?gnu/irssi/dcc_ip.pl/plaintext', 37 changed => 'Sa 26 Jun 2004 22:27:08 CEST', 38 ); 39 40sub dcc_ip { 41 my ($args, $shash, $c, $iface, $cmd, @arg, @ip) = @_; 42 @arg = split(" ", $args); 43 if (@arg[0] eq "send" || @arg[0] eq "chat") { 44 $iface = Irssi::settings_get_str('dcc_ip_interface'); 45 46 if ($iface eq "router") { 47 $cmd = `lynx -dump -nolist http://ipid.shat.net/iponly/`; 48 $cmd =~ s/[a-zA-Z:\ \n]//g; 49 } else { 50 $cmd = `/sbin/ifconfig $iface | head -n 2 | tail -n 1`; 51 $cmd =~ s/^[a-zA-Z\ ]*\://; 52 $cmd =~ s/\ .*$//; 53 $cmd =~ s/\n//; 54 } 55 Irssi::command("^set dcc_own_ip ".$cmd); 56 57 } 58}; 59 60Irssi::settings_add_str('dcc_ip', 'dcc_ip_interface', "ppp0"); 61Irssi::command_bind ('dcc', 'dcc_ip'); 62#EOF 63