openvpn-status-web 1.1.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1a94ecc4950275fa2d15151a0854215e75552e2b4eed1fad59b31476fdc3eef0
4
+ data.tar.gz: a7bc1ecd1cba15b208de2b5a45786f9bdaa8f2511641adb4437af759ee17a937
5
+ SHA512:
6
+ metadata.gz: ad621dde6babd84740b376948be7db24e6fcb1ef6c3783fcb7b73bf29577c2caf8e89fd88542de00c03eb68dc837e138b9de23c7c4f568f97652615414f21327
7
+ data.tar.gz: a1bfcbc4a2ae0446aa869f362ea4cc9463ef30e6be16198b011bf371d5007b70aaa3c38f7b06e04ef2db4eddc3be790855b3fe17b49d41de67a71626ae23896b
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.png)](https://travis-ci.org/cmur2/openvpn-status-web)
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.
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
1
3
 
2
4
  require 'openvpn-status-web'
3
5
 
@@ -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'] == "development"
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
- def call(lvl, time, progname, msg)
31
- "[%s] %-5s %s\n" % [Time.now.strftime('%Y-%m-%d %H:%M:%S'), lvl, msg.to_s]
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, {"Content-Type" => "text/plain"}, ["Method Not Allowed"]] if env["REQUEST_METHOD"] != "GET"
44
- return [404, {"Content-Type" => "text/plain"}, ["Not Found"]] if env["PATH_INFO"] != "/"
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, {"Content-Type" => "text/html"}, [html]]
64
+ [200, {'Content-Type' => 'text/html'}, [html]]
56
65
  end
57
66
 
58
67
  def read_template(file)
59
- text = File.open(file, 'rb') do |f| f.read end
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.open(vpn['status_file'], 'rb') do |f| f.read end
74
+ text = File.read(vpn['status_file'], mode: 'rb')
66
75
 
67
76
  case vpn['version']
68
77
  when 1
@@ -76,56 +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 "Usage: openvpn-status-web config_file"
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 not File.file?(config_file)
88
- puts "Config file not found!"
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::load(File.open(config_file, 'r') { |f| f.read })
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(STDOUT)
110
+ OpenVPNStatusWeb.logger = Logger.new($stdout)
101
111
  end
102
112
 
103
- OpenVPNStatusWeb.logger.progname = "openvpn-status-web"
113
+ OpenVPNStatusWeb.logger.progname = 'openvpn-status-web'
104
114
  OpenVPNStatusWeb.logger.formatter = LogFormatter.new
105
115
 
106
- OpenVPNStatusWeb.logger.info "Starting..."
116
+ OpenVPNStatusWeb.logger.info 'Starting...'
107
117
 
108
- # drop privs (first change group than user)
109
- Process::Sys.setgid(Etc.getgrnam(config['group']).gid) if config['group']
110
- Process::Sys.setuid(Etc.getpwnam(config['user']).uid) if config['user']
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'] == "development"
131
+ if ENV['RACK_ENV'] == 'development'
115
132
  app = BetterErrors::Middleware.new(app)
116
- BetterErrors.application_root = File.expand_path("..", __FILE__)
133
+ BetterErrors.application_root = File.expand_path(__dir__)
117
134
  end
118
135
 
119
136
  Signal.trap('INT') do
120
- OpenVPNStatusWeb.logger.info "Quitting..."
137
+ OpenVPNStatusWeb.logger.info 'Quitting...'
121
138
  Rack::Handler::WEBrick.shutdown
122
139
  end
123
140
  Signal.trap('TERM') do
124
- OpenVPNStatusWeb.logger.info "Quitting..."
141
+ OpenVPNStatusWeb.logger.info 'Quitting...'
125
142
  Rack::Handler::WEBrick.shutdown
126
143
  end
127
-
128
- Rack::Handler::WEBrick.run app, :Host => config['host'], :Port => config['port']
144
+
145
+ Rack::Handler::WEBrick.run app, Host: config['host'], Port: config['port']
129
146
  end
130
147
  end
131
148
  end
@@ -1,16 +1,17 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Integer
3
4
  def as_bytes
4
- return "1 Byte" if self == 1
5
-
6
- label = ["Bytes", "KiB", "MiB", "GiB", "TiB"]
5
+ return '1 Byte' if self == 1
6
+
7
+ label = %w[Bytes KiB MiB GiB TiB]
7
8
  i = 0
