提交 6c441618 编写于 作者: A Aaron Patterson

pass check_ip and proxies to GetIp constructor

The `GetIp` class doesn't need to keep a reference to the middleware, so
there is no reason to pass the middleware instance to the `GetIp` class
上级 814a994e
......@@ -74,7 +74,7 @@ def initialize(app, check_ip_spoofing = true, custom_proxies = nil)
# requests. For those requests that do need to know the IP, the
# GetIp#calculate_ip method will calculate the memoized client IP address.
def call(env)
env["action_dispatch.remote_ip"] = GetIp.new(env, self)
env["action_dispatch.remote_ip"] = GetIp.new(env, check_ip, proxies)
@app.call(env)
end
......@@ -82,10 +82,10 @@ def call(env)
# into an actual IP address. If the ActionDispatch::Request#remote_ip method
# is called, this class will calculate the value and then memoize it.
class GetIp
def initialize(env, middleware)
def initialize(env, check_ip, proxies)
@env = env
@check_ip = middleware.check_ip
@proxies = middleware.proxies
@check_ip = check_ip
@proxies = proxies
end
# Sort through the various IP address headers, looking for the IP most
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册