wafris 0.8.0 → 0.8.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: bc80b768ee486f172f3eb2d617fde7622bff15fca6078819e89ddbae2b112f97
4
- data.tar.gz: 6a2528038d9ca8d278ce2a599051e74803635626ee35a67f224bc531d9fa1d7d
3
+ metadata.gz: 8a2722b928a9589d9a25292b4116200e428fabfbbc7fa7d15e2eaada1a42927a
4
+ data.tar.gz: c3b941f3ed47136b92731e62df8dbb9d47c29d0817bf85e5b974bcd7b01c9ca8
5
5
  SHA512:
6
- metadata.gz: a0401a246649e42b5b2f801dae3ae5b362aca9d42446c45e93f3aa8e1c32e23c63b0e065cc8ae6e5f9131be420090d80d72fa5f1d0e85e9cdb9073036657db3b
7
- data.tar.gz: 2bf8cf0a8b1a0d13e0aef0c8bd08d869c619b3655b68a4de6a631b60f620212d171be294c9edfcb500bdfb1a856dc3e1fe578815e8d2b0ba6aa1ab9a57fb6324
6
+ metadata.gz: 8e52e73b5d385e3a81ee4f5845f50dc00cd52683b595db3e5cb4f47ca7e573d49343525b8c2d6de423f9f189752b82f47acb71240d298b509f1da9b72023313e
7
+ data.tar.gz: b8cb1ccb52d9edc06756f78b277ff4ca2c2c39c94bea68e1e913b74dd620cf8033342759b232cfa086e6cf55f683729258cbb44488eca08f4d821ee751ab1929
@@ -67,7 +67,7 @@ local function add_to_graph_timebucket(timebucket, request_id)
67
67
  local key = wafris_prefix .. "gr-ct:"
68
68
  redis.call("PFADD", key .. timebucket, request_id)
69
69
  -- Expire the key after 25 hours if it has no expiry
70
- redis.call("EXPIRE", key, 90000, "NX")
70
+ redis.call("EXPIRE", key, 90000)
71
71
  end
72
72
 
73
73
  -- For: Leaderboard of IPs with Request count as score
@@ -75,7 +75,7 @@ local function increment_timebucket_for(type, timebucket, property)
75
75
  local key = wafris_prefix .. type .. "lb:" .. timebucket
76
76
  redis.call("ZINCRBY", key, 1, property)
77
77
  -- Expire the key after 25 hours if it has no expiry
78
- redis.call("EXPIRE", key, 90000, "NX")
78
+ redis.call("EXPIRE", key, 90000)
79
79
  end
80
80
 
81
81
  local function increment_partial_hourly_request_counters(unix_time_milliseconds)
@@ -85,7 +85,7 @@ local function increment_partial_hourly_request_counters(unix_time_milliseconds)
85
85
  local key = wafris_prefix .. "hr-ct:" .. timebucket
86
86
  redis.call("INCR", key)
87
87
  -- Expire the key after 61 minutes if it has no expiry
88
- redis.call("EXPIRE", key, 3660, "NX")
88
+ redis.call("EXPIRE", key, 3660)
89
89
  end
90
90
  end
91
91
 
@@ -6,14 +6,22 @@ module Wafris
6
6
  attr_accessor :redis_pool_size
7
7
 
8
8
  def initialize
9
- @redis = Redis.new(
10
- url: ENV['REDIS_URL'],
11
- ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
12
- )
9
+ @redis = set_redis
13
10
  @redis_pool_size = 20
14
11
  set_version
15
12
  end
16
13
 
14
+ def set_redis
15
+ if ENV['REDIS_URL']
16
+ Redis.new(
17
+ url: ENV['REDIS_URL'],
18
+ ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
19
+ )
20
+ else
21
+ Redis.new
22
+ end
23
+ end
24
+
17
25
  def connection_pool
18
26
  @connection_pool ||=
19
27
  ConnectionPool.new(size: redis_pool_size) { redis }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wafris
4
- VERSION = "0.8.0"
4
+ VERSION = "0.8.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wafris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micahel Buckbee