This page last changed on июл 06, 2009 by esl.
Index Docs -> ip2name FAQ Thanks Version User Stuff Skins Contact Forum Download

IP2NAME

in some cases you have squid without authorization
but you have so many user for remeber who use ip ...

why I write this

once i have folowing configuration

about 80 pc, WINDOWS NT domain, squid without authorization (for some reason)
different user my use different pc in one day ...
and special utility on each pc, it sore login name and time in mysql database.

i wrote special IP2NAME who ask mysql (use time and ip) and recive username

plese reffer ip2name folder, for example ip2name

name description
ip return IP
demo return AUTHNAME, else DNSNAME, else IP
dns return DNSNAME
list use list for conver IP into NAME
simple return AUTHNAME else IP
smb return SMB name of pc
squidauth return AUTHNAME else IP, allow cyrilyc name
squidlist use different type of list

each ip2name contain 3 function

StartIp2Name call at lightparser startup, useful for initialization. init sql connection, etc
StopIp2Name call at lightparser shutdown, close sql connetction, etc.
Ip2Name lightparser call it for EACH line, for converting ip2name ....

sample script

#ESL
#convert user -> ip , get user name from file
#file format
#
#192.168.0.96 User1
#192.168.0.106 User2
#192.168.0.105 User3
#
#if user not found -> return IP 

sub StartIp2Name() {
    my $ipfile = "/etc/squid/users.txt";

    open (F, "<$ipfile") || die ("ERROR: Can't open $ipfile!!! \n");
    while (<F>) {
      chomp;
      ($ip,$user) = split;
      $hIP2NAME{$ip}=$user;
    }  
    close (F);
}

sub Ip2Name($$$) {
# $Lhost,$user,$Ltimestamp
    my $ip=shift;
    my $ret;
    
    if (defined $hIP2NAME{$ip}) {
      $ret=$hIP2NAME{$ip};
    } else {
      $ret=$ip;
    }
    
    return $ret;
}

sub StopIp2Name() {
}

#warning !!!
1;
Document generated by Confluence on июл 07, 2009 00:15
SourceForge.net Logo