TM::Virtual::DNS - Virtual Topic Map for DNS retrieval
# 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;
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>.
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.
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).
$ontology
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;'
We introduce here our own URN x-namespaces to provide subject indicators for IP addresses and FQDN:
urn:x-ip
Example:
urn:x-ip:1.2.3.4
urn:x-dns
urn:x-fqdn:www.google.com
This package recognizes these subject indicators:
print "yes" if $tm->tids (\ 'urn:x-ip:123.123.123.123');
Obviously, there are no subject locators for IP addresses and FQDNs.
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
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).
my $dns = new TM::Virtual::DNS;
The following options are currently recognized:
baseuri
dns:localhost:
All local IDs in the virtual map will be prefixed with that baseuri.
nameservers
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.
my $dns = new TM::Virtual::DNS (nameservers => [ 1.2.3.4 ]);
This subclass of TM overrides the following methods:
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.
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.
@assertions = $tm->match_forall (...search specification...)
This method finds all assertions matching the search specification. Following axes are currently supported:
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'
Returns all assertions where there are classes of a given toplet. For localhost and all FQDN toplets this is fqdn, for 127.0.0.1 and all IP addresses this is ip-address.
localhost
fqdn
127.0.0.1
ip-address
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.
lookup
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 @@@
See match_forall.
match_forall
TM
Robert Barta, <drrho@cpan.org>
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.
To install TM::Virtual::DNS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TM::Virtual::DNS
CPAN shell
perl -MCPAN -e shell install TM::Virtual::DNS
For more information on module installation, please visit the detailed CPAN module installation guide.