added theConnDesc message to the grpc protocol

This commit is contained in:
hyung-hwan 2025-02-20 00:59:00 +09:00
parent 1c49023c37
commit c7b7bfd25f
8 changed files with 240 additions and 120 deletions

View File

@ -64,6 +64,8 @@ type ClientConfig struct {
RpcConnMax int
PeerConnMax int
PeerConnTmout time.Duration
Token string // to send to the server for identification
}
type ClientConnNoticeHandler interface {
@ -98,6 +100,7 @@ type Client struct {
wg sync.WaitGroup
stop_req atomic.Bool
stop_chan chan bool
token string
log Logger
conn_notice ClientConnNoticeHandler
@ -1007,6 +1010,14 @@ start_over:
cts.psc = &GuardedPacketStreamClient{Hodu_PacketStreamClient: psc}
if cts.C.token != "" {
err = cts.psc.Send(MakeConnDescPacket(cts.C.token))
if err != nil {
cts.C.log.Write(cts.Sid, LOG_ERROR, "Failed to send conn-desc to server[%d] %s - %s", cts.cfg.Index, cts.cfg.ServerAddrs[cts.cfg.Index], err.Error())
goto reconnect_to_server
}
}
if len(cts.cfg.Routes) > 0 {
// the connection structure to a server is ready.
// let's add statically configured routes to the client-side peers
@ -1344,6 +1355,7 @@ func NewClient(ctx context.Context, name string, logger Logger, cfg *ClientConfi
c.stop_req.Store(false)
c.stop_chan = make(chan bool, 8)
c.log = logger
c.token = cfg.Token
c.rpc_tls = cfg.RpcTls
c.ctl_auth = cfg.CtlAuth

3
go.mod
View File

@ -3,6 +3,7 @@ module hodu
go 1.22.0
require (
github.com/prometheus/client_golang v1.20.5
golang.org/x/crypto v0.26.0
golang.org/x/net v0.28.0
golang.org/x/sys v0.24.0
@ -16,8 +17,8 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect

12
go.sum
View File

@ -2,10 +2,17 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
@ -16,6 +23,8 @@ github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
@ -32,7 +41,8 @@ google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.35.1
// protoc-gen-go v1.36.5
// protoc v3.19.6
// source: hodu.proto
@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@ -97,7 +98,8 @@ const (
PACKET_KIND_PEER_ABORTED PACKET_KIND = 7
PACKET_KIND_PEER_EOF PACKET_KIND = 8
PACKET_KIND_PEER_DATA PACKET_KIND = 9
PACKET_KIND_CONN_NOTICE PACKET_KIND = 10
PACKET_KIND_CONN_DESC PACKET_KIND = 11
PACKET_KIND_CONN_NOTICE PACKET_KIND = 12
)
// Enum value maps for PACKET_KIND.
@ -113,7 +115,8 @@ var (
7: "PEER_ABORTED",
8: "PEER_EOF",
9: "PEER_DATA",
10: "CONN_NOTICE",
11: "CONN_DESC",
12: "CONN_NOTICE",
}
PACKET_KIND_value = map[string]int32{
"RESERVED": 0,
@ -126,7 +129,8 @@ var (
"PEER_ABORTED": 7,
"PEER_EOF": 8,
"PEER_DATA": 9,
"CONN_NOTICE": 10,
"CONN_DESC": 11,
"CONN_NOTICE": 12,
}
)
@ -158,12 +162,11 @@ func (PACKET_KIND) EnumDescriptor() ([]byte, []int) {
}
type Seed struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Version uint32 `protobuf:"varint,1,opt,name=Version,proto3" json:"Version,omitempty"`
Flags uint64 `protobuf:"varint,2,opt,name=Flags,proto3" json:"Flags,omitempty"`
unknownFields protoimpl.UnknownFields
Version uint32 `protobuf:"varint,1,opt,name=Version,proto3" json:"Version,omitempty"`
Flags uint64 `protobuf:"varint,2,opt,name=Flags,proto3" json:"Flags,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *Seed) Reset() {
@ -211,11 +214,8 @@ func (x *Seed) GetFlags() uint64 {
}
type RouteDesc struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RouteId uint32 `protobuf:"varint,1,opt,name=RouteId,proto3" json:"RouteId,omitempty"`
state protoimpl.MessageState `protogen:"open.v1"`
RouteId uint32 `protobuf:"varint,1,opt,name=RouteId,proto3" json:"RouteId,omitempty"`
// C->S(ROUTE_START): client-side peer address
// S->C(ROUTE_STARTED): server-side listening address
TargetAddrStr string `protobuf:"bytes,2,opt,name=TargetAddrStr,proto3" json:"TargetAddrStr,omitempty"`
@ -235,6 +235,8 @@ type RouteDesc struct {
// C->S(ROUTE_START): permitted network of server-side peers.
// S->C(ROUTE_STARTED): cloned as sent by C.
ServiceNetStr string `protobuf:"bytes,6,opt,name=ServiceNetStr,proto3" json:"ServiceNetStr,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RouteDesc) Reset() {
@ -310,14 +312,13 @@ func (x *RouteDesc) GetServiceNetStr() string {
}
type PeerDesc struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
RouteId uint32 `protobuf:"varint,1,opt,name=RouteId,proto3" json:"RouteId,omitempty"`
PeerId uint32 `protobuf:"varint,2,opt,name=PeerId,proto3" json:"PeerId,omitempty"`
RemoteAddrStr string `protobuf:"bytes,3,opt,name=RemoteAddrStr,proto3" json:"RemoteAddrStr,omitempty"`
LocalAddrStr string `protobuf:"bytes,4,opt,name=LocalAddrStr,proto3" json:"LocalAddrStr,omitempty"`
unknownFields protoimpl.UnknownFields
RouteId uint32 `protobuf:"varint,1,opt,name=RouteId,proto3" json:"RouteId,omitempty"`
PeerId uint32 `protobuf:"varint,2,opt,name=PeerId,proto3" json:"PeerId,omitempty"`
RemoteAddrStr string `protobuf:"bytes,3,opt,name=RemoteAddrStr,proto3" json:"RemoteAddrStr,omitempty"`
LocalAddrStr string `protobuf:"bytes,4,opt,name=LocalAddrStr,proto3" json:"LocalAddrStr,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *PeerDesc) Reset() {
@ -379,13 +380,12 @@ func (x *PeerDesc) GetLocalAddrStr() string {
}
type PeerData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
RouteId uint32 `protobuf:"varint,1,opt,name=RouteId,proto3" json:"RouteId,omitempty"`
PeerId uint32 `protobuf:"varint,2,opt,name=PeerId,proto3" json:"PeerId,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
unknownFields protoimpl.UnknownFields
RouteId uint32 `protobuf:"varint,1,opt,name=RouteId,proto3" json:"RouteId,omitempty"`
PeerId uint32 `protobuf:"varint,2,opt,name=PeerId,proto3" json:"PeerId,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *PeerData) Reset() {
@ -439,17 +439,60 @@ func (x *PeerData) GetData() []byte {
return nil
}
type ConnNotice struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
type ConnDesc struct {
state protoimpl.MessageState `protogen:"open.v1"`
Token string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
Text string `protobuf:"bytes,1,opt,name=Text,proto3" json:"Text,omitempty"`
func (x *ConnDesc) Reset() {
*x = ConnDesc{}
mi := &file_hodu_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ConnDesc) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConnDesc) ProtoMessage() {}
func (x *ConnDesc) ProtoReflect() protoreflect.Message {
mi := &file_hodu_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 ConnDesc.ProtoReflect.Descriptor instead.
func (*ConnDesc) Descriptor() ([]byte, []int) {
return file_hodu_proto_rawDescGZIP(), []int{4}
}
func (x *ConnDesc) GetToken() string {
if x != nil {
return x.Token
}
return ""
}
type ConnNotice struct {
state protoimpl.MessageState `protogen:"open.v1"`
Text string `protobuf:"bytes,1,opt,name=Text,proto3" json:"Text,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ConnNotice) Reset() {
*x = ConnNotice{}
mi := &file_hodu_proto_msgTypes[4]
mi := &file_hodu_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -461,7 +504,7 @@ func (x *ConnNotice) String() string {
func (*ConnNotice) ProtoMessage() {}
func (x *ConnNotice) ProtoReflect() protoreflect.Message {
mi := &file_hodu_proto_msgTypes[4]
mi := &file_hodu_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -474,7 +517,7 @@ func (x *ConnNotice) ProtoReflect() protoreflect.Message {
// Deprecated: Use ConnNotice.ProtoReflect.Descriptor instead.
func (*ConnNotice) Descriptor() ([]byte, []int) {
return file_hodu_proto_rawDescGZIP(), []int{4}
return file_hodu_proto_rawDescGZIP(), []int{5}
}
func (x *ConnNotice) GetText() string {
@ -485,23 +528,23 @@ func (x *ConnNotice) GetText() string {
}
type Packet struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Kind PACKET_KIND `protobuf:"varint,1,opt,name=Kind,proto3,enum=PACKET_KIND" json:"Kind,omitempty"`
// Types that are assignable to U:
state protoimpl.MessageState `protogen:"open.v1"`
Kind PACKET_KIND `protobuf:"varint,1,opt,name=Kind,proto3,enum=PACKET_KIND" json:"Kind,omitempty"`
// Types that are valid to be assigned to U:
//
// *Packet_Route
// *Packet_Peer
// *Packet_Data
// *Packet_Conn
// *Packet_Notice
U isPacket_U `protobuf_oneof:"U"`
U isPacket_U `protobuf_oneof:"U"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Packet) Reset() {
*x = Packet{}
mi := &file_hodu_proto_msgTypes[5]
mi := &file_hodu_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -513,7 +556,7 @@ func (x *Packet) String() string {
func (*Packet) ProtoMessage() {}
func (x *Packet) 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 {
@ -526,7 +569,7 @@ func (x *Packet) ProtoReflect() protoreflect.Message {
// Deprecated: Use Packet.ProtoReflect.Descriptor instead.
func (*Packet) Descriptor() ([]byte, []int) {
return file_hodu_proto_rawDescGZIP(), []int{5}
return file_hodu_proto_rawDescGZIP(), []int{6}
}
func (x *Packet) GetKind() PACKET_KIND {
@ -536,37 +579,54 @@ func (x *Packet) GetKind() PACKET_KIND {
return PACKET_KIND_RESERVED
}
func (m *Packet) GetU() isPacket_U {
if m != nil {
return m.U
func (x *Packet) GetU() isPacket_U {
if x != nil {
return x.U
}
return nil
}
func (x *Packet) GetRoute() *RouteDesc {
if x, ok := x.GetU().(*Packet_Route); ok {
return x.Route
if x != nil {
if x, ok := x.U.(*Packet_Route); ok {
return x.Route
}
}
return nil
}
func (x *Packet) GetPeer() *PeerDesc {
if x, ok := x.GetU().(*Packet_Peer); ok {
return x.Peer
if x != nil {
if x, ok := x.U.(*Packet_Peer); ok {
return x.Peer
}
}
return nil
}
func (x *Packet) GetData() *PeerData {
if x, ok := x.GetU().(*Packet_Data); ok {
return x.Data
if x != nil {
if x, ok := x.U.(*Packet_Data); ok {
return x.Data
}
}
return nil
}
func (x *Packet) GetConn() *ConnDesc {
if x != nil {
if x, ok := x.U.(*Packet_Conn); ok {
return x.Conn
}
}
return nil
}
func (x *Packet) GetNotice() *ConnNotice {
if x, ok := x.GetU().(*Packet_Notice); ok {
return x.Notice
if x != nil {
if x, ok := x.U.(*Packet_Notice); ok {
return x.Notice
}
}
return nil
}
@ -587,8 +647,12 @@ type Packet_Data struct {
Data *PeerData `protobuf:"bytes,4,opt,name=Data,proto3,oneof"`
}
type Packet_Conn struct {
Conn *ConnDesc `protobuf:"bytes,5,opt,name=Conn,proto3,oneof"`
}
type Packet_Notice struct {
Notice *ConnNotice `protobuf:"bytes,5,opt,name=Notice,proto3,oneof"`
Notice *ConnNotice `protobuf:"bytes,6,opt,name=Notice,proto3,oneof"`
}
func (*Packet_Route) isPacket_U() {}
@ -597,11 +661,13 @@ func (*Packet_Peer) isPacket_U() {}
func (*Packet_Data) isPacket_U() {}
func (*Packet_Conn) isPacket_U() {}
func (*Packet_Notice) isPacket_U() {}
var File_hodu_proto protoreflect.FileDescriptor
var file_hodu_proto_rawDesc = []byte{
var file_hodu_proto_rawDesc = string([]byte{
0x0a, 0x0a, 0x68, 0x6f, 0x64, 0x75, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x36, 0x0a, 0x04,
0x53, 0x65, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14,
@ -634,61 +700,66 @@ var file_hodu_proto_rawDesc = []byte{
0x75, 0x74, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x65, 0x65, 0x72, 0x49, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x50, 0x65, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74,
0x61, 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, 0xbc, 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, 0x25, 0x0a, 0x06, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65,
0x18, 0x05, 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, 0xc6, 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, 0x0f, 0x0a, 0x0b, 0x43, 0x4f,
0x4e, 0x4e, 0x5f, 0x4e, 0x4f, 0x54, 0x49, 0x43, 0x45, 0x10, 0x0a, 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,
}
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,
})
var (
file_hodu_proto_rawDescOnce sync.Once
file_hodu_proto_rawDescData = file_hodu_proto_rawDesc
file_hodu_proto_rawDescData []byte
)
func file_hodu_proto_rawDescGZIP() []byte {
file_hodu_proto_rawDescOnce.Do(func() {
file_hodu_proto_rawDescData = protoimpl.X.CompressGZIP(file_hodu_proto_rawDescData)
file_hodu_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hodu_proto_rawDesc), len(file_hodu_proto_rawDesc)))
})
return file_hodu_proto_rawDescData
}
var file_hodu_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_hodu_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_hodu_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_hodu_proto_goTypes = []any{
(ROUTE_OPTION)(0), // 0: ROUTE_OPTION
(PACKET_KIND)(0), // 1: PACKET_KIND
@ -696,24 +767,26 @@ var file_hodu_proto_goTypes = []any{
(*RouteDesc)(nil), // 3: RouteDesc
(*PeerDesc)(nil), // 4: PeerDesc
(*PeerData)(nil), // 5: PeerData
(*ConnNotice)(nil), // 6: ConnNotice
(*Packet)(nil), // 7: Packet
(*ConnDesc)(nil), // 6: ConnDesc
(*ConnNotice)(nil), // 7: ConnNotice
(*Packet)(nil), // 8: Packet
}
var file_hodu_proto_depIdxs = []int32{
1, // 0: Packet.Kind:type_name -> PACKET_KIND
3, // 1: Packet.Route:type_name -> RouteDesc
4, // 2: Packet.Peer:type_name -> PeerDesc
5, // 3: Packet.Data:type_name -> PeerData
6, // 4: Packet.Notice:type_name -> ConnNotice
2, // 5: Hodu.GetSeed:input_type -> Seed
7, // 6: Hodu.PacketStream:input_type -> Packet
2, // 7: Hodu.GetSeed:output_type -> Seed
7, // 8: Hodu.PacketStream:output_type -> Packet
7, // [7:9] is the sub-list for method output_type
5, // [5:7] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
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
}
func init() { file_hodu_proto_init() }
@ -721,19 +794,20 @@ func file_hodu_proto_init() {
if File_hodu_proto != nil {
return
}
file_hodu_proto_msgTypes[5].OneofWrappers = []any{
file_hodu_proto_msgTypes[6].OneofWrappers = []any{
(*Packet_Route)(nil),
(*Packet_Peer)(nil),
(*Packet_Data)(nil),
(*Packet_Conn)(nil),
(*Packet_Notice)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_hodu_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_hodu_proto_rawDesc), len(file_hodu_proto_rawDesc)),
NumEnums: 2,
NumMessages: 6,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},
@ -743,7 +817,6 @@ func file_hodu_proto_init() {
MessageInfos: file_hodu_proto_msgTypes,
}.Build()
File_hodu_proto = out.File
file_hodu_proto_rawDesc = nil
file_hodu_proto_goTypes = nil
file_hodu_proto_depIdxs = nil
}

View File

@ -68,6 +68,10 @@ message PeerData {
bytes Data = 3;
};
message ConnDesc {
string Token = 1;
}
message ConnNotice {
string Text = 1;
}
@ -83,7 +87,8 @@ enum PACKET_KIND {
PEER_ABORTED = 7;
PEER_EOF = 8;
PEER_DATA = 9;
CONN_NOTICE = 10;
CONN_DESC = 11;
CONN_NOTICE = 12;
};
message Packet {
@ -93,6 +98,7 @@ message Packet {
RouteDesc Route = 2;
PeerDesc Peer = 3;
PeerData Data = 4;
ConnNotice Notice = 5;
ConnDesc Conn = 5;
ConnNotice Notice = 6;
};
}

View File

@ -63,6 +63,10 @@ func MakePeerDataPacket(route_id RouteId, peer_id PeerId, data []byte) *Packet {
U: &Packet_Data{Data: &PeerData{RouteId: uint32(route_id), PeerId: uint32(peer_id), Data: data}}}
}
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}}}
}

View File

@ -19,6 +19,7 @@ type json_out_server_conn struct {
Id ConnId `json:"id"`
ServerAddr string `json:"server-addr"`
ClientAddr string `json:"client-addr"`
ClientToken string `json:"client-token"`
Routes []json_out_server_route `json:"routes"`
}
@ -201,6 +202,7 @@ func (ctl *server_ctl_server_conns) ServeHTTP(w http.ResponseWriter, req *http.R
Id: cts.Id,
ClientAddr: cts.RemoteAddr.String(),
ServerAddr: cts.LocalAddr.String(),
ClientToken: cts.Token,
Routes: jsp,
})
cts.route_mtx.Unlock()
@ -268,6 +270,7 @@ func (ctl *server_ctl_server_conns_id) ServeHTTP(w http.ResponseWriter, req *htt
Id: cts.Id,
ClientAddr: cts.RemoteAddr.String(),
ServerAddr: cts.LocalAddr.String(),
ClientToken: cts.Token,
Routes: jsp,
}
cts.route_mtx.Unlock()

View File

@ -128,6 +128,7 @@ type ServerConn struct {
S *Server
Id ConnId
Sid string // for logging
Token string // provided by client
RemoteAddr net.Addr // client address that created this structure
LocalAddr net.Addr // local address that the client is connected to
@ -744,6 +745,16 @@ func (cts *ServerConn) receive_from_stream(wg *sync.WaitGroup) {
cts.S.log.Write(cts.Sid, LOG_ERROR, "Invalid peer_data event from %s", cts.RemoteAddr)
}
case PACKET_KIND_CONN_DESC:
var x *Packet_Conn
var ok bool
x, ok = pkt.U.(*Packet_Conn)
if ok {
cts.Token = x.Conn.Token
} else {
cts.S.log.Write(cts.Sid, LOG_ERROR, "Invalid conn_desc event from %s", cts.RemoteAddr)
}
case PACKET_KIND_CONN_NOTICE:
// the connection from the client to a peer has been established
var x *Packet_Notice