instance method to_s

Ruby on Rails 3.1.12

Since v3.0.20 Last seen in v3.1.12

Available in: v3.0.20 v3.1.12

Signature

to_s()

No documentation comment.

Source
# File actionpack/lib/action_dispatch/middleware/remote_ip.rb, line 19
      def to_s
        return remote_addrs.first if remote_addrs.any?

        forwarded_ips = @env['HTTP_X_FORWARDED_FOR'] ? @env['HTTP_X_FORWARDED_FOR'].strip.split(/[,\s]+/) : []

        if client_ip = @env['HTTP_CLIENT_IP']
          if @check_ip_spoofing && !forwarded_ips.include?(client_ip)
            # We don't know which came from the proxy, and which from the user
            raise IpSpoofAttackError, "IP spoofing attack?!" \
              "HTTP_CLIENT_IP=#{@env['HTTP_CLIENT_IP'].inspect}" \
              "HTTP_X_FORWARDED_FOR=#{@env['HTTP_X_FORWARDED_FOR'].inspect}"
          end
          return client_ip
        end

        return forwarded_ips.reject { |ip| ip =~ @trusted_proxies }.last || @env["REMOTE_ADDR"]
      end

Defined in actionpack/lib/action_dispatch/middleware/remote_ip.rb line 19 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::RemoteIp::RemoteIpGetter

Type at least 2 characters to search.

↑↓ navigate · open · esc close