mirror of
https://github.com/ehang-io/nps.git
synced 2026-03-19 16:12:59 +00:00
add new file
This commit is contained in:
736
lib/pb/bridge.pb.go
Normal file
736
lib/pb/bridge.pb.go
Normal file
@@ -0,0 +1,736 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.19.1
|
||||
// source: bridge.proto
|
||||
|
||||
package pb
|
||||
|
||||
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 ConnType int32
|
||||
|
||||
const (
|
||||
ConnType_tcp ConnType = 0
|
||||
ConnType_udp ConnType = 1
|
||||
ConnType_unix ConnType = 2
|
||||
)
|
||||
|
||||
// Enum value maps for ConnType.
|
||||
var (
|
||||
ConnType_name = map[int32]string{
|
||||
0: "tcp",
|
||||
1: "udp",
|
||||
2: "unix",
|
||||
}
|
||||
ConnType_value = map[string]int32{
|
||||
"tcp": 0,
|
||||
"udp": 1,
|
||||
"unix": 2,
|
||||
}
|
||||
)
|
||||
|
||||
func (x ConnType) Enum() *ConnType {
|
||||
p := new(ConnType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x ConnType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (ConnType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_bridge_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (ConnType) Type() protoreflect.EnumType {
|
||||
return &file_bridge_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x ConnType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ConnType.Descriptor instead.
|
||||
func (ConnType) EnumDescriptor() ([]byte, []int) {
|
||||
return file_bridge_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type ConnRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"`
|
||||
// Types that are assignable to ConnType:
|
||||
// *ConnRequest_AppInfo
|
||||
// *ConnRequest_NpcInfo
|
||||
// *ConnRequest_SecretInfo
|
||||
ConnType isConnRequest_ConnType `protobuf_oneof:"connType"`
|
||||
}
|
||||
|
||||
func (x *ConnRequest) Reset() {
|
||||
*x = ConnRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_bridge_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ConnRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ConnRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ConnRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_bridge_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 ConnRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ConnRequest) Descriptor() ([]byte, []int) {
|
||||
return file_bridge_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ConnRequest) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *ConnRequest) GetConnType() isConnRequest_ConnType {
|
||||
if m != nil {
|
||||
return m.ConnType
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ConnRequest) GetAppInfo() *AppInfo {
|
||||
if x, ok := x.GetConnType().(*ConnRequest_AppInfo); ok {
|
||||
return x.AppInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ConnRequest) GetNpcInfo() *NpcInfo {
|
||||
if x, ok := x.GetConnType().(*ConnRequest_NpcInfo); ok {
|
||||
return x.NpcInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ConnRequest) GetSecretInfo() *SecretInfo {
|
||||
if x, ok := x.GetConnType().(*ConnRequest_SecretInfo); ok {
|
||||
return x.SecretInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isConnRequest_ConnType interface {
|
||||
isConnRequest_ConnType()
|
||||
}
|
||||
|
||||
type ConnRequest_AppInfo struct {
|
||||
AppInfo *AppInfo `protobuf:"bytes,2,opt,name=app_info,json=appInfo,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ConnRequest_NpcInfo struct {
|
||||
NpcInfo *NpcInfo `protobuf:"bytes,3,opt,name=npc_info,json=npcInfo,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ConnRequest_SecretInfo struct {
|
||||
SecretInfo *SecretInfo `protobuf:"bytes,4,opt,name=secret_info,json=secretInfo,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*ConnRequest_AppInfo) isConnRequest_ConnType() {}
|
||||
|
||||
func (*ConnRequest_NpcInfo) isConnRequest_ConnType() {}
|
||||
|
||||
func (*ConnRequest_SecretInfo) isConnRequest_ConnType() {}
|
||||
|
||||
type ClientRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to ConnType:
|
||||
// *ClientRequest_AppInfo
|
||||
// *ClientRequest_Ping
|
||||
ConnType isClientRequest_ConnType `protobuf_oneof:"connType"`
|
||||
}
|
||||
|
||||
func (x *ClientRequest) Reset() {
|
||||
*x = ClientRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_bridge_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ClientRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ClientRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ClientRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_bridge_proto_msgTypes[1]
|
||||
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 ClientRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ClientRequest) Descriptor() ([]byte, []int) {
|
||||
return file_bridge_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (m *ClientRequest) GetConnType() isClientRequest_ConnType {
|
||||
if m != nil {
|
||||
return m.ConnType
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ClientRequest) GetAppInfo() *AppInfo {
|
||||
if x, ok := x.GetConnType().(*ClientRequest_AppInfo); ok {
|
||||
return x.AppInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ClientRequest) GetPing() *Ping {
|
||||
if x, ok := x.GetConnType().(*ClientRequest_Ping); ok {
|
||||
return x.Ping
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isClientRequest_ConnType interface {
|
||||
isClientRequest_ConnType()
|
||||
}
|
||||
|
||||
type ClientRequest_AppInfo struct {
|
||||
AppInfo *AppInfo `protobuf:"bytes,1,opt,name=app_info,json=appInfo,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ClientRequest_Ping struct {
|
||||
Ping *Ping `protobuf:"bytes,2,opt,name=ping,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*ClientRequest_AppInfo) isClientRequest_ConnType() {}
|
||||
|
||||
func (*ClientRequest_Ping) isClientRequest_ConnType() {}
|
||||
|
||||
type AppInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
AppAddr string `protobuf:"bytes,1,opt,name=app_addr,json=appAddr,proto3" json:"app_addr,omitempty"`
|
||||
NpcId string `protobuf:"bytes,2,opt,name=npc_id,json=npcId,proto3" json:"npc_id,omitempty"`
|
||||
ConnType ConnType `protobuf:"varint,3,opt,name=conn_type,json=connType,proto3,enum=ConnType" json:"conn_type,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AppInfo) Reset() {
|
||||
*x = AppInfo{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_bridge_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AppInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AppInfo) ProtoMessage() {}
|
||||
|
||||
func (x *AppInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_bridge_proto_msgTypes[2]
|
||||
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 AppInfo.ProtoReflect.Descriptor instead.
|
||||
func (*AppInfo) Descriptor() ([]byte, []int) {
|
||||
return file_bridge_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *AppInfo) GetAppAddr() string {
|
||||
if x != nil {
|
||||
return x.AppAddr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AppInfo) GetNpcId() string {
|
||||
if x != nil {
|
||||
return x.NpcId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AppInfo) GetConnType() ConnType {
|
||||
if x != nil {
|
||||
return x.ConnType
|
||||
}
|
||||
return ConnType_tcp
|
||||
}
|
||||
|
||||
type SecretInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
IsUdpConn bool `protobuf:"varint,1,opt,name=is_udp_conn,json=isUdpConn,proto3" json:"is_udp_conn,omitempty"`
|
||||
AppAddr string `protobuf:"bytes,2,opt,name=app_addr,json=appAddr,proto3" json:"app_addr,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SecretInfo) Reset() {
|
||||
*x = SecretInfo{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_bridge_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SecretInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SecretInfo) ProtoMessage() {}
|
||||
|
||||
func (x *SecretInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_bridge_proto_msgTypes[3]
|
||||
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 SecretInfo.ProtoReflect.Descriptor instead.
|
||||
func (*SecretInfo) Descriptor() ([]byte, []int) {
|
||||
return file_bridge_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *SecretInfo) GetIsUdpConn() bool {
|
||||
if x != nil {
|
||||
return x.IsUdpConn
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *SecretInfo) GetAppAddr() string {
|
||||
if x != nil {
|
||||
return x.AppAddr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type NpcInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
TunnelId string `protobuf:"bytes,2,opt,name=tunnel_id,json=tunnelId,proto3" json:"tunnel_id,omitempty"`
|
||||
IsControlTunnel bool `protobuf:"varint,3,opt,name=is_control_tunnel,json=isControlTunnel,proto3" json:"is_control_tunnel,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NpcInfo) Reset() {
|
||||
*x = NpcInfo{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_bridge_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *NpcInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NpcInfo) ProtoMessage() {}
|
||||
|
||||
func (x *NpcInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_bridge_proto_msgTypes[4]
|
||||
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 NpcInfo.ProtoReflect.Descriptor instead.
|
||||
func (*NpcInfo) Descriptor() ([]byte, []int) {
|
||||
return file_bridge_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *NpcInfo) GetTunnelId() string {
|
||||
if x != nil {
|
||||
return x.TunnelId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NpcInfo) GetIsControlTunnel() bool {
|
||||
if x != nil {
|
||||
return x.IsControlTunnel
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type NpcResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NpcResponse) Reset() {
|
||||
*x = NpcResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_bridge_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *NpcResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NpcResponse) ProtoMessage() {}
|
||||
|
||||
func (x *NpcResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_bridge_proto_msgTypes[5]
|
||||
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 NpcResponse.ProtoReflect.Descriptor instead.
|
||||
func (*NpcResponse) Descriptor() ([]byte, []int) {
|
||||
return file_bridge_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *NpcResponse) GetSuccess() bool {
|
||||
if x != nil {
|
||||
return x.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *NpcResponse) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Ping struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Now string `protobuf:"bytes,1,opt,name=now,proto3" json:"now,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Ping) Reset() {
|
||||
*x = Ping{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_bridge_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Ping) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Ping) ProtoMessage() {}
|
||||
|
||||
func (x *Ping) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_bridge_proto_msgTypes[6]
|
||||
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 Ping.ProtoReflect.Descriptor instead.
|
||||
func (*Ping) Descriptor() ([]byte, []int) {
|
||||
return file_bridge_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *Ping) GetNow() string {
|
||||
if x != nil {
|
||||
return x.Now
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_bridge_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_bridge_proto_rawDesc = []byte{
|
||||
0x0a, 0x0c, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa7,
|
||||
0x01, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x25,
|
||||
0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x08, 0x2e, 0x41, 0x70, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x07, 0x61, 0x70,
|
||||
0x70, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x25, 0x0a, 0x08, 0x6e, 0x70, 0x63, 0x5f, 0x69, 0x6e, 0x66,
|
||||
0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x4e, 0x70, 0x63, 0x49, 0x6e, 0x66,
|
||||
0x6f, 0x48, 0x00, 0x52, 0x07, 0x6e, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2e, 0x0a, 0x0b,
|
||||
0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x0b, 0x2e, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00,
|
||||
0x52, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x0a, 0x0a, 0x08,
|
||||
0x63, 0x6f, 0x6e, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, 0x5f, 0x0a, 0x0d, 0x43, 0x6c, 0x69, 0x65,
|
||||
0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x08, 0x61, 0x70, 0x70,
|
||||
0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x41, 0x70,
|
||||
0x70, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x07, 0x61, 0x70, 0x70, 0x49, 0x6e, 0x66, 0x6f,
|
||||
0x12, 0x1b, 0x0a, 0x04, 0x70, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05,
|
||||
0x2e, 0x70, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x04, 0x70, 0x69, 0x6e, 0x67, 0x42, 0x0a, 0x0a,
|
||||
0x08, 0x63, 0x6f, 0x6e, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, 0x64, 0x0a, 0x07, 0x41, 0x70, 0x70,
|
||||
0x49, 0x6e, 0x66, 0x6f, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x41, 0x64, 0x64, 0x72, 0x12,
|
||||
0x15, 0x0a, 0x06, 0x6e, 0x70, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x05, 0x6e, 0x70, 0x63, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x6e, 0x5f, 0x74,
|
||||
0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x63, 0x6f, 0x6e, 0x6e,
|
||||
0x5f, 0x74, 0x79, 0x70, 0x65, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22,
|
||||
0x47, 0x0a, 0x0a, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a,
|
||||
0x0b, 0x69, 0x73, 0x5f, 0x75, 0x64, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x55, 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x6e, 0x12, 0x19, 0x0a,
|
||||
0x08, 0x61, 0x70, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x07, 0x61, 0x70, 0x70, 0x41, 0x64, 0x64, 0x72, 0x22, 0x52, 0x0a, 0x07, 0x4e, 0x70, 0x63, 0x49,
|
||||
0x6e, 0x66, 0x6f, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64,
|
||||
0x12, 0x2a, 0x0a, 0x11, 0x69, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x5f, 0x74,
|
||||
0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x73, 0x43,
|
||||
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x22, 0x41, 0x0a, 0x0b,
|
||||
0x4e, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73,
|
||||
0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75,
|
||||
0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22,
|
||||
0x18, 0x0a, 0x04, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x6f, 0x77, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6e, 0x6f, 0x77, 0x2a, 0x27, 0x0a, 0x09, 0x63, 0x6f, 0x6e,
|
||||
0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x74, 0x63, 0x70, 0x10, 0x00, 0x12,
|
||||
0x07, 0x0a, 0x03, 0x75, 0x64, 0x70, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x75, 0x6e, 0x69, 0x78,
|
||||
0x10, 0x02, 0x42, 0x15, 0x5a, 0x13, 0x65, 0x68, 0x61, 0x6e, 0x67, 0x2e, 0x69, 0x6f, 0x2f, 0x6e,
|
||||
0x70, 0x73, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_bridge_proto_rawDescOnce sync.Once
|
||||
file_bridge_proto_rawDescData = file_bridge_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_bridge_proto_rawDescGZIP() []byte {
|
||||
file_bridge_proto_rawDescOnce.Do(func() {
|
||||
file_bridge_proto_rawDescData = protoimpl.X.CompressGZIP(file_bridge_proto_rawDescData)
|
||||
})
|
||||
return file_bridge_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_bridge_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_bridge_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_bridge_proto_goTypes = []interface{}{
|
||||
(ConnType)(0), // 0: conn_type
|
||||
(*ConnRequest)(nil), // 1: ConnRequest
|
||||
(*ClientRequest)(nil), // 2: ClientRequest
|
||||
(*AppInfo)(nil), // 3: AppInfo
|
||||
(*SecretInfo)(nil), // 4: SecretInfo
|
||||
(*NpcInfo)(nil), // 5: NpcInfo
|
||||
(*NpcResponse)(nil), // 6: NpcResponse
|
||||
(*Ping)(nil), // 7: ping
|
||||
}
|
||||
var file_bridge_proto_depIdxs = []int32{
|
||||
3, // 0: ConnRequest.app_info:type_name -> AppInfo
|
||||
5, // 1: ConnRequest.npc_info:type_name -> NpcInfo
|
||||
4, // 2: ConnRequest.secret_info:type_name -> SecretInfo
|
||||
3, // 3: ClientRequest.app_info:type_name -> AppInfo
|
||||
7, // 4: ClientRequest.ping:type_name -> ping
|
||||
0, // 5: AppInfo.conn_type:type_name -> conn_type
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_bridge_proto_init() }
|
||||
func file_bridge_proto_init() {
|
||||
if File_bridge_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_bridge_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ConnRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_bridge_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ClientRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_bridge_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*AppInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_bridge_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SecretInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_bridge_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*NpcInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_bridge_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*NpcResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_bridge_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Ping); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
file_bridge_proto_msgTypes[0].OneofWrappers = []interface{}{
|
||||
(*ConnRequest_AppInfo)(nil),
|
||||
(*ConnRequest_NpcInfo)(nil),
|
||||
(*ConnRequest_SecretInfo)(nil),
|
||||
}
|
||||
file_bridge_proto_msgTypes[1].OneofWrappers = []interface{}{
|
||||
(*ClientRequest_AppInfo)(nil),
|
||||
(*ClientRequest_Ping)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_bridge_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_bridge_proto_goTypes,
|
||||
DependencyIndexes: file_bridge_proto_depIdxs,
|
||||
EnumInfos: file_bridge_proto_enumTypes,
|
||||
MessageInfos: file_bridge_proto_msgTypes,
|
||||
}.Build()
|
||||
File_bridge_proto = out.File
|
||||
file_bridge_proto_rawDesc = nil
|
||||
file_bridge_proto_goTypes = nil
|
||||
file_bridge_proto_depIdxs = nil
|
||||
}
|
||||
51
lib/pb/bridge.proto
Normal file
51
lib/pb/bridge.proto
Normal file
@@ -0,0 +1,51 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "ehang.io/nps/lib/pb";
|
||||
|
||||
|
||||
message ConnRequest {
|
||||
string Id = 1;
|
||||
oneof connType {
|
||||
AppInfo app_info = 2;
|
||||
NpcInfo npc_info = 3;
|
||||
SecretInfo secret_info = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message ClientRequest {
|
||||
oneof connType {
|
||||
AppInfo app_info = 1;
|
||||
ping ping = 2;
|
||||
}
|
||||
}
|
||||
|
||||
enum conn_type{
|
||||
tcp = 0;
|
||||
udp = 1 ;
|
||||
unix = 2;
|
||||
}
|
||||
|
||||
message AppInfo {
|
||||
string app_addr = 1;
|
||||
string npc_id = 2;
|
||||
conn_type conn_type = 3;
|
||||
}
|
||||
|
||||
message SecretInfo {
|
||||
bool is_udp_conn = 1;
|
||||
string app_addr = 2;
|
||||
}
|
||||
|
||||
message NpcInfo {
|
||||
string tunnel_id = 2;
|
||||
bool is_control_tunnel = 3;
|
||||
}
|
||||
|
||||
message NpcResponse {
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
message ping{
|
||||
string now = 1;
|
||||
}
|
||||
29
lib/pb/pb.go
Normal file
29
lib/pb/pb.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package pb
|
||||
|
||||
import (
|
||||
"ehang.io/nps/lib/common"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/pkg/errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
// WriteMessage is used to write a message to writer
|
||||
func WriteMessage(w io.Writer, message proto.Message) (int, error) {
|
||||
b, err := proto.Marshal(message)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "proto Marshal")
|
||||
}
|
||||
n, err := common.WriteLenBytes(w, b)
|
||||
return n, err
|
||||
}
|
||||
|
||||
// ReadMessage is used to read a message from reader
|
||||
func ReadMessage(r io.Reader, message proto.Message) (int, error) {
|
||||
message.Reset()
|
||||
b := make([]byte, 4096)
|
||||
n, err := common.ReadLenBytes(r, b)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "read proto message")
|
||||
}
|
||||
return n, proto.Unmarshal(b[:n], message)
|
||||
}
|
||||
25
lib/pb/pb_test.go
Normal file
25
lib/pb/pb_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package pb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMarshal(t *testing.T) {
|
||||
app := &AppInfo{
|
||||
ConnType: ConnType_udp,
|
||||
AppAddr: "127.0.0.1:8080",
|
||||
}
|
||||
var buf []byte
|
||||
b := bytes.NewBuffer(buf)
|
||||
|
||||
_, err := WriteMessage(b, app)
|
||||
assert.NoError(t, err)
|
||||
|
||||
appRecv := &AppInfo{}
|
||||
_, err = ReadMessage(b, appRecv)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, app.AppAddr, appRecv.AppAddr)
|
||||
assert.Equal(t, app.ConnType, appRecv.ConnType)
|
||||
}
|
||||
Reference in New Issue
Block a user