Skip to content

Commit

Permalink
Fix Dial function crash instance when there is no instance context in…
Browse files Browse the repository at this point in the history
… the ctx
  • Loading branch information
xiaokangwang committed Apr 2, 2021
1 parent e31bfe0 commit fc73774
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func Dial(ctx context.Context, v *Instance, dest net.Destination) (net.Conn, err
if dispatcher == nil {
return nil, newError("routing.Dispatcher is not registered in V2Ray core")
}

if ctx.Value(v2rayKey) == nil {
ctx = context.WithValue(ctx, v2rayKey, v)
}

r, err := dispatcher.(routing.Dispatcher).Dispatch(ctx, dest)
if err != nil {
return nil, err
Expand Down

0 comments on commit fc73774

Please sign in to comment.