NAME
TM::Virtual::DNS - Virtual Topic Map for DNS retrieval
SYNOPSIS
# standalone
use TM::Virtual::DNS;
my $dns = new TM::Virtual::DNS;
# forward lookup
my @As = $tm->match_forall (irole => $tm->tids ('fqdn'),
iplayer => $tm->tids ('a.root-servers.net.'),
type => $tm->tids ('lookup'));
print map { TM::get_x_players ($dns, $_, $dns->tids ('ip-address') } @As;
# reverse lookup
my @PTRs = $tm->match_forall (irole => $tm->tids ('ip-address'),
iplayer => $tm->tids ('127.0.0.1'),
type => $tm->tids ('lookup'));
print map { TM::get_x_players ($dns, $_, $dns->tids ('fqdn') } @PTRs;
ABSTRACT
This class provides applications with a topicmapp-ish view of the DNS, the global domain name service. As the content in the DNS can never be materialized, this topic map is virtual.
In this
sense the topic map is I<virtual>.
DESCRIPTION
This package overloads central methods of the TM class. In that, it provides access to DNS information via the Topic Map paradigm. Hereby it uses a terminology from an onboard DNS ontology.
Ontology
While the map in its core functionality is virtual, it still is based on some fixed concepts, such as IP address or host name. These are defined in the ontology which is represented textually (in AsTMa= representation) within the string $ontology
(class property).
Whenever a DNS topic map is created, also this ontology is integrated, so that for the outside user there is no visible distinction between topics declared in the ontology and topics (and associations) created on-the-fly.
If you ever need the ontology, you can simply output it like so:
perl -MTM::Virtual::DNS -e 'print $TM::Virtual::DNS::ontology;'
Identification
We introduce here our own URN x-namespaces to provide subject indicators for IP addresses and FQDN:
Subject Identifiers
urn:x-ip
for IP addresses-
Example:
urn:x-ip:1.2.3.4
urn:x-dns
for DNS names-
Example:
urn:x-fqdn:www.google.com
This package recognizes these subject indicators:
print "yes" if $tm->tids (\ 'urn:x-ip:123.123.123.123');
Subject Locators
Obviously, there are no subject locators for IP addresses and FQDNs.
Local Identifiers
As local identifiers you can use IP addresses and FQDNs directly, they will be detected by their syntactic structure:
warn $tm->tids ('123.123.123.123'); # will create an absolutized local URI
warn $tm->tids ('www.google.com'); # ditto
INTERFACE
Constructor
The constructor needs no arguments and instantiates a virtual map hovering over the DNS. For this purpose the constructor also loads the background ontology (there is only a minimal overhead involved with this).
Example:
my $dns = new TM::Virtual::DNS;
The following options are currently recognized:
baseuri
(default:dns:localhost:
)-
All local IDs in the virtual map will be prefixed with that baseuri.
nameservers
(default: whatever the local installation uses by default)-
If this list reference is provided, the IP addresses in there will be used for name resolution.
Warning: This feature cannot be properly tested automatically as many firewall setups prohibit direct DNS access.
Example:
my $dns = new TM::Virtual::DNS (nameservers => [ 1.2.3.4 ]);
Methods
This subclass of TM overrides the following methods:
- tids
-
This method expects a list of identification parameters and will return a fully absolutized URI for each of these. Apart from understanding the identifiers (as explained above), it should follow the semantics of the mother class. It can also be used in list context.
- toplets
-
This method returns toplet structures as described in TM, either those of predefined concepts or ones which are created on the fly if we are dealing with IP addresses or FQDNs.
This method can only deal with a list of local identifiers, not with search specifications. It will refuse cooperation to enumerate the whole Internet when the list is empty.
- match_forall
-
@assertions = $tm->match_forall (...search specification...)
This method finds all assertions matching the search specification. Following axes are currently supported:
- Code:char.irole
-
Return all assertions which are characteristics of the given topic. For IP addresses, there is one name containing exactly the IP address as string. For FQDN also the string will be used as toplet name.
'irole' => 'the toplet for which characteristics are sought', 'char' => '1'
- Code:instance.type
-
Returns all assertions where there are classes of a given toplet. For
localhost
and all FQDN toplets this isfqdn
, for127.0.0.1
and all IP addresses this isip-address
. - Code:iplayer.irole.type and Code irole.type
-
Returns all assertions where there is a
lookup
assertion with the given toplet as player of the given role. For IP addresses a reverse DNS lookup is done, for FQDNs a forward lookup. - Code:*
-
All other axes will only look into the underlying ontology.
Examples:
my @as = # forward lookup for localhost $tm->match_forall (irole => $tm->tids ('fqdn'), iplayer => $tm->tids ('localhost'), type => $tm->tids ('lookup')) my @as = # forward lookup for one of the A servers $tm->match_forall (irole => $tm->tids ('fqdn'), iplayer => $tm->tids ('a.root-servers.net.'), type => $tm->tids ('lookup')); my @as = # reverse lookup $tm->match_forall (irole => $tm->tids ('ip-address'), iplayer => $tm->tids ($ip), type => $tm->tids ('lookup'))
@@@@ doc!! @@@
@@@ which axes are supported @@@
- match_exists
-
See
match_forall
.
SEE ALSO
AUTHOR
Robert Barta, <drrho@cpan.org>
COPYRIGHT AND LICENSE
Copyright 200[3568] by Robert Barta
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.