Skip to content

Commit

Permalink
fix: nil deref error in /services/status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mojtaba-esk committed Dec 12, 2023
1 parent b065de7 commit f5f94e6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/v1/net_services_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,24 @@ func (a *RESTApiV1) NetServicesStatus(resp http.ResponseWriter, req *http.Reques
if s, ok := ns.service.(*packetloss.PacketLoss); ok {
name = "packetloss"
params["packet_loss_rate"] = s.PacketLossRate
netIfaceName = s.NetworkInterface.Name
if s.NetworkInterface != nil {
netIfaceName = s.NetworkInterface.Name
}

} else if s, ok := ns.service.(*bandwidth.Bandwidth); ok {
name = "bandwidth"
params["limit"] = s.Limit
netIfaceName = s.NetworkInterface.Name
if s.NetworkInterface != nil {
netIfaceName = s.NetworkInterface.Name
}

} else if s, ok := ns.service.(*latency.Latency); ok {
name = "latency"
params["latency_ms"] = s.Latency.Milliseconds()
params["jitter_ms"] = s.Jitter.Milliseconds()
netIfaceName = s.NetworkInterface.Name
if s.NetworkInterface != nil {
netIfaceName = s.NetworkInterface.Name
}

} else {
sendJSONError(resp,
Expand Down

0 comments on commit f5f94e6

Please sign in to comment.