liveness 0.3.1 → 0.3.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
  SHA256:
3
- metadata.gz: a4c92cc1b31c6233492d1d20bf9e88b0c6705936aa396119e129ab937f551bc2
4
- data.tar.gz: 8f4dcb1ba03d9d6d2356cba8b825034f72ffb6abb54d55938c81f5e447bacd3a
3
+ metadata.gz: 630199531d58103ad49748b74a839676e701ac9e85efb7f2880f9242b66ae30b
4
+ data.tar.gz: 11efa4ea8d069d8fcd1d132eeaad736b2f3755ee390ea147b40843b68795a202
5
5
  SHA512:
6
- metadata.gz: 45c4011e178e1d9c24d21a06c85f2d96c3bff8571bc9261aefdd728767c5d27703d5860dd019221ab35f3fd86669da635881acc52500588c954204e1e7283519
7
- data.tar.gz: 4fdb7ad22065829414e9942eb94fd9393f54aa106ec57be27d878c8992922a2326d32d8d3735c0874b1edc91e4cf9f021ae26050c3d47805b5529ebd0b66803d
6
+ metadata.gz: 6e22c3008961610bb37e82ece2372c4b66899a0990d93164cdbbc16620e44958fe26571075ac1ade583391a7d13a3f04792efae5a710f3ba14a778e9c520be88
7
+ data.tar.gz: d23c983e988c45bf0a3e4b438c29e72b391c8af559b6f1d448479dbe91a9637c0c0c35de8e7a57eb157720e68f30461ab8f6e6ffd36a76d611d753337c98dba4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liveness (0.3.1)
4
+ liveness (0.3.2)
5
5
  rack (>= 1.0)
6
6
 
7
7
  GEM
@@ -7,6 +7,10 @@ module Liveness
7
7
  #
8
8
  # @since 0.3.0
9
9
  class Access
10
+ # @since 0.3.2
11
+ LOCAL_IPV4 = IPAddr.new('127.0.0.1')
12
+ LOCAL_IPV6 = IPAddr.new('::1')
13
+
10
14
  # @param request [Rack::Request]
11
15
  # @param config [Liveness::Config]
12
16
  #
@@ -22,7 +26,7 @@ module Liveness
22
26
  #
23
27
  # @since 0.3.0
24
28
  def allowed?
25
- whitelist? && valid_token?
29
+ local? || (whitelist? && valid_token?)
26
30
  end
27
31
 
28
32
  # Is token valid
@@ -36,6 +40,15 @@ module Liveness
36
40
  @config.token == @request.params['token']
37
41
  end
38
42
 
43
+ # Is from localhost
44
+ #
45
+ # @return [Boolean]
46
+ #
47
+ # @since 0.3.2
48
+ def local?
49
+ LOCAL_IPV4.include?(@request.ip) || LOCAL_IPV6.include?(@request.ip)
50
+ end
51
+
39
52
  # Is ip in whitelist
40
53
  #
41
54
  # @return [Boolean]
@@ -43,8 +56,6 @@ module Liveness
43
56
  # @sicne 0.3.0
44
57
  def whitelist?
45
58
  return true if @config.ip_whitelist.empty?
46
- return true if IPAddr.new('127.0.0.1').include?(@request.ip)
47
- return true if IPAddr.new('::1').include?(@request.ip)
48
59
 
49
60
  @config
50
61
  .ip_whitelist
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Liveness
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liveness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也