Class: WebSandboxConsole::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- WebSandboxConsole::ApplicationController
- Defined in:
- app/controllers/web_sandbox_console/application_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#restrict_ip ⇒ Object
限制ip.
Instance Method Details
#restrict_ip ⇒ Object
限制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 |