Sha256: d77bee0caf4534745de9f0d3c379bc5c91eb1fa8769f87ac8ea5c027a78be39d

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

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

module Dcmgr
  module VNet
    module Tasks
    
      # Contains specific rules for ip addresses to which connections should
      # not be natted.
      class ExcludeFromNat < Task
        include Dcmgr::VNet::Netfilter
        #An array of the ip addresses excluded from nat
        attr_accessor :excluded_ips
        
        def initialize(ips,self_ip)
          super()
          raise ArgumentError, "ips Must be an array containing IP addresses" unless ips.is_a? Array
          
          ips.each { |ip|
            if ip.is_a? String
              exclude = IPAddress(ip)
            elsif ip.is_a? IPAddress
              exclude = ip
            else
              next
            end
            
            #self.rules << IptablesRule.new(:nat,:prerouting,nil,:incoming,"-d #{self_ip} -s #{ip} -j ACCEPT")
            self.rules << IptablesRule.new(:nat,:postrouting,nil,:outgoing,"-d #{ip} -s #{self_ip} -j ACCEPT")
          }
        end
      end
      
      # Contains specific rules for ip addresses to which connections should
      # not be natted. Depends on the netfilter IpSet module
      class ExcludeFromNatIpSet < Task
        include Dcmgr::VNet::Netfilter
        attr_accessor :excluded_ips
        
        def initialize(ips,self_ip)
          raise NotImplementedError
        end
        #TODO: Write this class!
      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/tasks/exclude_from_nat.rb
wakame-vdc-dcmgr-11.12.0 lib/dcmgr/vnet/tasks/exclude_from_nat.rb