2018-05-31 05:55:11 -04:00
package core
import (
"context"
"v2ray.com/core/common"
2018-10-11 16:48:57 -04:00
"v2ray.com/core/common/buf"
2018-05-31 05:55:11 -04:00
)
// 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 ) {
ctx := context . Background ( )
if v != nil {
ctx = context . WithValue ( ctx , v2rayKey , v )
}
return common . CreateObject ( ctx , config )
}
2018-09-21 10:54:06 -04:00
2018-10-11 16:48:57 -04:00
// StartInstance starts a new V2Ray instance with given serialized config, and return a handle for shutting down the instance.
func StartInstance ( configFormat string , configBytes [ ] byte ) ( common . Closable , error ) {
var mb buf . MultiBuffer
common . Must2 ( mb . Write ( configBytes ) )
config , err := LoadConfig ( configFormat , "" , & mb )
if err != nil {
return nil , err
}
instance , err := New ( config )
if err != nil {
return nil , err
}
if err := instance . Start ( ) ; err != nil {
return nil , err
}
return instance , nil
}
2018-09-21 10:54:06 -04:00
func PrintDeprecatedFeatureWarning ( feature string ) {
2018-10-04 15:14:59 -04:00
newError ( "You are using a deprecated feature: " + feature + ". Please update your config file with latest configuration format, or update your client software." ) . WriteToLog ( )
2018-09-21 10:54:06 -04:00
}