mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-18 18:36:11 -05:00
aaa9e788e7
* introduce grpc transport structure * fix package name inconsistency * grpc gun transport dialer and listener * add selective build tag * add grpc:gun listener * add grpc:gun config * add generated files * various bug fix for gun:grpc transport * Cache dialed connections * grpc:gun Use V2Ray Managed Dial function * Update destination.pb.go * Update gun.go * GunSettings -> GunConfig * gu -> gs * add grpc alias Co-authored-by: RPRX <63339210+rprx@users.noreply.github.com> Co-authored-by: kslr <kslrwang@gmail.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// +build !confonly
|
|
|
|
package encoding
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
type GunServiceClientX interface {
|
|
TunCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GunService_TunClient, error)
|
|
Tun(ctx context.Context, opts ...grpc.CallOption) (GunService_TunClient, error)
|
|
}
|
|
|
|
func RegisterGunServiceServerX(s *grpc.Server, srv GunServiceServer, name string) {
|
|
desc := ServerDesc(name)
|
|
s.RegisterService(&desc, srv)
|
|
}
|