github.com/inazumav/sing-box@v0.0.0-20230926072359-ab51429a14f1/experimental/v2rayapi.go (about)

     1  package experimental
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/inazumav/sing-box/adapter"
     7  	"github.com/inazumav/sing-box/log"
     8  	"github.com/inazumav/sing-box/option"
     9  )
    10  
    11  type V2RayServerConstructor = func(logger log.Logger, options option.V2RayAPIOptions) (adapter.V2RayServer, error)
    12  
    13  var v2rayServerConstructor V2RayServerConstructor
    14  
    15  func RegisterV2RayServerConstructor(constructor V2RayServerConstructor) {
    16  	v2rayServerConstructor = constructor
    17  }
    18  
    19  func NewV2RayServer(logger log.Logger, options option.V2RayAPIOptions) (adapter.V2RayServer, error) {
    20  	if v2rayServerConstructor == nil {
    21  		return nil, os.ErrInvalid
    22  	}
    23  	return v2rayServerConstructor(logger, options)
    24  }