File: ip2name.dns

package info (click to toggle)
lightsquid 1.8-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 532 kB
  • sloc: perl: 2,320; sh: 13; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 479 bytes parent folder | download | duplicates (4)
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
#contributor: esl
#resolve hostname, cache it for speedup
# -- vim: filetype=perl

use Socket;

sub StartIp2Name() {
}

sub Ip2Name($$$) {
# $Lhost,$user,$Ltimestamp
  my $ip=shift;
  if (!defined $hIP{$ip}) {

    my $iaddr = inet_aton($ip);
    my $user = scalar gethostbyaddr($iaddr, AF_INET);
    
    # if gethostbyaddr failed to get host, use ip
    $user=$ip unless (defined $user);

    $hIP{$ip}=$user;
  }
  return $hIP{$ip};
}

sub StopIp2Name() {
}

#warning !!!!
1;