/usr/share/perl5/RipeWhois.pm is in asused 3.72-12.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | # Copyright (c) 2000 RIPE NCC
#
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of the author not be
# used in advertising or publicity pertaining to distribution of the
# software without specific, written prior permission.
#
# THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
# AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
# AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#------------------------------------------------------------------------------
# Module Header
# Filename : RipeWhois.pm
# Purpose : Make whois queries to RIPE-like servers
# Author : Timur Bakeyev <timur@ripe.net>
# Date : 08082000
# Description : General purpose, simple client to make whois queries
# Language Version : Perl5
# OSs Tested : BSD/OS 3.1
# Command Line : None
# Input Files : None
# Output Files : None
# External Programs : None
# Problems : None known
# To Do : Make more consistent(?)
# Comments :
# $Id: RipeWhois.pm,v 1.4 2001/04/18 17:01:20 timur Exp $
#------------------------------------------------------------------------------
package RipeWhois;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
require Exporter;
@ISA = qw(Exporter Whois);
use Whois qw(:ERROR_CODES);
use Whois qw(%ERROR);
$VERSION = '1.03';
# This strings are perl regexp
my %WHOIS_ERROR = (
$WHOIS_TIMEOUT => '%\s+Timeout',
$WHOIS_NO_ENTRY => '%\s+No\s+entries\s+found',
$WHOIS_UNKNOWN_QUERY=> '%\s+Request\s+for\+unknown',
$CONNECTION_CLOSED => '(Timeout|Connection)\s+closed\s+by\s+foreign',
);
# Default parameters for the class
my %default = (
'Host' => 'whois.ripe.net',
'FormatMode' => 0,
'KeepAlive' => 0
);
####################################################################
# DESCRIPTION: Create new object
# INPUT: Hash of parameters, can be:
# host, port, timeout, retry, KeepAlive.
# OUTPUT: Object
# SIDE EFFECTS: None
# SYNTAX: None
####################################################################
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my %param = (@_);
my $param = '';
my %extend = ();
# Keepalive connection
$param = delete $param{'KeepAlive'};
$extend{'KeepAlive'} = ($param && $param =~ /^\d+$/) ? $param : $default{'KeepAlive'};
# Extract the value of the mode
my $mode = delete $param{'FormatMode'};
if($mode && $mode =~ /^\d+$/) {
# We need this module only if we use legacy conversion
require RipeWhois::FormatMode;
# Strip continuation and comments
if($mode == 1) {
$extend{'FormatMode'} = 1;
}
# Sort the fields as well
elsif($mode == 2) {
$extend{'FormatMode'} = 2;
}
}
else {
$extend{'FormatMode'} = $default{'FormatMode'};
}
# Set the host to default if nothing was passed
unless($param{'Host'} && $param{'Host'} =~ /^\S+$/) {
$param{'Host'} = $default{'Host'};
}
# Call the parent constructor
my $self = $class->SUPER::new(%param);
# Fail, if parent constructor failed
return unless($self);
bless $self, $class;
# Fill additional parameters
$self->{'KeepAlive'} = $extend{'KeepAlive'};
$self->debug("KeepAlive: ", $self->{'KeepAlive'});
$self->{'FormatMode'} = $extend{'FormatMode'};
$self->debug("FormatMode: ", $self->{'FormatMode'});
return $self;
}
####################################################################
# DESCRIPTION: Query whois server
# INPUT: Query, that should be send to the server
# OUTPUT: Error code on error, 0 on success.
# SIDE EFFECTS: None
# SYNTAX: None
####################################################################
sub Query {
my $self = shift;
# Filter out empty paramters
my @query = grep { /\S+/ } @_;
# Fix for new whois query defaults (2 May 2005) ZS.
unshift(@query, '-B', '-G');
# Add keep-alive flag if necessary
if($self->{'KeepAlive'}) {
# Only for non-empty list
unshift(@query, '-k') if(@query);
}
# Make the query
my $error = $self->SUPER::Query(@query);
# If query failed return the error code
return $error if($error);
# On success
return 0;
}
####################################################################
# DESCRIPTION: Split raw query results into array of objects
# INPUT: Scalar with the query result or uses internal one
# OUTPUT: Error code on error, 0 on success.
# SIDE EFFECTS: None
# SYNTAX: None
####################################################################
sub SplitResult {
my $self = shift;
# We can obtain result from a parameter
my $result = shift || $self->GetResult();
return $self->error($NO_RESULT, $ERROR{$NO_RESULT})
unless($result);
# Did we get any errors from the server
foreach my $error (keys(%WHOIS_ERROR)) {
# Respond contains one of the errors codes
# from Whois server
return $self->error($error, $ERROR{$error})
if($result =~ m/$WHOIS_ERROR{$error}/m);
}
# Get rid of all comment lines
$result =~ s/^%.*$//mg;
# Remove spaces from the begining
# and end of the result
$result =~ s/^\s*//s;
$result =~ s/\s*$//s;
# No results or failure
return $self->error($NO_RESULT, $ERROR{$NO_RESULT})
unless($result);
# Split result into objects
my @objects = split(/\n\n/, $result);
# If we need to do conversion to the legacy format
if($self->{'FormatMode'}) {
# Do inline modification of the objects, if required
foreach my $object (@objects) {
# Stripping
if($self->{'FormatMode'} == 1) {
$object = RipeWhois::FormatMode::Filter($object);
}
# ...or stripping and sorting
elsif($self->{'FormatMode'} == 2) {
$object = RipeWhois::FormatMode::Filter($object, 'yes');
}
}
}
# Save results
$self->{'Objects'} = \@objects;
return 0;
}
####################################################################
# DESCRIPTION: Return array of objects
# INPUT: None
# OUTPUT: Array or reference to array of objects
# SIDE EFFECTS: None
# SYNTAX: None
####################################################################
sub GetObjects {
my $self = shift;
return wantarray() ? @{ $self->{'Objects'} } : $self->{'Objects'};
}
####################################################################
# DESCRIPTION: Query whois server and return array of objects
# INPUT: Query, that should be send to the server
# OUTPUT: Array of objects, or empty on error
# SIDE EFFECTS: None
# SYNTAX: None
####################################################################
sub QueryObjects {
my $self = shift;
my @query = @_;
if(!$self->Query(@query) && !$self->SplitResult()) {
return $self->GetObjects();
}
return;
}
####################################################################
# DESCRIPTION: Close connection with the whois server
# INPUT: None
# OUTPUT: None
# SIDE EFFECTS: None
# SYNTAX: None
####################################################################
sub Close {
my $self = shift;
# Don't close keep-alive session
unless($self->{'KeepAlive'}) {
# Call the parent method
$self->SUPER::Close();
}
}
####################################################################
# DESCRIPTION: Destructor for the object.
# INPUT: None
# OUTPUT: None
# SIDE EFFECTS: None
# SYNTAX: None
####################################################################
sub DESTROY {
my $self = shift;
if(defined($self->{'Sock'}) && $self->{'Sock'}->opened()) {
# Send notification to the server to close it's side of the
# connection if we were in keep-alive mode
if($self->{'KeepAlive'}) {
#
$self->debug("Terminate keep alive connection");
# We don't care about possible connection
# errors at this stage
$self->{'Sock'}->print("-k\x0d\x0a");
}
}
$self->SUPER::Close();
$self->debug(ref($self), " object was destroyed");
}
1;
__END__
# Below is the stub of documentation for your module. You better edit it!
=head1 NAME
RipeWhois - Perl extension to retrieve information from RIPE Whois database.
=head1 SYNOPSIS
use RipeWhois;
blah blah blah
=head1 DESCRIPTION
Stub documentation for RipeWhois was created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.
Blah blah blah.
=head1 AUTHOR
Timur Bakeyev <timur@ripe.net>
=head1 SEE ALSO
perl(1).
=cut
|