ip_restriction 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 610c67804a38c1dca7d3d83a9e9a70296ae03c3c
|
4
|
+
data.tar.gz: e306e1710319105b71f70c1dd5faf8f42f2144a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9015fa7a7db6bc9d723fb9d64ce408821869507fb785b1bf788629cd11493bc984a949d90be30fb904ab41824cce0c4404291cdbe6a406762f340a0b533667d8
|
7
|
+
data.tar.gz: 2f838fc3c5f0de2b2aa8613ac971cc1a69d2ea06b2a57bb03acd5c310109c857d5e2169b1bad9f4e4e4a40dcf37d961ebaa27c4b999fbdd08af748f464fbfbc8
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module IpRestriction
|
4
|
+
class Middleware
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
constraint = Constraint.instance
|
11
|
+
|
12
|
+
if constraint.checker.allowed?(env["REMOTE_ADDR"])
|
13
|
+
@app.call(env)
|
14
|
+
else
|
15
|
+
[404, {'Content-Type' => 'text/html'}, ['Not found!']]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Constraint
|
20
|
+
include Singleton
|
21
|
+
|
22
|
+
def checker
|
23
|
+
@checker ||= IpRestriction::IpChecker.new(IpRestriction::IpsRetriever.new.office_ips)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ip_restriction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Locaweb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-nav
|
@@ -123,7 +123,7 @@ files:
|
|
123
123
|
- lib/ip_restriction/ip_checker.rb
|
124
124
|
- lib/ip_restriction/ip_loader.rb
|
125
125
|
- lib/ip_restriction/ips_retriever.rb
|
126
|
-
- lib/ip_restriction/
|
126
|
+
- lib/ip_restriction/middleware.rb
|
127
127
|
- lib/ip_restriction/version.rb
|
128
128
|
homepage: ''
|
129
129
|
licenses:
|
@@ -145,9 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.4.
|
148
|
+
rubygems_version: 2.4.7
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: Restrict some IPs
|
152
152
|
test_files: []
|
153
|
-
has_rdoc:
|