mirror of
https://github.com/cmur2/openvpn-status-web.git
synced 2025-09-28 21:52:05 +02:00
Compare commits
61 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
648b4d94b6 | ||
![]() |
117f70e2e3 | ||
![]() |
1e0444a71d | ||
![]() |
20c6c9176a | ||
![]() |
a0ad379b00 | ||
![]() |
d8f4931657 | ||
![]() |
6676f47c97 | ||
![]() |
811b928403 | ||
![]() |
f4a48b8ce0 | ||
![]() |
f985ec1c12 | ||
![]() |
3d10b7d128 | ||
![]() |
27876c7f12 | ||
![]() |
9d584ceb71 | ||
![]() |
1996f1d9b9 | ||
![]() |
f342b07495 | ||
557a328336 | |||
057d243db8 | |||
![]() |
e3a06fdf6c | ||
![]() |
bfe39adaf8 | ||
![]() |
9159a53cce | ||
![]() |
51825eb2da | ||
![]() |
280e2b9ae1 | ||
![]() |
6d56db855f | ||
![]() |
0b782b7dd3 | ||
ea7b3a947c | |||
eb2bb4d632 | |||
2a9bacf196 | |||
39adc74fbc | |||
9ad59194bd | |||
528709c895 | |||
39d2b3ce94 | |||
406ed867f7 | |||
![]() |
22d9797f55 | ||
![]() |
55aecedef7 | ||
![]() |
d401074524 | ||
![]() |
ff6572bdac | ||
![]() |
b4bf74240b | ||
![]() |
fb4b3ca461 | ||
![]() |
8a6722f981 | ||
![]() |
8249b01c95 | ||
![]() |
5d04255a95 | ||
![]() |
846d41d35d | ||
![]() |
ce0e80f35f | ||
![]() |
0ec3faf5b4 | ||
![]() |
10a4e757f3 | ||
![]() |
f95134c315 | ||
![]() |
7da4cb910f | ||
![]() |
382daa34c6 | ||
![]() |
5338b30e32 | ||
![]() |
47ee407af2 | ||
![]() |
281750d6ea | ||
![]() |
42743a1786 | ||
![]() |
7c94192765 | ||
![]() |
a3a65f05bc | ||
![]() |
e87a4d86f6 | ||
![]() |
2145e183e3 | ||
![]() |
9e5aa1ff71 | ||
![]() |
a99ba901c9 | ||
![]() |
cc21291a5c | ||
![]() |
ba00407d55 | ||
![]() |
80bd4f8584 |
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -16,10 +16,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
ruby-version:
|
ruby-version:
|
||||||
- '2.5'
|
|
||||||
- '2.6'
|
|
||||||
- '2.7'
|
- '2.7'
|
||||||
- '3.0'
|
- '3.0'
|
||||||
|
- '3.1'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Ruby ${{ matrix.ruby-version }}
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
||||||
|
@@ -3,9 +3,12 @@ require:
|
|||||||
- rubocop-rspec
|
- rubocop-rspec
|
||||||
|
|
||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: '2.5'
|
TargetRubyVersion: '2.7'
|
||||||
NewCops: enable
|
NewCops: enable
|
||||||
|
|
||||||
|
Gemspec/RequireMFA:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Layout/EmptyLineAfterGuardClause:
|
Layout/EmptyLineAfterGuardClause:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
FROM alpine:3.13
|
FROM alpine:3.16
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
ENV VERSION=3.1.0
|
ENV VERSION=3.3.0
|
||||||
|
|
||||||
RUN apk --no-cache add openssl ca-certificates && \
|
RUN apk --no-cache add openssl ca-certificates && \
|
||||||
apk --no-cache add ruby ruby-etc ruby-webrick && \
|
apk --no-cache add ruby ruby-etc ruby-webrick && \
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
TITLE,OpenVPN 2.1_rc15 mipsel-unknown-linux-gnu [SSL] [LZO1] [EPOLL] built on Mar 27 2009
|
TITLE,OpenVPN 2.1_rc15 mipsel-unknown-linux-gnu [SSL] [LZO1] [EPOLL] built on Mar 27 2009
|
||||||
TIME,Sun Jan 1 23:42:00 2012,1238702330
|
TIME,Sun Jan 1 23:42:00 2012,1238702330
|
||||||
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t)
|
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t)
|
||||||
CLIENT_LIST,foo,1.2.3.4:1234,11811160064,4194304,Sun Jan 1 23:42:00 2012,1238702330
|
CLIENT_LIST,foo,1.2.3.4:1234,192.168.66.2,11811160064,4194304,Sun Jan 1 23:42:00 2012,1238702330
|
||||||
CLIENT_LIST,bar,1.2.3.5:1235,512,2048,Sun Jan 1 23:42:00 2012,1238702330
|
CLIENT_LIST,bar,1.2.3.5:1235,2001:db8:0:0::1000,512,2048,Sun Jan 1 23:42:00 2012,1238702330
|
||||||
HEADER,ROUTING_TABLE,Virtual Address,Common Name,Real Address,Last Ref,Last Ref (time_t)
|
HEADER,ROUTING_TABLE,Virtual Address,Common Name,Real Address,Last Ref,Last Ref (time_t)
|
||||||
ROUTING_TABLE,192.168.0.0/24,foo,1.2.3.4:1234,Sun Jan 1 23:42:00 2012,1238702330
|
ROUTING_TABLE,192.168.0.0/24,foo,1.2.3.4:1234,Sun Jan 1 23:42:00 2012,1238702330
|
||||||
ROUTING_TABLE,192.168.66.2,bar,1.2.3.5:1235,Sun Jan 1 23:42:00 2012,1238702330
|
ROUTING_TABLE,192.168.66.2,bar,1.2.3.5:1235,Sun Jan 1 23:42:00 2012,1238702330
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
TITLE OpenVPN 2.1_rc15 mipsel-unknown-linux-gnu [SSL] [LZO1] [EPOLL] built on Mar 27 2009
|
TITLE OpenVPN 2.1_rc15 mipsel-unknown-linux-gnu [SSL] [LZO1] [EPOLL] built on Mar 27 2009
|
||||||
TIME Sun Jan 1 23:42:00 2012 1238702330
|
TIME Sun Jan 1 23:42:00 2012 1238702330
|
||||||
HEADER CLIENT_LIST Common Name Real Address Virtual Address Bytes Received Bytes Sent Connected Since Connected Since (time_t)
|
HEADER CLIENT_LIST Common Name Real Address Virtual Address Bytes Received Bytes Sent Connected Since Connected Since (time_t)
|
||||||
CLIENT_LIST foo 1.2.3.4:1234 11811160064 4194304 Sun Jan 1 23:42:00 2012 1238702330
|
CLIENT_LIST foo 1.2.3.4:1234 192.168.66.2 11811160064 4194304 Sun Jan 1 23:42:00 2012 1238702330
|
||||||
CLIENT_LIST bar 1.2.3.5:1235 512 2048 Sun Jan 1 23:42:00 2012 1238702330
|
CLIENT_LIST bar 1.2.3.5:1235 2001:db8:0:0::1000 512 2048 Sun Jan 1 23:42:00 2012 1238702330
|
||||||
HEADER ROUTING_TABLE Virtual Address Common Name Real Address Last Ref Last Ref (time_t)
|
HEADER ROUTING_TABLE Virtual Address Common Name Real Address Last Ref Last Ref (time_t)
|
||||||
ROUTING_TABLE 192.168.0.0/24 foo 1.2.3.4:1234 Sun Jan 1 23:42:00 2012 1238702330
|
ROUTING_TABLE 192.168.0.0/24 foo 1.2.3.4:1234 Sun Jan 1 23:42:00 2012 1238702330
|
||||||
ROUTING_TABLE 192.168.66.2 bar 1.2.3.5:1235 Sun Jan 1 23:42:00 2012 1238702330
|
ROUTING_TABLE 192.168.66.2 bar 1.2.3.5:1235 Sun Jan 1 23:42:00 2012 1238702330
|
||||||
|
8
examples/status2_5.v2
Normal file
8
examples/status2_5.v2
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
TITLE,OpenVPN 2.5.1 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on May 14 2021
|
||||||
|
TIME,2012-01-01 23:42:00,1238702330
|
||||||
|
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Virtual IPv6 Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t),Username,Client ID,Peer ID,Data Channel Cipher
|
||||||
|
CLIENT_LIST,foo,1.2.3.4:1234,192.168.66.2,,11811160064,4194304,2012-01-01 23:42:00,1238702330,UNDEF,1,0,AES-256-GCM
|
||||||
|
HEADER,ROUTING_TABLE,Virtual Address,Common Name,Real Address,Last Ref,Last Ref (time_t)
|
||||||
|
ROUTING_TABLE,192.168.66.2,foo,1.2.3.4:1234,2012-01-01 23:42:00,1238702330
|
||||||
|
GLOBAL_STATS,Max bcast/mcast queue length,42
|
||||||
|
END
|
@@ -7,9 +7,10 @@ require 'logger'
|
|||||||
require 'ipaddr'
|
require 'ipaddr'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'rack'
|
require 'rack'
|
||||||
|
require 'rackup'
|
||||||
require 'erb'
|
require 'erb'
|
||||||
require 'metriks'
|
require 'metriks'
|
||||||
require 'better_errors' if ENV['RACK_ENV'] == 'development'
|
require 'better_errors' if ENV.fetch('RACK_ENV', nil) == 'development'
|
||||||
|
|
||||||
require 'openvpn-status-web/status'
|
require 'openvpn-status-web/status'
|
||||||
require 'openvpn-status-web/parser/v1'
|
require 'openvpn-status-web/parser/v1'
|
||||||
@@ -128,21 +129,21 @@ module OpenVPNStatusWeb
|
|||||||
|
|
||||||
# configure rack
|
# configure rack
|
||||||
app = Daemon.new(config['vpns'])
|
app = Daemon.new(config['vpns'])
|
||||||
if ENV['RACK_ENV'] == 'development'
|
if ENV.fetch('RACK_ENV', nil) == 'development'
|
||||||
app = BetterErrors::Middleware.new(app)
|
app = BetterErrors::Middleware.new(app)
|
||||||
BetterErrors.application_root = File.expand_path(__dir__)
|
BetterErrors.application_root = File.expand_path(__dir__)
|
||||||
end
|
end
|
||||||
|
|
||||||
Signal.trap('INT') do
|
Signal.trap('INT') do
|
||||||
OpenVPNStatusWeb.logger.info 'Quitting...'
|
OpenVPNStatusWeb.logger.info 'Quitting...'
|
||||||
Rack::Handler::WEBrick.shutdown
|
Rackup::Handler::WEBrick.shutdown
|
||||||
end
|
end
|
||||||
Signal.trap('TERM') do
|
Signal.trap('TERM') do
|
||||||
OpenVPNStatusWeb.logger.info 'Quitting...'
|
OpenVPNStatusWeb.logger.info 'Quitting...'
|
||||||
Rack::Handler::WEBrick.shutdown
|
Rackup::Handler::WEBrick.shutdown
|
||||||
end
|
end
|
||||||
|
|
||||||
Rack::Handler::WEBrick.run app, Host: config['host'], Port: config['port']
|
Rackup::Handler::WEBrick.run app, Host: config['host'], Port: config['port']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -50,20 +50,36 @@ thead {
|
|||||||
<div>
|
<div>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<td class="first">Common Name</td>
|
<% status.client_list_headers.each_with_index do |header,i| %>
|
||||||
<td class="middle">Real Address</td>
|
<% if i == 0 %>
|
||||||
<td class="middle">Data Received</td>
|
<td class="first">
|
||||||
<td class="middle">Data Sent</td>
|
<% elsif i == status.client_list_headers.size-1 %>
|
||||||
<td class="last">Connected Since</td>
|
<td class="last">
|
||||||
|
<% else %>
|
||||||
|
<td class="middle">
|
||||||
|
<% end %>
|
||||||
|
<%= header %></td>
|
||||||
|
<% end %>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% status.client_list.each do |client| %>
|
<% status.client_list.each do |client| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="first"><%= client[0] %></td>
|
<% status.client_list_headers.each_with_index do |header,i| %>
|
||||||
<td class="middle"><%= client[1] %></td>
|
<% if i == 0 %>
|
||||||
<td class="middle"><%= client[2].to_i.as_bytes %></td>
|
<td class="first">
|
||||||
<td class="middle"><%= client[3].to_i.as_bytes %></td>
|
<% elsif i == status.client_list_headers.size-1 %>
|
||||||
<td class="last"><%= client[4].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
|
<td class="last">
|
||||||
|
<% else %>
|
||||||
|
<td class="middle">
|
||||||
|
<% end %>
|
||||||
|
<% if header =~ /(Received|Sent)/ %>
|
||||||
|
<%= client[i].as_bytes %></td>
|
||||||
|
<% elsif client[i].is_a? DateTime %>
|
||||||
|
<%= client[i].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
|
||||||
|
<% else %>
|
||||||
|
<%= client[i] %></td>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -74,18 +90,34 @@ thead {
|
|||||||
<div>
|
<div>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<td class="first">Virtual Address</td>
|
<% status.routing_table_headers.each_with_index do |header,i| %>
|
||||||
<td class="middle">Common Name</td>
|
<% if i == 0 %>
|
||||||
<td class="middle">Real Address</td>
|
<td class="first">
|
||||||
<td class="last">Last Ref</td>
|
<% elsif i == status.routing_table_headers.size-1 %>
|
||||||
|
<td class="last">
|
||||||
|
<% else %>
|
||||||
|
<td class="middle">
|
||||||
|
<% end %>
|
||||||
|
<%= header %></td>
|
||||||
|
<% end %>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% status.routing_table.each do |route| %>
|
<% status.routing_table.each do |route| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="first"><%= route[0] %></td>
|
<% status.routing_table_headers.each_with_index do |header,i| %>
|
||||||
<td class="middle"><%= route[1] %></td>
|
<% if i == 0 %>
|
||||||
<td class="middle"><%= route[2] %></td>
|
<td class="first">
|
||||||
<td class="last"><%= route[3].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
|
<% elsif i == status.routing_table_headers.size-1 %>
|
||||||
|
<td class="last">
|
||||||
|
<% else %>
|
||||||
|
<td class="middle">
|
||||||
|
<% end %>
|
||||||
|
<% if route[i].is_a? DateTime %>
|
||||||
|
<%= route[i].strftime('%-d.%-m.%Y %H:%M:%S') %></td>
|
||||||
|
<% else %>
|
||||||
|
<%= route[i] %></td>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@@ -5,29 +5,38 @@ module OpenVPNStatusWeb
|
|||||||
class ModernStateless
|
class ModernStateless
|
||||||
def self.parse_status_log(text, sep)
|
def self.parse_status_log(text, sep)
|
||||||
status = Status.new
|
status = Status.new
|
||||||
|
status.client_list_headers = []
|
||||||
status.client_list = []
|
status.client_list = []
|
||||||
|
status.routing_table_headers = []
|
||||||
status.routing_table = []
|
status.routing_table = []
|
||||||
status.global_stats = []
|
status.global_stats = []
|
||||||
|
|
||||||
text.lines.each do |line|
|
text.lines.each do |line|
|
||||||
parts = line.strip.split(sep)
|
parts = line.strip.split(sep)
|
||||||
status.client_list << parse_client(parts[1..5]) if parts[0] == 'CLIENT_LIST'
|
status.client_list_headers = parts[2..] if parts[0] == 'HEADER' && parts[1] == 'CLIENT_LIST'
|
||||||
status.routing_table << parse_route(parts[1..4]) if parts[0] == 'ROUTING_TABLE'
|
status.client_list << parse_client(parts[1..], status.client_list_headers) if parts[0] == 'CLIENT_LIST'
|
||||||
|
status.routing_table_headers = parts[2..] if parts[0] == 'HEADER' && parts[1] == 'ROUTING_TABLE'
|
||||||
|
status.routing_table << parse_route(parts[1..], status.routing_table_headers) if parts[0] == 'ROUTING_TABLE'
|
||||||
status.global_stats << parse_global(parts[1..2]) if parts[0] == 'GLOBAL_STATS'
|
status.global_stats << parse_global(parts[1..2]) if parts[0] == 'GLOBAL_STATS'
|
||||||
end
|
end
|
||||||
|
|
||||||
status
|
status
|
||||||
end
|
end
|
||||||
|
|
||||||
private_class_method def self.parse_client(client)
|
private_class_method def self.parse_client(client, headers)
|
||||||
client[2] = client[2].to_i
|
headers.each_with_index do |header, i|
|
||||||
client[3] = client[3].to_i
|
client[i] = parse_date(client[i]) if header.end_with?('Since')
|
||||||
client[4] = DateTime.strptime(client[4], '%a %b %d %k:%M:%S %Y')
|
client[i] = client[i].to_i if header.start_with?('Bytes')
|
||||||
|
end
|
||||||
|
|
||||||
client
|
client
|
||||||
end
|
end
|
||||||
|
|
||||||
private_class_method def self.parse_route(route)
|
private_class_method def self.parse_route(route, headers)
|
||||||
route[3] = DateTime.strptime(route[3], '%a %b %d %k:%M:%S %Y')
|
headers.each_with_index do |header, i|
|
||||||
|
route[i] = parse_date(route[i]) if header.end_with?('Last Ref')
|
||||||
|
end
|
||||||
|
|
||||||
route
|
route
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -35,6 +44,12 @@ module OpenVPNStatusWeb
|
|||||||
global[1] = global[1].to_i
|
global[1] = global[1].to_i
|
||||||
global
|
global
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private_class_method def self.parse_date(date_string)
|
||||||
|
DateTime.strptime(date_string, '%a %b %d %k:%M:%S %Y')
|
||||||
|
rescue ArgumentError
|
||||||
|
DateTime.strptime(date_string, '%Y-%m-%d %k:%M:%S')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -26,8 +26,10 @@ module OpenVPNStatusWeb
|
|||||||
end
|
end
|
||||||
|
|
||||||
status = Status.new
|
status = Status.new
|
||||||
status.client_list = client_list[2..-1].map { |client| parse_client(client) }
|
status.client_list_headers = ['Common Name', 'Real Address', 'Data Received', 'Data Sent', 'Connected Since']
|
||||||
status.routing_table = routing_table[1..-1].map { |route| parse_route(route) }
|
status.client_list = client_list[2..].map { |client| parse_client(client) }
|
||||||
|
status.routing_table_headers = ['Virtual Address', 'Common Name', 'Real Address', 'Last Ref']
|
||||||
|
status.routing_table = routing_table[1..].map { |route| parse_route(route) }
|
||||||
status.global_stats = global_stats.map { |global| parse_global(global) }
|
status.global_stats = global_stats.map { |global| parse_global(global) }
|
||||||
status
|
status
|
||||||
end
|
end
|
||||||
|
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
module OpenVPNStatusWeb
|
module OpenVPNStatusWeb
|
||||||
class Status
|
class Status
|
||||||
|
attr_accessor :client_list_headers
|
||||||
attr_accessor :client_list
|
attr_accessor :client_list
|
||||||
|
attr_accessor :routing_table_headers
|
||||||
attr_accessor :routing_table
|
attr_accessor :routing_table
|
||||||
attr_accessor :global_stats
|
attr_accessor :global_stats
|
||||||
end
|
end
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module OpenVPNStatusWeb
|
module OpenVPNStatusWeb
|
||||||
VERSION = '3.1.0'
|
VERSION = '3.3.0'
|
||||||
end
|
end
|
||||||
|
@@ -24,21 +24,22 @@ Gem::Specification.new do |s|
|
|||||||
s.executables = ['openvpn-status-web']
|
s.executables = ['openvpn-status-web']
|
||||||
s.extra_rdoc_files = Dir['README.md', 'LICENSE']
|
s.extra_rdoc_files = Dir['README.md', 'LICENSE']
|
||||||
|
|
||||||
s.required_ruby_version = '>= 2.5'
|
s.required_ruby_version = '>= 2.7'
|
||||||
|
|
||||||
s.add_runtime_dependency 'metriks'
|
s.add_runtime_dependency 'metriks'
|
||||||
s.add_runtime_dependency 'rack', '~> 2.0'
|
s.add_runtime_dependency 'rack', '~> 3.0'
|
||||||
|
s.add_runtime_dependency 'rackup'
|
||||||
s.add_runtime_dependency 'webrick', '>= 1.6.1'
|
s.add_runtime_dependency 'webrick', '>= 1.6.1'
|
||||||
|
|
||||||
s.add_development_dependency 'better_errors'
|
s.add_development_dependency 'better_errors'
|
||||||
s.add_development_dependency 'binding_of_caller'
|
s.add_development_dependency 'binding_of_caller'
|
||||||
s.add_development_dependency 'bundler'
|
s.add_development_dependency 'bundler'
|
||||||
s.add_development_dependency 'bundler-audit', '~> 0.7.0'
|
s.add_development_dependency 'bundler-audit', '~> 0.9.0'
|
||||||
s.add_development_dependency 'rack-test'
|
s.add_development_dependency 'rack-test'
|
||||||
s.add_development_dependency 'rake'
|
s.add_development_dependency 'rake'
|
||||||
s.add_development_dependency 'rspec'
|
s.add_development_dependency 'rspec'
|
||||||
s.add_development_dependency 'rubocop', '~> 1.8.1'
|
s.add_development_dependency 'rubocop', '~> 1.36.0'
|
||||||
s.add_development_dependency 'rubocop-rake', '~> 0.5.1'
|
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
||||||
s.add_development_dependency 'rubocop-rspec', '~> 2.1.0'
|
s.add_development_dependency 'rubocop-rspec', '~> 2.13.1'
|
||||||
s.add_development_dependency 'solargraph', ' ~> 0.40.0'
|
s.add_development_dependency 'solargraph', '~> 0.46.0'
|
||||||
end
|
end
|
||||||
|
@@ -17,21 +17,30 @@ describe OpenVPNStatusWeb::Parser::ModernStateless do
|
|||||||
expect(status.client_list.map { |client| client[1] }).to eq(['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
|
end
|
||||||
|
|
||||||
|
it 'parses virtual addresses' do
|
||||||
|
expect(status.client_list.map { |client| client[2] }).to eq(['192.168.66.2', '2001:db8:0:0::1000'])
|
||||||
|
end
|
||||||
|
|
||||||
it 'parses received bytes' do
|
it 'parses received bytes' do
|
||||||
expect(status.client_list.map { |client| client[2] }).to eq([11_811_160_064, 512])
|
expect(status.client_list.map { |client| client[3] }).to eq([11_811_160_064, 512])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'parses sent bytes' do
|
it 'parses sent bytes' do
|
||||||
expect(status.client_list.map { |client| client[3] }).to eq([4_194_304, 2048])
|
expect(status.client_list.map { |client| client[4] }).to eq([4_194_304, 2048])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'parses connected since date' do
|
it 'parses connected since date' do
|
||||||
expect(status.client_list.map { |client| client[4] }).to eq(
|
expect(status.client_list.map { |client| client[5] }).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 'has the same number of headers' do
|
||||||
|
expect(status.client_list[0].size).to eq(status.client_list_headers.size)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with routing table' do
|
context 'with routing table' do
|
||||||
@@ -55,6 +64,10 @@ describe OpenVPNStatusWeb::Parser::ModernStateless do
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has the same number of headers' do
|
||||||
|
expect(status.routing_table[0].size).to eq(status.routing_table_headers.size)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'parses global stats' do
|
it 'parses global stats' do
|
||||||
@@ -63,4 +76,8 @@ describe OpenVPNStatusWeb::Parser::ModernStateless do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'parses status-version 2 of OpenVPN 2.5' do
|
||||||
|
expect(status_2_5_v2).not_to be_nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@@ -31,6 +31,10 @@ describe OpenVPNStatusWeb::Parser::V1 do
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has the same number of headers' do
|
||||||
|
expect(status.client_list[0].length).to eq(status.client_list_headers.length)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with routing table' do
|
context 'with routing table' do
|
||||||
@@ -54,6 +58,10 @@ describe OpenVPNStatusWeb::Parser::V1 do
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has the same number of headers' do
|
||||||
|
expect(status.routing_table[0].length).to eq(status.routing_table_headers.length)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'parses global stats' do
|
it 'parses global stats' do
|
||||||
|
@@ -7,16 +7,21 @@ require 'rack/test'
|
|||||||
require 'openvpn-status-web'
|
require 'openvpn-status-web'
|
||||||
|
|
||||||
def status_v1
|
def status_v1
|
||||||
text = File.open('examples/status.v1', 'rb', &:read)
|
text = File.binread('examples/status.v1')
|
||||||
OpenVPNStatusWeb::Parser::V1.new.parse_status_log text
|
OpenVPNStatusWeb::Parser::V1.new.parse_status_log text
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_v2
|
def status_v2
|
||||||
text = File.open('examples/status.v2', 'rb', &:read)
|
text = File.binread('examples/status.v2')
|
||||||
|
OpenVPNStatusWeb::Parser::V2.new.parse_status_log text
|
||||||
|
end
|
||||||
|
|
||||||
|
def status_2_5_v2
|
||||||
|
text = File.binread('examples/status2_5.v2')
|
||||||
OpenVPNStatusWeb::Parser::V2.new.parse_status_log text
|
OpenVPNStatusWeb::Parser::V2.new.parse_status_log text
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_v3
|
def status_v3
|
||||||
text = File.open('examples/status.v3', 'rb', &:read)
|
text = File.binread('examples/status.v3')
|
||||||
OpenVPNStatusWeb::Parser::V3.new.parse_status_log text
|
OpenVPNStatusWeb::Parser::V3.new.parse_status_log text
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user