mirror of
https://github.com/cmur2/openvpn-status-web.git
synced 2025-06-29 10:30:23 +02:00
Refactoring
This commit is contained in:
28
lib/openvpn-status-web/parser/v1.rb
Normal file
28
lib/openvpn-status-web/parser/v1.rb
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
module OpenVPNStatusWeb
|
||||
module Parser
|
||||
class V1
|
||||
def parse_status_log(text)
|
||||
current_section = :none
|
||||
client_list = []
|
||||
routing_table = []
|
||||
global_stats = []
|
||||
|
||||
text.lines.each do |line|
|
||||
(current_section = :cl; next) if line == "OpenVPN CLIENT LIST\n"
|
||||
(current_section = :rt; next) if line == "ROUTING TABLE\n"
|
||||
(current_section = :gs; next) if line == "GLOBAL STATS\n"
|
||||
(current_section = :end; next) if line == "END\n"
|
||||
|
||||
case current_section
|
||||
when :cl then client_list << line.strip.split(',')
|
||||
when :rt then routing_table << line.strip.split(',')
|
||||
when :gs then global_stats << line.strip.split(',')
|
||||
end
|
||||
end
|
||||
|
||||
[client_list[2..-1], routing_table[1..-1], global_stats]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
0
lib/openvpn-status-web/status.rb
Normal file
0
lib/openvpn-status-web/status.rb
Normal file
Reference in New Issue
Block a user