From 0de702218fe446ccf8342e41ce32dff871b03fdd Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 17 Jul 2002 17:06:44 +0000 Subject: moved makeHash to Tools --- Echolot/Pinger.pm | 13 ++----------- Echolot/Tools.pm | 11 ++++++++++- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'Echolot') diff --git a/Echolot/Pinger.pm b/Echolot/Pinger.pm index 18f72f9..57efaa8 100644 --- a/Echolot/Pinger.pm +++ b/Echolot/Pinger.pm @@ -1,7 +1,7 @@ package Echolot::Pinger; # (c) 2002 Peter Palfrader -# $Id: Pinger.pm,v 1.15 2002/07/17 16:14:23 weasel Exp $ +# $Id: Pinger.pm,v 1.16 2002/07/17 17:06:44 weasel Exp $ # =pod @@ -22,15 +22,6 @@ use English; use Echolot::Pinger::Mix; use Echolot::Pinger::CPunk; -sub makeHash($) { - my ($text) = @_; - - my $hash = Echolot::Tools::make_mac($text); - $hash = substr($hash, 0, 4); - my $sum = hex($hash); - return $sum; -}; - sub do_mix_ping($$$$$) { my ($address, $keyid, $time, $to, $body) = @_; @@ -109,7 +100,7 @@ sub send_pings() { for my $type (Echolot::Globals::get()->{'storage'}->get_types($address)) { next unless Echolot::Config::get()->{'do_pings'}->{$type}; for my $key (Echolot::Globals::get()->{'storage'}->get_keys($address, $type)) { - next unless ($this_call_id eq (makeHash($address.$type.$key) % $send_every_n_calls)); + next unless ($this_call_id eq (Echolot::Tools::makeShortNumHash($address.$type.$key) % $send_every_n_calls)); print "ping calling $type, $address, $key\n" if Echolot::Config::get()->{'verbose'}; do_ping($type, $address, $key); } diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm index 403c02b..e4bed61 100644 --- a/Echolot/Tools.pm +++ b/Echolot/Tools.pm @@ -1,7 +1,7 @@ package Echolot::Tools; # (c) 2002 Peter Palfrader -# $Id: Tools.pm,v 1.6 2002/07/16 02:48:57 weasel Exp $ +# $Id: Tools.pm,v 1.7 2002/07/17 17:06:44 weasel Exp $ # =pod @@ -54,6 +54,15 @@ sub make_mac($) { return $mac; }; +sub makeShortNumHash($) { + my ($text) = @_; + + my $hash = Echolot::Tools::make_mac($text); + $hash = substr($hash, 0, 4); + my $sum = hex($hash); + return $sum; +}; + sub verify_mac($$) { my ($token, $mac) = @_; -- cgit v1.2.3