openvpn-status-web 3.0.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bc46be9230486ffade1bc6234b86386fe6db50a060345a3dd87089272741e0c
4
- data.tar.gz: cdedbe66c9eeff9332c561b77c3be0ed10262e01b9feff23889b98a02a4cd77a
3
+ metadata.gz: ed1ab5c8bba8d386ca3f0e0f510a08983736a3824bec903d58022febe0fd4192
4
+ data.tar.gz: 6f8499f9bea2da379cb9b6fd9505cdc285c227d93b3ea0edb099753e5cd4023f
5
5
  SHA512:
6
- metadata.gz: 1702733dfbe5dca5fbd0803a3cfb80822152e65d9b59b196af560d311d596aa7fb59472a3c52dcf6a1ed1ae4a02de9742cd4ad7ba8eea298fe6205321dd43da5
7
- data.tar.gz: ac21793e1ebc175f3d8372fbcbf229593fe2b2dcc3d5bf863cf8ce761c94deeae4472ddf1805e8482fdfee17a4c50c58c4aebdc8146f4f46025eb6d6558c23b5
6
+ metadata.gz: 6f0d1ca61055f892765b66a59fb75e5675c63dceccc0c1a473aaebfa23b7aed8c1e24ee6fd05bf4e285fea7158977b1ce2902e0ff6c771131bbd9ccee1021aa8
7
+ data.tar.gz: df069649086305a98fa28e935504a18cb37ca561b94090ab169d67db9340cacfe1dca1b6c2ef79870af8603837a9ab3a5c2f0902f361fcfb2d2697592a50ced8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # openvpn-status-web
2
2
 
