home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / cgi-bin / ipv6.pm < prev    next >
Encoding:
Text File  |  2004-05-20  |  2.4 KB  |  73 lines

  1. #!/usr/bin/perl
  2. #-----------------------------------------------------------------------------
  3. # IPv6 AWStats plugin
  4. # This plugin allow AWStats to make reverse DNS Lookup on IPv6 addresses.
  5. #-----------------------------------------------------------------------------
  6. # Perl Required Modules: Net::IP and Net::DNS
  7. #-----------------------------------------------------------------------------
  8. # $Revision: 1.4 $ - $Author: joker $ - $Date: 2004/05/20 20:38:42 $
  9.  
  10.  
  11. # <-----
  12. # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
  13. if (!eval ('require "Net/IP.pm";'))        { return $@?"Error: $@":"Error: Need Perl module Net::IP"; }
  14. if (!eval ('require "Net/DNS.pm";'))     { return $@?"Error: $@":"Error: Need Perl module Net::DNS"; }
  15. # ----->
  16. use strict;no strict "refs";
  17.  
  18.  
  19.  
  20. #-----------------------------------------------------------------------------
  21. # PLUGIN VARIABLES
  22. #-----------------------------------------------------------------------------
  23. # <-----
  24. # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
  25. # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
  26. my $PluginNeedAWStatsVersion="5.5";
  27. my $PluginHooksFunctions="GetResolvedIP";
  28. # ----->
  29.  
  30. # <-----
  31. # IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
  32. use vars qw/
  33. $resolver
  34. /;
  35. # ----->
  36.  
  37.  
  38. #-----------------------------------------------------------------------------
  39. # PLUGIN FUNCTION: Init_pluginname
  40. #-----------------------------------------------------------------------------
  41. sub Init_ipv6 {
  42.     my $InitParams=shift;
  43.     my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
  44.  
  45.     # <-----
  46.     # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
  47.     debug(" InitParams=$InitParams",1);
  48.     $resolver = Net::DNS::Resolver->new;
  49.     # ----->
  50.  
  51.     return ($checkversion?$checkversion:"$PluginHooksFunctions");
  52. }
  53.  
  54.  
  55. #-----------------------------------------------------------------------------
  56. # PLUGIN FUNCTION: GetResolvedIP_pluginname
  57. # UNIQUE: YES (Only one plugin using this function can be loaded)
  58. # GetResolvedIP is called to resolve an IPv6 address into a host name
  59. #-----------------------------------------------------------------------------
  60. sub GetResolvedIP_ipv6 {
  61.     # <-----
  62.     my $ip = new Net::IP($_[0]);
  63.     my $reverseip= $ip->reverse_ip();
  64.     my $query = $resolver->query($reverseip, "PTR");
  65.     if (! defined($query)) { return; }
  66.     my @result=split(/\s/, ($query->answer)[0]->string);
  67.     return $result[4];
  68.     # ----->
  69. }
  70.  
  71.  
  72. 1;    # Do not remove this line
  73.