openvpn-status-web 3.1.0 → 3.2.0

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: 1a94ecc4950275fa2d15151a0854215e75552e2b4eed1fad59b31476fdc3eef0
4
- data.tar.gz: a7bc1ecd1cba15b208de2b5a45786f9bdaa8f2511641adb4437af759ee17a937
3
+ metadata.gz: 8e284e2bfa9af607cc1dcf480aea291452236f17d46f651f1f4a46cbd3366815
4
+ data.tar.gz: 44f59ccf0600b94e28d4be6562aea461543246509e146e60d19f9eaa9b78cdb3
5
5
  SHA512:
6
- metadata.gz: ad621dde6babd84740b376948be7db24e6fcb1ef6c3783fcb7b73bf29577c2caf8e89fd88542de00c03eb68dc837e138b9de23c7c4f568f97652615414f21327
7
- data.tar.gz: a1bfcbc4a2ae0446aa869f362ea4cc9463ef30e6be16198b011bf371d5007b70aaa3c38f7b06e04ef2db4eddc3be790855b3fe17b49d41de67a71626ae23896b
6
+ metadata.gz: c2ecd99b9315c7762718f6a4c09e57eb7bd462bc567749df1b4f49098c8edb9f1d51bcd44baa80ebf4a2251902ddc0fb642a2b8168710ee8456301f86247c2a7
7
+ data.tar.gz: 53769708ca5dddde0a667a20fde4a8453fc4e93bc4a0670872826f8848665e9b8272cdc2039ee67e05787de4d909ca7c8e0732137e37310601301abed4746383
@@ -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>
@@ -11,23 +11,30 @@ module OpenVPNStatusWeb
11
11
 
12
12
  text.lines.each do |line|
13
13
  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'
14
+ status.client_list_headers = parts[2..-1] if parts[0] == 'HEADER' && parts[1] == 'CLIENT_LIST'
15
+ status.client_list << parse_client(parts[1..-1], status.client_list_headers) if parts[0] == 'CLIENT_LIST'
16
+ status.routing_table_headers = parts[2..-1] if parts[0] == 'HEADER' && parts[1] == 'ROUTING_TABLE'
17
+ status.routing_table << parse_route(parts[1..-1], status.routing_table_headers) if parts[0] == 'ROUTING_TABLE'
16
18
  status.global_stats << parse_global(parts[1..2]) if parts[0] == 'GLOBAL_STATS'
17
19
  end
18
20
 
19
21
  status
20
22
  end
21
23
 
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')
24
+ private_class_method def self.parse_client(client, headers)
25
+ headers.each_with_index do |header, i|
26
+ client[i] = parse_date(client[i]) if header.end_with?('Since')
27
+ client[i] = client[i].to_i if header.start_with?('Bytes')
28
+ end
29
+
26
30
  client
27
31
  end
28
32
 
29
- private_class_method def self.parse_route(route)
30
- route[3] = DateTime.strptime(route[3], '%a %b %d %k:%M:%S %Y')
33
+ private_class_method def self.parse_route(route, headers)
34
+ headers.each_with_index do |header, i|
35
+ route[i] = parse_date(route[i]) if header.end_with?('Last Ref')
36
+ end
37
+
31
38
  route
32
39
  end
33
40
 
@@ -35,6 +42,12 @@ module OpenVPNStatusWeb
35
42
  global[1] = global[1].to_i
36
43
  global
37
44
  end
45
+
46
+ private_class_method def self.parse_date(date_string)
47
+ DateTime.strptime(date_string, '%a %b %d %k:%M:%S %Y')
48
+ rescue ArgumentError
49
+ DateTime.strptime(date_string, '%Y-%m-%d %k:%M:%S')
50
+ end
38
51
  end
39
52
  end
40
53
  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.1.0'
4
+ VERSION = '3.2.0'
5
5
  end
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.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Nicolai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-18 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
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.7.0
103
+ version: 0.9.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.7.0
110
+ version: 0.9.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rack-test
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -156,56 +156,56 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.8.1
159
+ version: 1.24.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 1.8.1
166
+ version: 1.24.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rubocop-rake
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 0.5.1
173
+ version: 0.6.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 0.5.1
180
+ version: 0.6.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rubocop-rspec
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 2.1.0
187
+ version: 2.7.0
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 2.1.0
194
+ version: 2.7.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: solargraph
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 0.40.0
201
+ version: 0.44.0
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 0.40.0
208
+ version: 0.44.0
209
209
  description: Small Rack (Ruby) application serving OpenVPN status file.
210
210
  email:
211
211
  executables:
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  - !ruby/object:Gem::Version
249
249
  version: '0'
250
250
  requirements: []
251
- rubygems_version: 3.2.4
251
+ rubygems_version: 3.2.32
252
252
  signing_key:
253
253
  specification_version: 4
254
254
  summary: openvpn-status-web