diff --git a/app/router/strategy_leastload.go b/app/router/strategy_leastload.go index e4620725..1bf3cbc0 100644 --- a/app/router/strategy_leastload.go +++ b/app/router/strategy_leastload.go @@ -139,6 +139,10 @@ func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node { } func (s *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration) []*node { + if s.observer == nil { + errors.LogError(s.ctx, "observer is nil") + return make([]*node, 0) + } observeResult, err := s.observer.GetObservation(s.ctx) if err != nil { errors.LogInfoInner(s.ctx, err, "cannot get observation") diff --git a/app/router/strategy_leastping.go b/app/router/strategy_leastping.go index f4e53ed7..ada3492d 100644 --- a/app/router/strategy_leastping.go +++ b/app/router/strategy_leastping.go @@ -28,9 +28,13 @@ func (l *LeastPingStrategy) InjectContext(ctx context.Context) { } func (l *LeastPingStrategy) PickOutbound(strings []string) string { + if l.observatory == nil { + errors.LogError(l.ctx, "observer is nil") + return "" + } observeReport, err := l.observatory.GetObservation(l.ctx) if err != nil { - errors.LogInfoInner(l.ctx, err, "cannot get observe report") + errors.LogInfoInner(l.ctx, err, "cannot get observer report") return "" } outboundsList := outboundList(strings)