1
0
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:
cn
2013-05-03 18:20:07 +02:00
parent 87d9ea302f
commit cd6e41fcfa
4 changed files with 31 additions and 20 deletions

View 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

View File