rack-dedos 0.7.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -4
- data/README.md +12 -1
- data/lib/rack/dedos/filters/base.rb +4 -14
- data/lib/rack/dedos/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a08f36618682f6ea88356457ae136dd78a470598e8254f537a56952435baf744
|
|
4
|
+
data.tar.gz: 4c24311d19a2bc7e8be8593b43022b35569a00ffe9a8293dd08df614afa50809
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4ffc6eaf1591ccd9359f5df317e72f67fbd08bcfd0df2c06389c468e4f41292afe922b4ed81e6b4fe2094a6931824b5baf8d982e1deafc79604d3d57a44931f
|
|
7
|
+
data.tar.gz: d15648fe182352df2979a8c0307ba9bcdf2c481e356e97e080fc892d870422aa8a9eedf974f25095db66026b534e167d6c8039bbabc0c374e5d8dc11d9dce20d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
## Main
|
|
2
|
-
|
|
3
|
-
Nothing so far
|
|
4
|
-
|
|
5
1
|
# Changelog
|
|
6
2
|
|
|
7
3
|
All notable changes to this project will be documented in this file.
|
|
@@ -13,6 +9,12 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
|
|
|
13
9
|
|
|
14
10
|
Nothing so far
|
|
15
11
|
|
|
12
|
+
## [1.0.0] - 2026-11-22
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **Breaking:** Modify the real IP detection added in [0.2.0]: If the default `request.ip` reported by Rack doesn't return the real IP, either use `Rack::Request.ip_filter` to fix it or pass the real IP of the connecting party explicitly (see README). `CF-Connecting-IP` and `X-Forwarded-For` headers are no longer consulted to prevent bypassing the filters by forging those.
|
|
17
|
+
|
|
16
18
|
## [0.7.3] - 2026-06-26
|
|
17
19
|
|
|
18
20
|
### Changed
|
data/README.md
CHANGED
|
@@ -92,9 +92,20 @@ end
|
|
|
92
92
|
|
|
93
93
|
Given the drastic nature of the filters, you should use this middleware for production environments only and/or if an environment variable like `UNDER_ATTACK` is set to true.
|
|
94
94
|
|
|
95
|
+
### Real IP
|
|
96
|
+
|
|
97
|
+
By default, `request.ip` provided by Rack is used to figure out the IP of the connecting client. Depending on the web framework you use or reverse proxies such as Cloudflare, this value might not contain the correct IP address.
|
|
98
|
+
|
|
99
|
+
However, it is possible to override this default behavior. Rails' Action Dispatch for instance determines `remote_ip` using its own mechanism. You can use this value instead with:
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
use Rack::Dedos,
|
|
103
|
+
ip: ->(request) { request.env['action_dispatch.remote_ip'].to_s }
|
|
104
|
+
```
|
|
105
|
+
|
|
95
106
|
### Request
|
|
96
107
|
|
|
97
|
-
By default, filters are applied to all request paths. You can
|
|
108
|
+
By default, filters are applied to all request paths. You can narrow this to only certain matching request paths:
|
|
98
109
|
|
|
99
110
|
```ruby
|
|
100
111
|
use Rack::Dedos,
|
|
@@ -8,6 +8,7 @@ module Rack
|
|
|
8
8
|
class Base
|
|
9
9
|
|
|
10
10
|
DEFAULT_OPTIONS = {
|
|
11
|
+
ip: nil,
|
|
11
12
|
logger: nil,
|
|
12
13
|
cache_url: 'Hash',
|
|
13
14
|
cache_key_prefix: nil,
|
|
@@ -61,22 +62,11 @@ module Rack
|
|
|
61
62
|
|
|
62
63
|
# Get the real IP of the client
|
|
63
64
|
#
|
|
64
|
-
# If containers and/or proxies such as Cloudflare are in the mix, the
|
|
65
|
-
# client IP reported by Rack may be wrong. Therefore, we determine the
|
|
66
|
-
# real client IP using the following priorities:
|
|
67
|
-
#
|
|
68
|
-
# 1. Cf-Connecting-Ip header
|
|
69
|
-
# 2. X-Forwarded-For header (also remove port number)
|
|
70
|
-
# 3. IP reported by Rack
|
|
71
|
-
#
|
|
72
65
|
# @param request [Rack::Request]
|
|
73
|
-
# @return [String]
|
|
66
|
+
# @return [String] IP
|
|
74
67
|
def real_ip(request)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
ip
|
|
78
|
-
when forwarded_for = request.forwarded_for
|
|
79
|
-
forwarded_for.split(/\s*,\s*/).first&.sub(/:\d+$/, '')
|
|
68
|
+
if (callable = @options[:ip]).respond_to? :call
|
|
69
|
+
callable.call(request)
|
|
80
70
|
else
|
|
81
71
|
request.ip
|
|
82
72
|
end
|
data/lib/rack/dedos/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rack-dedos
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sven Schwyn
|
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
183
183
|
- !ruby/object:Gem::Version
|
|
184
184
|
version: '0'
|
|
185
185
|
requirements: []
|
|
186
|
-
rubygems_version: 4.0.
|
|
186
|
+
rubygems_version: 4.0.20
|
|
187
187
|
specification_version: 4
|
|
188
188
|
summary: Radical filters to block denial-of-service (DoS) requests.
|
|
189
189
|
test_files: []
|