]> git.donarmstrong.com Git - infobot.git/commitdiff
* New hex2ip module
authordjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 1 Dec 2007 01:20:08 +0000 (01:20 +0000)
committerdjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 1 Dec 2007 01:20:08 +0000 (01:20 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1631 c11ca15a-4712-0410-83d8-924469b57eb5

doc/USAGE
files/infobot.help
src/CommandStubs.pl
src/Modules/hex2ip.pl [new file with mode: 0644]

index 9dac0a37fbe05a85181920ce17aed1fab3fe2604..23786fee9982bc3d994f4417eb0e36382eca6a2d 100644 (file)
--- a/doc/USAGE
+++ b/doc/USAGE
@@ -16,6 +16,9 @@ for list of configuration options, run:
 
 
 =====
+<me> infobot: hex2ip aaBBcD12
+<infobot> me: AABBCD12 = 170.187.205.18 
+
 <me> infobot: test is testing
 <infobot> me: okay
 <me> infobot: testing?
index c44576dc078fccce861ae4018e56e8d197fd75a5..c0370ee9f3fd8ce0c8b7bbd2ccb9954949b1925e 100644 (file)
@@ -490,4 +490,8 @@ rssfeeds: E: rssfeeds flush
 rssfeeds: D: flush - Will erase the cache file. (Must be chattr +o)
 rssfeeds: D: update - Force a manual update of the feeds. (Must be chattr +o)
 
+hex2ip: D: Convert Hex idents for some gateways to an IP address
+hex2ip: U: ## <8 char hex value>
+hex2ip: E: ## AabBcC12
+
 # vim:ts=4:sw=4:expandtab:tw=80
index 7df2c73220e89ad2f1dbb873a593557f9e0ae56a..95878b11a32db0ca9f502301c811b9b0ae49b4f4 100644 (file)
@@ -763,6 +763,7 @@ sub nullski {
 &addCmdHook('factinfo', ('CODEREF' => 'factinfo', 'Cmdstats' => 'Factoid Info', Module => 'Factoids', ) );
 &addCmdHook('factstats?', ('CODEREF' => 'factstats', 'Cmdstats' => 'Factoid Stats', Help => 'factstats', Forker => 1, 'Identifier' => 'Factoids', ) );
 &addCmdHook('help', ('CODEREF' => 'help', 'Cmdstats' => 'Help', ) );
+&addCmdHook('hex2ip', ('CODEREF' => 'hex2ip::query', 'Forker' => 1, 'Identifier' => 'hex2ip', 'Cmdstats' => 'hex2ip', 'Help' => 'hex2ip') );
 &addCmdHook('HTTPDtype', ('CODEREF' => 'HTTPDtype::HTTPDtype', 'Identifier' => 'HTTPDtype', 'Cmdstats' => 'HTTPDtype', 'Forker' => 1) );
 &addCmdHook('[ia]?spell', ('CODEREF' => 'spell::query', 'Identifier' => 'spell', 'Cmdstats' => 'spell', 'Forker' => 1, 'Help' => 'spell') );
 &addCmdHook('insult', ('CODEREF' => 'Insult::Insult', 'Forker' => 1, 'Identifier' => 'insult', 'Help' => 'insult' ) );
diff --git a/src/Modules/hex2ip.pl b/src/Modules/hex2ip.pl
new file mode 100644 (file)
index 0000000..6ac4585
--- /dev/null
@@ -0,0 +1,44 @@
+#
+#  hex2ip.pl: Convert hex gateway idents to an IP (eg:ABCDEF12)
+#     Author: Dan McGrath <djmcgrath@users.sourceforget.net>
+#  Licensing: Artistic License (as perl itself)
+#    Version: v0.1
+#
+#  Copyright (c) 2007 Dan McGrath
+#
+
+package hex2ip;
+
+use strict;
+
+sub hex2ip::convert {
+    my $hexstr = shift;
+    my $result;
+
+    &::VERB("hex2ip: Converting Hex address $hexstr to IP");
+
+    if ( $hexstr =~ /^([a-fA-F0-9]{2}){4}$/ ) {
+        my @conv;
+        $hexstr =~ /(..)(..)(..)(..)/;
+
+        push @conv, hex($1);
+        push @conv, hex($2);
+        push @conv, hex($3);
+        push @conv, hex($4);
+
+        $result = uc "$hexstr = " . join(".", @conv);
+    } else {
+        $result = "Invalid string: $hexstr";
+    }
+
+       return($result);
+}
+
+sub hex2ip::query {
+       &::performStrictReply(&convert(@_));
+       return;
+}
+
+1;
+
+# vim:ts=4:sw=4:expandtab:tw=80