Class: WebSandboxConsole::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/web_sandbox_console/application_controller.rb

Direct Known Subclasses

AuthorizationController, HomeController

Instance Method Summary collapse

Instance Method Details

#restrict_ipObject

限制ip



10
11
12
13
14
15
16
17
# File 'app/controllers/web_sandbox_console/application_controller.rb', line 10

def restrict_ip
  return unless ip_whitelist = WebSandboxConsole.ip_whitelist
  
  request_ip = IPAddr.new(request.remote_ip)
  unless ip_whitelist.any? {|legal_ip| IPAddr.new(legal_ip).include?(request_ip)}
    render text: "非法请求"
  end
end