From fc73774e4a132b5e6690595706fedec54f0240ee Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Fri, 2 Apr 2021 12:16:09 +0100 Subject: [PATCH] Fix Dial function crash instance when there is no instance context in the ctx --- functions.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions.go b/functions.go index d08091d8e..972fff39e 100644 --- a/functions.go +++ b/functions.go @@ -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