Skip to content

Commit 5d93eb4

Browse files
authored
fix(vnstat): panic when not enough data available (#14)
1 parent 2a238be commit 5d93eb4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/status/status.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ func TrafficVnstat() (uint64, uint64, error) {
122122
return 0, 0, err
123123
}
124124
vData := strings.Split(BytesToString(buf), ";")
125+
if len(vData) != 15 {
126+
// Not enough data available yet.
127+
return 0, 0, nil
128+
}
125129
rx, err := strconv.ParseUint(vData[8], 10, 64)
126130
if err != nil {
127131
return 0, 0, err

0 commit comments

Comments
 (0)