From 14f3c3aa78a6a661853fdeeb5d988763ae4a992c Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Fri, 23 Nov 2012 15:08:46 +0000 Subject: Use the new utility class to determine whether the IP is inside/outside the Bytemark network. --- lib/custodian/alerter.rb | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'lib/custodian') diff --git a/lib/custodian/alerter.rb b/lib/custodian/alerter.rb index ffa07dd..0504f2c 100644 --- a/lib/custodian/alerter.rb +++ b/lib/custodian/alerter.rb @@ -1,13 +1,11 @@ +require 'custodian/util/bytemark' require 'custodian/util/dns' require 'mauve/sender' require 'mauve/proto' -require 'ipaddr' - - # # This class encapsulates the raising and clearing of alerts via Mauve. @@ -25,14 +23,6 @@ class Alerter attr_reader :details - # - # The currently allocated IP-ranges which belong to Bytemark. - # - # These are used to test if an alert refers to a machine outwith our - # network. - # - BYTEMARK_RANGES = %w(80.68.80.0/20 89.16.160.0/19 212.110.160.0/19 46.43.0.0/18 91.223.58.0/24 213.138.96.0/19 5.153.224.0/21 2001:41c8::/32).collect{|i| IPAddr.new(i)} - # @@ -46,25 +36,6 @@ class Alerter - # - # Is the named target inside the Bytemark IP-range? - # - def inside_bytemark?( target ) - - # - # Test trange, and format the appropriate message. - # - inside = false - - if ( BYTEMARK_RANGES.any?{|range| range.include?(IPAddr.new(target))} ) - inside = true - end - - inside - end - - - # # Expand to a message indicating whether a hostname is inside the Bytemark network. @@ -110,7 +81,7 @@ class Alerter # # Return the formatted message # - if ( inside_bytemark?( resolved.to_s ) ) + if ( Custodian::Util::Bytemark.inside?( resolved.to_s ) ) if ( resolved == target ) return "

#{host} is inside the Bytemark network.

" else -- cgit v1.2.1