x-real-ip 0.1.2 → 0.2.0

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: cf291cf813934ff5cea79959fccb44d84318d1e3
4
- data.tar.gz: dea854479ed1c78e8b928abd4b9c57286b176152
3
+ metadata.gz: 40dcab19213ac6ec705d3cfd3de76f6e78ed7d32
4
+ data.tar.gz: fd2e8c28946aad55514a85d930e142c3716b703d
5
5
  SHA512:
6
- metadata.gz: fea58c026d438d9b6166dbc89f2db035bec441b3659aac781e11a0d670eaf289a71540e7cef885d5878b8ebf59a6931e918dc2879ea9aa488a41559cb7c4b76d
7
- data.tar.gz: 614fc853b2beb3cfec20993faaf87f05b130afcb25810a851dbc29367ad2b2a2230650f8fc92d24accabccb872382958f53cf6d726383a500a0f2ed392fe7c29
6
+ metadata.gz: cd0f3def36a4139b095a9e7d19caf1e1cc0c17f478111fb42c551b648c80bbacae95e49fe44a43247f95edbab79ce2e36096aebd4cb282e853fbcd18a7a0d54a
7
+ data.tar.gz: 91fad53ba60d914d54ab1ed26500905998094f762252b7ebfc55175934c1e54dd3f0938e8421068372b1c39de4dc33f6e07216c280913dee71be02d5f16b265e
@@ -1 +1 @@
1
- 2.0.0-p353
1
+ 2.1.2
data/README.md CHANGED
@@ -20,6 +20,29 @@ Or install it yourself as:
20
20
 
21
21
  For rails just add it to Gemfile
22
22
 
23
+ For rack/sinatra
24
+
25
+ use XRealIp::Middleware
26
+
27
+ Or in Rack::Builder like this:
28
+
29
+ app = Rack::Builder.new do
30
+ use XRealIp::Middleware
31
+ use Raven::Rack
32
+ map '/serve' do
33
+ run Serve.new
34
+ end
35
+ map '/' do
36
+ run App.new
37
+ end
38
+ end
39
+
40
+ run app
41
+
42
+ ## Credits
43
+
44
+ Some ideas from https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/remote_ip.rb
45
+
23
46
  ## Contributing
24
47
 
25
48
  1. Fork it
@@ -1,18 +1,21 @@
1
1
  require "x-real-ip/version"
2
- require "rpatricia"
3
2
  require "ipaddr"
3
+ # todo rails 4.2
4
+ #require 'action_dispatch/middleware/remote_ip'
4
5
  require "active_support/core_ext/module/attribute_accessors"
5
6
 
6
7
  module XRealIp
7
- mattr_accessor :trusted4, :trusted6
8
- self.trusted4 = Patricia.new()
9
- %w(10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 127.0.0.0/8).each do |a|
10
- self.trusted4.add(a)
11
- end
12
- self.trusted6 = Patricia.new(:AF_INET6)
13
- %w(::1/128).each do |a|
14
- self.trusted6.add(a)
15
- end
8
+ mattr_accessor :trusted
9
+ # todo rails 4.2
10
+ #self.trusted = ActionDispatch::RemoteIp::TRUSTED_PROXIES
11
+ self.trusted = [
12
+ "127.0.0.1", # localhost IPv4
13
+ "::1", # localhost IPv6
14
+ "fc00::/7", # private IPv6 range fc00::/7
15
+ "10.0.0.0/8", # private IPv4 range 10.x.x.x
16
+ "172.16.0.0/12", # private IPv4 range 172.16.0.0 .. 172.31.255.255
17
+ "192.168.0.0/16", # private IPv4 range 192.168.x.x
18
+ ].map { |proxy| IPAddr.new(proxy) }
16
19
  end
17
20
 
18
21
  require "x-real-ip/railtie" if defined? Rails
@@ -6,13 +6,9 @@ module XRealIp
6
6
 
7
7
  def is_trusted?(str)
8
8
  ip = IPAddr.new(str)
