mirror of
https://github.com/cmur2/openvpn-status-web.git
synced 2024-11-16 20:56:14 +01:00
gem: support date format used by OpenVPN 2.5
- smooth fallback
This commit is contained in:
parent
528709c895
commit
9ad59194bd
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
|
@ -45,6 +45,8 @@ module OpenVPNStatusWeb
|
||||
|
||||
private_class_method def self.parse_date(date_string)
|
||||
DateTime.strptime(date_string, '%a %b %d %k:%M:%S %Y')
|
||||
rescue Date::Error
|
||||
DateTime.strptime(date_string, '%Y-%m-%d %k:%M:%S')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -76,4 +76,8 @@ describe OpenVPNStatusWeb::Parser::ModernStateless do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'parses status-version 2 of OpenVPN 2.5' do
|
||||
expect(status_2_5_v2).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
@ -16,6 +16,11 @@ def 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
|
||||
end
|
||||
|
||||
def status_v3
|
||||
text = File.binread('examples/status.v3')
|
||||
OpenVPNStatusWeb::Parser::V3.new.parse_status_log text
|
||||
|
Loading…
Reference in New Issue
Block a user