added the CONN_ERROR event t ype

This commit is contained in:
hyung-hwan 2025-03-04 01:16:46 +09:00
parent 04e2de609e
commit bec93289f5
5 changed files with 201 additions and 93 deletions

View File

@ -1187,15 +1187,27 @@ start_over:
cts.C.log.Write(cts.Sid, LOG_ERROR, "Invalid peer_data event from %s", cts.remote_addr)
}
case PACKET_KIND_CONN_ERROR:
var x *Packet_ConnErr
var ok bool
x, ok = pkt.U.(*Packet_ConnErr)
if ok {
cts.C.log.Write(cts.Sid, LOG_ERROR, "Received conn_error(%d, %s) event from %s", x.ConnErr.ErrorId, x.ConnErr.Text, cts.remote_addr)
// if no retry goto done.. othersise reconnect...
goto done
} else {
cts.C.log.Write(cts.Sid, LOG_ERROR, "Invalid conn_error event from %s", cts.remote_addr)
}
case PACKET_KIND_CONN_NOTICE:
// the connection from the client to a peer has been established
var x *Packet_Notice
var x *Packet_ConnNoti
var ok bool
x, ok = pkt.U.(*Packet_Notice)
x, ok = pkt.U.(*Packet_ConnNoti)
if ok {
cts.C.log.Write(cts.Sid, LOG_DEBUG, "conn_notice message '%s' received from %s", x.Notice.Text, cts.remote_addr)
cts.C.log.Write(cts.Sid, LOG_DEBUG, "conn_notice message '%s' received from %s", x.ConnNoti.Text, cts.remote_addr)
if cts.C.conn_notice != nil {
cts.C.conn_notice.Handle(cts, x.Notice.Text)
cts.C.conn_notice.Handle(cts, x.ConnNoti.Text)
}
} else {
cts.C.log.Write(cts.Sid, LOG_ERROR, "Invalid conn_notice packet from %s", cts.remote_addr)

View File

@ -99,7 +99,8 @@ const (
PACKET_KIND_PEER_EOF PACKET_KIND = 8
PACKET_KIND_PEER_DATA PACKET_KIND = 9
PACKET_KIND_CONN_DESC PACKET_KIND = 11
PACKET_KIND_CONN_NOTICE PACKET_KIND = 12
PACKET_KIND_CONN_ERROR PACKET_KIND = 12
PACKET_KIND_CONN_NOTICE PACKET_KIND = 13
)
// Enum value maps for PACKET_KIND.
@ -116,7 +117,8 @@ var (
8: "PEER_EOF",
9: "PEER_DATA",
11: "CONN_DESC",
12: "CONN_NOTICE",
12: "CONN_ERROR",
13: "CONN_NOTICE",
}
PACKET_KIND_value = map[string]int32{
"RESERVED": 0,
@ -130,7 +132,8 @@ var (
"PEER_EOF": 8,
"PEER_DATA": 9,
"CONN_DESC": 11,
"CONN_NOTICE": 12,
"CONN_ERROR": 12,
"CONN_NOTICE": 13,
}
)
@ -483,6 +486,58 @@ func (x *ConnDesc) GetToken() string {
return ""
}
type ConnError struct {
state protoimpl.MessageState `protogen:"open.v1"`
ErrorId uint32 `protobuf:"varint,1,opt,name=ErrorId,proto3" json:"ErrorId,omitempty"`
Text string `protobuf:"bytes,2,opt,name=Text,proto3" json:"Text,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ConnError) Reset() {
*x = ConnError{}
mi := &file_hodu_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ConnError) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConnError) ProtoMessage() {}
func (x *ConnError) ProtoReflect() protoreflect.Message {
mi := &file_hodu_proto_msgTypes[5]
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 ConnError.ProtoReflect.Descriptor instead.
func (*ConnError) Descriptor() ([]byte, []int) {
return file_hodu_proto_rawDescGZIP(), []int{5}
}
func (x *ConnError) GetErrorId() uint32 {
if x != nil {
return x.ErrorId
}
return 0
}
func (x *ConnError) GetText() string {
if x != nil {
return x.Text
}
return ""
}
type ConnNotice struct {
state protoimpl.MessageState `protogen:"open.v1"`
Text string `protobuf:"bytes,1,opt,name=Text,proto3" json:"Text,omitempty"`
@ -492,7 +547,7 @@ type ConnNotice struct {
func (x *ConnNotice) Reset() {
*x = ConnNotice{}
mi := &file_hodu_proto_msgTypes[5]
mi := &file_hodu_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -504,7 +559,7 @@ func (x *ConnNotice) String() string {
func (*ConnNotice) ProtoMessage() {}
func (x *ConnNotice) ProtoReflect() protoreflect.Message {
mi := &file_hodu_proto_msgTypes[5]
mi := &file_hodu_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -517,7 +572,7 @@ func (x *ConnNotice) ProtoReflect() protoreflect.Message {
// Deprecated: Use ConnNotice.ProtoReflect.Descriptor instead.
func (*ConnNotice) Descriptor() ([]byte, []int) {
return file_hodu_proto_rawDescGZIP(), []int{5}
return file_hodu_proto_rawDescGZIP(), []int{6}
}
func (x *ConnNotice) GetText() string {
@ -536,7 +591,8 @@ type Packet struct {
// *Packet_Peer
// *Packet_Data
// *Packet_Conn
// *Packet_Notice
// *Packet_ConnErr
// *Packet_ConnNoti
U isPacket_U `protobuf_oneof:"U"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@ -544,7 +600,7 @@ type Packet struct {
func (x *Packet) Reset() {
*x = Packet{}
mi := &file_hodu_proto_msgTypes[6]
mi := &file_hodu_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -556,7 +612,7 @@ func (x *Packet) String() string {
func (*Packet) ProtoMessage() {}
func (x *Packet) ProtoReflect() protoreflect.Message {
mi := &file_hodu_proto_msgTypes[6]
mi := &file_hodu_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -569,7 +625,7 @@ func (x *Packet) ProtoReflect() protoreflect.Message {
// Deprecated: Use Packet.ProtoReflect.Descriptor instead.
func (*Packet) Descriptor() ([]byte, []int) {
return file_hodu_proto_rawDescGZIP(), []int{6}
return file_hodu_proto_rawDescGZIP(), []int{7}
}
func (x *Packet) GetKind() PACKET_KIND {
@ -622,10 +678,19 @@ func (x *Packet) GetConn() *ConnDesc {
return nil
}
func (x *Packet) GetNotice() *ConnNotice {
func (x *Packet) GetConnErr() *ConnError {
if x != nil {
if x, ok := x.U.(*Packet_Notice); ok {
return x.Notice
if x, ok := x.U.(*Packet_ConnErr); ok {
return x.ConnErr
}
}
return nil
}
func (x *Packet) GetConnNoti() *ConnNotice {
if x != nil {
if x, ok := x.U.(*Packet_ConnNoti); ok {
return x.ConnNoti
}
}
return nil
@ -651,8 +716,12 @@ type Packet_Conn struct {
Conn *ConnDesc `protobuf:"bytes,5,opt,name=Conn,proto3,oneof"`
}
type Packet_Notice struct {
Notice *ConnNotice `protobuf:"bytes,6,opt,name=Notice,proto3,oneof"`
type Packet_ConnErr struct {
ConnErr *ConnError `protobuf:"bytes,6,opt,name=ConnErr,proto3,oneof"`
}
type Packet_ConnNoti struct {
ConnNoti *ConnNotice `protobuf:"bytes,7,opt,name=ConnNoti,proto3,oneof"`
}
func (*Packet_Route) isPacket_U() {}
@ -663,7 +732,9 @@ func (*Packet_Data) isPacket_U() {}
func (*Packet_Conn) isPacket_U() {}
func (*Packet_Notice) isPacket_U() {}
func (*Packet_ConnErr) isPacket_U() {}
func (*Packet_ConnNoti) isPacket_U() {}
var File_hodu_proto protoreflect.FileDescriptor
@ -702,48 +773,56 @@ var file_hodu_proto_rawDesc = string([]byte{
0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74,
0x61, 0x22, 0x20, 0x0a, 0x08, 0x43, 0x6f, 0x6e, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x12, 0x14, 0x0a,
0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f,
0x6b, 0x65, 0x6e, 0x22, 0x20, 0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x63,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x54, 0x65, 0x78, 0x74, 0x22, 0xdd, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74,
0x12, 0x20, 0x0a, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c,
0x2e, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x52, 0x04, 0x4b, 0x69,
0x6e, 0x64, 0x12, 0x22, 0x0a, 0x05, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x0a, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x44, 0x65, 0x73, 0x63, 0x48, 0x00, 0x52,
0x05, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x48,
0x00, 0x52, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18,
0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61,
0x48, 0x00, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1f, 0x0a, 0x04, 0x43, 0x6f, 0x6e, 0x6e,
0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x44, 0x65, 0x73,
0x63, 0x48, 0x00, 0x52, 0x04, 0x43, 0x6f, 0x6e, 0x6e, 0x12, 0x25, 0x0a, 0x06, 0x4e, 0x6f, 0x74,
0x69, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x43, 0x6f, 0x6e, 0x6e,
0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x48, 0x00, 0x52, 0x06, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65,
0x42, 0x03, 0x0a, 0x01, 0x55, 0x2a, 0x5e, 0x0a, 0x0c, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x4f,
0x50, 0x54, 0x49, 0x4f, 0x4e, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x10,
0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x43,
0x50, 0x34, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x43, 0x50, 0x36, 0x10, 0x04, 0x12, 0x07,
0x0a, 0x03, 0x54, 0x54, 0x59, 0x10, 0x08, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10,
0x10, 0x12, 0x09, 0x0a, 0x05, 0x48, 0x54, 0x54, 0x50, 0x53, 0x10, 0x20, 0x12, 0x07, 0x0a, 0x03,
0x53, 0x53, 0x48, 0x10, 0x40, 0x2a, 0xd5, 0x01, 0x0a, 0x0b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x53, 0x45, 0x52, 0x56, 0x45,
0x44, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x41,
0x52, 0x54, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54,
0x4f, 0x50, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54,
0x41, 0x52, 0x54, 0x45, 0x44, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x52, 0x4f, 0x55, 0x54, 0x45,
0x5f, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x45,
0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x52, 0x54, 0x45, 0x44, 0x10, 0x05, 0x12, 0x10, 0x0a, 0x0c,
0x50, 0x45, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, 0x06, 0x12, 0x10,
0x0a, 0x0c, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x41, 0x42, 0x4f, 0x52, 0x54, 0x45, 0x44, 0x10, 0x07,
0x12, 0x0c, 0x0a, 0x08, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x45, 0x4f, 0x46, 0x10, 0x08, 0x12, 0x0d,
0x0a, 0x09, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x10, 0x09, 0x12, 0x0d, 0x0a,
0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x0b, 0x12, 0x0f, 0x0a, 0x0b,
0x43, 0x4f, 0x4e, 0x4e, 0x5f, 0x4e, 0x4f, 0x54, 0x49, 0x43, 0x45, 0x10, 0x0c, 0x32, 0x49, 0x0a,
0x04, 0x48, 0x6f, 0x64, 0x75, 0x12, 0x19, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x53, 0x65, 0x65, 0x64,
0x12, 0x05, 0x2e, 0x53, 0x65, 0x65, 0x64, 0x1a, 0x05, 0x2e, 0x53, 0x65, 0x65, 0x64, 0x22, 0x00,
0x12, 0x26, 0x0a, 0x0c, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d,
0x12, 0x07, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x1a, 0x07, 0x2e, 0x50, 0x61, 0x63, 0x6b,
0x65, 0x74, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x68, 0x6f,
0x64, 0x75, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6b, 0x65, 0x6e, 0x22, 0x39, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72,
0x12, 0x18, 0x0a, 0x07, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0d, 0x52, 0x07, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x65,
0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x54, 0x65, 0x78, 0x74, 0x22, 0x20,
0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04,
0x54, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x54, 0x65, 0x78, 0x74,
0x22, 0x89, 0x02, 0x0a, 0x06, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x20, 0x0a, 0x04, 0x4b,
0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x50, 0x41, 0x43, 0x4b,
0x45, 0x54, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x52, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x22, 0x0a,
0x05, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x52,
0x6f, 0x75, 0x74, 0x65, 0x44, 0x65, 0x73, 0x63, 0x48, 0x00, 0x52, 0x05, 0x52, 0x6f, 0x75, 0x74,
0x65, 0x12, 0x1f, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x09, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x65, 0x73, 0x63, 0x48, 0x00, 0x52, 0x04, 0x50, 0x65,
0x65, 0x72, 0x12, 0x1f, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x09, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x04, 0x44,
0x61, 0x74, 0x61, 0x12, 0x1f, 0x0a, 0x04, 0x43, 0x6f, 0x6e, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x09, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x48, 0x00, 0x52, 0x04,
0x43, 0x6f, 0x6e, 0x6e, 0x12, 0x26, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x6e, 0x45, 0x72, 0x72, 0x18,
0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x45, 0x72, 0x72, 0x6f,
0x72, 0x48, 0x00, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x6e, 0x45, 0x72, 0x72, 0x12, 0x29, 0x0a, 0x08,
0x43, 0x6f, 0x6e, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b,
0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x48, 0x00, 0x52, 0x08, 0x43,
0x6f, 0x6e, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x42, 0x03, 0x0a, 0x01, 0x55, 0x2a, 0x5e, 0x0a, 0x0c,
0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x12, 0x0a, 0x0a, 0x06,
0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10,
0x01, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x43, 0x50, 0x34, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x54,
0x43, 0x50, 0x36, 0x10, 0x04, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x54, 0x59, 0x10, 0x08, 0x12, 0x08,
0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x10, 0x12, 0x09, 0x0a, 0x05, 0x48, 0x54, 0x54, 0x50,
0x53, 0x10, 0x20, 0x12, 0x07, 0x0a, 0x03, 0x53, 0x53, 0x48, 0x10, 0x40, 0x2a, 0xe5, 0x01, 0x0a,
0x0b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x12, 0x0c, 0x0a, 0x08,
0x52, 0x45, 0x53, 0x45, 0x52, 0x56, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x52, 0x4f,
0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x52,
0x4f, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x52,
0x4f, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x52, 0x54, 0x45, 0x44, 0x10, 0x03, 0x12, 0x11,
0x0a, 0x0d, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10,
0x04, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x52, 0x54, 0x45,
0x44, 0x10, 0x05, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x4f, 0x50,
0x50, 0x45, 0x44, 0x10, 0x06, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x41, 0x42,
0x4f, 0x52, 0x54, 0x45, 0x44, 0x10, 0x07, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x45, 0x45, 0x52, 0x5f,
0x45, 0x4f, 0x46, 0x10, 0x08, 0x12, 0x0d, 0x0a, 0x09, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x44, 0x41,
0x54, 0x41, 0x10, 0x09, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x5f, 0x44, 0x45, 0x53,
0x43, 0x10, 0x0b, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x4f, 0x4e, 0x4e, 0x5f, 0x45, 0x52, 0x52, 0x4f,
0x52, 0x10, 0x0c, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x4f, 0x4e, 0x4e, 0x5f, 0x4e, 0x4f, 0x54, 0x49,
0x43, 0x45, 0x10, 0x0d, 0x32, 0x49, 0x0a, 0x04, 0x48, 0x6f, 0x64, 0x75, 0x12, 0x19, 0x0a, 0x07,
0x47, 0x65, 0x74, 0x53, 0x65, 0x65, 0x64, 0x12, 0x05, 0x2e, 0x53, 0x65, 0x65, 0x64, 0x1a, 0x05,
0x2e, 0x53, 0x65, 0x65, 0x64, 0x22, 0x00, 0x12, 0x26, 0x0a, 0x0c, 0x50, 0x61, 0x63, 0x6b, 0x65,
0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x07, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74,
0x1a, 0x07, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42,
0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x68, 0x6f, 0x64, 0x75, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
})
var (
@ -759,7 +838,7 @@ func file_hodu_proto_rawDescGZIP() []byte {
}
var file_hodu_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_hodu_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_hodu_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_hodu_proto_goTypes = []any{
(ROUTE_OPTION)(0), // 0: ROUTE_OPTION
(PACKET_KIND)(0), // 1: PACKET_KIND
@ -768,8 +847,9 @@ var file_hodu_proto_goTypes = []any{
(*PeerDesc)(nil), // 4: PeerDesc
(*PeerData)(nil), // 5: PeerData
(*ConnDesc)(nil), // 6: ConnDesc
(*ConnNotice)(nil), // 7: ConnNotice
(*Packet)(nil), // 8: Packet
(*ConnError)(nil), // 7: ConnError
(*ConnNotice)(nil), // 8: ConnNotice
(*Packet)(nil), // 9: Packet
}
var file_hodu_proto_depIdxs = []int32{
1, // 0: Packet.Kind:type_name -> PACKET_KIND
@ -777,16 +857,17 @@ var file_hodu_proto_depIdxs = []int32{
4, // 2: Packet.Peer:type_name -> PeerDesc
5, // 3: Packet.Data:type_name -> PeerData
6, // 4: Packet.Conn:type_name -> ConnDesc
7, // 5: Packet.Notice:type_name -> ConnNotice
2, // 6: Hodu.GetSeed:input_type -> Seed
8, // 7: Hodu.PacketStream:input_type -> Packet
2, // 8: Hodu.GetSeed:output_type -> Seed
8, // 9: Hodu.PacketStream:output_type -> Packet
8, // [8:10] is the sub-list for method output_type
6, // [6:8] 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
7, // 5: Packet.ConnErr:type_name -> ConnError
8, // 6: Packet.ConnNoti:type_name -> ConnNotice
2, // 7: Hodu.GetSeed:input_type -> Seed
9, // 8: Hodu.PacketStream:input_type -> Packet
2, // 9: Hodu.GetSeed:output_type -> Seed
9, // 10: Hodu.PacketStream:output_type -> Packet
9, // [9:11] is the sub-list for method output_type
7, // [7:9] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
}
func init() { file_hodu_proto_init() }
@ -794,12 +875,13 @@ func file_hodu_proto_init() {
if File_hodu_proto != nil {
return
}
file_hodu_proto_msgTypes[6].OneofWrappers = []any{
file_hodu_proto_msgTypes[7].OneofWrappers = []any{
(*Packet_Route)(nil),
(*Packet_Peer)(nil),
(*Packet_Data)(nil),
(*Packet_Conn)(nil),
(*Packet_Notice)(nil),
(*Packet_ConnErr)(nil),
(*Packet_ConnNoti)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -807,7 +889,7 @@ func file_hodu_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_hodu_proto_rawDesc), len(file_hodu_proto_rawDesc)),
NumEnums: 2,
NumMessages: 7,
NumMessages: 8,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -69,12 +69,17 @@ message PeerData {
};
message ConnDesc {
string Token = 1;
}
string Token = 1;
};
message ConnError {
uint32 ErrorId = 1;
string Text = 2;
};
message ConnNotice {
string Text = 1;
}
};
enum PACKET_KIND {
RESERVED = 0; // not used
@ -87,18 +92,20 @@ enum PACKET_KIND {
PEER_ABORTED = 7;
PEER_EOF = 8;
PEER_DATA = 9;
CONN_DESC = 11;
CONN_NOTICE = 12;
CONN_DESC = 11;
CONN_ERROR = 12;
CONN_NOTICE = 13;
};
message Packet {
PACKET_KIND Kind = 1;
oneof U {
RouteDesc Route = 2;
PeerDesc Peer = 3;
PeerData Data = 4;
ConnDesc Conn = 5;
ConnNotice Notice = 6;
RouteDesc Route = 2;
PeerDesc Peer = 3;
PeerData Data = 4;
ConnDesc Conn = 5;
ConnError ConnErr = 6;
ConnNotice ConnNoti = 7;
};
}

View File

@ -67,6 +67,10 @@ func MakeConnDescPacket(token string) *Packet {
return &Packet{Kind: PACKET_KIND_CONN_DESC,U: &Packet_Conn{Conn: &ConnDesc{Token: token}}}
}
func MakeConnNoticePacket(msg string) *Packet {
return &Packet{Kind: PACKET_KIND_CONN_NOTICE, U: &Packet_Notice{Notice: &ConnNotice{Text: msg}}}
func MakeConnErrorPacket(error_id uint32, msg string) *Packet {
return &Packet{Kind: PACKET_KIND_CONN_ERROR, U: &Packet_ConnErr{ConnErr: &ConnError{ErrorId: error_id, Text: msg}}}
}
func MakeConnNoticePacket(msg string) *Packet {
return &Packet{Kind: PACKET_KIND_CONN_NOTICE, U: &Packet_ConnNoti{ConnNoti: &ConnNotice{Text: msg}}}
}

View File

@ -754,11 +754,13 @@ func (cts *ServerConn) receive_from_stream(wg *sync.WaitGroup) {
if ok {
if x.Conn.Token == "" {
cts.S.log.Write(cts.Sid, LOG_ERROR, "Invalid conn_desc packet from %s - blank token", cts.RemoteAddr)
cts.pss.Send(MakeConnErrorPacket(1, "blank token refused"))
cts.ReqStop() // TODO: is this desirable to disconnect?
} else if x.Conn.Token != cts.ClientToken {
_, err = strconv.ParseUint(x.Conn.Token, 10, int(unsafe.Sizeof(ConnId(0)) * 8))
if err == nil { // this is not != nil. this is to check if the token is numeric
cts.S.log.Write(cts.Sid, LOG_ERROR, "Invalid conn_desc packet from %s - numeric token '%s'", cts.RemoteAddr, x.Conn.Token)
cts.pss.Send(MakeConnErrorPacket(1, "numeric token refused"))
cts.ReqStop() // TODO: is this desirable to disconnect?
} else {
cts.S.cts_mtx.Lock()
@ -767,6 +769,7 @@ func (cts *ServerConn) receive_from_stream(wg *sync.WaitGroup) {
// error
cts.S.cts_mtx.Unlock()
cts.S.log.Write(cts.Sid, LOG_ERROR, "Invalid conn_desc packet from %s - duplicate token '%s'", cts.RemoteAddr, x.Conn.Token)
cts.pss.Send(MakeConnErrorPacket(1, "duplicate token refused"))
cts.ReqStop() // TODO: is this desirable to disconnect?
} else {
if cts.ClientToken != "" { delete(cts.S.cts_map_by_token, cts.ClientToken) }
@ -783,12 +786,12 @@ func (cts *ServerConn) receive_from_stream(wg *sync.WaitGroup) {
case PACKET_KIND_CONN_NOTICE:
// the connection from the client to a peer has been established
var x *Packet_Notice
var x *Packet_ConnNoti
var ok bool
x, ok = pkt.U.(*Packet_Notice)
x, ok = pkt.U.(*Packet_ConnNoti)
if ok {
if cts.S.conn_notice != nil {
cts.S.conn_notice.Handle(cts, x.Notice.Text)
cts.S.conn_notice.Handle(cts, x.ConnNoti.Text)
}
} else {
cts.S.log.Write(cts.Sid, LOG_ERROR, "Invalid conn_notice packet from %s", cts.RemoteAddr)