9
- if ip.ipv4?
10
- XRealIp.trusted4.include?(ip.to_s)
11
- else
12
- XRealIp.trusted6.include?(ip.to_s)
13
- end
9
+ XRealIp.trusted.any? { |proxy| proxy === ip }
14
10
  end
15
-
11
+
16
12
  def call(env)
17
13
  real_ips = env["HTTP_X_REAL_IP"]
18
14
  if real_ips
@@ -52,4 +48,4 @@ module XRealIp
52
48
  @app.call(env)
53
49
  end
54
50
  end
55
- end
51
+ end
@@ -1,3 +1,4 @@
1
1
  module XRealIp
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
4
+
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
3
 
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  require 'spec_helper'
3
2
 
4
3
  describe 'X-Forwarded-For' do
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  require 'spec_helper'
3
2
 
4
3
  describe XRealIp do
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'x-real-ip/version'
@@ -9,7 +8,7 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["55ideas"]
10
9
  spec.email = ["info@55ideas.ru"]
11
10
  spec.description = %q{Replace REMOTE_IP with X-Real-Ip if it's trusted (useful for Nginx)}
12
- spec.summary = %q{Replace REMOTE_IP with X-Real-Ip if it's trusted (useful for Nginx)}
11
+ spec.summary = %q{}
13
12
  spec.homepage = "https://github.com/55ideas/x-real-ip"
14
13
  spec.license = "MIT"
15
14
 
@@ -18,11 +17,13 @@ Gem::Specification.new do |spec|
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ["lib"]
20
19
 
21
- spec.add_dependency "rpatricia", "~> 1.0"
22
20
  spec.add_dependency "rack"
21
+ # todo rails 4.2
22
+ #spec.add_dependency 'actionpack'
23
23
  spec.add_dependency "activesupport"
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
26
  spec.add_development_dependency "rake"
27
- spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "rspec", '~> 2.14'
28
28
  end
29
+
metadata CHANGED
@@ -1,99 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: x-real-ip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 55ideas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-01 00:00:00.000000000 Z
11
+ date: 2014-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rpatricia
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rack
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - '>='
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
19
  version: '0'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - '>='
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: activesupport
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - '>='
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
33
  version: '0'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - '>='
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ~>
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1.3'
47
+ version: '1.7'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ~>
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '1.3'
54
+ version: '1.7'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - '>='
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
61
  version: '0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - '>='
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - '>='
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: '2.14'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - '>='
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '2.14'
97
83
  description: Replace REMOTE_IP with X-Real-Ip if it's trusted (useful for Nginx)
98
84
  email:
99
85
  - info@55ideas.ru
@@ -101,9 +87,9 @@ executables: []
101
87
  extensions: []
102
88
  extra_rdoc_files: []
103
89
  files:
104
- - .gitignore
105
- - .ruby-gemset
106
- - .ruby-version
90
+ - ".gitignore"
91
+ - ".ruby-gemset"
92
+ - ".ruby-version"
107
93
  - Gemfile
108
94
  - LICENSE.txt
109
95
  - README.md
@@ -126,20 +112,20 @@ require_paths:
126
112
  - lib
127
113
  required_ruby_version: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - '>='
115
+ - - ">="
130
116
  - !ruby/object:Gem::Version
131
117
  version: '0'
132
118
  required_rubygems_version: !ruby/object:Gem::Requirement
133
119
  requirements:
134
- - - '>='
120
+ - - ">="
135
121
  - !ruby/object:Gem::Version
136
122
  version: '0'
137
123
  requirements: []
138
124
  rubyforge_project:
139
- rubygems_version: 2.1.11
125
+ rubygems_version: 2.2.2
140
126
  signing_key:
141
127
  specification_version: 4
142
- summary: Replace REMOTE_IP with X-Real-Ip if it's trusted (useful for Nginx)
128
+ summary: ''
143
129
  test_files:
144
130
  - spec/spec_helper.rb
145
131
  - spec/x_forwarded_for_spec.rb