yao/tai/tunnel/taipb/tunnel.pb.go
Max 9c9701ed7e feat(tunnel): refactor VNC and proxy handling with structured routing
- Updated VNC and proxy handling in the tunnel to utilize a structured routing approach, enhancing clarity and maintainability.
- Replaced direct port checks with a new `forwardRoute` struct to encapsulate routing information, including channel type, container ID, and port.
- Modified request handling to streamline the forwarding process and improve error handling for unknown routes.
- Enhanced tests to validate the new routing logic and ensure consistent behavior across VNC and proxy requests.

Made-with: Cursor
2026-03-14 21:51:32 +08:00

536 lines
16 KiB
Go

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
// protoc v4.25.0
// source: tunnel/proto/tunnel.proto
package taipb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
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 TunnelControl struct {
state protoimpl.MessageState `protogen:"open.v1"`
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // "register" / "registered" / "open" / "ping" / "pong"
// Carried on "register" (Tai → Yao)
NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
MachineId string `protobuf:"bytes,3,opt,name=machine_id,json=machineId,proto3" json:"machine_id,omitempty"`
DisplayName string `protobuf:"bytes,4,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"`
Ports *Ports `protobuf:"bytes,6,opt,name=ports,proto3" json:"ports,omitempty"`
Caps *Capabilities `protobuf:"bytes,7,opt,name=caps,proto3" json:"caps,omitempty"`
System *SystemInfo `protobuf:"bytes,8,opt,name=system,proto3" json:"system,omitempty"`
// Carried on "open" (Yao → Tai)
ChannelId string `protobuf:"bytes,10,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
TargetPort int32 `protobuf:"varint,11,opt,name=target_port,json=targetPort,proto3" json:"target_port,omitempty"`
ChannelType string `protobuf:"bytes,12,opt,name=channel_type,json=channelType,proto3" json:"channel_type,omitempty"` // "proxy" | "vnc" | "" (legacy/raw TCP)
ContainerId string `protobuf:"bytes,13,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` // target container or "__host__"
ContainerPort int32 `protobuf:"varint,14,opt,name=container_port,json=containerPort,proto3" json:"container_port,omitempty"` // container-internal port (vnc default 5900)
// Carried on "registered" (Yao → Tai)
TaiId string `protobuf:"bytes,20,opt,name=tai_id,json=taiId,proto3" json:"tai_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TunnelControl) Reset() {
*x = TunnelControl{}
mi := &file_tunnel_proto_tunnel_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TunnelControl) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TunnelControl) ProtoMessage() {}
func (x *TunnelControl) ProtoReflect() protoreflect.Message {
mi := &file_tunnel_proto_tunnel_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TunnelControl.ProtoReflect.Descriptor instead.
func (*TunnelControl) Descriptor() ([]byte, []int) {
return file_tunnel_proto_tunnel_proto_rawDescGZIP(), []int{0}
}
func (x *TunnelControl) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *TunnelControl) GetNodeId() string {
if x != nil {
return x.NodeId
}
return ""
}
func (x *TunnelControl) GetMachineId() string {
if x != nil {
return x.MachineId
}
return ""
}
func (x *TunnelControl) GetDisplayName() string {
if x != nil {
return x.DisplayName
}
return ""
}
func (x *TunnelControl) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
func (x *TunnelControl) GetPorts() *Ports {
if x != nil {
return x.Ports
}
return nil
}
func (x *TunnelControl) GetCaps() *Capabilities {
if x != nil {
return x.Caps
}
return nil
}
func (x *TunnelControl) GetSystem() *SystemInfo {
if x != nil {
return x.System
}
return nil
}
func (x *TunnelControl) GetChannelId() string {
if x != nil {
return x.ChannelId
}
return ""
}
func (x *TunnelControl) GetTargetPort() int32 {
if x != nil {
return x.TargetPort
}
return 0
}
func (x *TunnelControl) GetChannelType() string {
if x != nil {
return x.ChannelType
}
return ""
}
func (x *TunnelControl) GetContainerId() string {
if x != nil {
return x.ContainerId
}
return ""
}
func (x *TunnelControl) GetContainerPort() int32 {
if x != nil {
return x.ContainerPort
}
return 0
}
func (x *TunnelControl) GetTaiId() string {
if x != nil {
return x.TaiId
}
return ""
}
type ForwardData struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ForwardData) Reset() {
*x = ForwardData{}
mi := &file_tunnel_proto_tunnel_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ForwardData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ForwardData) ProtoMessage() {}
func (x *ForwardData) ProtoReflect() protoreflect.Message {
mi := &file_tunnel_proto_tunnel_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ForwardData.ProtoReflect.Descriptor instead.
func (*ForwardData) Descriptor() ([]byte, []int) {
return file_tunnel_proto_tunnel_proto_rawDescGZIP(), []int{1}
}
func (x *ForwardData) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
type Ports struct {
state protoimpl.MessageState `protogen:"open.v1"`
Grpc int32 `protobuf:"varint,1,opt,name=grpc,proto3" json:"grpc,omitempty"`
Http int32 `protobuf:"varint,2,opt,name=http,proto3" json:"http,omitempty"`
Vnc int32 `protobuf:"varint,3,opt,name=vnc,proto3" json:"vnc,omitempty"`
Docker int32 `protobuf:"varint,4,opt,name=docker,proto3" json:"docker,omitempty"`
K8S int32 `protobuf:"varint,5,opt,name=k8s,proto3" json:"k8s,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Ports) Reset() {
*x = Ports{}
mi := &file_tunnel_proto_tunnel_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Ports) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Ports) ProtoMessage() {}
func (x *Ports) ProtoReflect() protoreflect.Message {
mi := &file_tunnel_proto_tunnel_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Ports.ProtoReflect.Descriptor instead.
func (*Ports) Descriptor() ([]byte, []int) {
return file_tunnel_proto_tunnel_proto_rawDescGZIP(), []int{2}
}
func (x *Ports) GetGrpc() int32 {
if x != nil {
return x.Grpc
}
return 0
}
func (x *Ports) GetHttp() int32 {
if x != nil {
return x.Http
}
return 0
}
func (x *Ports) GetVnc() int32 {
if x != nil {
return x.Vnc
}
return 0
}
func (x *Ports) GetDocker() int32 {
if x != nil {
return x.Docker
}
return 0
}
func (x *Ports) GetK8S() int32 {
if x != nil {
return x.K8S
}
return 0
}
type Capabilities struct {
state protoimpl.MessageState `protogen:"open.v1"`
Docker bool `protobuf:"varint,1,opt,name=docker,proto3" json:"docker,omitempty"`
K8S bool `protobuf:"varint,2,opt,name=k8s,proto3" json:"k8s,omitempty"`
HostExec bool `protobuf:"varint,3,opt,name=host_exec,json=hostExec,proto3" json:"host_exec,omitempty"`
Vnc bool `protobuf:"varint,4,opt,name=vnc,proto3" json:"vnc,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Capabilities) Reset() {
*x = Capabilities{}
mi := &file_tunnel_proto_tunnel_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Capabilities) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Capabilities) ProtoMessage() {}
func (x *Capabilities) ProtoReflect() protoreflect.Message {
mi := &file_tunnel_proto_tunnel_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Capabilities.ProtoReflect.Descriptor instead.
func (*Capabilities) Descriptor() ([]byte, []int) {
return file_tunnel_proto_tunnel_proto_rawDescGZIP(), []int{3}
}
func (x *Capabilities) GetDocker() bool {
if x != nil {
return x.Docker
}
return false
}
func (x *Capabilities) GetK8S() bool {
if x != nil {
return x.K8S
}
return false
}
func (x *Capabilities) GetHostExec() bool {
if x != nil {
return x.HostExec
}
return false
}
func (x *Capabilities) GetVnc() bool {
if x != nil {
return x.Vnc
}
return false
}
type SystemInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
Os string `protobuf:"bytes,1,opt,name=os,proto3" json:"os,omitempty"`
Arch string `protobuf:"bytes,2,opt,name=arch,proto3" json:"arch,omitempty"`
Hostname string `protobuf:"bytes,3,opt,name=hostname,proto3" json:"hostname,omitempty"`
Shell string `protobuf:"bytes,4,opt,name=shell,proto3" json:"shell,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SystemInfo) Reset() {
*x = SystemInfo{}
mi := &file_tunnel_proto_tunnel_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SystemInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SystemInfo) ProtoMessage() {}
func (x *SystemInfo) ProtoReflect() protoreflect.Message {
mi := &file_tunnel_proto_tunnel_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SystemInfo.ProtoReflect.Descriptor instead.
func (*SystemInfo) Descriptor() ([]byte, []int) {
return file_tunnel_proto_tunnel_proto_rawDescGZIP(), []int{4}
}
func (x *SystemInfo) GetOs() string {
if x != nil {
return x.Os
}
return ""
}
func (x *SystemInfo) GetArch() string {
if x != nil {
return x.Arch
}
return ""
}
func (x *SystemInfo) GetHostname() string {
if x != nil {
return x.Hostname
}
return ""
}
func (x *SystemInfo) GetShell() string {
if x != nil {
return x.Shell
}
return ""
}
var File_tunnel_proto_tunnel_proto protoreflect.FileDescriptor
const file_tunnel_proto_tunnel_proto_rawDesc = "" +
"\n" +
"\x19tunnel/proto/tunnel.proto\x12\n" +
"tai.tunnel\"\xe3\x03\n" +
"\rTunnelControl\x12\x12\n" +
"\x04type\x18\x01 \x01(\tR\x04type\x12\x17\n" +
"\anode_id\x18\x02 \x01(\tR\x06nodeId\x12\x1d\n" +
"\n" +
"machine_id\x18\x03 \x01(\tR\tmachineId\x12!\n" +
"\fdisplay_name\x18\x04 \x01(\tR\vdisplayName\x12\x18\n" +
"\aversion\x18\x05 \x01(\tR\aversion\x12'\n" +
"\x05ports\x18\x06 \x01(\v2\x11.tai.tunnel.PortsR\x05ports\x12,\n" +
"\x04caps\x18\a \x01(\v2\x18.tai.tunnel.CapabilitiesR\x04caps\x12.\n" +
"\x06system\x18\b \x01(\v2\x16.tai.tunnel.SystemInfoR\x06system\x12\x1d\n" +
"\n" +
"channel_id\x18\n" +
" \x01(\tR\tchannelId\x12\x1f\n" +
"\vtarget_port\x18\v \x01(\x05R\n" +
"targetPort\x12!\n" +
"\fchannel_type\x18\f \x01(\tR\vchannelType\x12!\n" +
"\fcontainer_id\x18\r \x01(\tR\vcontainerId\x12%\n" +
"\x0econtainer_port\x18\x0e \x01(\x05R\rcontainerPort\x12\x15\n" +
"\x06tai_id\x18\x14 \x01(\tR\x05taiId\"!\n" +
"\vForwardData\x12\x12\n" +
"\x04data\x18\x01 \x01(\fR\x04data\"k\n" +
"\x05Ports\x12\x12\n" +
"\x04grpc\x18\x01 \x01(\x05R\x04grpc\x12\x12\n" +
"\x04http\x18\x02 \x01(\x05R\x04http\x12\x10\n" +
"\x03vnc\x18\x03 \x01(\x05R\x03vnc\x12\x16\n" +
"\x06docker\x18\x04 \x01(\x05R\x06docker\x12\x10\n" +
"\x03k8s\x18\x05 \x01(\x05R\x03k8s\"g\n" +
"\fCapabilities\x12\x16\n" +
"\x06docker\x18\x01 \x01(\bR\x06docker\x12\x10\n" +
"\x03k8s\x18\x02 \x01(\bR\x03k8s\x12\x1b\n" +
"\thost_exec\x18\x03 \x01(\bR\bhostExec\x12\x10\n" +
"\x03vnc\x18\x04 \x01(\bR\x03vnc\"b\n" +
"\n" +
"SystemInfo\x12\x0e\n" +
"\x02os\x18\x01 \x01(\tR\x02os\x12\x12\n" +
"\x04arch\x18\x02 \x01(\tR\x04arch\x12\x1a\n" +
"\bhostname\x18\x03 \x01(\tR\bhostname\x12\x14\n" +
"\x05shell\x18\x04 \x01(\tR\x05shell2\x92\x01\n" +
"\tTaiTunnel\x12D\n" +
"\bRegister\x12\x19.tai.tunnel.TunnelControl\x1a\x19.tai.tunnel.TunnelControl(\x010\x01\x12?\n" +
"\aForward\x12\x17.tai.tunnel.ForwardData\x1a\x17.tai.tunnel.ForwardData(\x010\x01B$Z\"github.com/yaoapp/tai/tunnel/taipbb\x06proto3"
var (
file_tunnel_proto_tunnel_proto_rawDescOnce sync.Once
file_tunnel_proto_tunnel_proto_rawDescData []byte
)
func file_tunnel_proto_tunnel_proto_rawDescGZIP() []byte {
file_tunnel_proto_tunnel_proto_rawDescOnce.Do(func() {
file_tunnel_proto_tunnel_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_tunnel_proto_tunnel_proto_rawDesc), len(file_tunnel_proto_tunnel_proto_rawDesc)))
})
return file_tunnel_proto_tunnel_proto_rawDescData
}
var file_tunnel_proto_tunnel_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_tunnel_proto_tunnel_proto_goTypes = []any{
(*TunnelControl)(nil), // 0: tai.tunnel.TunnelControl
(*ForwardData)(nil), // 1: tai.tunnel.ForwardData
(*Ports)(nil), // 2: tai.tunnel.Ports
(*Capabilities)(nil), // 3: tai.tunnel.Capabilities
(*SystemInfo)(nil), // 4: tai.tunnel.SystemInfo
}
var file_tunnel_proto_tunnel_proto_depIdxs = []int32{
2, // 0: tai.tunnel.TunnelControl.ports:type_name -> tai.tunnel.Ports
3, // 1: tai.tunnel.TunnelControl.caps:type_name -> tai.tunnel.Capabilities
4, // 2: tai.tunnel.TunnelControl.system:type_name -> tai.tunnel.SystemInfo
0, // 3: tai.tunnel.TaiTunnel.Register:input_type -> tai.tunnel.TunnelControl
1, // 4: tai.tunnel.TaiTunnel.Forward:input_type -> tai.tunnel.ForwardData
0, // 5: tai.tunnel.TaiTunnel.Register:output_type -> tai.tunnel.TunnelControl
1, // 6: tai.tunnel.TaiTunnel.Forward:output_type -> tai.tunnel.ForwardData
5, // [5:7] is the sub-list for method output_type
3, // [3:5] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_tunnel_proto_tunnel_proto_init() }
func file_tunnel_proto_tunnel_proto_init() {
if File_tunnel_proto_tunnel_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_tunnel_proto_tunnel_proto_rawDesc), len(file_tunnel_proto_tunnel_proto_rawDesc)),
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_tunnel_proto_tunnel_proto_goTypes,
DependencyIndexes: file_tunnel_proto_tunnel_proto_depIdxs,
MessageInfos: file_tunnel_proto_tunnel_proto_msgTypes,
}.Build()
File_tunnel_proto_tunnel_proto = out.File
file_tunnel_proto_tunnel_proto_goTypes = nil
file_tunnel_proto_tunnel_proto_depIdxs = nil
}