diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-23 15:08:46 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-23 15:08:46 +0000 |
commit | 44c5280c8748f4b2ce9e305d6a60f4b5ba80aad1 (patch) | |
tree | 0dff104912e11fa803b5f91c036238540ad2bcc2 /lib | |
parent | 1531a4e34041d42600bea0904e209434e480952d (diff) |
Use the new utility class to determine whether the IP is inside/outside the Bytemark network.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/custodian/alerter.rb | 33 |
1 files changed, 2 insertions, 31 deletions
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 "<p>#{host} is inside the Bytemark network.</p>" else |