rack-dedos 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 499458581f04fa158a8cd0bfb41068b72c41e0d33c0a4321aeaa123a66af7c53
4
- data.tar.gz: 22777d21fa4db1beb2571792683835780a561dd466c366803212b88a5e828711
3
+ metadata.gz: a6136473af715369f93cdd16ed44fbbbdc241ee0efa1c7743a5590735ec5d392
4
+ data.tar.gz: cd541b5cfb7cd9dfdb4262670d8190bf942215a65e6a984e48e9e7e7f7db1f6c
5
5
  SHA512:
6
- metadata.gz: 889de2da536b7376f39e901caa59e78fb3a59faffd3dddb833051dafe8fae40199d31125ea1c5595480df4cb85cfb61edeb0e3a224335e0a512a503c5275121f
7
- data.tar.gz: 22c1060501f2c686b8ad0f499e9ffd366d99640aedcc40f84ac94208ed6e5a917c03e3ad82ae0583705306bb6d9ca09a350e82c838466dbc34316bc24560ff34
6
+ metadata.gz: caf872690a89e1e502974fa7560a5e5aa6499545a213cb82b2e03b788cda2075822ae1a8be23e23ff67a220087d56c6fa6d76a7388d6b4887c8f0a6e51f10f0c
7
+ data.tar.gz: 14a31dd383c251c9333968744c91ebb9833e7dc501b68db2cda7e2c1c10b4f44090dafbdb1edf1de1f9042dba0338c44279852478a48a1bbd1a5394b05078b4a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Nothing so far
4
4
 
5
+ ## 0.4.1
6
+
7
+ ### Fixes
8
+ * Correctly include details in warnings (i.e. country code)
9
+
5
10
  ## 0.4.0
6
11
 
7
12
  ### Changes
@@ -12,12 +12,14 @@ module Rack
12
12
 
13
13
  attr_reader :app
14
14
  attr_reader :options
15
+ attr_reader :details
15
16
 
16
17
  # @param app [#call]
17
18
  # @param options [Hash{Symbol => Object}]
18
19
  def initialize(app, options = {})
19
20
  @app = app
20
21
  @options = DEFAULT_OPTIONS.merge(options)
22
+ @details = nil
21
23
  end
22
24
 
23
25
  def call(env)
@@ -26,7 +28,8 @@ module Rack
26
28
  if allowed?(request, ip)
27
29
  app.call(env)
28
30
  else
29
- warn("rack-dedos: request from #{ip} blocked by #{self.class} `#{@country_code.inspect}'")
31
+ message = "rack-dedos: request from #{ip} blocked by #{self.class}"
32
+ warn([message, details].compact.join(": "))
30
33
  [options[:status], { 'Content-Type' => 'text/plain' }, [options[:text]]]
31
34
  end
32
35
  end
@@ -23,7 +23,7 @@ module Rack
23
23
 
24
24
  def allowed?(request, ip)
25
25
  if country = maxmind_db&.get(ip)
26
- country_code = country.dig('country', 'iso_code').to_sym
26
+ country_code = @details = country.dig('country', 'iso_code').to_sym
27
27
  @countries.include?(country_code) ? @allowed : !@allowed
28
28
  else # not found in database
29
29
  true
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  module Dedos
5
- VERSION = "0.4.0"
5
+ VERSION = "0.4.1"
6
6
  end
7
7
  end
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn