fix nil route panic
This commit is contained in:
@ -204,7 +204,7 @@ func (r *Router) Bind(ctx context.Context, network, address string, opts ...Bind
|
|||||||
var route Route
|
var route Route
|
||||||
if r.options.Chain != nil {
|
if r.options.Chain != nil {
|
||||||
route = r.options.Chain.Route(ctx, network, address)
|
route = r.options.Chain.Route(ctx, network, address)
|
||||||
if len(route.Nodes()) == 0 {
|
if route == nil || len(route.Nodes()) == 0 {
|
||||||
err = ErrEmptyRoute
|
err = ErrEmptyRoute
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -219,6 +219,9 @@ func (r *Router) Bind(ctx context.Context, network, address string, opts ...Bind
|
|||||||
r.options.Logger.Debugf("route(retry=%d) %s", i, buf.String())
|
r.options.Logger.Debugf("route(retry=%d) %s", i, buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if route == nil {
|
||||||
|
route = DefaultRoute
|
||||||
|
}
|
||||||
ln, err = route.Bind(ctx, network, address, opts...)
|
ln, err = route.Bind(ctx, network, address, opts...)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user