openvpn-status-web 2.0.0 → 2.1.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: 211f9344884e61aefa346043a38689c30d74bc30f9fa7f3b1b580bbf5b0e3575
4
- data.tar.gz: 11ad21226d37f88a427cf7571c2c98860cc3d6cc8daea3def18e2e603c10c298
3
+ metadata.gz: de8d358e0600c1f0843ff7bccc59bcc4a9ad685b70856509118d8ad6791bb870
4
+ data.tar.gz: d38bbd5238e321bdf5814a6c2e998f706e35897fa49f88180cdd4197852c1a42
5
5
  SHA512:
6
- metadata.gz: a34579dcd1d6c7d1b84264d293342eb8cc813bb92d3aea556602f0f34ff485d7dab6e9442b522bc500780cf25478f2f143a3796212d03a770b825faaeaf44214
7
- data.tar.gz: 3293608797c7a143bef0155818c765e92e53e16897f6855137d45ab368321528a83b52578f294ed97e44f1d0f49aec71832460adf8c1b96f77df6353c46b8904
6
+ metadata.gz: e4ce6ce068a55fe4ea2f9ee1815719033458307a476c9106c56fe22bcc65933d32e1b1c34ad42aa0981b6765a63a0842a2953d365554d044bb01734b3a9f04e9
7
+ data.tar.gz: b64467e939fde4ea6130d5f868351f9772da39440f1016c65adcaefd90904ba950d5ec16fa235f6343ebdf88260619b73785a4a0b037dcb49abd61c1f4078301
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
+ [![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)
4
4
 
5
5
  ## Description
6
6
 
@@ -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,23 +85,24 @@ 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'])
@@ -100,32 +110,39 @@ module OpenVPNStatusWeb
100
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 = "2.0.0"
4
+ VERSION = '2.1.0'
4
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openvpn-status-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Nicolai
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-05 00:00:00.000000000 Z
11
+ date: 2020-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: metriks
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rack
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,13 +39,13 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '2.0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: metriks
42
+ name: better_errors
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
- type: :runtime
48
+ type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: bundler
56
+ name: binding_of_caller
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rake
70
+ name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,21 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rspec
84
+ name: bundler-audit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.6.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.6.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rack-test
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -81,7 +109,7 @@ dependencies:
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
- name: rack-test
112
+ name: rake
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - ">="
@@ -95,7 +123,7 @@ dependencies:
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
- name: better_errors
126
+ name: rspec
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - ">="
@@ -109,7 +137,21 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
- name: binding_of_caller
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.80.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.80.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: solargraph
113
155
  requirement: !ruby/object:Gem::Requirement
114
156
  requirements:
115
157
  - - ">="
@@ -123,22 +165,17 @@ dependencies:
123
165
  - !ruby/object:Gem::Version
124
166
  version: '0'
125
167
  description: Small Rack (Ruby) application serving OpenVPN status file.
126
- email: chrnicolai@gmail.com
168
+ email:
127
169
  executables:
128
170
  - openvpn-status-web
129
171
  extensions: []
130
- extra_rdoc_files: []
172
+ extra_rdoc_files:
173
+ - README.md
174
+ - LICENSE
131
175
  files:
132
- - ".gitignore"
133
- - ".travis.yml"
134
- - Gemfile
135
176
  - LICENSE
136
177
  - README.md
137
- - Rakefile
138
- - bin/openvpn-status-web
139
- - examples/status.v1
140
- - examples/status.v2
141
- - examples/status.v3
178
+ - exe/openvpn-status-web
142
179
  - init.d/debian-6-openvpn-status-web
143
180
  - lib/openvpn-status-web.rb
144
181
  - lib/openvpn-status-web/int_patch.rb
@@ -149,14 +186,12 @@ files:
149
186
  - lib/openvpn-status-web/parser/v3.rb
150
187
  - lib/openvpn-status-web/status.rb
151
188
  - lib/openvpn-status-web/version.rb
152
- - openvpn-status-web.gemspec
153
- - spec/parser/modern_stateless_spec.rb
154
- - spec/parser/v1_spec.rb
155
- - spec/spec_helper.rb
156
- homepage: https://github.com/cmur2/dyndnsd
189
+ homepage: https://github.com/cmur2/openvpn-status-web
157
190
  licenses:
158
191
  - Apache-2.0
159
- metadata: {}
192
+ metadata:
193
+ bug_tracker_uri: https://github.com/cmur2/openvpn-status-web/issues
194
+ source_code_uri: https://github.com/cmur2/openvpn-status-web
160
195
  post_install_message:
161
196
  rdoc_options: []
162
197
  require_paths:
@@ -172,12 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
207
  - !ruby/object:Gem::Version
173
208
  version: '0'
174
209
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.7.7
210
+ rubygems_version: 3.0.6
177
211
  signing_key:
178
212
  specification_version: 4
179
213
  summary: openvpn-status-web
180
- test_files:
181
- - spec/parser/modern_stateless_spec.rb
182
- - spec/parser/v1_spec.rb
183
- - spec/spec_helper.rb
214
+ test_files: []
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- .DS_Store
2
- *.lock
3
- pkg/*
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- rvm:
5
- - 2.5
6
- - 2.4
7
- - 2.3
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,32 +0,0 @@
1
-
2
- $LOAD_PATH.push File.expand_path('lib', __dir__)
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.homepage = 'https://github.com/cmur2/dyndnsd'
14
- s.license = 'Apache-2.0'
15
-
16
- s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
- s.require_paths = ['lib']
19
- s.executables = ['openvpn-status-web']
20
-
21
- s.required_ruby_version = '>= 2.3'
22
-
23
- s.add_runtime_dependency 'rack', '~> 2.0'
24
- s.add_runtime_dependency 'metriks'
25
-
26
- s.add_development_dependency 'bundler'
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
- expect(status.client_list.map { |client| client[0] }).to eq(["foo", "bar"])
12
- end
13
-
14
- it 'parses real addresses' do
15
- expect(status.client_list.map { |client| client[1] }).to eq(["1.2.3.4:1234", "1.2.3.5:1235"])
16
- end
17
-
18
- it 'parses received bytes' do
19
- expect(status.client_list.map { |client| client[2] }).to eq([11811160064, 512])
20
- end
21
-
22
- it 'parses sent bytes' do
23
- expect(status.client_list.map { |client| client[3] }).to eq([4194304, 2048])
24
- end
25
-
26
- it 'parses connected since date' do
27
- expect(status.client_list.map { |client| client[4] }).to eq([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
- expect(status.routing_table.map { |route| route[0] }).to eq(["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
- expect(status.routing_table.map { |route| route[1] }).to eq(["foo", "bar", "foo", "bar"])
38
- end
39
-
40
- it 'parses real addresses' do
41
- expect(status.routing_table.map { |route| route[2] }).to eq(["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
- expect(status.routing_table.map { |route| route[3] }).to eq([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
- expect(status.global_stats.size).to eq(1)
51
- expect(status.global_stats.first).to eq(["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
- expect(status.client_list.map { |client| client[0] }).to eq(["foo", "bar"])
9
- end
10
-
11
- it 'parses real addresses' do
12
- expect(status.client_list.map { |client| client[1] }).to eq(["1.2.3.4:1234", "1.2.3.5:1235"])
13
- end
14
-
15
- it 'parses received bytes' do
16
- expect(status.client_list.map { |client| client[2] }).to eq([11811160064, 512])
17
- end
18
-
19
- it 'parses sent bytes' do
20
- expect(status.client_list.map { |client| client[3] }).to eq([4194304, 2048])
21
- end
22
-
23
- it 'parses connected since date' do
24
- expect(status.client_list.map { |client| client[4] }).to eq([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
- expect(status.routing_table.map { |route| route[0] }).to eq(["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
- expect(status.routing_table.map { |route| route[1] }).to eq(["foo", "bar", "foo", "bar"])
35
- end
36
-
37
- it 'parses real addresses' do
38
- expect(status.routing_table.map { |route| route[2] }).to eq(["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
- expect(status.routing_table.map { |route| route[3] }).to eq([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
- expect(status.global_stats.size).to eq(1)
48
- expect(status.global_stats.first).to eq(["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