DNS::Bananafonana - Perl extension for Bananafonana encoding / decoding
use DNS::Bananafonana; $bigint = from_bananafonana($number); $bafostr = to_bananafonana($bigint); $hostname = bananafonana($ptr, $domain, $prefix); $ip = bananafonana($hostname, $domain, $prefix);
RFC 1924 describes a compact, fixed-size representation of IPv6 addresses which uses a base 85 number system. The base 85 numbers (from 0 to 84) are as follows:
0..9 A..Z a..z ! # $ % & ( ) * + - ; < = > ? @ ^ _ ` { | } ~
In order to let human beings pronounce the resulting string more easily and to be able to use base 85 encoding in DNS naming schemes, an alternative encoding scheme is used, based on 85 consonant-vowel pairs, as suggested by DGolden on Slashdot (http://tech.slashdot.org/comments.pl?sid=649579&cid=24654733).
This module has a variable called $DNS::Bananafonana::bananafonana_strings, which is a string containing the 85 two-character strings that make up the bananafonana "alphabet" from lowest to highest , in that order.
$DNS::Bananafonana::bananafonana_strings
Additionally, the following three functions are defined for general use. (They will be exported upon request.)
A string composed of valid bananafonana strings.
A DNS::BigInt object representing the number.
DNS::BigInt
A DNS::BigInt object.
Optionally:
A markup character to split the string in more readable parts. Can be -, _ or .. Defaults to -.
-
_
.
A blocksize that determines the number of consonant-vowel combinations between each markup character. Defaults to 5.
A string of bananafonana strings representing the number.
A string
A string containing the domain name of the record. It will be appended to the result when a pointer record is asked and removed from the input for hostname lookups.
A string containing a prefix that needs to be added before the bananafonana representation of the ip address. Defaults to empty.
A string containing either the bananafonana representation of the ip address (presented in 1.2.3.4.in-addr.arpa or a.b...e.f.ip6.arpa notation) or a string representing the ip address determined from the bonananfonana encoded hostname (for all domains not ending in in-addr|ip6.arpa).
The bananafonana function is currently decoding all hostnames with 10 character bonanafonana encoded addresses as IPv4 addresses. This prevends the correct encoding and decoding for IPv6 addresses in the range ::/96, which should not be a big limitation in practice.
Michiel Fokke <michiel@fokke.org> Based upon work from Tony Monroe <tmonroe+perl@nog.net>
perl(1).
To install DNS::Bananafonana, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DNS::Bananafonana
CPAN shell
perl -MCPAN -e shell install DNS::Bananafonana
For more information on module installation, please visit the detailed CPAN module installation guide.