mirror of https://github.com/XTLS/Xray-core
Fix null pointer exception for observatory
Core setup router object first, when InjectContext() is called, observatory object is still null, so observatory need to be injected after InjectContext()pull/838/head
parent
d6ae4e9ba2
commit
7c240e8630
|
@ -15,14 +15,17 @@ type LeastPingStrategy struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LeastPingStrategy) InjectContext(ctx context.Context) {
|
func (l *LeastPingStrategy) InjectContext(ctx context.Context) {
|
||||||
common.Must(core.RequireFeatures(ctx, func(observatory extension.Observatory) error {
|
|
||||||
l.observatory = observatory
|
|
||||||
return nil
|
|
||||||
}))
|
|
||||||
l.ctx = ctx
|
l.ctx = ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LeastPingStrategy) PickOutbound(strings []string) string {
|
func (l *LeastPingStrategy) PickOutbound(strings []string) string {
|
||||||
|
if l.observatory == nil {
|
||||||
|
common.Must(core.RequireFeatures(l.ctx, func(observatory extension.Observatory) error {
|
||||||
|
l.observatory = observatory
|
||||||
|
return nil
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
observeReport, err := l.observatory.GetObservation(l.ctx)
|
observeReport, err := l.observatory.GetObservation(l.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError("cannot get observe report").Base(err).WriteToLog()
|
newError("cannot get observe report").Base(err).WriteToLog()
|
||||||
|
|
Loading…
Reference in New Issue