nfagent 0.9.28 → 0.9.29
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nfagent.rb +1 -1
- data/lib/nfagent/chunk_handler.rb +10 -3
- data/test/plugins/my_mapper.rb +1 -0
- data/test/test_chunk_handler.rb +13 -0
- metadata +3 -3
data/lib/nfagent.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module NFAgent
|
2
|
+
class LookUpError < StandardError; end
|
3
|
+
class IgnoreLine < StandardError; end
|
4
|
+
|
2
5
|
class ChunkHandler
|
3
6
|
|
4
7
|
attr_accessor :chunk_group
|
@@ -24,9 +27,13 @@ module NFAgent
|
|
24
27
|
parsed = @parser.parse(line)
|
25
28
|
return if parsed.invalid?
|
26
29
|
if Config.mode == 'multi'
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
begin
|
31
|
+
key = MapperProxy.find_account_id(parsed.username, parsed.client_ip)
|
32
|
+
# TODO: Still appending line as string until Server API has been updated
|
33
|
+
return append2(line, key)
|
34
|
+
rescue LookUpError, IgnoreLine
|
35
|
+
return # Do nothing
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
32
39
|
# TODO: rename append2
|
data/test/plugins/my_mapper.rb
CHANGED
data/test/test_chunk_handler.rb
CHANGED
@@ -9,6 +9,7 @@ class TestChunkHandler < ActiveSupport::TestCase
|
|
9
9
|
NFAgent::Plugin.load_plugins
|
10
10
|
@logline = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico dan NONE/- text/html"
|
11
11
|
@logline2 = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico paul NONE/- text/html"
|
12
|
+
@ignored_logline = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico andrew NONE/- text/html"
|
12
13
|
end
|
13
14
|
|
14
15
|
test "append line" do
|
@@ -41,6 +42,18 @@ class TestChunkHandler < ActiveSupport::TestCase
|
|
41
42
|
assert_equal 1, chunk_handler.chunk_group['jetson'].size
|
42
43
|
end
|
43
44
|
|
45
|
+
test "mapper raises ignore line in multi mode" do
|
46
|
+
NFAgent::Config.parse = 'locally'
|
47
|
+
NFAgent::Config.mode = 'multi'
|
48
|
+
NFAgent::Config.mapper = 'MyMapper'
|
49
|
+
chunk_handler = NFAgent::ChunkHandler.new
|
50
|
+
chunk_handler.append(@ignored_logline)
|
51
|
+
assert !chunk_handler.chunk_group.has_key?('acme')
|
52
|
+
assert !chunk_handler.chunk_group.has_key?('jetson')
|
53
|
+
assert chunk_handler.chunk_group['acme'].blank?
|
54
|
+
assert chunk_handler.chunk_group['jetson'].blank?
|
55
|
+
end
|
56
|
+
|
44
57
|
test "reset chunk after expiry in multi mode" do
|
45
58
|
NFAgent::Config.parse = 'locally'
|
46
59
|
NFAgent::Config.mode = 'multi'
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 29
|
9
|
+
version: 0.9.29
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Draper
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-10 00:00:00 +10:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|