1
0
mirror of https://github.com/cmur2/openvpn-status-web.git synced 2025-08-08 08:33:59 +02:00

gem: refactor to prepare supporting flexible list headers

This commit is contained in:
cn
2022-01-17 11:37:50 +01:00
committed by Christian Nicolai
parent 406ed867f7
commit 39d2b3ce94
6 changed files with 72 additions and 18 deletions

View File

@@ -11,7 +11,9 @@ module OpenVPNStatusWeb
text.lines.each do |line|
parts = line.strip.split(sep)
status.client_list_headers = ['Common Name', 'Real Address', 'Data Received', 'Data Sent', 'Connected Since']
status.client_list << parse_client(parts[1..5]) if parts[0] == 'CLIENT_LIST'
status.routing_table_headers = ['Virtual Address', 'Common Name', 'Real Address', 'Last Ref']
status.routing_table << parse_route(parts[1..4]) if parts[0] == 'ROUTING_TABLE'
status.global_stats << parse_global(parts[1..2]) if parts[0] == 'GLOBAL_STATS'
end

View File

@@ -26,7 +26,9 @@ module OpenVPNStatusWeb
end
status = Status.new
status.client_list_headers = ['Common Name', 'Real Address', 'Data Received', 'Data Sent', 'Connected Since']
status.client_list = client_list[2..-1].map { |client| parse_client(client) }
status.routing_table_headers = ['Virtual Address', 'Common Name', 'Real Address', 'Last Ref']
status.routing_table = routing_table[1..-1].map { |route| parse_route(route) }
status.global_stats = global_stats.map { |global| parse_global(global) }
status