From 19b816a6647d3c0d275604a126b17824ec87ba52 Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Sat, 19 May 2018 14:59:17 -0600 Subject: [PATCH] Further update to protobuf - Rename Uid to connID in PubMsg protocol - Send connID to ConnectRequest - Send client protocol version in ConnectRequest - Receive server protocol version in ConnectResponse - Add Ping and PingResponse protocols to allow future extensions (instead of sending connID directly as a byte array in payload) Signed-off-by: Ivan Kozlovic --- pb/protocol.pb.go | 499 +++++++++++++++++++++++++++++++++++++++------- pb/protocol.proto | 21 +- 2 files changed, 443 insertions(+), 77 deletions(-) diff --git a/pb/protocol.pb.go b/pb/protocol.pb.go index cd8b3cf..380485e 100644 --- a/pb/protocol.pb.go +++ b/pb/protocol.pb.go @@ -14,6 +14,8 @@ Ack ConnectRequest ConnectResponse + Ping + PingResponse SubscriptionRequest SubscriptionResponse UnsubscribeRequest @@ -78,7 +80,7 @@ type PubMsg struct { Subject string `protobuf:"bytes,3,opt,name=subject,proto3" json:"subject,omitempty"` Reply string `protobuf:"bytes,4,opt,name=reply,proto3" json:"reply,omitempty"` Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` - Uid []byte `protobuf:"bytes,6,opt,name=uid,proto3" json:"uid,omitempty"` + ConnID []byte `protobuf:"bytes,6,opt,name=connID,proto3" json:"connID,omitempty"` Sha256 []byte `protobuf:"bytes,10,opt,name=sha256,proto3" json:"sha256,omitempty"` } @@ -130,9 +132,11 @@ func (*Ack) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{ type ConnectRequest struct { ClientID string `protobuf:"bytes,1,opt,name=clientID,proto3" json:"clientID,omitempty"` HeartbeatInbox string `protobuf:"bytes,2,opt,name=heartbeatInbox,proto3" json:"heartbeatInbox,omitempty"` - PingInterval int64 `protobuf:"varint,4,opt,name=pingInterval,proto3" json:"pingInterval,omitempty"` - PingTimeout int64 `protobuf:"varint,5,opt,name=pingTimeout,proto3" json:"pingTimeout,omitempty"` - PingMaxOut int32 `protobuf:"varint,6,opt,name=pingMaxOut,proto3" json:"pingMaxOut,omitempty"` + Protocol int32 `protobuf:"varint,3,opt,name=protocol,proto3" json:"protocol,omitempty"` + ConnID []byte `protobuf:"bytes,4,opt,name=connID,proto3" json:"connID,omitempty"` + PingInterval int64 `protobuf:"varint,5,opt,name=pingInterval,proto3" json:"pingInterval,omitempty"` + PingTimeout int64 `protobuf:"varint,6,opt,name=pingTimeout,proto3" json:"pingTimeout,omitempty"` + PingMaxOut int32 `protobuf:"varint,7,opt,name=pingMaxOut,proto3" json:"pingMaxOut,omitempty"` } func (m *ConnectRequest) Reset() { *m = ConnectRequest{} } @@ -152,6 +156,7 @@ type ConnectResponse struct { PingInterval int64 `protobuf:"varint,8,opt,name=pingInterval,proto3" json:"pingInterval,omitempty"` PingTimeout int64 `protobuf:"varint,9,opt,name=pingTimeout,proto3" json:"pingTimeout,omitempty"` PingMaxOut int32 `protobuf:"varint,10,opt,name=pingMaxOut,proto3" json:"pingMaxOut,omitempty"` + Protocol int32 `protobuf:"varint,11,opt,name=protocol,proto3" json:"protocol,omitempty"` PublicKey string `protobuf:"bytes,100,opt,name=publicKey,proto3" json:"publicKey,omitempty"` } @@ -160,6 +165,26 @@ func (m *ConnectResponse) String() string { return proto.CompactTextS func (*ConnectResponse) ProtoMessage() {} func (*ConnectResponse) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{5} } +// PING from client to server +type Ping struct { + ConnID []byte `protobuf:"bytes,1,opt,name=connID,proto3" json:"connID,omitempty"` +} + +func (m *Ping) Reset() { *m = Ping{} } +func (m *Ping) String() string { return proto.CompactTextString(m) } +func (*Ping) ProtoMessage() {} +func (*Ping) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{6} } + +// PING response from the server +type PingResponse struct { + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (m *PingResponse) Reset() { *m = PingResponse{} } +func (m *PingResponse) String() string { return proto.CompactTextString(m) } +func (*PingResponse) ProtoMessage() {} +func (*PingResponse) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{7} } + // Protocol for a client to subscribe type SubscriptionRequest struct { ClientID string `protobuf:"bytes,1,opt,name=clientID,proto3" json:"clientID,omitempty"` @@ -177,7 +202,7 @@ type SubscriptionRequest struct { func (m *SubscriptionRequest) Reset() { *m = SubscriptionRequest{} } func (m *SubscriptionRequest) String() string { return proto.CompactTextString(m) } func (*SubscriptionRequest) ProtoMessage() {} -func (*SubscriptionRequest) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{6} } +func (*SubscriptionRequest) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{8} } // Response for SubscriptionRequest and UnsubscribeRequests type SubscriptionResponse struct { @@ -188,7 +213,7 @@ type SubscriptionResponse struct { func (m *SubscriptionResponse) Reset() { *m = SubscriptionResponse{} } func (m *SubscriptionResponse) String() string { return proto.CompactTextString(m) } func (*SubscriptionResponse) ProtoMessage() {} -func (*SubscriptionResponse) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{7} } +func (*SubscriptionResponse) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{9} } // Protocol for a clients to unsubscribe. Will return a SubscriptionResponse type UnsubscribeRequest struct { @@ -201,7 +226,7 @@ type UnsubscribeRequest struct { func (m *UnsubscribeRequest) Reset() { *m = UnsubscribeRequest{} } func (m *UnsubscribeRequest) String() string { return proto.CompactTextString(m) } func (*UnsubscribeRequest) ProtoMessage() {} -func (*UnsubscribeRequest) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{8} } +func (*UnsubscribeRequest) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{10} } // Protocol for a client to close a connection type CloseRequest struct { @@ -211,7 +236,7 @@ type CloseRequest struct { func (m *CloseRequest) Reset() { *m = CloseRequest{} } func (m *CloseRequest) String() string { return proto.CompactTextString(m) } func (*CloseRequest) ProtoMessage() {} -func (*CloseRequest) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{9} } +func (*CloseRequest) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{11} } // Response for CloseRequest type CloseResponse struct { @@ -221,7 +246,7 @@ type CloseResponse struct { func (m *CloseResponse) Reset() { *m = CloseResponse{} } func (m *CloseResponse) String() string { return proto.CompactTextString(m) } func (*CloseResponse) ProtoMessage() {} -func (*CloseResponse) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{10} } +func (*CloseResponse) Descriptor() ([]byte, []int) { return fileDescriptorProtocol, []int{12} } func init() { proto.RegisterType((*PubMsg)(nil), "pb.PubMsg") @@ -230,6 +255,8 @@ func init() { proto.RegisterType((*Ack)(nil), "pb.Ack") proto.RegisterType((*ConnectRequest)(nil), "pb.ConnectRequest") proto.RegisterType((*ConnectResponse)(nil), "pb.ConnectResponse") + proto.RegisterType((*Ping)(nil), "pb.Ping") + proto.RegisterType((*PingResponse)(nil), "pb.PingResponse") proto.RegisterType((*SubscriptionRequest)(nil), "pb.SubscriptionRequest") proto.RegisterType((*SubscriptionResponse)(nil), "pb.SubscriptionResponse") proto.RegisterType((*UnsubscribeRequest)(nil), "pb.UnsubscribeRequest") @@ -282,11 +309,11 @@ func (m *PubMsg) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintProtocol(dAtA, i, uint64(len(m.Data))) i += copy(dAtA[i:], m.Data) } - if len(m.Uid) > 0 { + if len(m.ConnID) > 0 { dAtA[i] = 0x32 i++ - i = encodeVarintProtocol(dAtA, i, uint64(len(m.Uid))) - i += copy(dAtA[i:], m.Uid) + i = encodeVarintProtocol(dAtA, i, uint64(len(m.ConnID))) + i += copy(dAtA[i:], m.ConnID) } if len(m.Sha256) > 0 { dAtA[i] = 0x52 @@ -444,18 +471,29 @@ func (m *ConnectRequest) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintProtocol(dAtA, i, uint64(len(m.HeartbeatInbox))) i += copy(dAtA[i:], m.HeartbeatInbox) } + if m.Protocol != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintProtocol(dAtA, i, uint64(m.Protocol)) + } + if len(m.ConnID) > 0 { + dAtA[i] = 0x22 + i++ + i = encodeVarintProtocol(dAtA, i, uint64(len(m.ConnID))) + i += copy(dAtA[i:], m.ConnID) + } if m.PingInterval != 0 { - dAtA[i] = 0x20 + dAtA[i] = 0x28 i++ i = encodeVarintProtocol(dAtA, i, uint64(m.PingInterval)) } if m.PingTimeout != 0 { - dAtA[i] = 0x28 + dAtA[i] = 0x30 i++ i = encodeVarintProtocol(dAtA, i, uint64(m.PingTimeout)) } if m.PingMaxOut != 0 { - dAtA[i] = 0x30 + dAtA[i] = 0x38 i++ i = encodeVarintProtocol(dAtA, i, uint64(m.PingMaxOut)) } @@ -534,6 +572,11 @@ func (m *ConnectResponse) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintProtocol(dAtA, i, uint64(m.PingMaxOut)) } + if m.Protocol != 0 { + dAtA[i] = 0x58 + i++ + i = encodeVarintProtocol(dAtA, i, uint64(m.Protocol)) + } if len(m.PublicKey) > 0 { dAtA[i] = 0xa2 i++ @@ -545,6 +588,54 @@ func (m *ConnectResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *Ping) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Ping) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ConnID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintProtocol(dAtA, i, uint64(len(m.ConnID))) + i += copy(dAtA[i:], m.ConnID) + } + return i, nil +} + +func (m *PingResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PingResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Error) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintProtocol(dAtA, i, uint64(len(m.Error))) + i += copy(dAtA[i:], m.Error) + } + return i, nil +} + func (m *SubscriptionRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -770,7 +861,7 @@ func (m *PubMsg) Size() (n int) { if l > 0 { n += 1 + l + sovProtocol(uint64(l)) } - l = len(m.Uid) + l = len(m.ConnID) if l > 0 { n += 1 + l + sovProtocol(uint64(l)) } @@ -849,6 +940,13 @@ func (m *ConnectRequest) Size() (n int) { if l > 0 { n += 1 + l + sovProtocol(uint64(l)) } + if m.Protocol != 0 { + n += 1 + sovProtocol(uint64(m.Protocol)) + } + l = len(m.ConnID) + if l > 0 { + n += 1 + l + sovProtocol(uint64(l)) + } if m.PingInterval != 0 { n += 1 + sovProtocol(uint64(m.PingInterval)) } @@ -901,6 +999,9 @@ func (m *ConnectResponse) Size() (n int) { if m.PingMaxOut != 0 { n += 1 + sovProtocol(uint64(m.PingMaxOut)) } + if m.Protocol != 0 { + n += 1 + sovProtocol(uint64(m.Protocol)) + } l = len(m.PublicKey) if l > 0 { n += 2 + l + sovProtocol(uint64(l)) @@ -908,6 +1009,26 @@ func (m *ConnectResponse) Size() (n int) { return n } +func (m *Ping) Size() (n int) { + var l int + _ = l + l = len(m.ConnID) + if l > 0 { + n += 1 + l + sovProtocol(uint64(l)) + } + return n +} + +func (m *PingResponse) Size() (n int) { + var l int + _ = l + l = len(m.Error) + if l > 0 { + n += 1 + l + sovProtocol(uint64(l)) + } + return n +} + func (m *SubscriptionRequest) Size() (n int) { var l int _ = l @@ -1196,7 +1317,7 @@ func (m *PubMsg) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConnID", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1220,9 +1341,9 @@ func (m *PubMsg) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Uid = append(m.Uid[:0], dAtA[iNdEx:postIndex]...) - if m.Uid == nil { - m.Uid = []byte{} + m.ConnID = append(m.ConnID[:0], dAtA[iNdEx:postIndex]...) + if m.ConnID == nil { + m.ConnID = []byte{} } iNdEx = postIndex case 10: @@ -1786,7 +1907,57 @@ func (m *ConnectRequest) Unmarshal(dAtA []byte) error { } m.HeartbeatInbox = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Protocol", wireType) + } + m.Protocol = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtocol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Protocol |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnID", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtocol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProtocol + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnID = append(m.ConnID[:0], dAtA[iNdEx:postIndex]...) + if m.ConnID == nil { + m.ConnID = []byte{} + } + iNdEx = postIndex + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PingInterval", wireType) } @@ -1805,7 +1976,7 @@ func (m *ConnectRequest) Unmarshal(dAtA []byte) error { break } } - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PingTimeout", wireType) } @@ -1824,7 +1995,7 @@ func (m *ConnectRequest) Unmarshal(dAtA []byte) error { break } } - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PingMaxOut", wireType) } @@ -2153,6 +2324,25 @@ func (m *ConnectResponse) Unmarshal(dAtA []byte) error { break } } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Protocol", wireType) + } + m.Protocol = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtocol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Protocol |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } case 100: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) @@ -2203,6 +2393,166 @@ func (m *ConnectResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *Ping) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtocol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Ping: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Ping: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnID", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtocol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProtocol + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnID = append(m.ConnID[:0], dAtA[iNdEx:postIndex]...) + if m.ConnID == nil { + m.ConnID = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProtocol(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthProtocol + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PingResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtocol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PingResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtocol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProtocol + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProtocol(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthProtocol + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *SubscriptionRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3033,55 +3383,58 @@ var ( func init() { proto.RegisterFile("protocol.proto", fileDescriptorProtocol) } var fileDescriptorProtocol = []byte{ - // 800 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0x41, 0x6f, 0xdb, 0x36, - 0x14, 0xc7, 0x23, 0xcb, 0x76, 0xec, 0x17, 0xdb, 0x73, 0x38, 0x23, 0x10, 0x8c, 0xc1, 0x08, 0x84, - 0x6d, 0x08, 0x02, 0xcc, 0x01, 0x1c, 0x6c, 0x3b, 0xec, 0xb4, 0x39, 0xc8, 0x66, 0x6c, 0x49, 0x0c, - 0x79, 0xc3, 0xae, 0xa5, 0x64, 0x46, 0x66, 0x23, 0x4b, 0x8a, 0x48, 0xa5, 0xce, 0xb5, 0x97, 0x5e, - 0xfb, 0x29, 0xfa, 0x21, 0x7a, 0xea, 0x31, 0xc7, 0x7e, 0x84, 0x36, 0xbd, 0xf5, 0x53, 0x14, 0xa4, - 0x68, 0x99, 0x72, 0x9a, 0xa4, 0x40, 0x6f, 0x7c, 0x3f, 0x3f, 0x92, 0xef, 0xff, 0x7f, 0x8f, 0x32, - 0xb4, 0xe2, 0x24, 0xe2, 0x91, 0x17, 0x05, 0x7d, 0xb9, 0x40, 0xa5, 0xd8, 0xed, 0xfe, 0xe4, 0x53, - 0x3e, 0x4b, 0xdd, 0xbe, 0x17, 0xcd, 0x0f, 0xfc, 0xc8, 0x8f, 0x0e, 0xe4, 0x4f, 0x6e, 0x7a, 0x2e, - 0x23, 0x19, 0xc8, 0x55, 0xb6, 0xc5, 0x7e, 0x65, 0x40, 0x75, 0x9c, 0xba, 0x27, 0xcc, 0x47, 0x5d, - 0xa8, 0x79, 0x01, 0x25, 0x21, 0x1f, 0x1d, 0x59, 0xc6, 0xae, 0xb1, 0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a6, 0x6b, 0xff, 0x09, 0x34, 0x0b, 0xfd, 0x40, 0x5b, 0xb0, 0x79, 0x4a, 0x9e, 0x9d, 0x85, 0xc1, - 0x75, 0x7b, 0x03, 0xb5, 0xa1, 0xf1, 0x0f, 0x66, 0xdc, 0x21, 0x1e, 0xa1, 0x57, 0x64, 0xda, 0x36, - 0x10, 0x82, 0x56, 0x6e, 0xaf, 0xdc, 0xd8, 0x2e, 0xa1, 0x6d, 0x68, 0x2e, 0x3b, 0x93, 0x21, 0x13, - 0xd5, 0xa1, 0x72, 0x4c, 0x13, 0xc6, 0xdb, 0xe5, 0x3f, 0x3a, 0x37, 0xef, 0x7b, 0x1b, 0x37, 0xb7, - 0x3d, 0xe3, 0xed, 0x6d, 0xcf, 0x78, 0x77, 0xdb, 0x33, 0x5e, 0x7e, 0xe8, 0x6d, 0xb8, 0x55, 0xf9, - 0x8f, 0x79, 0xf8, 0x29, 0x00, 0x00, 0xff, 0xff, 0x0e, 0xac, 0xac, 0x47, 0x76, 0x07, 0x00, 0x00, + // 843 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0xae, 0x63, 0x3b, 0x4d, 0xdf, 0x26, 0x21, 0x3b, 0x54, 0x2b, 0xab, 0x42, 0x51, 0x65, 0x2d, + 0x68, 0x55, 0x89, 0xae, 0xd4, 0x15, 0x70, 0xe0, 0x04, 0xad, 0x16, 0x22, 0xe8, 0x6e, 0xe4, 0x80, + 0xb8, 0x32, 0x76, 0x66, 0x9d, 0xa1, 0xce, 0x8c, 0xd7, 0x33, 0x2e, 0xe9, 0x95, 0x5f, 0xc0, 0x7f, + 0xe0, 0xca, 0x8f, 0xe0, 0xb8, 0x47, 0x7e, 0x02, 0x94, 0x1b, 0x07, 0x7e, 0x03, 0x9a, 0xd7, 0x8e, + 0x33, 0x4e, 0xd9, 0x16, 0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xf5, 0xcd, 0xd8, 0xf9, 0xfd, 0x66, 0xec, + 0xfc, 0x71, 0x33, 0x76, 0x7e, 0xfe, 0x6b, 0xbc, 0x13, 0x77, 0x71, 0xe8, 0x9e, 0xfe, 0x1b, 0x00, + 0x00, 0xff, 0xff, 0x36, 0x69, 0x1d, 0x67, 0x12, 0x08, 0x00, 0x00, } diff --git a/pb/protocol.proto b/pb/protocol.proto index 07e7b93..cab01da 100644 --- a/pb/protocol.proto +++ b/pb/protocol.proto @@ -31,7 +31,7 @@ message PubMsg { string subject = 3; // subject string reply = 4; // optional reply bytes data = 5; // payload - bytes uid = 6; // client's UID + bytes connID = 6; // Connection ID. For servers that know about this field, clientID can be omitted bytes sha256 = 10; // optional sha256 of data } @@ -65,9 +65,11 @@ message Ack { message ConnectRequest { string clientID = 1; // Client name/identifier. string heartbeatInbox = 2; // Inbox for server initiated heartbeats. - int64 pingInterval = 4; // Interval at which client wishes to send PINGs (time.Duration, so unit is nanoseconds). - int64 pingTimeout = 5; // Time to wait for a reply (time.Duration, so unit is nanoseconds). - int32 pingMaxOut = 6; // Maximum number of PINGs without a response after which the connection can be considered lost. + int32 protocol = 3; // Protocol the client is at. + bytes connID = 4; // Connection ID, a way to uniquely identify a connection (no connection should ever have the same) + int64 pingInterval = 5; // Interval at which client wishes to send PINGs (time.Duration, so unit is nanoseconds). + int64 pingTimeout = 6; // Time to wait for a reply (time.Duration, so unit is nanoseconds). + int32 pingMaxOut = 7; // Maximum number of PINGs without a response after which the connection can be considered lost. } // Response to a client connect @@ -82,10 +84,21 @@ message ConnectResponse { int64 pingInterval = 8; // Interval at which client should send PINGs (time.Duration, so unit is nanoseconds) int64 pingTimeout = 9; // Time to wait for a reply (time.Duration, so unit is nanoseconds) int32 pingMaxOut = 10; // Maximum number of PINGs without a response after which the connection can be considered lost + int32 protocol = 11; // Protocol version the server is at string publicKey = 100; // Possibly used to sign acks, etc. } +// PING from client to server +message Ping { + bytes connID = 1; // Connection ID +} + +// PING response from the server +message PingResponse { + string error = 1; // Error string, empty/omitted if no error +} + // Enum for start position type. enum StartPosition { NewOnly = 0;