3
- [![Build Status](https://travis-ci.org/cmur2/openvpn-status-web.svg?branch=master)](https://travis-ci.org/cmur2/openvpn-status-web) [![Depfu](https://badges.depfu.com/badges/c264e2f70f2a19c43f880ddcb4a12ba8/overview.svg)](https://depfu.com/github/cmur2/openvpn-status-web?project_id=6194)
3
+ ![ci](https://github.com/cmur2/openvpn-status-web/workflows/ci/badge.svg) [![Depfu](https://badges.depfu.com/badges/c264e2f70f2a19c43f880ddcb4a12ba8/overview.svg)](https://depfu.com/github/cmur2/openvpn-status-web?project_id=6194)
4
4
 
5
5
  ## Description
6
6
 
@@ -50,20 +50,36 @@ thead {
50
50
  <div>
51
51
  <table>
52
52
  <thead>
53
- <td class="first">Common Name</td>
54
- <td class="middle">Real Address</td>
55
- <td class="middle">Data Received</td>
56
- <td class="middle">Data Sent</td>
57
- <td class="last">Connected Since</td>
53
+ <% status.client_list_headers.each_with_index do |header,i| %>
54
+ <% if i == 0 %>
55
+ <td class="first">
56
+ <% elsif i == status.client_list_headers.size-1 %>
57
+ <td class="last">
58
+ <% else %>
59
+ <td class="middle">
60
+ <% end %>
61
+ <%= header %></td>
62
+ <% end %>
58
63
  </thead>
59
64
  <tbody>
60
65
  <% status.client_list.each do |client| %>
61
66
  <tr>
62
- <td class="first"><%= client[0] %></td>
63
- <td class="middle"><%= client[1] %></td>
64
- <td class="middle"><%= client[2].to_i.as_bytes %></td>
65
- <td class="middle"><%= client[3].to_i.as_bytes %></td>
66
- <td class="last"><%= client[4].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
67
+ <% status.client_list_headers.each_with_index do |header,i| %>
68
+ <% if i == 0 %>
69
+ <td class="first">
70
+ <% elsif i == status.client_list_headers.size-1 %>
71
+ <td class="last">
72
+ <% else %>
73
+ <td class="middle">
74
+ <% end %>
75
+ <% if header =~ /(Received|Sent)/ %>
76
+ <%= client[i].as_bytes %></td>
77
+ <% elsif client[i].is_a? DateTime %>
78
+ <%= client[i].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
79
+ <% else %>
80
+ <%= client[i] %></td>
81
+ <% end %>
82
+ <% end %>
67
83
  </tr>
68
84
  <% end %>
69
85
  </tbody>
@@ -74,18 +90,34 @@ thead {
74
90
  <div>
75
91
  <table>
76
92
  <thead>
77
- <td class="first">Virtual Address</td>
78
- <td class="middle">Common Name</td>
79
- <td class="middle">Real Address</td>
80
- <td class="last">Last Ref</td>
93
+ <% status.routing_table_headers.each_with_index do |header,i| %>
94
+ <% if i == 0 %>
95
+ <td class="first">
96
+ <% elsif i == status.routing_table_headers.size-1 %>
97
+ <td class="last">
98
+ <% else %>
99
+ <td class="middle">
100
+ <% end %>
101
+ <%= header %></td>
102
+ <% end %>
81
103
  </thead>
82
104
  <tbody>
83
105
  <% status.routing_table.each do |route| %>
84
106
  <tr>
85
- <td class="first"><%= route[0] %></td>
86
- <td class="middle"><%= route[1] %></td>
87
- <td class="middle"><%= route[2] %></td>
88
- <td class="last"><%= route[3].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
107
+ <% status.routing_table_headers.each_with_index do |header,i| %>
108
+ <% if i == 0 %>
109
+ <td class="first">
110
+ <% elsif i == status.routing_table_headers.size-1 %>
111
+ <td class="last">
112
+ <% else %>
113
+ <td class="middle">
114
+ <% end %>
115
+ <% if route[i].is_a? DateTime %>
116
+ <%= route[i].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
117
+ <% else %>
118
+ <%= route[i] %></td>
119
+ <% end %>
120
+ <% end %>
89
121
  </tr>
90
122
  <% end %>
91
123
  </tbody>
@@ -5,29 +5,38 @@ module OpenVPNStatusWeb
5
5
  class ModernStateless
6
6
  def self.parse_status_log(text, sep)
7
7
  status = Status.new
8
+ status.client_list_headers = []
8
9
  status.client_list = []
10
+ status.routing_table_headers = []
9
11
  status.routing_table = []
10
12
  status.global_stats = []
11
13
 
12
14
  text.lines.each do |line|
13
15
  parts = line.strip.split(sep)
14
- status.client_list << parse_client(parts[1..5]) if parts[0] == 'CLIENT_LIST'
15
- status.routing_table << parse_route(parts[1..4]) if parts[0] == 'ROUTING_TABLE'
16
+ status.client_list_headers = parts[2..-1] if parts[0] == 'HEADER' && parts[1] == 'CLIENT_LIST'
17
+ status.client_list << parse_client(parts[1..-1], status.client_list_headers) if parts[0] == 'CLIENT_LIST'
18
+ status.routing_table_headers = parts[2..-1] if parts[0] == 'HEADER' && parts[1] == 'ROUTING_TABLE'
19
+ status.routing_table << parse_route(parts[1..-1], status.routing_table_headers) if parts[0] == 'ROUTING_TABLE'
16
20
  status.global_stats << parse_global(parts[1..2]) if parts[0] == 'GLOBAL_STATS'
17
21
  end
18
22
 
19
23
  status
20
24
  end
21
25
 
22
- private_class_method def self.parse_client(client)
23
- client[2] = client[2].to_i
24
- client[3] = client[3].to_i
25
- client[4] = DateTime.strptime(client[4], '%a %b %d %k:%M:%S %Y')
26
+ private_class_method def self.parse_client(client, headers)
27
+ headers.each_with_index do |header, i|
28
+ client[i] = parse_date(client[i]) if header.end_with?('Since')
29
+ client[i] = client[i].to_i if header.start_with?('Bytes')
30
+ end
31
+
26
32
  client
27
33
  end
28
34
 
29
- private_class_method def self.parse_route(route)
30
- route[3] = DateTime.strptime(route[3], '%a %b %d %k:%M:%S %Y')
35
+ private_class_method def self.parse_route(route, headers)
36
+ headers.each_with_index do |header, i|
37
+ route[i] = parse_date(route[i]) if header.end_with?('Last Ref')
38
+ end
39
+
31
40
  route
32
41
  end
33
42
 
@@ -35,6 +44,12 @@ module OpenVPNStatusWeb
35
44
  global[1] = global[1].to_i
36
45
  global
37
46
  end
47
+
48
+ private_class_method def self.parse_date(date_string)
49
+ DateTime.strptime(date_string, '%a %b %d %k:%M:%S %Y')
50
+ rescue ArgumentError
51
+ DateTime.strptime(date_string, '%Y-%m-%d %k:%M:%S')
52
+ end
38
53
  end
39
54
  end
40
55
  end
@@ -26,7 +26,9 @@ module OpenVPNStatusWeb
26
26
  end
27
27
 
28
28
  status = Status.new
29
+ status.client_list_headers = ['Common Name', 'Real Address', 'Data Received', 'Data Sent', 'Connected Since']
29
30
  status.client_list = client_list[2..-1].map { |client| parse_client(client) }
31
+ status.routing_table_headers = ['Virtual Address', 'Common Name', 'Real Address', 'Last Ref']
30
32
  status.routing_table = routing_table[1..-1].map { |route| parse_route(route) }
31
33
  status.global_stats = global_stats.map { |global| parse_global(global) }
32
34
  status
@@ -2,7 +2,9 @@
2
2
 
3
3
  module OpenVPNStatusWeb
4
4
  class Status
5
+ attr_accessor :client_list_headers
5
6
  attr_accessor :client_list
7
+ attr_accessor :routing_table_headers
6
8
  attr_accessor :routing_table
7
9
  attr_accessor :global_stats
8
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenVPNStatusWeb
4
- VERSION = '3.0.0'
4
+ VERSION = '3.2.1'
5
5
  end
@@ -107,7 +107,7 @@ module OpenVPNStatusWeb
107
107
  if config['logfile']
108
108
  OpenVPNStatusWeb.logger = Logger.new(config['logfile'])
109
109
  else
110
- OpenVPNStatusWeb.logger = Logger.new(STDOUT)
110
+ OpenVPNStatusWeb.logger = Logger.new($stdout)
111
111
  end
112
112
 
113
113
  OpenVPNStatusWeb.logger.progname = 'openvpn-status-web'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openvpn-status-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Nicolai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-14 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metriks
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webrick
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: better_errors
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +100,14 @@ dependencies:
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 0.7.0
103
+ version: 0.9.0
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 0.7.0
110
+ version: 0.9.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rack-test
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -142,28 +156,56 @@ dependencies:
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: 0.88.0
159
+ version: 1.24.0
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 0.88.0
166
+ version: 1.24.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-rake
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.6.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.6.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-rspec
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 2.7.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 2.7.0
153
195
  - !ruby/object:Gem::Dependency
154
196
  name: solargraph
155
197
  requirement: !ruby/object:Gem::Requirement
156
198
  requirements:
157
- - - ">="
199
+ - - "~>"
158
200
  - !ruby/object:Gem::Version
159
- version: '0'
201
+ version: 0.44.0
160
202
  type: :development
161
203
  prerelease: false
162
204
  version_requirements: !ruby/object:Gem::Requirement
163
205
  requirements:
164
- - - ">="
206
+ - - "~>"
165
207
  - !ruby/object:Gem::Version
166
- version: '0'
208
+ version: 0.44.0
167
209
  description: Small Rack (Ruby) application serving OpenVPN status file.
168
210
  email:
169
211
  executables:
@@ -206,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
248
  - !ruby/object:Gem::Version
207
249
  version: '0'
208
250
  requirements: []
209
- rubygems_version: 3.0.8
251
+ rubygems_version: 3.2.32
210
252
  signing_key:
211
253
  specification_version: 4
212
254
  summary: openvpn-status-web