haproxy_log_parser 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -15,6 +15,11 @@ module HAProxyLogParser
15
15
  # @return [String]
16
16
  attr_accessor :frontend_name
17
17
 
18
+ # @return [String]
19
+ # '~' if SSL, '' otherwise (HAProxy 1.5 adds a '~' suffix to the frontend
20
+ # name if request went through SSL)
21
+ attr_accessor :transport_mode
22
+
18
23
  # @return [String]
19
24
  attr_accessor :backend_name
20
25
 
@@ -80,5 +85,10 @@ module HAProxyLogParser
80
85
 
81
86
  # @return [String]
82
87
  attr_accessor :http_request
88
+
89
+ # return [true, false] true if and only if request was SSL
90
+ def ssl?
91
+ @transport_mode == '~'
92
+ end
83
93
  end
84
94
  end
@@ -4,7 +4,7 @@ module HAProxyLogParser
4
4
  syslog_portion:([^\[]+ '[' integer ']: ')
5
5
  client_ip:ip4_address ':' client_port:integer ' '
6
6
  '[' accept_date '] '
7
- frontend_name:proxy_name ' '
7
+ frontend_name:proxy_name transport_mode:'~'? ' '
8
8
  backend_name:proxy_name '/' server_name ' '
9
9
  tq:integer '/' tw:integer '/' tc:integer '/' tr:integer '/' tt:integer ' '
10
10
  status_code:integer ' '
@@ -21,8 +21,8 @@ module HAProxyLogParser
21
21
 
22
22
  entry = Entry.new
23
23
  [
24
- :client_ip, :frontend_name, :backend_name, :server_name,
25
- :termination_state
24
+ :client_ip, :frontend_name, :transport_mode,
25
+ :backend_name, :server_name, :termination_state
26
26
  ].each do |field|
27
27
  entry.send("#{field}=", result.send(field).text_value)
28
28
  end
@@ -11,6 +11,7 @@ describe HAProxyLogParser do
11
11
  entry.client_port.should == 34028
12
12
  entry.accept_date.should == Time.local(2011, 8, 9, 20, 30, 46, 429)
13
13
  entry.frontend_name.should == 'proxy-out'
14
+ expect(entry).to be_ssl
14
15
  entry.backend_name.should == 'proxy-out'
15
16
  entry.server_name.should == 'cache1'
16
17
  entry.tq.should == 1
@@ -41,6 +42,7 @@ describe HAProxyLogParser do
41
42
  entry.client_port.should == 50679
42
43
  entry.accept_date.should == Time.local(2012, 5, 21, 1, 35, 46, 146)
43
44
  entry.frontend_name.should == 'webapp'
45
+ expect(entry).to_not be_ssl
44
46
  entry.backend_name.should == 'webapp_backend'
45
47
  entry.server_name.should == 'web09'
46
48
  entry.tq.should == 27
data/spec/sample.log CHANGED
@@ -1,2 +1,2 @@
1
- Aug 9 20:30:46 localhost haproxy[2022]: 10.0.8.2:34028 [09/Aug/2011:20:30:46.429] proxy-out proxy-out/cache1 1/0/2/126/+128 301 +223 - - ---- 617/523/336/168/0 0/0 {www.sytadin.equipement.gouv.fr||http://trafic.1wt.eu/} {Apache|230|||http://www.sytadin.} "GET http://www.sytadin.equipement.gouv.fr/ HTTP/1.1"
1
+ Aug 9 20:30:46 localhost haproxy[2022]: 10.0.8.2:34028 [09/Aug/2011:20:30:46.429] proxy-out~ proxy-out/cache1 1/0/2/126/+128 301 +223 - - ---- 617/523/336/168/0 0/0 {www.sytadin.equipement.gouv.fr||http://trafic.1wt.eu/} {Apache|230|||http://www.sytadin.} "GET http://www.sytadin.equipement.gouv.fr/ HTTP/1.1"
2
2
  May 21 01:35:46 10.18.237.5 haproxy[26747]: 192.168.1.215:50679 [21/May/2012:01:35:46.146] webapp webapp_backend/web09 27/0/1/0/217 200 1367 session=abc session=xyz ---- 600/529/336/158/0 0/0 {#7C#7C #7B5F41#7D|http://google.com/|} {1270925568||} "GET /images/image.gif HTTP/1.1"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haproxy_log_parser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Toby Hsieh
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-19 00:00:00 -08:00
18
+ date: 2013-09-23 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency