Initial commit
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v6.33.1
|
||||
// source: tunnel.proto
|
||||
|
||||
package tunnelpb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type FrameType int32
|
||||
|
||||
const (
|
||||
FrameType_FRAME_UNSPECIFIED FrameType = 0
|
||||
FrameType_FRAME_OPEN FrameType = 1 // открыть TCP stream
|
||||
FrameType_FRAME_DATA FrameType = 2
|
||||
FrameType_FRAME_CLOSE FrameType = 3
|
||||
FrameType_FRAME_PING FrameType = 4
|
||||
FrameType_FRAME_PONG FrameType = 5
|
||||
FrameType_FRAME_BIND_REQUEST FrameType = 10 // device → relay
|
||||
FrameType_FRAME_BIND_OK FrameType = 11 // relay → device
|
||||
FrameType_FRAME_BIND_REJECTED FrameType = 12 // relay → device
|
||||
)
|
||||
|
||||
// Enum value maps for FrameType.
|
||||
var (
|
||||
FrameType_name = map[int32]string{
|
||||
0: "FRAME_UNSPECIFIED",
|
||||
1: "FRAME_OPEN",
|
||||
2: "FRAME_DATA",
|
||||
3: "FRAME_CLOSE",
|
||||
4: "FRAME_PING",
|
||||
5: "FRAME_PONG",
|
||||
10: "FRAME_BIND_REQUEST",
|
||||
11: "FRAME_BIND_OK",
|
||||
12: "FRAME_BIND_REJECTED",
|
||||
}
|
||||
FrameType_value = map[string]int32{
|
||||
"FRAME_UNSPECIFIED": 0,
|
||||
"FRAME_OPEN": 1,
|
||||
"FRAME_DATA": 2,
|
||||
"FRAME_CLOSE": 3,
|
||||
"FRAME_PING": 4,
|
||||
"FRAME_PONG": 5,
|
||||
"FRAME_BIND_REQUEST": 10,
|
||||
"FRAME_BIND_OK": 11,
|
||||
"FRAME_BIND_REJECTED": 12,
|
||||
}
|
||||
)
|
||||
|
||||
func (x FrameType) Enum() *FrameType {
|
||||
p := new(FrameType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x FrameType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (FrameType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_tunnel_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (FrameType) Type() protoreflect.EnumType {
|
||||
return &file_tunnel_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x FrameType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use FrameType.Descriptor instead.
|
||||
func (FrameType) EnumDescriptor() ([]byte, []int) {
|
||||
return file_tunnel_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type Frame struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Type FrameType `protobuf:"varint,1,opt,name=type,proto3,enum=tunnel.FrameType" json:"type,omitempty"`
|
||||
StreamId uint32 `protobuf:"varint,2,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"`
|
||||
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Frame) Reset() {
|
||||
*x = Frame{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_tunnel_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Frame) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Frame) ProtoMessage() {}
|
||||
|
||||
func (x *Frame) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_tunnel_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Frame.ProtoReflect.Descriptor instead.
|
||||
func (*Frame) Descriptor() ([]byte, []int) {
|
||||
return file_tunnel_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Frame) GetType() FrameType {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return FrameType_FRAME_UNSPECIFIED
|
||||
}
|
||||
|
||||
func (x *Frame) GetStreamId() uint32 {
|
||||
if x != nil {
|
||||
return x.StreamId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Frame) GetPayload() []byte {
|
||||
if x != nil {
|
||||
return x.Payload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_tunnel_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_tunnel_proto_rawDesc = []byte{
|
||||
0x0a, 0x0c, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06,
|
||||
0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x22, 0x65, 0x0a, 0x05, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12,
|
||||
0x25, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e,
|
||||
0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65,
|
||||
0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,
|
||||
0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x73, 0x74, 0x72, 0x65, 0x61,
|
||||
0x6d, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0xb7, 0x01,
|
||||
0x0a, 0x09, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x46,
|
||||
0x52, 0x41, 0x4d, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44,
|
||||
0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x52, 0x41, 0x4d, 0x45, 0x5f, 0x4f, 0x50, 0x45, 0x4e,
|
||||
0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x52, 0x41, 0x4d, 0x45, 0x5f, 0x44, 0x41, 0x54, 0x41,
|
||||
0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x52, 0x41, 0x4d, 0x45, 0x5f, 0x43, 0x4c, 0x4f, 0x53,
|
||||
0x45, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x52, 0x41, 0x4d, 0x45, 0x5f, 0x50, 0x49, 0x4e,
|
||||
0x47, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x52, 0x41, 0x4d, 0x45, 0x5f, 0x50, 0x4f, 0x4e,
|
||||
0x47, 0x10, 0x05, 0x12, 0x16, 0x0a, 0x12, 0x46, 0x52, 0x41, 0x4d, 0x45, 0x5f, 0x42, 0x49, 0x4e,
|
||||
0x44, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x46,
|
||||
0x52, 0x41, 0x4d, 0x45, 0x5f, 0x42, 0x49, 0x4e, 0x44, 0x5f, 0x4f, 0x4b, 0x10, 0x0b, 0x12, 0x17,
|
||||
0x0a, 0x13, 0x46, 0x52, 0x41, 0x4d, 0x45, 0x5f, 0x42, 0x49, 0x4e, 0x44, 0x5f, 0x52, 0x45, 0x4a,
|
||||
0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x0c, 0x32, 0x3b, 0x0a, 0x0d, 0x54, 0x75, 0x6e, 0x6e, 0x65,
|
||||
0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x54, 0x75, 0x6e, 0x6e,
|
||||
0x65, 0x6c, 0x12, 0x0d, 0x2e, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x46, 0x72, 0x61, 0x6d,
|
||||
0x65, 0x1a, 0x0d, 0x2e, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65,
|
||||
0x28, 0x01, 0x30, 0x01, 0x42, 0x46, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x73, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x61, 0x70, 0x70, 0x2e, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a,
|
||||
0x1b, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x75, 0x6e,
|
||||
0x6e, 0x65, 0x6c, 0x3b, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_tunnel_proto_rawDescOnce sync.Once
|
||||
file_tunnel_proto_rawDescData = file_tunnel_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_tunnel_proto_rawDescGZIP() []byte {
|
||||
file_tunnel_proto_rawDescOnce.Do(func() {
|
||||
file_tunnel_proto_rawDescData = protoimpl.X.CompressGZIP(file_tunnel_proto_rawDescData)
|
||||
})
|
||||
return file_tunnel_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_tunnel_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_tunnel_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_tunnel_proto_goTypes = []interface{}{
|
||||
(FrameType)(0), // 0: tunnel.FrameType
|
||||
(*Frame)(nil), // 1: tunnel.Frame
|
||||
}
|
||||
var file_tunnel_proto_depIdxs = []int32{
|
||||
0, // 0: tunnel.Frame.type:type_name -> tunnel.FrameType
|
||||
1, // 1: tunnel.TunnelService.Tunnel:input_type -> tunnel.Frame
|
||||
1, // 2: tunnel.TunnelService.Tunnel:output_type -> tunnel.Frame
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_tunnel_proto_init() }
|
||||
func file_tunnel_proto_init() {
|
||||
if File_tunnel_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_tunnel_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Frame); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_tunnel_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_tunnel_proto_goTypes,
|
||||
DependencyIndexes: file_tunnel_proto_depIdxs,
|
||||
EnumInfos: file_tunnel_proto_enumTypes,
|
||||
MessageInfos: file_tunnel_proto_msgTypes,
|
||||
}.Build()
|
||||
File_tunnel_proto = out.File
|
||||
file_tunnel_proto_rawDesc = nil
|
||||
file_tunnel_proto_goTypes = nil
|
||||
file_tunnel_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v6.33.1
|
||||
// source: tunnel.proto
|
||||
|
||||
package tunnelpb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
TunnelService_Tunnel_FullMethodName = "/tunnel.TunnelService/Tunnel"
|
||||
)
|
||||
|
||||
// TunnelServiceClient is the client API for TunnelService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type TunnelServiceClient interface {
|
||||
Tunnel(ctx context.Context, opts ...grpc.CallOption) (TunnelService_TunnelClient, error)
|
||||
}
|
||||
|
||||
type tunnelServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewTunnelServiceClient(cc grpc.ClientConnInterface) TunnelServiceClient {
|
||||
return &tunnelServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *tunnelServiceClient) Tunnel(ctx context.Context, opts ...grpc.CallOption) (TunnelService_TunnelClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &TunnelService_ServiceDesc.Streams[0], TunnelService_Tunnel_FullMethodName, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &tunnelServiceTunnelClient{stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type TunnelService_TunnelClient interface {
|
||||
Send(*Frame) error
|
||||
Recv() (*Frame, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type tunnelServiceTunnelClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *tunnelServiceTunnelClient) Send(m *Frame) error {
|
||||
return x.ClientStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *tunnelServiceTunnelClient) Recv() (*Frame, error) {
|
||||
m := new(Frame)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// TunnelServiceServer is the server API for TunnelService service.
|
||||
// All implementations must embed UnimplementedTunnelServiceServer
|
||||
// for forward compatibility
|
||||
type TunnelServiceServer interface {
|
||||
Tunnel(TunnelService_TunnelServer) error
|
||||
mustEmbedUnimplementedTunnelServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedTunnelServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedTunnelServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedTunnelServiceServer) Tunnel(TunnelService_TunnelServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Tunnel not implemented")
|
||||
}
|
||||
func (UnimplementedTunnelServiceServer) mustEmbedUnimplementedTunnelServiceServer() {}
|
||||
|
||||
// UnsafeTunnelServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to TunnelServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeTunnelServiceServer interface {
|
||||
mustEmbedUnimplementedTunnelServiceServer()
|
||||
}
|
||||
|
||||
func RegisterTunnelServiceServer(s grpc.ServiceRegistrar, srv TunnelServiceServer) {
|
||||
s.RegisterService(&TunnelService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _TunnelService_Tunnel_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
return srv.(TunnelServiceServer).Tunnel(&tunnelServiceTunnelServer{stream})
|
||||
}
|
||||
|
||||
type TunnelService_TunnelServer interface {
|
||||
Send(*Frame) error
|
||||
Recv() (*Frame, error)
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type tunnelServiceTunnelServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *tunnelServiceTunnelServer) Send(m *Frame) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *tunnelServiceTunnelServer) Recv() (*Frame, error) {
|
||||
m := new(Frame)
|
||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// TunnelService_ServiceDesc is the grpc.ServiceDesc for TunnelService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var TunnelService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "tunnel.TunnelService",
|
||||
HandlerType: (*TunnelServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "Tunnel",
|
||||
Handler: _TunnelService_Tunnel_Handler,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "tunnel.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user