-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
custom_name.go
51 lines (43 loc) · 1.27 KB
/
custom_name.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package v2raygrpc
import (
"context"
"google.golang.org/grpc"
)
type GunService interface {
Context() context.Context
Send(*Hunk) error
Recv() (*Hunk, error)
}
func ServerDesc(name string) grpc.ServiceDesc {
return grpc.ServiceDesc{
ServiceName: name,
HandlerType: (*GunServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "Tun",
Handler: _GunService_Tun_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "gun.proto",
}
}
func (c *gunServiceClient) TunCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GunService_TunClient, error) {
stream, err := c.cc.NewStream(ctx, &ServerDesc(name).Streams[0], "/"+name+"/Tun", opts...)
if err != nil {
return nil, err
}
x := &gunServiceTunClient{stream}
return x, nil
}
var _ GunServiceCustomNameClient = (*gunServiceClient)(nil)
type GunServiceCustomNameClient interface {
TunCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GunService_TunClient, error)
Tun(ctx context.Context, opts ...grpc.CallOption) (GunService_TunClient, error)
}
func RegisterGunServiceCustomNameServer(s *grpc.Server, srv GunServiceServer, name string) {
desc := ServerDesc(name)
s.RegisterService(&desc, srv)
}