github.com/imannamdari/v2ray-core/v5@v5.0.5/transport/internet/security/util.go (about) 1 package security 2 3 import ( 4 "context" 5 6 "github.com/imannamdari/v2ray-core/v5/common" 7 "github.com/imannamdari/v2ray-core/v5/transport/internet" 8 ) 9 10 func CreateSecurityEngineFromSettings(context context.Context, settings *internet.MemoryStreamConfig) (Engine, error) { 11 if settings == nil || settings.SecurityType == "" { 12 return nil, nil 13 } 14 securityEngine, err := common.CreateObject(context, settings.SecuritySettings) 15 if err != nil { 16 return nil, newError("unable to create security engine from security settings").Base(err) 17 } 18 securityEngineTyped, ok := securityEngine.(Engine) 19 if !ok { 20 return nil, newError("type assertion error when create security engine from security settings") 21 } 22 return securityEngineTyped, nil 23 }