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->mids ('fqdn'), 
                              iplayer => $tm->mids ('a.root-servers.net.'),
                              type    => $tm->mids ('lookup'));
  print map { TM::get_x_player ($dns, $_, $dns->mids ('ip-address') } @As;

  # reverse lookup
  my @PTRs = $tm->match_forall (irole   => $tm->mids ('ip-address'), 
                                iplayer => $tm->mids ('127.0.0.1'),
                                type    => $tm->mids ('lookup'));

ABSTRACT

This class provides applications with a topicmapp-ish view of DNS, the domain name service. In this sense the topic map is virtual.

DESCRIPTION

This package overloads central methods of the TM class. In that, it provides access to DNS information via the Topic Map paradigm according to the 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.

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

While the predefined concepts have subject indicators, we introduce here our own URI namespaces to provide for 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->mids (\ 'urn:x-ip:123.123.123.123');

Subject Locators

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->mids ('123.123.123.123');  # will create an absolutized local URI

   warn $tm->mids ('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). If you want to use a different one, it has to be replaced before the instantiation.

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 tested properly 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:

midlets

This method would list all items in the DNS. Of course, this will not be possible, so this method will raise an exception.

mids

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.

midlet

This method returns midlet 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.

match_forall

@@@@ doc!! @@@

match_exists

See match_forall.

SEE ALSO

TM

AUTHOR

Robert Barta, <drrho@cpan.org>

COPYRIGHT AND LICENSE

Copyright 200[356] by Robert Barta

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.