Module: NginxTail::LocalIpAddresses
- Included in:
- LogLine
- Defined in:
- lib/ntail/local_ip_addresses.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
local IP addresses, for filtering and formatting purposes.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
local IP addresses, for filtering and formatting purposes
e.g. downstream proxy servers (nginx web servers -> passenger app servers)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ntail/local_ip_addresses.rb', line 10 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 |
Instance Method Details
#local_ip_address? ⇒ Boolean
39 40 41 |
# File 'lib/ntail/local_ip_addresses.rb', line 39 def local_ip_address? self.class.local_ip_address?(self.remote_addr) end |