1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#contributor : vovich2005
#
#convert user -> ip , get user name from file
#file format
#
#192.168.0.96/255.255.255.255 # User1
#192.168.0.106/255.255.255.255 # User2
#192.168.0.105/255.255.255.255 # User3
#
#if user not found -> return IP
sub StartIp2Name() {
}
sub Ip2Name($$$) {
my $ip=shift;
my $ipfile = "/etc/squid/users.txt";
my $ipaddr = shift;
open (F, "<".$ipfile) || die ("ERROR: Can't open ".$ipfile."!!!\n");
while (<F>) {
if (/$ipaddr/){
chomp;
@FLD = split (' ', $_);
@IP = split ('/', $FLD[0]);
if ($ipaddr eq $IP[0]) {
$res = $FLD[2];
last;
}
} else {
$res = $ipaddr;
}
}
close (F);
return $res;
}
sub StopIp2Name() {
}
#warning !!!
1;
|