openvpn-status-web 1.0.1 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +6 -4
- data/{bin → exe}/openvpn-status-web +2 -0
- data/lib/openvpn-status-web.rb +48 -27
- data/lib/openvpn-status-web/int_patch.rb +8 -7
- data/lib/openvpn-status-web/parser/modern_stateless.rb +7 -8
- data/lib/openvpn-status-web/parser/v1.rb +2 -1
- data/lib/openvpn-status-web/parser/v2.rb +2 -1
- data/lib/openvpn-status-web/parser/v3.rb +2 -1
- data/lib/openvpn-status-web/status.rb +1 -0
- data/lib/openvpn-status-web/version.rb +2 -1
- metadata +101 -81
- data/.gitignore +0 -3
- data/.travis.yml +0 -8
- data/Gemfile +0 -3
- data/Rakefile +0 -6
- data/examples/status.v1 +0 -14
- data/examples/status.v2 +0 -12
- data/examples/status.v3 +0 -12
- data/init.d/debian-6-openvpn-status-web +0 -40
- data/openvpn-status-web.gemspec +0 -32
- data/spec/parser/modern_stateless_spec.rb +0 -55
- data/spec/parser/v1_spec.rb +0 -50
- data/spec/spec_helper.rb +0 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8eef6ed771ba70fb929815f28a96b966ae2fcba4147deff48b634249a6a2421d
|
4
|
+
data.tar.gz: 8d2ac5e84f30d8e8fc78c49425db1b6a2a5bacb19682c8e9c54c1f628b23fa20
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 703b781885d9aa694f4ce65b13109c2fd1ca25c3dc06d9bc9275c7140d1b79bb7fd705159c744a4de301fb6b1a3076d9440f950bcce8fb4b8f542ac497cacd07
|
7
|
+
data.tar.gz: 863ea3060f3f218dc48c0397cc1b092bdc204d4be14ae295aab10d231dfaa01f60dadb0e89f83876c36bd41413f79b5f25a6ef38a77400bf6b92abcad7f4b2e3
|
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.
|
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)
|
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
|
-
###
|
60
|
+
### Startup
|
61
61
|
|
62
|
-
|
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-
|
68
|
+
openvpn-status-web is licensed under the Apache License, Version 2.0. See LICENSE for more information.
|
data/lib/openvpn-status-web.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'date'
|
4
5
|
require 'etc'
|
@@ -8,7 +9,7 @@ require 'yaml'
|
|
8
9
|
require 'rack'
|
9
10
|
require 'erb'
|
10
11
|
require 'metriks'
|
11
|
-
require 'better_errors' if ENV['RACK_ENV'] ==
|
12
|
+
require 'better_errors' if ENV['RACK_ENV'] == 'development'
|
12
13
|
|
13
14
|
require 'openvpn-status-web/status'
|
14
15
|
require 'openvpn-status-web/parser/v1'
|
@@ -18,17 +19,25 @@ require 'openvpn-status-web/int_patch'
|
|
18
19
|
require 'openvpn-status-web/version'
|
19
20
|
|
20
21
|
module OpenVPNStatusWeb
|
22
|
+
# @return [Logger]
|
21
23
|
def self.logger
|
22
24
|
@logger
|
23
25
|
end
|
24
26
|
|
27
|
+
# @param logger [Logger]
|
28
|
+
# @return [Logger]
|
25
29
|
def self.logger=(logger)
|
26
30
|
@logger = logger
|
27
31
|
end
|
28
32
|
|
29
33
|
class LogFormatter
|
30
|
-
|
31
|
-
|
34
|
+
# @param lvl [Object]
|
35
|
+
# @param _time [DateTime]
|
36
|
+
# @param _progname [String]
|
37
|
+
# @param msg [Object]
|
38
|
+
# @return [String]
|
39
|
+
def call(lvl, _time, _progname, msg)
|
40
|
+
format("[%s] %-5s %s\n", Time.now.strftime('%Y-%m-%d %H:%M:%S'), lvl, msg.to_s)
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
@@ -40,29 +49,29 @@ module OpenVPNStatusWeb
|
|
40
49
|
end
|
41
50
|
|
42
51
|
def call(env)
|
43
|
-
return [405, {
|
44
|
-
return [404, {
|
52
|
+
return [405, {'Content-Type' => 'text/plain'}, ['Method Not Allowed']] if env['REQUEST_METHOD'] != 'GET'
|
53
|
+
return [404, {'Content-Type' => 'text/plain'}, ['Not Found']] if env['PATH_INFO'] != '/'
|
45
54
|
|
46
55
|
# variables for template
|
47
56
|
vpns = @vpns
|
48
57
|
stati = {}
|
49
|
-
@vpns.each do |name,config|
|
58
|
+
@vpns.each do |name, config|
|
50
59
|
stati[name] = parse_status_log(config)
|
51
60
|
end
|
52
61
|
# eval
|
53
62
|
html = @main_tmpl.result(binding)
|
54
63
|
|
55
|
-
[200, {
|
64
|
+
[200, {'Content-Type' => 'text/html'}, [html]]
|
56
65
|
end
|
57
66
|
|
58
67
|
def read_template(file)
|
59
|
-
text = File.
|
60
|
-
|
68
|
+
text = File.read(file, mode: 'rb')
|
69
|
+
|
61
70
|
ERB.new(text)
|
62
71
|
end
|
63
|
-
|
72
|
+
|
64
73
|
def parse_status_log(vpn)
|
65
|
-
text = File.
|
74
|
+
text = File.read(vpn['status_file'], mode: 'rb')
|
66
75
|
|
67
76
|
case vpn['version']
|
68
77
|
when 1
|
@@ -76,52 +85,64 @@ module OpenVPNStatusWeb
|
|
76
85
|
end
|
77
86
|
end
|
78
87
|
|
88
|
+
# @return [void]
|
79
89
|
def self.run!
|
80
90
|
if ARGV.length != 1
|
81
|
-
puts
|
91
|
+
puts 'Usage: openvpn-status-web config_file'
|
82
92
|
exit 1
|
83
93
|
end
|
84
94
|
|
85
95
|
config_file = ARGV[0]
|
86
96
|
|
87
|
-
if
|
88
|
-
puts
|
97
|
+
if !File.file?(config_file)
|
98
|
+
puts 'Config file not found!'
|
89
99
|
exit 1
|
90
100
|
end
|
91
|
-
|
101
|
+
|
92
102
|
puts "openvpn-status-web version #{OpenVPNStatusWeb::VERSION}"
|
93
103
|
puts "Using config file #{config_file}"
|
94
104
|
|
95
|
-
config = YAML
|
105
|
+
config = YAML.safe_load(File.read(config_file, mode: 'r'))
|
96
106
|
|
97
107
|
if config['logfile']
|
98
108
|
OpenVPNStatusWeb.logger = Logger.new(config['logfile'])
|
99
109
|
else
|
100
|
-
OpenVPNStatusWeb.logger = Logger.new(
|
110
|
+
OpenVPNStatusWeb.logger = Logger.new($stdout)
|
101
111
|
end
|
102
112
|
|
103
|
-
OpenVPNStatusWeb.logger.progname =
|
113
|
+
OpenVPNStatusWeb.logger.progname = 'openvpn-status-web'
|
104
114
|
OpenVPNStatusWeb.logger.formatter = LogFormatter.new
|
105
115
|
|
106
|
-
OpenVPNStatusWeb.logger.info
|
116
|
+
OpenVPNStatusWeb.logger.info 'Starting...'
|
107
117
|
|
108
|
-
# drop
|
109
|
-
|
110
|
-
|
118
|
+
# drop priviliges as soon as possible
|
119
|
+
# NOTE: first change group than user
|
120
|
+
if config['group']
|
121
|
+
group = Etc.getgrnam(config['group'])
|
122
|
+
Process::Sys.setgid(group.gid) if group
|
123
|
+
end
|
124
|
+
if config['user']
|
125
|
+
user = Etc.getpwnam(config['user'])
|
126
|
+
Process::Sys.setuid(user.uid) if user
|
127
|
+
end
|
111
128
|
|
112
129
|
# configure rack
|
113
130
|
app = Daemon.new(config['vpns'])
|
114
|
-
if ENV['RACK_ENV'] ==
|
131
|
+
if ENV['RACK_ENV'] == 'development'
|
115
132
|
app = BetterErrors::Middleware.new(app)
|
116
|
-
BetterErrors.application_root = File.expand_path(
|
133
|
+
BetterErrors.application_root = File.expand_path(__dir__)
|
117
134
|
end
|
118
135
|
|
119
136
|
Signal.trap('INT') do
|
120
|
-
OpenVPNStatusWeb.logger.info
|
137
|
+
OpenVPNStatusWeb.logger.info 'Quitting...'
|
138
|
+
Rack::Handler::WEBrick.shutdown
|
139
|
+
end
|
140
|
+
Signal.trap('TERM') do
|
141
|
+
OpenVPNStatusWeb.logger.info 'Quitting...'
|
121
142
|
Rack::Handler::WEBrick.shutdown
|
122
143
|
end
|
123
|
-
|
124
|
-
Rack::Handler::WEBrick.run app, :
|
144
|
+
|
145
|
+
Rack::Handler::WEBrick.run app, Host: config['host'], Port: config['port']
|
125
146
|
end
|
126
147
|
end
|
127
148
|
end
|
@@ -1,16 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
class Integer
|
3
4
|
def as_bytes
|
4
|
-
return
|
5
|
-
|
6
|
-
label = [
|
5
|
+
return '1 Byte' if self == 1
|
6
|
+
|
7
|
+
label = %w[Bytes KiB MiB GiB TiB]
|
7
8
|
i = 0
|
8
|
-
num =
|
9
|
-
while num >= 1024
|
10
|
-
num
|
9
|
+
num = to_f
|
10
|
+
while num >= 1024
|
11
|
+
num /= 1024
|
11
12
|
i += 1
|
12
13
|
end
|
13
|
-
|
14
|
+
|
14
15
|
"#{format('%.2f', num)} #{label[i]}"
|
15
16
|
end
|
16
17
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module OpenVPNStatusWeb
|
3
4
|
module Parser
|
@@ -10,29 +11,27 @@ module OpenVPNStatusWeb
|
|
10
11
|
|
11
12
|
text.lines.each do |line|
|
12
13
|
parts = line.strip.split(sep)
|
13
|
-
status.client_list << parse_client(parts[1..5]) if parts[0] ==
|
14
|
-
status.routing_table << parse_route(parts[1..4]) if parts[0] ==
|
15
|
-
status.global_stats << parse_global(parts[1..2]) if parts[0] ==
|
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.global_stats << parse_global(parts[1..2]) if parts[0] == 'GLOBAL_STATS'
|
16
17
|
end
|
17
18
|
|
18
19
|
status
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
def self.parse_client(client)
|
22
|
+
private_class_method def self.parse_client(client)
|
24
23
|
client[2] = client[2].to_i
|
25
24
|
client[3] = client[3].to_i
|
26
25
|
client[4] = DateTime.strptime(client[4], '%a %b %d %k:%M:%S %Y')
|
27
26
|
client
|
28
27
|
end
|
29
28
|
|
30
|
-
def self.parse_route(route)
|
29
|
+
private_class_method def self.parse_route(route)
|
31
30
|
route[3] = DateTime.strptime(route[3], '%a %b %d %k:%M:%S %Y')
|
32
31
|
route
|
33
32
|
end
|
34
33
|
|
35
|
-
def self.parse_global(global)
|
34
|
+
private_class_method def self.parse_global(global)
|
36
35
|
global[1] = global[1].to_i
|
37
36
|
global
|
38
37
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module OpenVPNStatusWeb
|
3
4
|
module Parser
|
@@ -13,7 +14,7 @@ module OpenVPNStatusWeb
|
|
13
14
|
(current_section = :rt; next) if line == "ROUTING TABLE\n"
|
14
15
|
(current_section = :gs; next) if line == "GLOBAL STATS\n"
|
15
16
|
(current_section = :end; next) if line == "END\n"
|
16
|
-
|
17
|
+
|
17
18
|
case current_section
|
18
19
|
when :cl
|
19
20
|
client_list << line.strip.split(',')
|
metadata
CHANGED
@@ -1,162 +1,195 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openvpn-status-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 3.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Christian Nicolai
|
9
8
|
autorequire:
|
10
|
-
bindir:
|
9
|
+
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-10-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: metriks
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: rack
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
33
|
+
version: '2.0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
40
|
+
version: '2.0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
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
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: better_errors
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
58
|
requirements:
|
51
|
-
- -
|
59
|
+
- - ">="
|
52
60
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
61
|
+
version: '0'
|
54
62
|
type: :development
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
|
-
- -
|
66
|
+
- - ">="
|
60
67
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
68
|
+
version: '0'
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
70
|
+
name: binding_of_caller
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
|
-
- -
|
73
|
+
- - ">="
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '0'
|
70
76
|
type: :development
|
71
77
|
prerelease: false
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
|
-
- -
|
80
|
+
- - ">="
|
76
81
|
- !ruby/object:Gem::Version
|
77
82
|
version: '0'
|
78
83
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
84
|
+
name: bundler
|
80
85
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
86
|
requirements:
|
83
|
-
- -
|
87
|
+
- - ">="
|
84
88
|
- !ruby/object:Gem::Version
|
85
89
|
version: '0'
|
86
90
|
type: :development
|
87
91
|
prerelease: false
|
88
92
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
93
|
requirements:
|
91
|
-
- -
|
94
|
+
- - ">="
|
92
95
|
- !ruby/object:Gem::Version
|
93
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler-audit
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.7.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.7.0
|
94
111
|
- !ruby/object:Gem::Dependency
|
95
112
|
name: rack-test
|
96
113
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
114
|
requirements:
|
99
|
-
- -
|
115
|
+
- - ">="
|
100
116
|
- !ruby/object:Gem::Version
|
101
117
|
version: '0'
|
102
118
|
type: :development
|
103
119
|
prerelease: false
|
104
120
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
121
|
requirements:
|
107
|
-
- -
|
122
|
+
- - ">="
|
108
123
|
- !ruby/object:Gem::Version
|
109
124
|
version: '0'
|
110
125
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
126
|
+
name: rake
|
112
127
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
135
|
requirements:
|
123
|
-
- -
|
136
|
+
- - ">="
|
124
137
|
- !ruby/object:Gem::Version
|
125
138
|
version: '0'
|
126
139
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
140
|
+
name: rspec
|
128
141
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
142
|
requirements:
|
131
|
-
- -
|
143
|
+
- - ">="
|
132
144
|
- !ruby/object:Gem::Version
|
133
145
|
version: '0'
|
134
146
|
type: :development
|
135
147
|
prerelease: false
|
136
148
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
149
|
requirements:
|
139
|
-
- -
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.92.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.92.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: solargraph
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
140
179
|
- !ruby/object:Gem::Version
|
141
180
|
version: '0'
|
142
181
|
description: Small Rack (Ruby) application serving OpenVPN status file.
|
143
|
-
email:
|
182
|
+
email:
|
144
183
|
executables:
|
145
184
|
- openvpn-status-web
|
146
185
|
extensions: []
|
147
|
-
extra_rdoc_files:
|
186
|
+
extra_rdoc_files:
|
187
|
+
- README.md
|
188
|
+
- LICENSE
|
148
189
|
files:
|
149
|
-
- .gitignore
|
150
|
-
- .travis.yml
|
151
|
-
- Gemfile
|
152
190
|
- LICENSE
|
153
191
|
- README.md
|
154
|
-
-
|
155
|
-
- bin/openvpn-status-web
|
156
|
-
- examples/status.v1
|
157
|
-
- examples/status.v2
|
158
|
-
- examples/status.v3
|
159
|
-
- init.d/debian-6-openvpn-status-web
|
192
|
+
- exe/openvpn-status-web
|
160
193
|
- lib/openvpn-status-web.rb
|
161
194
|
- lib/openvpn-status-web/int_patch.rb
|
162
195
|
- lib/openvpn-status-web/main.html.erb
|
@@ -166,42 +199,29 @@ files:
|
|
166
199
|
- lib/openvpn-status-web/parser/v3.rb
|
167
200
|
- lib/openvpn-status-web/status.rb
|
168
201
|
- lib/openvpn-status-web/version.rb
|
169
|
-
- openvpn-status-web.gemspec
|
170
|
-
- spec/parser/modern_stateless_spec.rb
|
171
|
-
- spec/parser/v1_spec.rb
|
172
|
-
- spec/spec_helper.rb
|
173
202
|
homepage: https://github.com/cmur2/openvpn-status-web
|
174
203
|
licenses:
|
175
|
-
- Apache
|
204
|
+
- Apache-2.0
|
205
|
+
metadata:
|
206
|
+
bug_tracker_uri: https://github.com/cmur2/openvpn-status-web/issues
|
207
|
+
source_code_uri: https://github.com/cmur2/openvpn-status-web
|
176
208
|
post_install_message:
|
177
209
|
rdoc_options: []
|
178
210
|
require_paths:
|
179
211
|
- lib
|
180
212
|
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
-
none: false
|
182
213
|
requirements:
|
183
|
-
- -
|
214
|
+
- - ">="
|
184
215
|
- !ruby/object:Gem::Version
|
185
|
-
version: '
|
186
|
-
segments:
|
187
|
-
- 0
|
188
|
-
hash: 229156271
|
216
|
+
version: '2.5'
|
189
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
-
none: false
|
191
218
|
requirements:
|
192
|
-
- -
|
219
|
+
- - ">="
|
193
220
|
- !ruby/object:Gem::Version
|
194
221
|
version: '0'
|
195
|
-
segments:
|
196
|
-
- 0
|
197
|
-
hash: 229156271
|
198
222
|
requirements: []
|
199
|
-
|
200
|
-
rubygems_version: 1.8.25
|
223
|
+
rubygems_version: 3.1.2
|
201
224
|
signing_key:
|
202
|
-
specification_version:
|
225
|
+
specification_version: 4
|
203
226
|
summary: openvpn-status-web
|
204
|
-
test_files:
|
205
|
-
- spec/parser/modern_stateless_spec.rb
|
206
|
-
- spec/parser/v1_spec.rb
|
207
|
-
- spec/spec_helper.rb
|
227
|
+
test_files: []
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/examples/status.v1
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
OpenVPN CLIENT LIST
|
2
|
-
Updated,Sun Jan 1 23:42:00 2012
|
3
|
-
Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
|
4
|
-
foo,1.2.3.4:1234,11811160064,4194304,Sun Jan 1 23:42:00 2012
|
5
|
-
bar,1.2.3.5:1235,512,2048,Sun Jan 1 23:42:00 2012
|
6
|
-
ROUTING TABLE
|
7
|
-
Virtual Address,Common Name,Real Address,Last Ref
|
8
|
-
192.168.0.0/24,foo,1.2.3.4:1234,Sun Jan 1 23:42:00 2012
|
9
|
-
192.168.66.2,bar,1.2.3.5:1235,Sun Jan 1 23:42:00 2012
|
10
|
-
192.168.66.3,foo,1.2.3.4:1234,Sun Jan 1 23:42:00 2012
|
11
|
-
2001:db8:0:0::1000,bar,1.2.3.5:1235,Sun Jan 1 23:42:00 2012
|
12
|
-
GLOBAL STATS
|
13
|
-
Max bcast/mcast queue length,42
|
14
|
-
END
|
data/examples/status.v2
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
TITLE,OpenVPN 2.1_rc15 mipsel-unknown-linux-gnu [SSL] [LZO1] [EPOLL] built on Mar 27 2009
|
2
|
-
TIME,Sun Jan 1 23:42:00 2012,1238702330
|
3
|
-
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t)
|
4
|
-
CLIENT_LIST,foo,1.2.3.4:1234,11811160064,4194304,Sun Jan 1 23:42:00 2012,1238702330
|
5
|
-
CLIENT_LIST,bar,1.2.3.5:1235,512,2048,Sun Jan 1 23:42:00 2012,1238702330
|
6
|
-
HEADER,ROUTING_TABLE,Virtual Address,Common Name,Real Address,Last Ref,Last Ref (time_t)
|
7
|
-
ROUTING_TABLE,192.168.0.0/24,foo,1.2.3.4:1234,Sun Jan 1 23:42:00 2012,1238702330
|
8
|
-
ROUTING_TABLE,192.168.66.2,bar,1.2.3.5:1235,Sun Jan 1 23:42:00 2012,1238702330
|
9
|
-
ROUTING_TABLE,192.168.66.3,foo,1.2.3.4:1234,Sun Jan 1 23:42:00 2012,1238702330
|
10
|
-
ROUTING_TABLE,2001:db8:0:0::1000,bar,1.2.3.5:1235,Sun Jan 1 23:42:00 2012,1238702330
|
11
|
-
GLOBAL_STATS,Max bcast/mcast queue length,42
|
12
|
-
END
|
data/examples/status.v3
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
TITLE OpenVPN 2.1_rc15 mipsel-unknown-linux-gnu [SSL] [LZO1] [EPOLL] built on Mar 27 2009
|
2
|
-
TIME Sun Jan 1 23:42:00 2012 1238702330
|
3
|
-
HEADER CLIENT_LIST Common Name Real Address Virtual Address Bytes Received Bytes Sent Connected Since Connected Since (time_t)
|
4
|
-
CLIENT_LIST foo 1.2.3.4:1234 11811160064 4194304 Sun Jan 1 23:42:00 2012 1238702330
|
5
|
-
CLIENT_LIST bar 1.2.3.5:1235 512 2048 Sun Jan 1 23:42:00 2012 1238702330
|
6
|
-
HEADER ROUTING_TABLE Virtual Address Common Name Real Address Last Ref Last Ref (time_t)
|
7
|
-
ROUTING_TABLE 192.168.0.0/24 foo 1.2.3.4:1234 Sun Jan 1 23:42:00 2012 1238702330
|
8
|
-
ROUTING_TABLE 192.168.66.2 bar 1.2.3.5:1235 Sun Jan 1 23:42:00 2012 1238702330
|
9
|
-
ROUTING_TABLE 192.168.66.3 foo 1.2.3.4:1234 Sun Jan 1 23:42:00 2012 1238702330
|
10
|
-
ROUTING_TABLE 2001:db8:0:0::1000 bar 1.2.3.5:1235 Sun Jan 1 23:42:00 2012 1238702330
|
11
|
-
GLOBAL_STATS Max bcast/mcast queue length 42
|
12
|
-
END
|
@@ -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
|
data/openvpn-status-web.gemspec
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
|
4
|
-
require 'openvpn-status-web/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = 'openvpn-status-web'
|
8
|
-
s.version = OpenVPNStatusWeb::VERSION
|
9
|
-
s.summary = 'openvpn-status-web'
|
10
|
-
s.description = 'Small Rack (Ruby) application serving OpenVPN status file.'
|
11
|
-
s.author = 'Christian Nicolai'
|
12
|
-
s.email = 'chrnicolai@gmail.com'
|
13
|
-
s.license = 'Apache License Version 2.0'
|
14
|
-
s.homepage = 'https://github.com/cmur2/openvpn-status-web'
|
15
|
-
|
16
|
-
s.files = `git ls-files`.split($/)
|
17
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
-
|
19
|
-
s.require_paths = ['lib']
|
20
|
-
|
21
|
-
s.executables = ['openvpn-status-web']
|
22
|
-
|
23
|
-
s.add_runtime_dependency 'rack'
|
24
|
-
s.add_runtime_dependency 'metriks'
|
25
|
-
|
26
|
-
s.add_development_dependency 'bundler', '~> 1.3'
|
27
|
-
s.add_development_dependency 'rake'
|
28
|
-
s.add_development_dependency 'rspec'
|
29
|
-
s.add_development_dependency 'rack-test'
|
30
|
-
s.add_development_dependency 'better_errors'
|
31
|
-
s.add_development_dependency 'binding_of_caller'
|
32
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenVPNStatusWeb::Parser::ModernStateless do
|
4
|
-
{
|
5
|
-
2 => status_v2,
|
6
|
-
3 => status_v3
|
7
|
-
}.each do |version, status|
|
8
|
-
context "for status-version #{version}" do
|
9
|
-
context 'for client list' do
|
10
|
-
it 'parses common names' do
|
11
|
-
status.client_list.map { |client| client[0] }.should be == ["foo", "bar"]
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'parses real addresses' do
|
15
|
-
status.client_list.map { |client| client[1] }.should be == ["1.2.3.4:1234", "1.2.3.5:1235"]
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'parses received bytes' do
|
19
|
-
status.client_list.map { |client| client[2] }.should be == [11811160064, 512]
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'parses sent bytes' do
|
23
|
-
status.client_list.map { |client| client[3] }.should be == [4194304, 2048]
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'parses connected since date' do
|
27
|
-
status.client_list.map { |client| client[4] }.should be == [DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0)]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'for routing table' do
|
32
|
-
it 'parses virtual addresses' do
|
33
|
-
status.routing_table.map { |route| route[0] }.should be == ["192.168.0.0/24", "192.168.66.2", "192.168.66.3", "2001:db8:0:0::1000"]
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'parses common names' do
|
37
|
-
status.routing_table.map { |route| route[1] }.should be == ["foo", "bar", "foo", "bar"]
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'parses real addresses' do
|
41
|
-
status.routing_table.map { |route| route[2] }.should be == ["1.2.3.4:1234", "1.2.3.5:1235", "1.2.3.4:1234", "1.2.3.5:1235"]
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'parses last ref date' do
|
45
|
-
status.routing_table.map { |route| route[3] }.should be == [DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0)]
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'parses global stats' do
|
50
|
-
status.global_stats.size.should be == 1
|
51
|
-
status.global_stats.first.should be == ["Max bcast/mcast queue length", 42]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/spec/parser/v1_spec.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenVPNStatusWeb::Parser::V1 do
|
4
|
-
def status; status_v1; end
|
5
|
-
|
6
|
-
context 'for client list' do
|
7
|
-
it 'parses common names' do
|
8
|
-
status.client_list.map { |client| client[0] }.should be == ["foo", "bar"]
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'parses real addresses' do
|
12
|
-
status.client_list.map { |client| client[1] }.should be == ["1.2.3.4:1234", "1.2.3.5:1235"]
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'parses received bytes' do
|
16
|
-
status.client_list.map { |client| client[2] }.should be == [11811160064, 512]
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'parses sent bytes' do
|
20
|
-
status.client_list.map { |client| client[3] }.should be == [4194304, 2048]
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'parses connected since date' do
|
24
|
-
status.client_list.map { |client| client[4] }.should be == [DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0)]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'for routing table' do
|
29
|
-
it 'parses virtual addresses' do
|
30
|
-
status.routing_table.map { |route| route[0] }.should be == ["192.168.0.0/24", "192.168.66.2", "192.168.66.3", "2001:db8:0:0::1000"]
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'parses common names' do
|
34
|
-
status.routing_table.map { |route| route[1] }.should be == ["foo", "bar", "foo", "bar"]
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'parses real addresses' do
|
38
|
-
status.routing_table.map { |route| route[2] }.should be == ["1.2.3.4:1234", "1.2.3.5:1235", "1.2.3.4:1234", "1.2.3.5:1235"]
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'parses last ref date' do
|
42
|
-
status.routing_table.map { |route| route[3] }.should be == [DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0)]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'parses global stats' do
|
47
|
-
status.global_stats.size.should be == 1
|
48
|
-
status.global_stats.first.should be == ["Max bcast/mcast queue length", 42]
|
49
|
-
end
|
50
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'rack/test'
|
5
|
-
|
6
|
-
require 'openvpn-status-web'
|
7
|
-
|
8
|
-
def status_v1
|
9
|
-
text = File.open('examples/status.v1', 'rb') do |f| f.read end
|
10
|
-
OpenVPNStatusWeb::Parser::V1.new.parse_status_log text
|
11
|
-
end
|
12
|
-
|
13
|
-
def status_v2
|
14
|
-
text = File.open('examples/status.v2', 'rb') do |f| f.read end
|
15
|
-
OpenVPNStatusWeb::Parser::V2.new.parse_status_log text
|
16
|
-
end
|
17
|
-
|
18
|
-
def status_v3
|
19
|
-
text = File.open('examples/status.v3', 'rb') do |f| f.read end
|
20
|
-
OpenVPNStatusWeb::Parser::V3.new.parse_status_log text
|
21
|
-
end
|