mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-05 03:16:03 +03:00
Add nil check
This commit is contained in:
parent
83d6acf536
commit
bf47769592
@ -139,6 +139,10 @@ func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration) []*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)
|
observeResult, err := s.observer.GetObservation(s.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.LogInfoInner(s.ctx, err, "cannot get observation")
|
errors.LogInfoInner(s.ctx, err, "cannot get observation")
|
||||||
|
@ -28,9 +28,13 @@ func (l *LeastPingStrategy) InjectContext(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *LeastPingStrategy) PickOutbound(strings []string) string {
|
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)
|
observeReport, err := l.observatory.GetObservation(l.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.LogInfoInner(l.ctx, err, "cannot get observe report")
|
errors.LogInfoInner(l.ctx, err, "cannot get observer report")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
outboundsList := outboundList(strings)
|
outboundsList := outboundList(strings)
|
||||||
|
Loading…
Reference in New Issue
Block a user