Class: Fog::Bouncer::Protocols::ICMP

Inherits:
Fog::Bouncer::Protocol show all
Defined in:
lib/fog/bouncer/protocols.rb

Constant Summary collapse

ICMP_MAPPING =
{
  all: -1,
  echo_reply: 0..-1,
  echo_request: 8..-1
}
ICMP_TYPE_RANGE =
(-1..255)

Instance Attribute Summary

Attributes inherited from Fog::Bouncer::Protocol

#from, #local, #remote, #source, #to

Instance Method Summary collapse

Methods inherited from Fog::Bouncer::Protocol

#<=>, #==, #group, #inspect, #local?, range, #remote?, #to_log, #type

Constructor Details

#initialize(port, source) ⇒ ICMP

Returns a new instance of ICMP.



81
82
83
84
85
86
# File 'lib/fog/bouncer/protocols.rb', line 81

def initialize(port, source)
  if port.is_a?(Symbol) && range = ICMP_MAPPING[port]
    port = range
  end
  super
end

Instance Method Details

#match(type, port) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/fog/bouncer/protocols.rb', line 88

def match(type, port)
  if port.is_a?(Symbol) && range = ICMP_MAPPING[port]
    type.to_s == self.type && Protocol.range(range) == [from, to]
  else
    super
  end
end