1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

Fix Dial function crash instance when there is no instance context in the ctx

This commit is contained in:
Shelikhoo 2021-04-02 12:16:09 +01:00
parent e31bfe02f0
commit fc73774e4a
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316

View File

@ -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