Skip to content

Commit

Permalink
fix(vnstat): panic when not enough data available (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
cubercsl committed Feb 2, 2022
1 parent 2a238be commit 5d93eb4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/status/status.go
Expand Up @@ -122,6 +122,10 @@ func TrafficVnstat() (uint64, uint64, error) {
return 0, 0, err
}
vData := strings.Split(BytesToString(buf), ";")
if len(vData) != 15 {
// Not enough data available yet.
return 0, 0, nil
}
rx, err := strconv.ParseUint(vData[8], 10, 64)
if err != nil {
return 0, 0, err
Expand Down

0 comments on commit 5d93eb4

Please sign in to comment.