module Geocoder::Request

def geocoder_spoofable_ip

def geocoder_spoofable_ip
  # We could use a more sophisticated IP-guessing algorithm here,
  # in which we'd try to resolve the use of different headers by
  # different proxies.  The idea is that by comparing IPs repeated
  # in different headers, you can sometimes decide which header
  # was used by a proxy further along in the chain, and thus
  # prefer the headers used earlier.  However, the gains might not
  # be worth the performance tradeoff, since this method is likely
  # to be called on every request in a lot of applications.
  GEOCODER_CANDIDATE_HEADERS.each do |header|
    if @env.has_key? header
      addrs = geocoder_split_ip_addresses(@env[header])
      addrs = geocoder_remove_port_from_addresses(addrs)
      addrs = geocoder_reject_non_ipv4_addresses(addrs)
      addrs = geocoder_reject_trusted_ip_addresses(addrs)
      return addrs.first if addrs.any?
    end
  end
  @env['REMOTE_ADDR']
end