lib/puffy/rule.rb in puffy-0.1.0 vs lib/puffy/rule.rb in puffy-0.2.0

- old
+ new

@@ -64,10 +64,12 @@ def initialize(options = {}) send_options(options) @af = detect_af unless af + self.proto ||= from_proto_hint || to_proto_hint + raise "unsupported action `#{options[:action]}'" unless valid_action? raise 'if from_port or to_port is specified, the protocol must also be given' if port_without_protocol? end # Instanciate a forward Puffy::Rule. @@ -136,20 +138,26 @@ # @!method from_host # Returns the source host of the Puffy::Rule. # @!method from_port # Returns the source port of the Puffy::Rule. + # @!method from_proto_hint + # Returns the proto hint of the Puffy::Rule. # @!method to_host # Returns the destination host of the Puffy::Rule. # @!method to_port # Returns the destination port of the Puffy::Rule. + # @!method to_proto_hint + # Returns the proto hint of the Puffy::Rule. # @!method rdr_to_host # Returns the redirect destination host of the Puffy::Rule. # @!method rdr_to_port # Returns the redirect destination port of the Puffy::Rule. + # @!method rdr_to_proto_hint + # Returns the proto hint of the Puffy::Rule (does not make sense). %i[from to rdr_to].each do |destination| - %i[host port].each do |param| + %i[host port proto_hint].each do |param| define_method("#{destination}_#{param}") do res = public_send(destination) res && res[param] end end @@ -195,10 +203,11 @@ %i[from_host to_host rdr_to_host].map do |method| res = send(method) if res.nil? then nil elsif res.ipv4? then :inet elsif res.ipv6? then :inet6 - else raise 'Fail' + else + raise 'Fail' end end.uniq.compact end # @!method from_ipv4?