#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;
