(file) Return to ipv6.pm CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / awstats-6.3 / wwwroot / cgi-bin / plugins

 1 rizwank 1.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: eldy $ - $Date: 2004/05/21 21:18:11 $
 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 rizwank 1.1 #-----------------------------------------------------------------------------
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 rizwank 1.1 	my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
44             
45             	# <-----
46             	# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
47             	debug(" Plugin ipv6: 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 rizwank 1.1 	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

Rizwan Kassim
Powered by
ViewCVS 0.9.2