소스 검색

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

Shelikhoo 4 년 전
부모
커밋
fc73774e4a
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      functions.go

+ 5 - 0
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