8
- num = self.to_f
9
- while num >= 1024 do
10
- num = num / 1024
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] == "CLIENT_LIST"
14
- status.routing_table << parse_route(parts[1..4]) if parts[0] == "ROUTING_TABLE"
15
- status.global_stats << parse_global(parts[1..2]) if parts[0] == "GLOBAL_STATS"
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
- private
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(',')
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
 
2
- require 'openvpn-status-web/parser/modern_stateless'
3
+ require_relative 'modern_stateless'
3
4
 
4
5
  module OpenVPNStatusWeb
5
6
  module Parser
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
 
2
- require 'openvpn-status-web/parser/modern_stateless'
3
+ require_relative 'modern_stateless'
3
4
 
4
5
  module OpenVPNStatusWeb
5
6
  module Parser
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module OpenVPNStatusWeb
3
4
  class Status
@@ -1,4 +1,5 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module OpenVPNStatusWeb
3
- VERSION = "1.1.0"
4
+ VERSION = '3.1.0'
4
5
  end
metadata CHANGED
@@ -1,162 +1,223 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openvpn-status-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 3.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christian Nicolai
9
8
  autorequire:
10
- bindir: bin
9
+ bindir: exe
11
10
  cert_chain: []
12
- date: 2013-10-08 00:00:00.000000000 Z
11
+ date: 2021-01-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rack
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: metriks
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: bundler
42
+ name: webrick
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: '1.3'
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
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::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: '1.3'
68
+ version: '0'
62
69
  - !ruby/object:Gem::Dependency
63
- name: rake
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: rspec
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: better_errors
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: binding_of_caller
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
+ - - ">="
140
151
  - !ruby/object:Gem::Version
141
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: 1.8.1
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 1.8.1
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.5.1
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.5.1
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.1.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.1.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: solargraph
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 0.40.0
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 0.40.0
142
209
  description: Small Rack (Ruby) application serving OpenVPN status file.
143
- email: chrnicolai@gmail.com
210
+ email:
144
211
  executables:
145
212
  - openvpn-status-web
146
213
  extensions: []
147
- extra_rdoc_files: []
214
+ extra_rdoc_files:
215
+ - README.md
216
+ - LICENSE
148
217
  files:
149
- - .gitignore
150
- - .travis.yml
151
- - Gemfile
152
218
  - LICENSE
153
219
  - README.md
154
- - Rakefile
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
220
+ - exe/openvpn-status-web
160
221
  - lib/openvpn-status-web.rb
161
222
  - lib/openvpn-status-web/int_patch.rb
162
223
  - lib/openvpn-status-web/main.html.erb
@@ -166,42 +227,29 @@ files:
166
227
  - lib/openvpn-status-web/parser/v3.rb
167
228
  - lib/openvpn-status-web/status.rb
168
229
  - 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
230
  homepage: https://github.com/cmur2/openvpn-status-web
174
231
  licenses:
175
- - Apache License Version 2.0
232
+ - Apache-2.0
233
+ metadata:
234
+ bug_tracker_uri: https://github.com/cmur2/openvpn-status-web/issues
235
+ source_code_uri: https://github.com/cmur2/openvpn-status-web
176
236
  post_install_message:
177
237
  rdoc_options: []
178
238
  require_paths:
179
239
  - lib
180
240
  required_ruby_version: !ruby/object:Gem::Requirement
181
- none: false
182
241
  requirements:
183
- - - ! '>='
242
+ - - ">="
184
243
  - !ruby/object:Gem::Version
185
- version: '0'
186
- segments:
187
- - 0
188
- hash: -923549073
244
+ version: '2.5'
189
245
  required_rubygems_version: !ruby/object:Gem::Requirement
190
- none: false
191
246
  requirements:
192
- - - ! '>='
247
+ - - ">="
193
248
  - !ruby/object:Gem::Version
194
249
  version: '0'
195
- segments:
196
- - 0
197
- hash: -923549073
198
250
  requirements: []
199
- rubyforge_project:
200
- rubygems_version: 1.8.25
251
+ rubygems_version: 3.2.4
201
252
  signing_key:
202
- specification_version: 3
253
+ specification_version: 4
203
254
  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
255
+ test_files: []
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- .DS_Store
2
- *.lock
3
- pkg/*
@@ -1,8 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.0.0
5
- - 1.9.3
6
-
7
- gemfile:
8
- - Gemfile
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -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
@@ -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,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
@@ -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
@@ -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
@@ -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