Skip to content

Commit

Permalink
Fix parsing last online user (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonovk authored Aug 3, 2024
1 parent 1103673 commit bdface0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/wire_guard/stat_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse_wg_line(peer_data)
end

def build_latest_data(data)
data[-3..]&.join(' ')
data[2..]&.join(' ')
end

def build_traffic_data(data)
Expand Down
2 changes: 1 addition & 1 deletion spec/app/clients_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
dns: '1.1.1.1',
persistent_keepalive: 0,
endpoint: '2.2.2.2:51820',
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/stat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ peer: LiXk4UOfnScgf4UnkcYNcz4wWeqTOW1UrHKRVhZ1OXg=
preshared key: (hidden)
endpoint: 109.252.46.192:1382
allowed ips: 10.8.0.26/32
latest handshake: 25 seconds ago
latest handshake: 2 hours, 10 minutes, 20 seconds ago
transfer: 56.28 MiB received, 1.35 GiB sent

peer: hvIyIW2o8JROVKuY2yYFdUn0oA+43aLuT8KCy0YbORE=
Expand Down
18 changes: 9 additions & 9 deletions spec/lib/wire_guard/server_stat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
let(:expected_result) do
{
'LiXk4UOfnScgf4UnkcYNcz4wWeqTOW1UrHKRVhZ1OXg=' => {
last_online: '25 seconds ago',
last_online: '2 hours, 10 minutes, 20 seconds ago',
traffic: {
received: '56.28 MiB',
sent: '1.35 GiB'
Expand All @@ -33,7 +33,7 @@
}
},
'bPKBg66uC1J2hlkE31Of5wnkg+IjowVXgoLcjcLn0js=' => {
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand Down Expand Up @@ -63,7 +63,7 @@
let(:expected_result) do
{
'LiXk4UOfnScgf4UnkcYNcz4wWeqTOW1UrHKRVhZ1OXg=' => {
last_online: '25 seconds ago',
last_online: '2 hours, 10 minutes, 20 seconds ago',
traffic: {
received: '56.28 MiB',
sent: '1.35 GiB'
Expand All @@ -77,7 +77,7 @@
}
},
'bPKBg66uC1J2hlkE31Of5wnkg+IjowVXgoLcjcLn0js=' => {
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand Down Expand Up @@ -108,7 +108,7 @@
'LiXk4UOfnScgf4UnkcYNcz4wWeqTOW1UrHKRVhZ1OXg=' => {},
'hvIyIW2o8JROVKuY2yYFdUn0oA+43aLuT8KCy0YbORE=' => {},
'bPKBg66uC1J2hlkE31Of5wnkg+IjowVXgoLcjcLn0js=' => {
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand Down Expand Up @@ -154,7 +154,7 @@
}
},
'bPKBg66uC1J2hlkE31Of5wnkg+IjowVXgoLcjcLn0js=' => {
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand Down Expand Up @@ -186,7 +186,7 @@
let(:expected_result) do
{
'LiXk4UOfnScgf4UnkcYNcz4wWeqTOW1UrHKRVhZ1OXg=' => {
last_online: '25 seconds ago',
last_online: '2 hours, 10 minutes, 20 seconds ago',
traffic: {
received: '56.28 MiB',
sent: '1.35 GiB'
Expand All @@ -200,7 +200,7 @@
}
},
'bPKBg66uC1J2hlkE31Of5wnkg+IjowVXgoLcjcLn0js=' => {
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand Down Expand Up @@ -236,7 +236,7 @@
},
'hvIyIW2o8JROVKuY2yYFdUn0oA+43aLuT8KCy0YbORE=' => {},
'bPKBg66uC1J2hlkE31Of5wnkg+IjowVXgoLcjcLn0js=' => {
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/wire_guard/stat_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let(:expected_result) do
{
'LiXk4UOfnScgf4UnkcYNcz4wWeqTOW1UrHKRVhZ1OXg=' => {
last_online: '25 seconds ago',
last_online: '2 hours, 10 minutes, 20 seconds ago',
traffic: {
received: '56.28 MiB',
sent: '1.35 GiB'
Expand All @@ -26,7 +26,7 @@
}
},
'bPKBg66uC1J2hlkE31Of5wnkg+IjowVXgoLcjcLn0js=' => {
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand All @@ -47,7 +47,7 @@
'LiXk4UOfnScgf4UnkcYNcz4wWeqTOW1UrHKRVhZ1OXg=' => {},
'hvIyIW2o8JROVKuY2yYFdUn0oA+43aLuT8KCy0YbORE=' => {},
'bPKBg66uC1J2hlkE31Of5wnkg+IjowVXgoLcjcLn0js=' => {
last_online: '13 seconds ago',
last_online: '1 minute, 13 seconds ago',
traffic: {
received: '62.44 MiB',
sent: '3.21 GiB'
Expand Down

0 comments on commit bdface0

Please sign in to comment.