t-1000 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/t-1000/transaction_list.rb +11 -15
- data/lib/t-1000/version.rb +1 -1
- data/t-1000.gemspec +1 -0
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 679c7af15f2b693f48013cfe9243a7fec52e1608
|
4
|
+
data.tar.gz: 06f237d96b5839a6f00bff7c99e77a4d621cd76a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58b68040942c6220c67ce393689515b57181db2910a02cc58cc282bfcf4f64a768b16ac8862b1fcdab64eda16f7cec6155856ee77eb3e712f07c6afe06957f04
|
7
|
+
data.tar.gz: cf417c864221f132d1e97f284bf1e95cc765a7e2b1d5f452cc524698e9c0079de33a4b09ef02ce83d1c061b30e3eb14753e12f28d30c0ba2aa2b027255e4f970
|
@@ -1,28 +1,27 @@
|
|
1
|
+
require 'enumerable_observer'
|
1
2
|
require 'active_support/cache'
|
2
3
|
|
3
4
|
module T1000
|
4
5
|
class TransactionList < Array
|
6
|
+
include EnumerableObserver
|
5
7
|
|
6
8
|
alias_method :track_before, :dup
|
7
9
|
|
8
|
-
Array.instance_methods(false).each do |meth|
|
9
|
-
old = instance_method(meth)
|
10
|
-
define_method(meth) do |*args, &block|
|
11
|
-
before = to_a
|
12
|
-
old.bind(self).call(*args, &block).tap do
|
13
|
-
changed if before != to_a
|
14
|
-
end
|
15
|
-
end unless %i{to_a}.include? meth
|
16
|
-
end
|
17
|
-
|
18
10
|
def self.for_ip(ip, timeout: 3600)
|
19
11
|
new(ip, timeout: timeout)
|
20
12
|
end
|
21
13
|
|
22
14
|
def initialize(ip, timeout: 3600)
|
23
15
|
@timeout = timeout
|
24
|
-
@key
|
25
|
-
|
16
|
+
@key = ActiveSupport::Cache.expand_cache_key [ip], :ip_request_tracker
|
17
|
+
value = T1000.cache.store.read(@key)
|
18
|
+
replace Marshal.load value if value
|
19
|
+
observe.added do
|
20
|
+
T1000.cache.store.write @key, Marshal.dump(dup), expires_in: @timeout
|
21
|
+
end
|
22
|
+
rescue Exception => e
|
23
|
+
T1000.cache.store.delete @key
|
24
|
+
raise e
|
26
25
|
end
|
27
26
|
|
28
27
|
def within(time)
|
@@ -33,8 +32,5 @@ module T1000
|
|
33
32
|
dup.replace select { |t| t.response.status >= 400 }
|
34
33
|
end
|
35
34
|
|
36
|
-
def changed
|
37
|
-
T1000.cache.store.write @key, self, expires_in: @timeout
|
38
|
-
end
|
39
35
|
end
|
40
36
|
end
|
data/lib/t-1000/version.rb
CHANGED
data/t-1000.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'rack-attack', '~> 4.3'
|
23
23
|
spec.add_dependency 'activesupport', ['>= 3.2', '< 5']
|
24
24
|
spec.add_dependency 'colorize', '~> 0.7'
|
25
|
+
spec.add_dependency 'enumerable_observer'
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.9"
|
27
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: t-1000
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Waldrip
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-attack
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0.7'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: enumerable_observer
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: bundler
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,9 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
148
|
version: '0'
|
135
149
|
requirements: []
|
136
150
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.4.
|
151
|
+
rubygems_version: 2.4.8
|
138
152
|
signing_key:
|
139
153
|
specification_version: 4
|
140
154
|
summary: Rack::Attack + Common attack vectors
|
141
155
|
test_files: []
|
142
|
-
has_rdoc:
|