openvpn-status-web 2.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: de8d358e0600c1f0843ff7bccc59bcc4a9ad685b70856509118d8ad6791bb870
4
- data.tar.gz: d38bbd5238e321bdf5814a6c2e998f706e35897fa49f88180cdd4197852c1a42
3
+ metadata.gz: 8e284e2bfa9af607cc1dcf480aea291452236f17d46f651f1f4a46cbd3366815
4
+ data.tar.gz: 44f59ccf0600b94e28d4be6562aea461543246509e146e60d19f9eaa9b78cdb3
5
5
  SHA512:
6
- metadata.gz: e4ce6ce068a55fe4ea2f9ee1815719033458307a476c9106c56fe22bcc65933d32e1b1c34ad42aa0981b6765a63a0842a2953d365554d044bb01734b3a9f04e9
7
- data.tar.gz: b64467e939fde4ea6130d5f868351f9772da39440f1016c65adcaefd90904ba950d5ec16fa235f6343ebdf88260619b73785a4a0b037dcb49abd61c1f4078301
6
+ metadata.gz: c2ecd99b9315c7762718f6a4c09e57eb7bd462bc567749df1b4f49098c8edb9f1d51bcd44baa80ebf4a2251902ddc0fb642a2b8168710ee8456301f86247c2a7
7
+ data.tar.gz: 53769708ca5dddde0a667a20fde4a8453fc4e93bc4a0670872826f8848665e9b8272cdc2039ee67e05787de4d909ca7c8e0732137e37310601301abed4746383
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)](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
 
@@ -57,10 +57,12 @@ For more information about OpenVPN status file and version, see their [man page]
57
57
 
58
58
  If the information exposed is important to you serve it via the VPN or use a webserver as a proxy to handle SSL and/or HTTP authentication.
59
59
 
60
- ### Init scripts
60
+ ### Startup
61
61
 
62
- The [Debian 6 init.d script](init.d/debian-6-openvpn-status-web) assumes that openvpn-status-web is installed into the system ruby (no RVM support) and the config.yaml is at /opt/openvpn-status-web/config.yaml. Modify to your needs.
62
+ There is a [Dockerfile](docs/Dockerfile) that can be used to build a Docker image for running openvpn-status-web.
63
+
64
+ The [Debian 6 init script](docs/debian-init-openvpn-status-web) assumes that openvpn-status-web is installed into the system ruby (no RVM support) and the config.yaml is at `/opt/openvpn-status-web/config.yaml`. Modify to your needs.
63
65
 
64
66
  ## License
65
67
 
66
- openvpn-statsu-web is licensed under the Apache License, Version 2.0. See LICENSE for more information.
68
+ openvpn-status-web is licensed under the Apache License, Version 2.0. See LICENSE for more information.
@@ -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 = '2.1.0'
4
+ VERSION = '3.2.0'
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: 2.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: 2020-03-07 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.6.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.6.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.80.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.80.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:
@@ -176,7 +218,6 @@ files:
176
218
  - LICENSE
177
219
  - README.md
178
220
  - exe/openvpn-status-web
179
- - init.d/debian-6-openvpn-status-web
180
221
  - lib/openvpn-status-web.rb
181
222
  - lib/openvpn-status-web/int_patch.rb
182
223
  - lib/openvpn-status-web/main.html.erb
@@ -200,14 +241,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
241
  requirements:
201
242
  - - ">="
202
243
  - !ruby/object:Gem::Version
203
- version: '2.3'
244
+ version: '2.5'
204
245
  required_rubygems_version: !ruby/object:Gem::Requirement
205
246
  requirements:
206
247
  - - ">="
207
248
  - !ruby/object:Gem::Version
208
249
  version: '0'
209
250
  requirements: []
210
- rubygems_version: 3.0.6
251
+ rubygems_version: 3.2.32
211
252
  signing_key:
212
253
  specification_version: 4
213
254
  summary: openvpn-status-web
@@ -1,40 +0,0 @@
1
- #! /bin/sh
2
- ### BEGIN INIT INFO
3
- # Provides: openvpn-status-web
4
- # Required-Start: $remote_fs $syslog
5
- # Required-Stop: $remote_fs $syslog
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Handle openvpn-status-web gem
9
- ### END INIT INFO
10
-
11
- # using the system ruby's gem binaries directory
12
- DAEMON="/var/lib/gems/1.8/bin/openvpn-status-web"
13
-
14
- CONFIG_FILE="/opt/openvpn-status-web/config.yaml"
15
-
16
- DAEMON_OPTS="$CONFIG_FILE"
17
-
18
- test -x $DAEMON || exit 0
19
-
20
- . /lib/lsb/init-functions
21
-
22
- case "$1" in
23
- start)
24
- log_daemon_msg "Starting openvpn-web-status" "openvpn-web-status"
25
- start-stop-daemon --start --quiet --oknodo --make-pidfile --pidfile "/var/run/openvpn-web-status.pid" --background --exec $DAEMON -- $DAEMON_OPTS
26
- ;;
27
- stop)
28
- log_daemon_msg "Stopping openvpn-web-status" "openvpn-web-status"
29
- start-stop-daemon --stop --quiet --oknodo --pidfile "/var/run/openvpn-web-status.pid"
30
- ;;
31
- restart|force-reload)
32
- log_daemon_msg "Restarting openvpn-web-status" "openvpn-web-status"
33
- start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile "/var/run/openvpn-web-status.pid"
34
- start-stop-daemon --start --quiet --oknodo --make-pidfile --pidfile "/var/run/openvpn-web-status.pid" --background --exec $DAEMON -- $DAEMON_OPTS
35
- ;;
36
- *)
37
- echo "Usage: $0 {start|stop|restart|force-reload}" >&2
38
- exit 1
39
- ;;
40
- esac