github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/transport/internet/grpc/encoding/customSeviceName.go (about) 1 //go:build !confonly 2 // +build !confonly 3 4 package encoding 5 6 import ( 7 "context" 8 9 "google.golang.org/grpc" 10 ) 11 12 func ServerDesc(name string) grpc.ServiceDesc { 13 return grpc.ServiceDesc{ 14 ServiceName: name, 15 HandlerType: (*GunServiceServer)(nil), 16 Methods: []grpc.MethodDesc{}, 17 Streams: []grpc.StreamDesc{ 18 { 19 StreamName: "Tun", 20 Handler: _GunService_Tun_Handler, 21 ServerStreams: true, 22 ClientStreams: true, 23 }, 24 }, 25 Metadata: "gun.proto", 26 } 27 } 28 29 func (c *gunServiceClient) TunCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GunService_TunClient, error) { 30 stream, err := c.cc.NewStream(ctx, &ServerDesc(name).Streams[0], "/"+name+"/Tun", opts...) 31 if err != nil { 32 return nil, err 33 } 34 x := &gunServiceTunClient{stream} 35 return x, nil 36 } 37 38 type GunServiceClientX interface { 39 TunCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GunService_TunClient, error) 40 Tun(ctx context.Context, opts ...grpc.CallOption) (GunService_TunClient, error) 41 } 42 43 func RegisterGunServiceServerX(s *grpc.Server, srv GunServiceServer, name string) { 44 desc := ServerDesc(name) 45 s.RegisterService(&desc, srv) 46 }