Skip to content

Commit

Permalink
fix bug for nil pointer (MHSanaei#2438)
Browse files Browse the repository at this point in the history
  • Loading branch information
athom authored and aircross committed Jul 23, 2024
1 parent a13d10c commit 1276277
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xray/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ func (x *XrayAPI) GetTraffic(reset bool) ([]*Traffic, []*ClientTraffic, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

if x.StatsServiceClient == nil {
return nil, nil, common.NewError("xray StatusServiceClient is not initialized")
}

resp, err := (*x.StatsServiceClient).QueryStats(ctx, &statsService.QueryStatsRequest{Reset_: reset})
if err != nil {
logger.Debug("Failed to query Xray stats:", err)
Expand Down

0 comments on commit 1276277

Please sign in to comment.