Class: IPTuple
- Inherits:
-
Object
- Object
- IPTuple
- Defined in:
- lib/ipaddr_extensions.rb
Instance Attribute Summary collapse
-
#destination_ip ⇒ Object
Returns the value of attribute destination_ip.
-
#destination_port ⇒ Object
Returns the value of attribute destination_port.
-
#ip_protocol ⇒ Object
Returns the value of attribute ip_protocol.
-
#source_ip ⇒ Object
Returns the value of attribute source_ip.
-
#source_port ⇒ Object
Returns the value of attribute source_port.
Instance Method Summary collapse
-
#initialize(src_ip = nil, dst_ip = nil, ip_proto = nil, src_port = nil, dst_port = nil) ⇒ IPTuple
constructor
A new instance of IPTuple.
- #ipv4? ⇒ Boolean
- #ipv6? ⇒ Boolean
Constructor Details
#initialize(src_ip = nil, dst_ip = nil, ip_proto = nil, src_port = nil, dst_port = nil) ⇒ IPTuple
Returns a new instance of IPTuple.
545 546 547 548 549 550 551 552 553 554 |
# File 'lib/ipaddr_extensions.rb', line 545 def initialize src_ip=nil, dst_ip=nil, ip_proto=nil, src_port=nil, dst_port=nil @source_ip = src_ip if src_ip.is_a? IPAddr @source_ip = src_ip.to_ip if src_ip.is_a? String @destination_ip = dst_ip if dst_ip.is_a? IPAddr @destination_ip = dst_ip.to_ip if dst_ip.is_a? String @ip_protocol = ip_proto if ip_proto.is_a? IPProtocol @ip_protocol = IPProtocol.new(ip_proto) if ip_proto.is_a? Integer @source_port = src_port if ((1..65535).include? src_port) @destination_port = dst_port if ((1..65535).include? dst_port) end |
Instance Attribute Details
#destination_ip ⇒ Object
Returns the value of attribute destination_ip.
543 544 545 |
# File 'lib/ipaddr_extensions.rb', line 543 def destination_ip @destination_ip end |
#destination_port ⇒ Object
Returns the value of attribute destination_port.
543 544 545 |
# File 'lib/ipaddr_extensions.rb', line 543 def destination_port @destination_port end |
#ip_protocol ⇒ Object
Returns the value of attribute ip_protocol.
543 544 545 |
# File 'lib/ipaddr_extensions.rb', line 543 def ip_protocol @ip_protocol end |
#source_ip ⇒ Object
Returns the value of attribute source_ip.
543 544 545 |
# File 'lib/ipaddr_extensions.rb', line 543 def source_ip @source_ip end |
#source_port ⇒ Object
Returns the value of attribute source_port.
543 544 545 |
# File 'lib/ipaddr_extensions.rb', line 543 def source_port @source_port end |
Instance Method Details
#ipv4? ⇒ Boolean
556 557 558 559 560 561 562 563 564 |
# File 'lib/ipaddr_extensions.rb', line 556 def ipv4? if @source_ip && @destination_ip @source_ip.ipv4? && @destination_ip.ipv4? elsif @source_ip @source_ip.ipv4? elsif @destination_ip @destination_ip.ipv4? end end |
#ipv6? ⇒ Boolean
566 567 568 569 570 571 572 573 574 |
# File 'lib/ipaddr_extensions.rb', line 566 def ipv6? if @source_ip && @destination_ip @source_ip.ipv6? && @destination_ip.ipv6? elsif @source_ip @source_ip.ipv6? elsif @destination_ip @destination_ip.ipv6? end end |