From 49ea72d0edef92a24fb1daddf6ee7485039b4ff9 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Mon, 7 Feb 2022 22:10:58 +0000 Subject: [PATCH] Add create object with environment api --- functions.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/functions.go b/functions.go index e084fc549..772606b78 100644 --- a/functions.go +++ b/functions.go @@ -3,6 +3,7 @@ package core import ( "bytes" "context" + "github.com/v2fly/v2ray-core/v5/common/environment/envctx" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/net" @@ -12,10 +13,15 @@ import ( // CreateObject creates a new object based on the given V2Ray instance and config. The V2Ray instance may be nil. func CreateObject(v *Instance, config interface{}) (interface{}, error) { + return CreateObjectWithEnvironment(v, config, nil) +} + +func CreateObjectWithEnvironment(v *Instance, config, environment interface{}) (interface{}, error) { var ctx context.Context if v != nil { ctx = toContext(v.ctx, v) } + ctx = envctx.ContextWithEnvironment(ctx, environment) return common.CreateObject(ctx, config) }