Sha256: 45696a85e8ce17d214735f6048e1fd823884ff8fb0f849fbea8cbdd2165889d1

Contents?: true

Size: 430 Bytes

Versions: 3

Compression:

Stored size: 430 Bytes

Contents

module WebSandboxConsole
  class ApplicationController < ActionController::Base
    protect_from_forgery with: :exception

    # 限制ip
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
web_sandbox_console-0.3.0 app/controllers/web_sandbox_console/application_controller.rb
web_sandbox_console-0.2.0 app/controllers/web_sandbox_console/application_controller.rb
web_sandbox_console-0.1.0 app/controllers/web_sandbox_console/application_controller.rb