wafris 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 283b178e632194aa6ff2e0aaaa5e3eca428cacb17a6383a8aa3b57d005c5a316
4
- data.tar.gz: 9ce784b1e57629d072ccc9da4c9e8ec81916dbdcf03c3138e004777e498db4d4
3
+ metadata.gz: 8cbb8c27a7af9771ecf6c07a34fd7da75f4ebacf4fd21dba0b37551a8b2ca2cd
4
+ data.tar.gz: 492a0f193e4c976a612106b5a0bb8c25aa008f170ec8111fa9504bd1cf585faf
5
5
  SHA512:
6
- metadata.gz: 32df667c3fa70c28fb2ea9b298c05ca2542f38d2c6ecee45208e1de6df518c33e6252cce179f2d9a65759fd60093c06909b3aef65068f926405daa07722d6ee8
7
- data.tar.gz: 46722bd780d683360be5382f7b9729067cc1624e12d602caba624629ebb9b88e7e454e23e3231aef98a63087d2824fded586088cbf0d5a6ceff4203fbe0c0385
6
+ metadata.gz: b50f3ad94a373c55285d5e800e55a483f7311a45d18c80d42464931f265edae1bc36a39f97ecf803a99065e5f12b106cc1739cd3716b3219f3a1a60f31b1a6c5
7
+ data.tar.gz: d23d85b065a338c454216d37755ec6d112d4392f9415e7e13df30c4610c96ab58a15a046211332a273cee3da12bdeae2fc3c4f09722239e5cd3b414fa09d4351
@@ -1,4 +1,4 @@
1
- local function get_time_bucket_from_timestamp(unix_time_milliseconds)
1
+ local function get_time_bucket_from_timestamp(unix_time_milliseconds, minutes_flag)
2
2
  local function calculate_years_number_of_days(yr)
3
3
  return (yr % 4 == 0 and (yr % 100 ~= 0 or yr % 400 == 0)) and 366 or 365
4
4
  end
@@ -45,7 +45,12 @@ local function get_time_bucket_from_timestamp(unix_time_milliseconds)
45
45
  local hours = math.floor(unix_time / 3600 % 24)
46
46
  -- local minutes, seconds = math.floor(unix_time / 60 % 60), math.floor(unix_time % 60)
47
47
  -- hours = hours > 12 and hours - 12 or hours == 0 and 12 or hours
48
- return string.format("%04d-%02d-%02d-%02d", year, month, days, hours)
48
+ if minutes_flag == false then
49
+ return string.format("%04d-%02d-%02d-%02d", year, month, days, hours)
50
+ elseif minutes_flag == true then
51
+ local minutes = math.floor(unix_time / 60 % 60)
52
+ return string.format("%04d-%02d-%02d-%02d-%02d", year, month, days, hours, minutes)
53
+ end
49
54
  end
50
55
 
51
56
  -- For: Relationship of IP to time of Request (Stream)
@@ -66,6 +71,17 @@ local function increment_timebucket_for(type, timebucket, property)
66
71
  redis.call("ZINCRBY", type .. "leader-sset:" .. timebucket, 1, property)
67
72
  end
68
73
 
74
+ local function increment_hourly_request_counters(unix_time_milliseconds)
75
+ for i = 1, 60 do
76
+ local timebucket_in_milliseconds = unix_time_milliseconds + 60000 * (i - 1)
77
+ local timebucket = get_time_bucket_from_timestamp(timebucket_in_milliseconds, true)
78
+ local key = "w:v0:hr-ct:" .. timebucket
79
+ redis.call("INCR", key)
80
+ -- Expire the key after 61 minutes if it has no expiry
81
+ redis.call("EXPIRE", key, 3660, "NX")
82
+ end
83
+ end
84
+
69
85
  -- Configuration
70
86
  local max_requests = 100000
71
87
  local max_requests_per_ip = 10000
@@ -80,7 +96,10 @@ local host = ARGV[6]
80
96
 
81
97
  -- Initialize local variables
82
98
  local request_id = get_request_id(nil, client_ip, max_requests)
83
- local current_timebucket = get_time_bucket_from_timestamp(unix_time_milliseconds)
99
+ local current_timebucket = get_time_bucket_from_timestamp(unix_time_milliseconds, false)
100
+
101
+ -- CARD DATA COLLECTION
102
+ increment_hourly_request_counters(unix_time_milliseconds)
84
103
 
85
104
  -- GRAPH DATA COLLECTION
86
105
  add_to_HLL_request_count(current_timebucket, request_id)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wafris
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micahel Buckbee