~ubuntu-branches/ubuntu/breezy/awstats/breezy

« back to all changes in this revision

Viewing changes to wwwroot/cgi-bin/plugins/ipv6.pm

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2004-05-05 05:12:07 UTC
  • Revision ID: james.westby@ubuntu.com-20040505051207-wfi8hydpa89pvuoi
Tags: upstream-6.0
ImportĀ upstreamĀ versionĀ 6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.3 $ - $Author: eldy $ - $Date: 2003/10/29 21:20:39 $
 
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