1
0
mirror of https://github.com/cmur2/openvpn-status-web.git synced 2025-09-28 21:52:05 +02:00

9 Commits

Author SHA1 Message Date
cn
cdc20e8042 Bump version 2018-11-05 09:12:20 +01:00
cn
998f9e683c spec: use new rspec expect syntax 2018-11-02 10:16:28 +01:00
cn
cf69d6417d gem: upgrade to Rack 2.0, loosen version constraints by dropping old rubies 2018-11-02 10:16:18 +01:00
cn
cb1d029326 travis: update rubies 2018-11-02 10:11:26 +01:00
cn
563fb5743b Bump version 2013-10-08 13:23:22 +02:00
cn
a852aa4b4d React to SIGTERM 2013-10-08 13:23:02 +02:00
cn
d5f8d66422 Bump version 2013-10-07 22:27:18 +02:00
cn
f873d8176e Update README 2013-07-19 09:32:37 +02:00
cn
c14d59e0bf Require better_errors only in development 2013-07-18 23:39:59 +02:00
7 changed files with 56 additions and 47 deletions

View File

@@ -1,8 +1,7 @@
---
sudo: false
language: ruby
rvm:
- 2.0.0
- 1.9.3
gemfile:
- Gemfile
- 2.5
- 2.4
- 2.3

View File

@@ -4,12 +4,10 @@
## Description
Small (another word for naive in this case, it's simple and serves my needs) [Rack](http://rack.github.com/) application providing the information the [OpenVPN](http://openvpn.net/index.php/open-source.html) server collects in it's status file especially including a list of currently connected clients (common name, remote address, traffic, ...).
Small (another word for naive in this case, it's simple and serves my needs) [Rack](http://rack.github.com/) application providing the information an [OpenVPN](http://openvpn.net/index.php/open-source.html) server collects in it's status file especially including a list of currently connected clients (common name, remote address, traffic, ...).
It lacks:
* tracking multiple status at the same time
* newer status file versions than v1
* caching (parses file on each request, page does auto-refresh every minute as OpenVPN updates the status file these often by default)
* management interface support
* *possibly more...*
@@ -31,9 +29,15 @@ user: "nobody"
group: "nogroup"
# logfile is optional, logs to STDOUT else
logfile: "openvpn-status-web.log"
# display name for humans and the status file path
name: "My Small VPN"
status_file: "/var/log/openvpn-status.log"
# hash with each VPNs display name for humans as key and further config as value
vpns:
My Small VPN:
# the status file path and status file format version are required
version: 1
status_file: "/var/log/openvpn-status.log"
My Other VPN:
version: 3
status_file: "/var/log/other-openvpn-status.log"
```
Your OpenVPN configuration should contain something like this:
@@ -45,6 +49,8 @@ status-version 1
# ...snip...
```
For more information about OpenVPN status file and version, see their [man page](https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage). openvpn-status-web is able to parse all versions from 1 to 3.
## Advanced topics
### Authentication

View File

@@ -8,7 +8,7 @@ require 'yaml'
require 'rack'
require 'erb'
require 'metriks'
require 'better_errors'
require 'better_errors' if ENV['RACK_ENV'] == "development"
require 'openvpn-status-web/status'
require 'openvpn-status-web/parser/v1'
@@ -120,6 +120,10 @@ module OpenVPNStatusWeb
OpenVPNStatusWeb.logger.info "Quitting..."
Rack::Handler::WEBrick.shutdown
end
Signal.trap('TERM') do
OpenVPNStatusWeb.logger.info "Quitting..."
Rack::Handler::WEBrick.shutdown
end
Rack::Handler::WEBrick.run app, :Host => config['host'], :Port => config['port']
end

View File

@@ -1,4 +1,4 @@
module OpenVPNStatusWeb
VERSION = "1.0.0"
VERSION = "2.0.0"
end

View File

@@ -1,5 +1,5 @@
$:.push File.expand_path("../lib", __FILE__)
$LOAD_PATH.push File.expand_path('lib', __dir__)
require 'openvpn-status-web/version'
@@ -10,20 +10,20 @@ Gem::Specification.new do |s|
s.description = 'Small Rack (Ruby) application serving OpenVPN status file.'
s.author = 'Christian Nicolai'
s.email = 'chrnicolai@gmail.com'
s.license = 'Apache License Version 2.0'
s.homepage = 'https://github.com/cmur2/openvpn-status-web'
s.homepage = 'https://github.com/cmur2/dyndnsd'
s.license = 'Apache-2.0'
s.files = `git ls-files`.split($/)
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.require_paths = ['lib']
s.executables = ['openvpn-status-web']
s.add_runtime_dependency 'rack'
s.required_ruby_version = '>= 2.3'
s.add_runtime_dependency 'rack', '~> 2.0'
s.add_runtime_dependency 'metriks'
s.add_development_dependency 'bundler', '~> 1.3'
s.add_development_dependency 'bundler'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rack-test'

View File

@@ -8,47 +8,47 @@ describe OpenVPNStatusWeb::Parser::ModernStateless do
context "for status-version #{version}" do
context 'for client list' do
it 'parses common names' do
status.client_list.map { |client| client[0] }.should be == ["foo", "bar"]
expect(status.client_list.map { |client| client[0] }).to eq(["foo", "bar"])
end
it 'parses real addresses' do
status.client_list.map { |client| client[1] }.should be == ["1.2.3.4:1234", "1.2.3.5:1235"]
expect(status.client_list.map { |client| client[1] }).to eq(["1.2.3.4:1234", "1.2.3.5:1235"])
end
it 'parses received bytes' do
status.client_list.map { |client| client[2] }.should be == [11811160064, 512]
expect(status.client_list.map { |client| client[2] }).to eq([11811160064, 512])
end
it 'parses sent bytes' do
status.client_list.map { |client| client[3] }.should be == [4194304, 2048]
expect(status.client_list.map { |client| client[3] }).to eq([4194304, 2048])
end
it 'parses connected since date' do
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)]
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)])
end
end
context 'for routing table' do
it 'parses virtual addresses' do
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"]
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"])
end
it 'parses common names' do
status.routing_table.map { |route| route[1] }.should be == ["foo", "bar", "foo", "bar"]
expect(status.routing_table.map { |route| route[1] }).to eq(["foo", "bar", "foo", "bar"])
end
it 'parses real addresses' do
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"]
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"])
end
it 'parses last ref date' do
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)]
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)])
end
end
it 'parses global stats' do
status.global_stats.size.should be == 1
status.global_stats.first.should be == ["Max bcast/mcast queue length", 42]
expect(status.global_stats.size).to eq(1)
expect(status.global_stats.first).to eq(["Max bcast/mcast queue length", 42])
end
end
end

