Sha256: 34840481bac6c168aa08f18955e89774be009373d25f54f72c5c23d46055f670

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# -*- coding: utf-8 -*-

module Dcmgr
  module VNet
    module Netfilter
    
      class IptablesRule < Rule
        attr_accessor :table
        attr_accessor :chain
        attr_accessor :rule
        # Should be either :incoming or :outgoing
        attr_accessor :bound
        attr_accessor :protocol
        
        def initialize(table = nil, chain = nil, protocol = nil, bound = nil, rule = nil)
          super()
          raise ArgumentError, "table does not exist: #{table}" unless IptablesChain.pre_made.keys.member?(table)
          self.table = table
          self.chain = chain
          self.protocol = protocol
          self.bound = bound
          self.rule = rule
        end
        
        def chain
          if IptablesChain.pre_made[self.table].member?(@chain)
            @chain.to_s.upcase 
          else
            @chain
          end
        end
        
        # Getter for the protocols iptables supports
        def self.protocols
          {
            'tcp'  => 'tcp',
            'udp'  => 'udp',
            'icmp' => 'icmp',
          }
        end
      end
    
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
wakame-vdc-agents-11.12.0 lib/dcmgr/vnet/netfilter/iptables_rule.rb
wakame-vdc-dcmgr-11.12.0 lib/dcmgr/vnet/netfilter/iptables_rule.rb