github.com/sagernet/sing-box@v1.9.0-rc.20/transport/v2ray/grpc_lite.go (about)

     1  //go:build !with_grpc
     2  
     3  package v2ray
     4  
     5  import (
     6  	"context"
     7  
     8  	"github.com/sagernet/sing-box/adapter"
     9  	"github.com/sagernet/sing-box/common/tls"
    10  	"github.com/sagernet/sing-box/option"
    11  	"github.com/sagernet/sing-box/transport/v2raygrpclite"
    12  	M "github.com/sagernet/sing/common/metadata"
    13  	N "github.com/sagernet/sing/common/network"
    14  )
    15  
    16  func NewGRPCServer(ctx context.Context, options option.V2RayGRPCOptions, tlsConfig tls.ServerConfig, handler adapter.V2RayServerTransportHandler) (adapter.V2RayServerTransport, error) {
    17  	return v2raygrpclite.NewServer(ctx, options, tlsConfig, handler)
    18  }
    19  
    20  func NewGRPCClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, options option.V2RayGRPCOptions, tlsConfig tls.Config) (adapter.V2RayClientTransport, error) {
    21  	return v2raygrpclite.NewClient(ctx, dialer, serverAddr, options, tlsConfig), nil
    22  }