View File

@@ -5,46 +5,46 @@ describe OpenVPNStatusWeb::Parser::V1 do
context 'for client list' do
it 'parses common names' do
status.client_list.map { |client| client[0] }.should be == ["foo", "bar"]
expect(status.client_list.map { |client| client[0] }).to eq(["foo", "bar"])
end
it 'parses real addresses' do
status.client_list.map { |client| client[1] }.should be == ["1.2.3.4:1234", "1.2.3.5:1235"]
expect(status.client_list.map { |client| client[1] }).to eq(["1.2.3.4:1234", "1.2.3.5:1235"])
end
it 'parses received bytes' do
status.client_list.map { |client| client[2] }.should be == [11811160064, 512]
expect(status.client_list.map { |client| client[2] }).to eq([11811160064, 512])
end
it 'parses sent bytes' do
status.client_list.map { |client| client[3] }.should be == [4194304, 2048]
expect(status.client_list.map { |client| client[3] }).to eq([4194304, 2048])
end
it 'parses connected since date' do
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)]
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)])
end
end
context 'for routing table' do
it 'parses virtual addresses' do
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"]
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"])
end
it 'parses common names' do
status.routing_table.map { |route| route[1] }.should be == ["foo", "bar", "foo", "bar"]
expect(status.routing_table.map { |route| route[1] }).to eq(["foo", "bar", "foo", "bar"])
end
it 'parses real addresses' do
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"]
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"])
end
it 'parses last ref date' do
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)]
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)])
end
end
it 'parses global stats' do
status.global_stats.size.should be == 1
status.global_stats.first.should be == ["Max bcast/mcast queue length", 42]
expect(status.global_stats.size).to eq(1)
expect(status.global_stats.first).to eq(["Max bcast/mcast queue length", 42])
end
end