Sha256: 3a50fe1a9a9650945a9a79ffb3e4443c550f844e870331200fe65f08b658de61
Contents?: true
Size: 1.22 KB
Versions: 13
Compression:
Stored size: 1.22 KB
Contents
module NginxTail module LocalIpAddresses # # local IP addresses, for filtering and formatting purposes # # e.g. downstream proxy servers (nginx web servers -> passenger app servers) # def self.included(base) # :nodoc: base.class_eval do @@local_ip_addresses = [] # mainly (solely?) for testing purposes... def self.local_ip_addresses() @@local_ip_addresses.dup end # mainly (solely?) for testing purposes... def self.reset_local_ip_addresses() while !@@local_ip_addresses.empty? ; @@local_ip_addresses.pop ; end end def self.add_local_ip_address(local_ip_address) (@@local_ip_addresses << local_ip_address).uniq! end def self.local_ip_address?(remote_addr) @@local_ip_addresses.include?(remote_addr) end # this ensures the below module methods actually make sense... raise "Class #{base.name} should implement instance method 'remote_addr'" unless base.instance_methods.map(&:to_s).include? 'remote_addr' end end def local_ip_address? self.class.local_ip_address?(self.remote_addr) end end end
Version data entries
13 entries across 13 versions & 1 rubygems