diff --git a/.gitignore b/.gitignore index 868507e16..40a12d2d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .DS_Store release/ -db/ +/db/ # Binaries for programs and plugins *.exe *.exe~ diff --git a/ADOPTERS.md b/ADOPTERS.md index 14b8cb154..66e3f08df 100644 --- a/ADOPTERS.md +++ b/ADOPTERS.md @@ -14,9 +14,19 @@ If you're interested in getting your project added to the list either: * Link to logo * Fork the repo and put up a pull request for this page! :) -## Adopters +## Open Source Projects -Here's the list of projects using and adopting OpenZiti +The OpenZiti project supports a strong, open source ecosystem. This table will contain the list of projects which are +open source that have embedded OpenZiti into the project, or use OpenZiti for secure communication in some other way. + +| Project Name | Project Link | Source URL | Logo | How OpenZiti is used or why OpenZiti was chosen | +|-------------|-----------------|------------|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------| +| zrok | https://zrok.io | https://github.com/openziti/zrok | | An open source sharing solution built on OpenZiti, the zero trust networking platform. Available as SaaS or self-hosted. | + + +## Other Adopters + +Here's the list of projects which are proudly adopting and using OpenZiti | Project Name | Project Link | Logo | How OpenZiti is used or why OpenZiti was chosen | |----------------------------------|-----------------------------------------------|----------|-----------------| @@ -28,3 +38,5 @@ Here's the list of projects using and adopting OpenZiti | Analytics HQ | https://AnalyticsHQ.com/ | | Analytics HQ is a next-generation unified platform built for modern data management and advanced analytics. | | PITS Global Data Recovery Services | https://www.pitsdatarecovery.net/ | | PITS Global Data Recovery Services is a data recovery company in the United States that offers services for recovering data from hard drives, SSDs, flash drives, RAID arrays and more. | | KEOIC | http://www.keoic.com/ | | KEO International Consultants is a multifaceted AEC firm with a presence across the Middle East and Europe. KEO uses the CloudZiti platform to facilitate zero-trust connections for users, devices, and applications throughout their worldwide network of branch offices and sites. | +| ChirpWireless | https://chirpwireless.io/ | | Chirp is a project at the forefront of the DePIN (Decentralized physical infrastructure) movement, revolutionizing the world of wireless connectivity. It's a global telecommunications network that offers wireless internet and IoT connectivity for both residential and commercial use. OpenZiti overlay network is used for management of our LoRaWAN gateway miners ("Blackbirds") across multiple countries, allowing them to be dark. | +| GIGO Dev | https://gigo.dev/ | | GIGO Dev is a learn-to-code platform that focuses on aligning learning with the real world of development. On GIGO you work in DevSpaces (Cloud Development Environments) capable of running nearly any system configuration needed for the challenge. We use OpenZiti to dynamically and securely expose network applications inside your DevSpace. Ziti provides the simplest, easiest, and most reliable system to securely route traffic into the local network of your DevSpace. | diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c91da482..fdc673b36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,64 @@ +# Release 0.31.1 + +## What's New + +* SDK Hosting Improvements +* Terminator validation utility +* Circuit/Link query support + +## SDK Hosting Improvments + +In previous versions of OpenZiti, if many SDK clients were attempting to establish hosting, the controller could get overwhelmed. +In this release, routers will use the rate limiter pool introduced in 0.27.6 when creating terminators on behalf of sdk clients +hosting applications. Additionally, routers now have the ability to verify terminator state with the sdk, if the sdk supports it. +In general, hosting large numbers of services using the sdk should now be less suceptible to thundering herd issues. + +## Manual Terminator Validation + +There is a new CLI command available to validate terminator state. This is primarily a developer tool to validate that terminator +setup logic is correct. However it may also be used to diagnose and resolve issues with production systems, should the need arise. + +``` +ziti fabric validate terminators +``` + +## Circuit/Link Query Support + +Previously listing circuit and links always showed the full list. This is because these types are in memory only and are not stored +in the bbolt datastore. There's now basic support for querying in-memory types and circuits and links can now be filtered/paged/sorted + the same as other entity types. + +## Component Updates and Bug Fixes + +* github.com/openziti/channel/v2: [v2.0.105 -> v2.0.111](https://github.com/openziti/channel/compare/v2.0.105...v2.0.111) + * [Issue #118](https://github.com/openziti/channel/issues/118) - Allowing checking if reconnecting impl is currently connected + +* github.com/openziti/edge-api: [v0.26.0 -> v0.26.1](https://github.com/openziti/edge-api/compare/v0.26.0...v0.26.1) +* github.com/openziti/foundation/v2: [v2.0.33 -> v2.0.35](https://github.com/openziti/foundation/compare/v2.0.33...v2.0.35) +* github.com/openziti/identity: [v1.0.66 -> v1.0.68](https://github.com/openziti/identity/compare/v1.0.66...v1.0.68) +* github.com/openziti/metrics: [v1.2.37 -> v1.2.40](https://github.com/openziti/metrics/compare/v1.2.37...v1.2.40) +* github.com/openziti/runzmd: [v1.0.33 -> v1.0.36](https://github.com/openziti/runzmd/compare/v1.0.33...v1.0.36) +* github.com/openziti/sdk-golang: [v0.20.129 -> v0.20.139](https://github.com/openziti/sdk-golang/compare/v0.20.129...v0.20.139) + * [Issue #457](https://github.com/openziti/sdk-golang/issues/457) - Add inspect support + * [Issue #450](https://github.com/openziti/sdk-golang/issues/450) - Support idempotent terminator creation + +* github.com/openziti/secretstream: [v0.1.13 -> v0.1.14](https://github.com/openziti/secretstream/compare/v0.1.13...v0.1.14) +* github.com/openziti/storage: [v0.2.23 -> v0.2.26](https://github.com/openziti/storage/compare/v0.2.23...v0.2.26) + * [Issue #57](https://github.com/openziti/storage/issues/57) - Support querying collections of in memory objects + +* github.com/openziti/transport/v2: [v2.0.113 -> v2.0.119](https://github.com/openziti/transport/compare/v2.0.113...v2.0.119) +* github.com/openziti/ziti: [v0.31.0 -> v0.31.1](https://github.com/openziti/ziti/compare/v0.31.0...v0.31.1) + * [Issue #1555](https://github.com/openziti/ziti/issues/1555) - Consolidate fabric/edge persistence code + * [Issue #1547](https://github.com/openziti/ziti/issues/1547) - Support filtering, sorting and paging circuits and links + * [Issue #1446](https://github.com/openziti/ziti/issues/1446) - Allow for idempotent sdk based terminators + * [Issue #1540](https://github.com/openziti/ziti/issues/1540) - Transit router create fails in HA environment + * [Issue #1523](https://github.com/openziti/ziti/issues/1523) - Bootstrap members not working + * [Issue #1525](https://github.com/openziti/ziti/issues/1525) - Improve cluster list output + * [Issue #1519](https://github.com/openziti/ziti/issues/1519) - Simplify link ack handling + * [Issue #1513](https://github.com/openziti/ziti/issues/1513) - DNS service failure should not cause a router restart + * [Issue #1494](https://github.com/openziti/ziti/issues/1494) - Panic if applying raft log returns nil result + + # Release 0.31.0 ## What's New diff --git a/common/pb/ctrl_pb/ctrl.pb.go b/common/pb/ctrl_pb/ctrl.pb.go index ef42a1738..00dbd4d30 100644 --- a/common/pb/ctrl_pb/ctrl.pb.go +++ b/common/pb/ctrl_pb/ctrl.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v3.19.1 +// protoc v3.21.12 // source: ctrl.proto package ctrl_pb @@ -45,18 +45,20 @@ const ( ContentType_ValidateTerminatorsRequestType ContentType = 1017 ContentType_UpdateTerminatorRequestType ContentType = 1018 // VerifyLinkType = 1019; Unusable since links are now generated by routers - ContentType_SettingsType ContentType = 1020 - ContentType_CircuitConfirmationType ContentType = 1034 - ContentType_RouterLinksType ContentType = 1035 - ContentType_VerifyRouterType ContentType = 1036 - ContentType_UpdateCtrlAddressesType ContentType = 1037 - ContentType_RemoveTerminatorsRequestType ContentType = 1038 - ContentType_QuiesceRouterRequestType ContentType = 1039 - ContentType_DequiesceRouterRequestType ContentType = 1040 - ContentType_PeerStateChangeRequestType ContentType = 1050 - ContentType_ListenersHeader ContentType = 10 - ContentType_RouterMetadataHeader ContentType = 11 - ContentType_CapabilitiesHeader ContentType = 12 + ContentType_SettingsType ContentType = 1020 + ContentType_CircuitConfirmationType ContentType = 1034 + ContentType_RouterLinksType ContentType = 1035 + ContentType_VerifyRouterType ContentType = 1036 + ContentType_UpdateCtrlAddressesType ContentType = 1037 + ContentType_RemoveTerminatorsRequestType ContentType = 1038 + ContentType_QuiesceRouterRequestType ContentType = 1039 + ContentType_DequiesceRouterRequestType ContentType = 1040 + ContentType_ValidateTerminatorsV2RequestType ContentType = 1041 + ContentType_ValidateTerminatorsV2ResponseType ContentType = 1042 + ContentType_PeerStateChangeRequestType ContentType = 1050 + ContentType_ListenersHeader ContentType = 10 + ContentType_RouterMetadataHeader ContentType = 11 + ContentType_CapabilitiesHeader ContentType = 12 ) // Enum value maps for ContentType. @@ -86,40 +88,44 @@ var ( 1038: "RemoveTerminatorsRequestType", 1039: "QuiesceRouterRequestType", 1040: "DequiesceRouterRequestType", + 1041: "ValidateTerminatorsV2RequestType", + 1042: "ValidateTerminatorsV2ResponseType", 1050: "PeerStateChangeRequestType", 10: "ListenersHeader", 11: "RouterMetadataHeader", 12: "CapabilitiesHeader", } ContentType_value = map[string]int32{ - "Zero": 0, - "CircuitRequestType": 1000, - "DialType": 1002, - "LinkConnectedType": 1003, - "FaultType": 1004, - "RouteType": 1005, - "UnrouteType": 1006, - "MetricsType": 1007, - "TogglePipeTracesRequestType": 1008, - "TraceEventType": 1010, - "CreateTerminatorRequestType": 1011, - "RemoveTerminatorRequestType": 1012, - "InspectRequestType": 1013, - "InspectResponseType": 1014, - "ValidateTerminatorsRequestType": 1017, - "UpdateTerminatorRequestType": 1018, - "SettingsType": 1020, - "CircuitConfirmationType": 1034, - "RouterLinksType": 1035, - "VerifyRouterType": 1036, - "UpdateCtrlAddressesType": 1037, - "RemoveTerminatorsRequestType": 1038, - "QuiesceRouterRequestType": 1039, - "DequiesceRouterRequestType": 1040, - "PeerStateChangeRequestType": 1050, - "ListenersHeader": 10, - "RouterMetadataHeader": 11, - "CapabilitiesHeader": 12, + "Zero": 0, + "CircuitRequestType": 1000, + "DialType": 1002, + "LinkConnectedType": 1003, + "FaultType": 1004, + "RouteType": 1005, + "UnrouteType": 1006, + "MetricsType": 1007, + "TogglePipeTracesRequestType": 1008, + "TraceEventType": 1010, + "CreateTerminatorRequestType": 1011, + "RemoveTerminatorRequestType": 1012, + "InspectRequestType": 1013, + "InspectResponseType": 1014, + "ValidateTerminatorsRequestType": 1017, + "UpdateTerminatorRequestType": 1018, + "SettingsType": 1020, + "CircuitConfirmationType": 1034, + "RouterLinksType": 1035, + "VerifyRouterType": 1036, + "UpdateCtrlAddressesType": 1037, + "RemoveTerminatorsRequestType": 1038, + "QuiesceRouterRequestType": 1039, + "DequiesceRouterRequestType": 1040, + "ValidateTerminatorsV2RequestType": 1041, + "ValidateTerminatorsV2ResponseType": 1042, + "PeerStateChangeRequestType": 1050, + "ListenersHeader": 10, + "RouterMetadataHeader": 11, + "CapabilitiesHeader": 12, } ) @@ -295,6 +301,55 @@ func (TerminatorPrecedence) EnumDescriptor() ([]byte, []int) { return file_ctrl_proto_rawDescGZIP(), []int{3} } +type TerminatorInvalidReason int32 + +const ( + TerminatorInvalidReason_UnknownBinding TerminatorInvalidReason = 0 + TerminatorInvalidReason_UnknownTerminator TerminatorInvalidReason = 1 + TerminatorInvalidReason_BadState TerminatorInvalidReason = 2 +) + +// Enum value maps for TerminatorInvalidReason. +var ( + TerminatorInvalidReason_name = map[int32]string{ + 0: "UnknownBinding", + 1: "UnknownTerminator", + 2: "BadState", + } + TerminatorInvalidReason_value = map[string]int32{ + "UnknownBinding": 0, + "UnknownTerminator": 1, + "BadState": 2, + } +) + +func (x TerminatorInvalidReason) Enum() *TerminatorInvalidReason { + p := new(TerminatorInvalidReason) + *p = x + return p +} + +func (x TerminatorInvalidReason) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (TerminatorInvalidReason) Descriptor() protoreflect.EnumDescriptor { + return file_ctrl_proto_enumTypes[4].Descriptor() +} + +func (TerminatorInvalidReason) Type() protoreflect.EnumType { + return &file_ctrl_proto_enumTypes[4] +} + +func (x TerminatorInvalidReason) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use TerminatorInvalidReason.Descriptor instead. +func (TerminatorInvalidReason) EnumDescriptor() ([]byte, []int) { + return file_ctrl_proto_rawDescGZIP(), []int{4} +} + type FaultSubject int32 const ( @@ -337,11 +392,11 @@ func (x FaultSubject) String() string { } func (FaultSubject) Descriptor() protoreflect.EnumDescriptor { - return file_ctrl_proto_enumTypes[4].Descriptor() + return file_ctrl_proto_enumTypes[5].Descriptor() } func (FaultSubject) Type() protoreflect.EnumType { - return &file_ctrl_proto_enumTypes[4] + return &file_ctrl_proto_enumTypes[5] } func (x FaultSubject) Number() protoreflect.EnumNumber { @@ -350,7 +405,7 @@ func (x FaultSubject) Number() protoreflect.EnumNumber { // Deprecated: Use FaultSubject.Descriptor instead. func (FaultSubject) EnumDescriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{4} + return file_ctrl_proto_rawDescGZIP(), []int{5} } type DestType int32 @@ -386,11 +441,11 @@ func (x DestType) String() string { } func (DestType) Descriptor() protoreflect.EnumDescriptor { - return file_ctrl_proto_enumTypes[5].Descriptor() + return file_ctrl_proto_enumTypes[6].Descriptor() } func (DestType) Type() protoreflect.EnumType { - return &file_ctrl_proto_enumTypes[5] + return &file_ctrl_proto_enumTypes[6] } func (x DestType) Number() protoreflect.EnumNumber { @@ -399,7 +454,7 @@ func (x DestType) Number() protoreflect.EnumNumber { // Deprecated: Use DestType.Descriptor instead. func (DestType) EnumDescriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{5} + return file_ctrl_proto_rawDescGZIP(), []int{6} } type PeerState int32 @@ -435,11 +490,11 @@ func (x PeerState) String() string { } func (PeerState) Descriptor() protoreflect.EnumDescriptor { - return file_ctrl_proto_enumTypes[6].Descriptor() + return file_ctrl_proto_enumTypes[7].Descriptor() } func (PeerState) Type() protoreflect.EnumType { - return &file_ctrl_proto_enumTypes[6] + return &file_ctrl_proto_enumTypes[7] } func (x PeerState) Number() protoreflect.EnumNumber { @@ -448,7 +503,7 @@ func (x PeerState) Number() protoreflect.EnumNumber { // Deprecated: Use PeerState.Descriptor instead. func (PeerState) EnumDescriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{6} + return file_ctrl_proto_rawDescGZIP(), []int{7} } // Settings are sent to to routers to configure arbitrary runtime settings. @@ -916,6 +971,171 @@ func (x *ValidateTerminatorsRequest) GetTerminators() []*Terminator { return nil } +type ValidateTerminatorsV2Request struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Terminators []*Terminator `protobuf:"bytes,1,rep,name=terminators,proto3" json:"terminators,omitempty"` + FixInvalid bool `protobuf:"varint,2,opt,name=fixInvalid,proto3" json:"fixInvalid,omitempty"` +} + +func (x *ValidateTerminatorsV2Request) Reset() { + *x = ValidateTerminatorsV2Request{} + if protoimpl.UnsafeEnabled { + mi := &file_ctrl_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ValidateTerminatorsV2Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ValidateTerminatorsV2Request) ProtoMessage() {} + +func (x *ValidateTerminatorsV2Request) ProtoReflect() protoreflect.Message { + mi := &file_ctrl_proto_msgTypes[8] + 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 ValidateTerminatorsV2Request.ProtoReflect.Descriptor instead. +func (*ValidateTerminatorsV2Request) Descriptor() ([]byte, []int) { + return file_ctrl_proto_rawDescGZIP(), []int{8} +} + +func (x *ValidateTerminatorsV2Request) GetTerminators() []*Terminator { + if x != nil { + return x.Terminators + } + return nil +} + +func (x *ValidateTerminatorsV2Request) GetFixInvalid() bool { + if x != nil { + return x.FixInvalid + } + return false +} + +type RouterTerminatorState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"` + Reason TerminatorInvalidReason `protobuf:"varint,2,opt,name=reason,proto3,enum=ziti.ctrl.pb.TerminatorInvalidReason" json:"reason,omitempty"` + Detail string `protobuf:"bytes,3,opt,name=detail,proto3" json:"detail,omitempty"` // inspect info if valid +} + +func (x *RouterTerminatorState) Reset() { + *x = RouterTerminatorState{} + if protoimpl.UnsafeEnabled { + mi := &file_ctrl_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RouterTerminatorState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RouterTerminatorState) ProtoMessage() {} + +func (x *RouterTerminatorState) ProtoReflect() protoreflect.Message { + mi := &file_ctrl_proto_msgTypes[9] + 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 RouterTerminatorState.ProtoReflect.Descriptor instead. +func (*RouterTerminatorState) Descriptor() ([]byte, []int) { + return file_ctrl_proto_rawDescGZIP(), []int{9} +} + +func (x *RouterTerminatorState) GetValid() bool { + if x != nil { + return x.Valid + } + return false +} + +func (x *RouterTerminatorState) GetReason() TerminatorInvalidReason { + if x != nil { + return x.Reason + } + return TerminatorInvalidReason_UnknownBinding +} + +func (x *RouterTerminatorState) GetDetail() string { + if x != nil { + return x.Detail + } + return "" +} + +type ValidateTerminatorsV2Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + States map[string]*RouterTerminatorState `protobuf:"bytes,1,rep,name=states,proto3" json:"states,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *ValidateTerminatorsV2Response) Reset() { + *x = ValidateTerminatorsV2Response{} + if protoimpl.UnsafeEnabled { + mi := &file_ctrl_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ValidateTerminatorsV2Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ValidateTerminatorsV2Response) ProtoMessage() {} + +func (x *ValidateTerminatorsV2Response) ProtoReflect() protoreflect.Message { + mi := &file_ctrl_proto_msgTypes[10] + 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 ValidateTerminatorsV2Response.ProtoReflect.Descriptor instead. +func (*ValidateTerminatorsV2Response) Descriptor() ([]byte, []int) { + return file_ctrl_proto_rawDescGZIP(), []int{10} +} + +func (x *ValidateTerminatorsV2Response) GetStates() map[string]*RouterTerminatorState { + if x != nil { + return x.States + } + return nil +} + type UpdateTerminatorRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -931,7 +1151,7 @@ type UpdateTerminatorRequest struct { func (x *UpdateTerminatorRequest) Reset() { *x = UpdateTerminatorRequest{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[8] + mi := &file_ctrl_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -944,7 +1164,7 @@ func (x *UpdateTerminatorRequest) String() string { func (*UpdateTerminatorRequest) ProtoMessage() {} func (x *UpdateTerminatorRequest) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[8] + mi := &file_ctrl_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -957,7 +1177,7 @@ func (x *UpdateTerminatorRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateTerminatorRequest.ProtoReflect.Descriptor instead. func (*UpdateTerminatorRequest) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{8} + return file_ctrl_proto_rawDescGZIP(), []int{11} } func (x *UpdateTerminatorRequest) GetTerminatorId() string { @@ -1010,7 +1230,7 @@ type Dial struct { func (x *Dial) Reset() { *x = Dial{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[9] + mi := &file_ctrl_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1023,7 +1243,7 @@ func (x *Dial) String() string { func (*Dial) ProtoMessage() {} func (x *Dial) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[9] + mi := &file_ctrl_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1036,7 +1256,7 @@ func (x *Dial) ProtoReflect() protoreflect.Message { // Deprecated: Use Dial.ProtoReflect.Descriptor instead. func (*Dial) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{9} + return file_ctrl_proto_rawDescGZIP(), []int{12} } func (x *Dial) GetLinkId() string { @@ -1087,7 +1307,7 @@ type LinkConn struct { func (x *LinkConn) Reset() { *x = LinkConn{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[10] + mi := &file_ctrl_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1100,7 +1320,7 @@ func (x *LinkConn) String() string { func (*LinkConn) ProtoMessage() {} func (x *LinkConn) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[10] + mi := &file_ctrl_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1113,7 +1333,7 @@ func (x *LinkConn) ProtoReflect() protoreflect.Message { // Deprecated: Use LinkConn.ProtoReflect.Descriptor instead. func (*LinkConn) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{10} + return file_ctrl_proto_rawDescGZIP(), []int{13} } func (x *LinkConn) GetId() string { @@ -1149,7 +1369,7 @@ type LinkConnected struct { func (x *LinkConnected) Reset() { *x = LinkConnected{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[11] + mi := &file_ctrl_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1162,7 +1382,7 @@ func (x *LinkConnected) String() string { func (*LinkConnected) ProtoMessage() {} func (x *LinkConnected) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[11] + mi := &file_ctrl_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1175,7 +1395,7 @@ func (x *LinkConnected) ProtoReflect() protoreflect.Message { // Deprecated: Use LinkConnected.ProtoReflect.Descriptor instead. func (*LinkConnected) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{11} + return file_ctrl_proto_rawDescGZIP(), []int{14} } func (x *LinkConnected) GetId() string { @@ -1203,7 +1423,7 @@ type RouterLinks struct { func (x *RouterLinks) Reset() { *x = RouterLinks{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[12] + mi := &file_ctrl_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1216,7 +1436,7 @@ func (x *RouterLinks) String() string { func (*RouterLinks) ProtoMessage() {} func (x *RouterLinks) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[12] + mi := &file_ctrl_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1229,7 +1449,7 @@ func (x *RouterLinks) ProtoReflect() protoreflect.Message { // Deprecated: Use RouterLinks.ProtoReflect.Descriptor instead. func (*RouterLinks) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{12} + return file_ctrl_proto_rawDescGZIP(), []int{15} } func (x *RouterLinks) GetLinks() []*RouterLinks_RouterLink { @@ -1251,7 +1471,7 @@ type Fault struct { func (x *Fault) Reset() { *x = Fault{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[13] + mi := &file_ctrl_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1264,7 +1484,7 @@ func (x *Fault) String() string { func (*Fault) ProtoMessage() {} func (x *Fault) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[13] + mi := &file_ctrl_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1277,7 +1497,7 @@ func (x *Fault) ProtoReflect() protoreflect.Message { // Deprecated: Use Fault.ProtoReflect.Descriptor instead. func (*Fault) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{13} + return file_ctrl_proto_rawDescGZIP(), []int{16} } func (x *Fault) GetSubject() FaultSubject { @@ -1306,7 +1526,7 @@ type Context struct { func (x *Context) Reset() { *x = Context{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[14] + mi := &file_ctrl_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1319,7 +1539,7 @@ func (x *Context) String() string { func (*Context) ProtoMessage() {} func (x *Context) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[14] + mi := &file_ctrl_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1332,7 +1552,7 @@ func (x *Context) ProtoReflect() protoreflect.Message { // Deprecated: Use Context.ProtoReflect.Descriptor instead. func (*Context) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{14} + return file_ctrl_proto_rawDescGZIP(), []int{17} } func (x *Context) GetFields() map[string]string { @@ -1366,7 +1586,7 @@ type Route struct { func (x *Route) Reset() { *x = Route{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[15] + mi := &file_ctrl_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1379,7 +1599,7 @@ func (x *Route) String() string { func (*Route) ProtoMessage() {} func (x *Route) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[15] + mi := &file_ctrl_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1392,7 +1612,7 @@ func (x *Route) ProtoReflect() protoreflect.Message { // Deprecated: Use Route.ProtoReflect.Descriptor instead. func (*Route) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{15} + return file_ctrl_proto_rawDescGZIP(), []int{18} } func (x *Route) GetCircuitId() string { @@ -1456,7 +1676,7 @@ type Unroute struct { func (x *Unroute) Reset() { *x = Unroute{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[16] + mi := &file_ctrl_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1469,7 +1689,7 @@ func (x *Unroute) String() string { func (*Unroute) ProtoMessage() {} func (x *Unroute) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[16] + mi := &file_ctrl_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1482,7 +1702,7 @@ func (x *Unroute) ProtoReflect() protoreflect.Message { // Deprecated: Use Unroute.ProtoReflect.Descriptor instead. func (*Unroute) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{16} + return file_ctrl_proto_rawDescGZIP(), []int{19} } func (x *Unroute) GetCircuitId() string { @@ -1510,7 +1730,7 @@ type InspectRequest struct { func (x *InspectRequest) Reset() { *x = InspectRequest{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[17] + mi := &file_ctrl_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1523,7 +1743,7 @@ func (x *InspectRequest) String() string { func (*InspectRequest) ProtoMessage() {} func (x *InspectRequest) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[17] + mi := &file_ctrl_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1536,7 +1756,7 @@ func (x *InspectRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use InspectRequest.ProtoReflect.Descriptor instead. func (*InspectRequest) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{17} + return file_ctrl_proto_rawDescGZIP(), []int{20} } func (x *InspectRequest) GetRequestedValues() []string { @@ -1559,7 +1779,7 @@ type InspectResponse struct { func (x *InspectResponse) Reset() { *x = InspectResponse{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[18] + mi := &file_ctrl_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1572,7 +1792,7 @@ func (x *InspectResponse) String() string { func (*InspectResponse) ProtoMessage() {} func (x *InspectResponse) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[18] + mi := &file_ctrl_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1585,7 +1805,7 @@ func (x *InspectResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use InspectResponse.ProtoReflect.Descriptor instead. func (*InspectResponse) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{18} + return file_ctrl_proto_rawDescGZIP(), []int{21} } func (x *InspectResponse) GetSuccess() bool { @@ -1621,7 +1841,7 @@ type VerifyRouter struct { func (x *VerifyRouter) Reset() { *x = VerifyRouter{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[19] + mi := &file_ctrl_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1634,7 +1854,7 @@ func (x *VerifyRouter) String() string { func (*VerifyRouter) ProtoMessage() {} func (x *VerifyRouter) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[19] + mi := &file_ctrl_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1647,7 +1867,7 @@ func (x *VerifyRouter) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyRouter.ProtoReflect.Descriptor instead. func (*VerifyRouter) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{19} + return file_ctrl_proto_rawDescGZIP(), []int{22} } func (x *VerifyRouter) GetRouterId() string { @@ -1679,7 +1899,7 @@ type Listener struct { func (x *Listener) Reset() { *x = Listener{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[20] + mi := &file_ctrl_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1692,7 +1912,7 @@ func (x *Listener) String() string { func (*Listener) ProtoMessage() {} func (x *Listener) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[20] + mi := &file_ctrl_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1705,7 +1925,7 @@ func (x *Listener) ProtoReflect() protoreflect.Message { // Deprecated: Use Listener.ProtoReflect.Descriptor instead. func (*Listener) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{20} + return file_ctrl_proto_rawDescGZIP(), []int{23} } func (x *Listener) GetAddress() string { @@ -1754,7 +1974,7 @@ type Listeners struct { func (x *Listeners) Reset() { *x = Listeners{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[21] + mi := &file_ctrl_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1767,7 +1987,7 @@ func (x *Listeners) String() string { func (*Listeners) ProtoMessage() {} func (x *Listeners) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[21] + mi := &file_ctrl_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1780,7 +2000,7 @@ func (x *Listeners) ProtoReflect() protoreflect.Message { // Deprecated: Use Listeners.ProtoReflect.Descriptor instead. func (*Listeners) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{21} + return file_ctrl_proto_rawDescGZIP(), []int{24} } func (x *Listeners) GetListeners() []*Listener { @@ -1803,7 +2023,7 @@ type UpdateCtrlAddresses struct { func (x *UpdateCtrlAddresses) Reset() { *x = UpdateCtrlAddresses{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[22] + mi := &file_ctrl_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1816,7 +2036,7 @@ func (x *UpdateCtrlAddresses) String() string { func (*UpdateCtrlAddresses) ProtoMessage() {} func (x *UpdateCtrlAddresses) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[22] + mi := &file_ctrl_proto_msgTypes[25] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1829,7 +2049,7 @@ func (x *UpdateCtrlAddresses) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateCtrlAddresses.ProtoReflect.Descriptor instead. func (*UpdateCtrlAddresses) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{22} + return file_ctrl_proto_rawDescGZIP(), []int{25} } func (x *UpdateCtrlAddresses) GetAddresses() []string { @@ -1867,7 +2087,7 @@ type PeerStateChange struct { func (x *PeerStateChange) Reset() { *x = PeerStateChange{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[23] + mi := &file_ctrl_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1880,7 +2100,7 @@ func (x *PeerStateChange) String() string { func (*PeerStateChange) ProtoMessage() {} func (x *PeerStateChange) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[23] + mi := &file_ctrl_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1893,7 +2113,7 @@ func (x *PeerStateChange) ProtoReflect() protoreflect.Message { // Deprecated: Use PeerStateChange.ProtoReflect.Descriptor instead. func (*PeerStateChange) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{23} + return file_ctrl_proto_rawDescGZIP(), []int{26} } func (x *PeerStateChange) GetId() string { @@ -1935,7 +2155,7 @@ type PeerStateChanges struct { func (x *PeerStateChanges) Reset() { *x = PeerStateChanges{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[24] + mi := &file_ctrl_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1948,7 +2168,7 @@ func (x *PeerStateChanges) String() string { func (*PeerStateChanges) ProtoMessage() {} func (x *PeerStateChanges) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[24] + mi := &file_ctrl_proto_msgTypes[27] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1961,7 +2181,7 @@ func (x *PeerStateChanges) ProtoReflect() protoreflect.Message { // Deprecated: Use PeerStateChanges.ProtoReflect.Descriptor instead. func (*PeerStateChanges) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{24} + return file_ctrl_proto_rawDescGZIP(), []int{27} } func (x *PeerStateChanges) GetChanges() []*PeerStateChange { @@ -1982,7 +2202,7 @@ type RouterMetadata struct { func (x *RouterMetadata) Reset() { *x = RouterMetadata{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[25] + mi := &file_ctrl_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1995,7 +2215,7 @@ func (x *RouterMetadata) String() string { func (*RouterMetadata) ProtoMessage() {} func (x *RouterMetadata) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[25] + mi := &file_ctrl_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2008,7 +2228,7 @@ func (x *RouterMetadata) ProtoReflect() protoreflect.Message { // Deprecated: Use RouterMetadata.ProtoReflect.Descriptor instead. func (*RouterMetadata) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{25} + return file_ctrl_proto_rawDescGZIP(), []int{28} } func (x *RouterMetadata) GetCapabilities() []RouterCapability { @@ -2033,7 +2253,7 @@ type RouterLinks_RouterLink struct { func (x *RouterLinks_RouterLink) Reset() { *x = RouterLinks_RouterLink{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[29] + mi := &file_ctrl_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2046,7 +2266,7 @@ func (x *RouterLinks_RouterLink) String() string { func (*RouterLinks_RouterLink) ProtoMessage() {} func (x *RouterLinks_RouterLink) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[29] + mi := &file_ctrl_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2059,7 +2279,7 @@ func (x *RouterLinks_RouterLink) ProtoReflect() protoreflect.Message { // Deprecated: Use RouterLinks_RouterLink.ProtoReflect.Descriptor instead. func (*RouterLinks_RouterLink) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{12, 0} + return file_ctrl_proto_rawDescGZIP(), []int{15, 0} } func (x *RouterLinks_RouterLink) GetId() string { @@ -2111,7 +2331,7 @@ type Route_Egress struct { func (x *Route_Egress) Reset() { *x = Route_Egress{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[31] + mi := &file_ctrl_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2124,7 +2344,7 @@ func (x *Route_Egress) String() string { func (*Route_Egress) ProtoMessage() {} func (x *Route_Egress) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[31] + mi := &file_ctrl_proto_msgTypes[35] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2137,7 +2357,7 @@ func (x *Route_Egress) ProtoReflect() protoreflect.Message { // Deprecated: Use Route_Egress.ProtoReflect.Descriptor instead. func (*Route_Egress) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{15, 0} + return file_ctrl_proto_rawDescGZIP(), []int{18, 0} } func (x *Route_Egress) GetBinding() string { @@ -2181,7 +2401,7 @@ type Route_Forward struct { func (x *Route_Forward) Reset() { *x = Route_Forward{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[32] + mi := &file_ctrl_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2194,7 +2414,7 @@ func (x *Route_Forward) String() string { func (*Route_Forward) ProtoMessage() {} func (x *Route_Forward) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[32] + mi := &file_ctrl_proto_msgTypes[36] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2207,7 +2427,7 @@ func (x *Route_Forward) ProtoReflect() protoreflect.Message { // Deprecated: Use Route_Forward.ProtoReflect.Descriptor instead. func (*Route_Forward) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{15, 1} + return file_ctrl_proto_rawDescGZIP(), []int{18, 1} } func (x *Route_Forward) GetSrcAddress() string { @@ -2243,7 +2463,7 @@ type InspectResponse_InspectValue struct { func (x *InspectResponse_InspectValue) Reset() { *x = InspectResponse_InspectValue{} if protoimpl.UnsafeEnabled { - mi := &file_ctrl_proto_msgTypes[35] + mi := &file_ctrl_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2256,7 +2476,7 @@ func (x *InspectResponse_InspectValue) String() string { func (*InspectResponse_InspectValue) ProtoMessage() {} func (x *InspectResponse_InspectValue) ProtoReflect() protoreflect.Message { - mi := &file_ctrl_proto_msgTypes[35] + mi := &file_ctrl_proto_msgTypes[39] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2269,7 +2489,7 @@ func (x *InspectResponse_InspectValue) ProtoReflect() protoreflect.Message { // Deprecated: Use InspectResponse_InspectValue.ProtoReflect.Descriptor instead. func (*InspectResponse_InspectValue) Descriptor() ([]byte, []int) { - return file_ctrl_proto_rawDescGZIP(), []int{18, 0} + return file_ctrl_proto_rawDescGZIP(), []int{21, 0} } func (x *InspectResponse_InspectValue) GetName() string { @@ -2359,256 +2579,296 @@ var file_ctrl_proto_rawDesc = []byte{ 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0b, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, - 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0xe1, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x49, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, - 0x74, 0x6f, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, - 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x10, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x73, 0x74, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x73, - 0x74, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x22, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, - 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x50, - 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x63, 0x65, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x73, 0x74, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x73, 0x74, 0x22, 0x9e, 0x01, 0x0a, 0x04, 0x44, 0x69, - 0x61, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, - 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x58, 0x0a, 0x08, 0x4c, 0x69, - 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x41, - 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, - 0x41, 0x64, 0x64, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x41, 0x64, - 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, - 0x41, 0x64, 0x64, 0x72, 0x22, 0x4d, 0x0a, 0x0d, 0x4c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x6e, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, - 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x6e, 0x52, 0x05, 0x63, 0x6f, - 0x6e, 0x6e, 0x73, 0x22, 0xf6, 0x01, 0x0a, 0x0b, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4c, 0x69, - 0x6e, 0x6b, 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, - 0x62, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x2e, 0x52, 0x6f, - 0x75, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x1a, - 0xaa, 0x01, 0x0a, 0x0a, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x22, - 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, - 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x69, - 0x6e, 0x6b, 0x43, 0x6f, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x69, - 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x4d, 0x0a, 0x05, - 0x46, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x34, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, - 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xa1, 0x01, 0x0a, 0x07, - 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x39, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, - 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x46, - 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, - 0x64, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4d, 0x61, 0x73, - 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x4d, 0x61, 0x73, 0x6b, 0x1a, 0x39, 0x0a, 0x0b, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0xc4, 0x05, 0x0a, 0x05, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x69, 0x72, - 0x63, 0x75, 0x69, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x69, - 0x72, 0x63, 0x75, 0x69, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x74, 0x74, 0x65, 0x6d, - 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, - 0x74, 0x12, 0x32, 0x0a, 0x06, 0x65, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, - 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x45, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x06, 0x65, - 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, - 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x46, 0x6f, 0x72, - 0x77, 0x61, 0x72, 0x64, 0x52, 0x08, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x73, 0x12, 0x2f, - 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x15, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, - 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x61, 0x67, - 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, - 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x54, 0x61, 0x67, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0xe1, 0x01, 0x0a, - 0x06, 0x45, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x69, - 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, - 0x67, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, - 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x44, 0x0a, - 0x08, 0x70, 0x65, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x28, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, - 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x45, 0x67, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x50, 0x65, 0x65, 0x72, - 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, 0x65, 0x65, 0x72, 0x44, - 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, 0x50, 0x65, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x1a, 0x7b, 0x0a, 0x07, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, - 0x72, 0x63, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x73, 0x72, 0x63, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x64, - 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x64, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x64, - 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x7a, - 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x73, 0x74, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x64, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x1a, 0x37, 0x0a, - 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x39, 0x0a, 0x07, 0x55, 0x6e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x49, 0x64, 0x12, - 0x10, 0x0a, 0x03, 0x6e, 0x6f, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x6e, 0x6f, - 0x77, 0x22, 0x3a, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x64, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0xc1, 0x01, - 0x0a, 0x0f, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 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, 0x16, 0x0a, 0x06, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x73, 0x12, 0x42, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, - 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, - 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x1a, 0x38, 0x0a, 0x0c, 0x49, 0x6e, 0x73, 0x70, 0x65, - 0x63, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0x7a, 0x0a, 0x1c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x56, 0x32, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3a, 0x0a, 0x0b, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, + 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x7a, 0x69, 0x74, + 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0b, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, + 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x69, 0x78, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x66, 0x69, 0x78, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x22, 0x84, 0x01, 0x0a, 0x15, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x54, 0x65, 0x72, 0x6d, + 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x12, 0x3d, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x25, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, + 0x2e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, + 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0xd0, 0x01, 0x0a, 0x1d, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, + 0x56, 0x32, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x7a, 0x69, 0x74, + 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x56, 0x32, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x73, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x65, 0x73, 0x1a, 0x5e, 0x0a, 0x0b, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x39, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x7a, 0x69, + 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xe1, 0x01, 0x0a, 0x17, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x65, 0x72, 0x6d, 0x69, + 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, + 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x65, + 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x43, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x43, 0x6f, 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x63, 0x65, + 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x22, 0x2e, 0x7a, 0x69, + 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x54, 0x65, 0x72, 0x6d, 0x69, + 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, + 0x0a, 0x70, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, + 0x6f, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x73, 0x74, 0x22, + 0x9e, 0x01, 0x0a, 0x04, 0x44, 0x69, 0x61, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x6e, 0x6b, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, + 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, + 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x69, + 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x6f, + 0x75, 0x74, 0x65, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x22, 0x58, 0x0a, 0x08, 0x4c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x6e, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, + 0x6d, 0x6f, 0x74, 0x65, 0x41, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x41, 0x64, 0x64, 0x72, 0x22, 0x4d, 0x0a, 0x0d, 0x4c, 0x69, + 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, + 0x6f, 0x6e, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x7a, 0x69, 0x74, + 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, + 0x6e, 0x6e, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x6e, 0x73, 0x22, 0xf6, 0x01, 0x0a, 0x0b, 0x52, 0x6f, + 0x75, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x6c, 0x69, 0x6e, + 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, + 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4c, 0x69, + 0x6e, 0x6b, 0x73, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x05, + 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x1a, 0xaa, 0x01, 0x0a, 0x0a, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, + 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x74, + 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6c, 0x69, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x22, 0x0a, 0x0c, + 0x6c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, + 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x22, 0x4d, 0x0a, 0x05, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x34, 0x0a, 0x07, 0x73, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x7a, + 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x61, 0x75, 0x6c, + 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x22, 0xa1, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x39, 0x0a, + 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, + 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, + 0x6e, 0x65, 0x6c, 0x4d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x63, + 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4d, 0x61, 0x73, 0x6b, 0x1a, 0x39, 0x0a, 0x0b, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x22, 0x4e, 0x0a, 0x0c, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x6f, 0x75, 0x74, 0x65, - 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, - 0x0c, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x73, 0x22, 0x98, 0x01, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x12, 0x18, - 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, - 0x12, 0x16, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x6f, 0x63, 0x61, - 0x6c, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x22, 0x41, 0x0a, 0x09, - 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, 0x12, 0x34, 0x0a, 0x09, 0x6c, 0x69, 0x73, - 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x7a, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc4, 0x05, 0x0a, 0x05, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, + 0x1c, 0x0a, 0x09, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x63, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, + 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x12, 0x32, 0x0a, 0x06, 0x65, 0x67, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, + 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x45, 0x67, 0x72, + 0x65, 0x73, 0x73, 0x52, 0x06, 0x65, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, + 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, + 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, + 0x74, 0x65, 0x2e, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x52, 0x08, 0x66, 0x6f, 0x72, 0x77, + 0x61, 0x72, 0x64, 0x73, 0x12, 0x2f, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, + 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x07, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, + 0x31, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, + 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, + 0x74, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, + 0x67, 0x73, 0x1a, 0xe1, 0x01, 0x0a, 0x06, 0x45, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, + 0x07, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x44, 0x0a, 0x08, 0x70, 0x65, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, + 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x45, 0x67, 0x72, 0x65, 0x73, + 0x73, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x08, 0x70, 0x65, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, 0x50, 0x65, 0x65, + 0x72, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x7b, 0x0a, 0x07, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, + 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x72, 0x63, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x72, 0x63, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x30, 0x0a, 0x07, 0x64, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, + 0x62, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x64, 0x73, 0x74, 0x54, + 0x79, 0x70, 0x65, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x39, 0x0a, 0x07, + 0x55, 0x6e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x69, 0x72, 0x63, 0x75, + 0x69, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x69, 0x72, 0x63, + 0x75, 0x69, 0x74, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x6f, 0x77, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x03, 0x6e, 0x6f, 0x77, 0x22, 0x3a, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x70, 0x65, + 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x0f, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 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, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12, 0x42, 0x0a, 0x06, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x7a, 0x69, 0x74, 0x69, + 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x1a, 0x38, 0x0a, + 0x0c, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x4e, 0x0a, 0x0c, 0x56, 0x65, 0x72, 0x69, 0x66, + 0x79, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, + 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x69, 0x6e, 0x67, 0x65, + 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x98, 0x01, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, + 0x65, 0x6e, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, + 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, + 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, + 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x22, + 0x0a, 0x0c, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x42, 0x69, 0x6e, 0x64, 0x69, + 0x6e, 0x67, 0x22, 0x41, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, 0x12, + 0x34, 0x0a, 0x09, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, + 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x52, 0x09, 0x6c, 0x69, 0x73, 0x74, + 0x65, 0x6e, 0x65, 0x72, 0x73, 0x22, 0x65, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, + 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x22, 0xa0, 0x01, 0x0a, + 0x0f, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x7a, 0x69, 0x74, 0x69, + 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x6c, 0x69, 0x73, + 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x52, 0x09, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, 0x22, - 0x65, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, - 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, - 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x22, 0xa0, 0x01, 0x0a, 0x0f, 0x50, 0x65, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, - 0x70, 0x62, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, - 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, - 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x52, 0x09, - 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, 0x22, 0x4b, 0x0a, 0x10, 0x50, 0x65, 0x65, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x37, 0x0a, - 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, - 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x65, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x07, 0x63, - 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x22, 0x54, 0x0a, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x42, 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x61, - 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x1e, - 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, - 0x75, 0x74, 0x65, 0x72, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0c, - 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2a, 0xd7, 0x05, 0x0a, - 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, - 0x5a, 0x65, 0x72, 0x6f, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x12, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xe8, 0x07, 0x12, - 0x0d, 0x0a, 0x08, 0x44, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x10, 0xea, 0x07, 0x12, 0x16, - 0x0a, 0x11, 0x4c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x54, - 0x79, 0x70, 0x65, 0x10, 0xeb, 0x07, 0x12, 0x0e, 0x0a, 0x09, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x54, - 0x79, 0x70, 0x65, 0x10, 0xec, 0x07, 0x12, 0x0e, 0x0a, 0x09, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x10, 0xed, 0x07, 0x12, 0x10, 0x0a, 0x0b, 0x55, 0x6e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x10, 0xee, 0x07, 0x12, 0x10, 0x0a, 0x0b, 0x4d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x73, 0x54, 0x79, 0x70, 0x65, 0x10, 0xef, 0x07, 0x12, 0x20, 0x0a, 0x1b, 0x54, 0x6f, - 0x67, 0x67, 0x6c, 0x65, 0x50, 0x69, 0x70, 0x65, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf0, 0x07, 0x12, 0x13, 0x0a, 0x0e, - 0x54, 0x72, 0x61, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf2, - 0x07, 0x12, 0x20, 0x0a, 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, - 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, - 0x10, 0xf3, 0x07, 0x12, 0x20, 0x0a, 0x1b, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x65, 0x72, + 0x4b, 0x0a, 0x10, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x73, 0x12, 0x37, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, + 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x22, 0x54, 0x0a, 0x0e, + 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x42, + 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x63, 0x74, 0x72, 0x6c, + 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, + 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, + 0x65, 0x73, 0x2a, 0xa6, 0x06, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x5a, 0x65, 0x72, 0x6f, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x12, + 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x10, 0xe8, 0x07, 0x12, 0x0d, 0x0a, 0x08, 0x44, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, + 0x65, 0x10, 0xea, 0x07, 0x12, 0x16, 0x0a, 0x11, 0x4c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x65, 0x64, 0x54, 0x79, 0x70, 0x65, 0x10, 0xeb, 0x07, 0x12, 0x0e, 0x0a, 0x09, + 0x46, 0x61, 0x75, 0x6c, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xec, 0x07, 0x12, 0x0e, 0x0a, 0x09, + 0x52, 0x6f, 0x75, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x10, 0xed, 0x07, 0x12, 0x10, 0x0a, 0x0b, + 0x55, 0x6e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x10, 0xee, 0x07, 0x12, 0x10, + 0x0a, 0x0b, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x54, 0x79, 0x70, 0x65, 0x10, 0xef, 0x07, + 0x12, 0x20, 0x0a, 0x1b, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x50, 0x69, 0x70, 0x65, 0x54, 0x72, + 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, + 0xf0, 0x07, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x54, 0x79, 0x70, 0x65, 0x10, 0xf2, 0x07, 0x12, 0x20, 0x0a, 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf3, 0x07, 0x12, 0x20, 0x0a, 0x1b, 0x52, 0x65, 0x6d, + 0x6f, 0x76, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf4, 0x07, 0x12, 0x17, 0x0a, 0x12, 0x49, + 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x10, 0xf5, 0x07, 0x12, 0x18, 0x0a, 0x13, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf6, 0x07, 0x12, 0x23, + 0x0a, 0x1e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x10, 0xf9, 0x07, 0x12, 0x20, 0x0a, 0x1b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x10, 0xf4, 0x07, 0x12, 0x17, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf5, 0x07, 0x12, 0x18, - 0x0a, 0x13, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf6, 0x07, 0x12, 0x23, 0x0a, 0x1e, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf9, 0x07, 0x12, 0x20, 0x0a, - 0x1b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xfa, 0x07, 0x12, - 0x11, 0x0a, 0x0c, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x54, 0x79, 0x70, 0x65, 0x10, - 0xfc, 0x07, 0x12, 0x1c, 0x0a, 0x17, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x10, 0x8a, 0x08, - 0x12, 0x14, 0x0a, 0x0f, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x54, - 0x79, 0x70, 0x65, 0x10, 0x8b, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, - 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x10, 0x8c, 0x08, 0x12, 0x1c, 0x0a, - 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x10, 0x8d, 0x08, 0x12, 0x21, 0x0a, 0x1c, 0x52, - 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0x8e, 0x08, 0x12, 0x1d, - 0x0a, 0x18, 0x51, 0x75, 0x69, 0x65, 0x73, 0x63, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0x8f, 0x08, 0x12, 0x1f, 0x0a, - 0x1a, 0x44, 0x65, 0x71, 0x75, 0x69, 0x65, 0x73, 0x63, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0x90, 0x08, 0x12, 0x1f, - 0x0a, 0x1a, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0x9a, 0x08, 0x12, - 0x13, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x73, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x10, 0x0a, 0x12, 0x18, 0x0a, 0x14, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x0b, 0x12, 0x16, - 0x0a, 0x12, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x10, 0x0c, 0x2a, 0x3a, 0x0a, 0x10, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x61, - 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x5a, 0x65, 0x72, 0x6f, 0x10, 0x00, 0x12, 0x12, - 0x0a, 0x0e, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x10, 0x01, 0x2a, 0x35, 0x0a, 0x0c, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, - 0x65, 0x73, 0x12, 0x11, 0x0a, 0x0d, 0x55, 0x6e, 0x75, 0x73, 0x65, 0x64, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x4e, 0x65, 0x77, 0x43, 0x74, 0x72, 0x6c, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x01, 0x2a, 0x3d, 0x0a, 0x14, 0x54, 0x65, 0x72, - 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x00, 0x12, 0x0c, - 0x0a, 0x08, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, - 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0x02, 0x2a, 0x83, 0x01, 0x0a, 0x0c, 0x46, 0x61, 0x75, - 0x6c, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x6e, 0x67, - 0x72, 0x65, 0x73, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x45, - 0x67, 0x72, 0x65, 0x73, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, - 0x4c, 0x69, 0x6e, 0x6b, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x46, - 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x03, 0x12, 0x1c, 0x0a, - 0x18, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x46, 0x6f, 0x72, - 0x77, 0x61, 0x72, 0x64, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x4c, - 0x69, 0x6e, 0x6b, 0x44, 0x75, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x65, 0x10, 0x05, 0x2a, 0x28, - 0x0a, 0x08, 0x44, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x74, - 0x61, 0x72, 0x74, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x45, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x08, - 0x0a, 0x04, 0x4c, 0x69, 0x6e, 0x6b, 0x10, 0x02, 0x2a, 0x34, 0x0a, 0x09, 0x50, 0x65, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, - 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x10, - 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x10, 0x02, 0x42, 0x27, - 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, - 0x6e, 0x7a, 0x69, 0x74, 0x69, 0x2f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x2f, 0x70, 0x62, 0x2f, - 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x65, 0x10, 0xfa, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x54, 0x79, 0x70, 0x65, 0x10, 0xfc, 0x07, 0x12, 0x1c, 0x0a, 0x17, 0x43, 0x69, 0x72, 0x63, + 0x75, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, + 0x79, 0x70, 0x65, 0x10, 0x8a, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x54, 0x79, 0x70, 0x65, 0x10, 0x8b, 0x08, 0x12, 0x15, 0x0a, 0x10, + 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, + 0x10, 0x8c, 0x08, 0x12, 0x1c, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x74, 0x72, + 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x10, 0x8d, + 0x08, 0x12, 0x21, 0x0a, 0x1c, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, + 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x10, 0x8e, 0x08, 0x12, 0x1d, 0x0a, 0x18, 0x51, 0x75, 0x69, 0x65, 0x73, 0x63, 0x65, 0x52, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x10, 0x8f, 0x08, 0x12, 0x1f, 0x0a, 0x1a, 0x44, 0x65, 0x71, 0x75, 0x69, 0x65, 0x73, 0x63, 0x65, + 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x10, 0x90, 0x08, 0x12, 0x25, 0x0a, 0x20, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x56, 0x32, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0x91, 0x08, 0x12, 0x26, 0x0a, 0x21, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, + 0x72, 0x73, 0x56, 0x32, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x10, 0x92, 0x08, 0x12, 0x1f, 0x0a, 0x1a, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x10, 0x9a, 0x08, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, + 0x73, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x0a, 0x12, 0x18, 0x0a, 0x14, 0x52, 0x6f, 0x75, + 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x10, 0x0b, 0x12, 0x16, 0x0a, 0x12, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, + 0x69, 0x65, 0x73, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x0c, 0x2a, 0x3a, 0x0a, 0x10, 0x52, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, + 0x12, 0x0a, 0x0e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x5a, 0x65, 0x72, + 0x6f, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0x01, 0x2a, 0x35, 0x0a, 0x0c, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x11, 0x0a, 0x0d, 0x55, 0x6e, 0x75, 0x73, 0x65, + 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x4e, 0x65, + 0x77, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x01, 0x2a, 0x3d, + 0x0a, 0x14, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x65, 0x63, + 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, + 0x74, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x10, + 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0x02, 0x2a, 0x52, 0x0a, + 0x17, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x0e, 0x55, 0x6e, 0x6b, 0x6e, + 0x6f, 0x77, 0x6e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, + 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, + 0x72, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x42, 0x61, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x10, + 0x02, 0x2a, 0x83, 0x01, 0x0a, 0x0c, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x6e, 0x67, 0x72, 0x65, 0x73, 0x73, 0x46, 0x61, 0x75, + 0x6c, 0x74, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x45, 0x67, 0x72, 0x65, 0x73, 0x73, 0x46, 0x61, + 0x75, 0x6c, 0x74, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4c, 0x69, 0x6e, 0x6b, 0x46, 0x61, 0x75, + 0x6c, 0x74, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x46, + 0x61, 0x75, 0x6c, 0x74, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, + 0x6e, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x46, 0x61, 0x75, + 0x6c, 0x74, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x4c, 0x69, 0x6e, 0x6b, 0x44, 0x75, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x74, 0x65, 0x10, 0x05, 0x2a, 0x28, 0x0a, 0x08, 0x44, 0x65, 0x73, 0x74, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x72, 0x74, 0x10, 0x00, 0x12, 0x07, + 0x0a, 0x03, 0x45, 0x6e, 0x64, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x69, 0x6e, 0x6b, 0x10, + 0x02, 0x2a, 0x34, 0x0a, 0x09, 0x50, 0x65, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, + 0x0a, 0x07, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x55, + 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x10, 0x02, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x7a, 0x69, 0x74, 0x69, 0x2f, 0x66, + 0x61, 0x62, 0x72, 0x69, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2623,81 +2883,90 @@ func file_ctrl_proto_rawDescGZIP() []byte { return file_ctrl_proto_rawDescData } -var file_ctrl_proto_enumTypes = make([]protoimpl.EnumInfo, 7) -var file_ctrl_proto_msgTypes = make([]protoimpl.MessageInfo, 36) +var file_ctrl_proto_enumTypes = make([]protoimpl.EnumInfo, 8) +var file_ctrl_proto_msgTypes = make([]protoimpl.MessageInfo, 40) var file_ctrl_proto_goTypes = []interface{}{ - (ContentType)(0), // 0: ziti.ctrl.pb.ContentType - (RouterCapability)(0), // 1: ziti.ctrl.pb.RouterCapability - (SettingTypes)(0), // 2: ziti.ctrl.pb.SettingTypes - (TerminatorPrecedence)(0), // 3: ziti.ctrl.pb.TerminatorPrecedence - (FaultSubject)(0), // 4: ziti.ctrl.pb.FaultSubject - (DestType)(0), // 5: ziti.ctrl.pb.DestType - (PeerState)(0), // 6: ziti.ctrl.pb.PeerState - (*Settings)(nil), // 7: ziti.ctrl.pb.Settings - (*CircuitRequest)(nil), // 8: ziti.ctrl.pb.CircuitRequest - (*CircuitConfirmation)(nil), // 9: ziti.ctrl.pb.CircuitConfirmation - (*CreateTerminatorRequest)(nil), // 10: ziti.ctrl.pb.CreateTerminatorRequest - (*RemoveTerminatorRequest)(nil), // 11: ziti.ctrl.pb.RemoveTerminatorRequest - (*RemoveTerminatorsRequest)(nil), // 12: ziti.ctrl.pb.RemoveTerminatorsRequest - (*Terminator)(nil), // 13: ziti.ctrl.pb.Terminator - (*ValidateTerminatorsRequest)(nil), // 14: ziti.ctrl.pb.ValidateTerminatorsRequest - (*UpdateTerminatorRequest)(nil), // 15: ziti.ctrl.pb.UpdateTerminatorRequest - (*Dial)(nil), // 16: ziti.ctrl.pb.Dial - (*LinkConn)(nil), // 17: ziti.ctrl.pb.LinkConn - (*LinkConnected)(nil), // 18: ziti.ctrl.pb.LinkConnected - (*RouterLinks)(nil), // 19: ziti.ctrl.pb.RouterLinks - (*Fault)(nil), // 20: ziti.ctrl.pb.Fault - (*Context)(nil), // 21: ziti.ctrl.pb.Context - (*Route)(nil), // 22: ziti.ctrl.pb.Route - (*Unroute)(nil), // 23: ziti.ctrl.pb.Unroute - (*InspectRequest)(nil), // 24: ziti.ctrl.pb.InspectRequest - (*InspectResponse)(nil), // 25: ziti.ctrl.pb.InspectResponse - (*VerifyRouter)(nil), // 26: ziti.ctrl.pb.VerifyRouter - (*Listener)(nil), // 27: ziti.ctrl.pb.Listener - (*Listeners)(nil), // 28: ziti.ctrl.pb.Listeners - (*UpdateCtrlAddresses)(nil), // 29: ziti.ctrl.pb.UpdateCtrlAddresses - (*PeerStateChange)(nil), // 30: ziti.ctrl.pb.PeerStateChange - (*PeerStateChanges)(nil), // 31: ziti.ctrl.pb.PeerStateChanges - (*RouterMetadata)(nil), // 32: ziti.ctrl.pb.RouterMetadata - nil, // 33: ziti.ctrl.pb.Settings.DataEntry - nil, // 34: ziti.ctrl.pb.CircuitRequest.PeerDataEntry - nil, // 35: ziti.ctrl.pb.CreateTerminatorRequest.PeerDataEntry - (*RouterLinks_RouterLink)(nil), // 36: ziti.ctrl.pb.RouterLinks.RouterLink - nil, // 37: ziti.ctrl.pb.Context.FieldsEntry - (*Route_Egress)(nil), // 38: ziti.ctrl.pb.Route.Egress - (*Route_Forward)(nil), // 39: ziti.ctrl.pb.Route.Forward - nil, // 40: ziti.ctrl.pb.Route.TagsEntry - nil, // 41: ziti.ctrl.pb.Route.Egress.PeerDataEntry - (*InspectResponse_InspectValue)(nil), // 42: ziti.ctrl.pb.InspectResponse.InspectValue + (ContentType)(0), // 0: ziti.ctrl.pb.ContentType + (RouterCapability)(0), // 1: ziti.ctrl.pb.RouterCapability + (SettingTypes)(0), // 2: ziti.ctrl.pb.SettingTypes + (TerminatorPrecedence)(0), // 3: ziti.ctrl.pb.TerminatorPrecedence + (TerminatorInvalidReason)(0), // 4: ziti.ctrl.pb.TerminatorInvalidReason + (FaultSubject)(0), // 5: ziti.ctrl.pb.FaultSubject + (DestType)(0), // 6: ziti.ctrl.pb.DestType + (PeerState)(0), // 7: ziti.ctrl.pb.PeerState + (*Settings)(nil), // 8: ziti.ctrl.pb.Settings + (*CircuitRequest)(nil), // 9: ziti.ctrl.pb.CircuitRequest + (*CircuitConfirmation)(nil), // 10: ziti.ctrl.pb.CircuitConfirmation + (*CreateTerminatorRequest)(nil), // 11: ziti.ctrl.pb.CreateTerminatorRequest + (*RemoveTerminatorRequest)(nil), // 12: ziti.ctrl.pb.RemoveTerminatorRequest + (*RemoveTerminatorsRequest)(nil), // 13: ziti.ctrl.pb.RemoveTerminatorsRequest + (*Terminator)(nil), // 14: ziti.ctrl.pb.Terminator + (*ValidateTerminatorsRequest)(nil), // 15: ziti.ctrl.pb.ValidateTerminatorsRequest + (*ValidateTerminatorsV2Request)(nil), // 16: ziti.ctrl.pb.ValidateTerminatorsV2Request + (*RouterTerminatorState)(nil), // 17: ziti.ctrl.pb.RouterTerminatorState + (*ValidateTerminatorsV2Response)(nil), // 18: ziti.ctrl.pb.ValidateTerminatorsV2Response + (*UpdateTerminatorRequest)(nil), // 19: ziti.ctrl.pb.UpdateTerminatorRequest + (*Dial)(nil), // 20: ziti.ctrl.pb.Dial + (*LinkConn)(nil), // 21: ziti.ctrl.pb.LinkConn + (*LinkConnected)(nil), // 22: ziti.ctrl.pb.LinkConnected + (*RouterLinks)(nil), // 23: ziti.ctrl.pb.RouterLinks + (*Fault)(nil), // 24: ziti.ctrl.pb.Fault + (*Context)(nil), // 25: ziti.ctrl.pb.Context + (*Route)(nil), // 26: ziti.ctrl.pb.Route + (*Unroute)(nil), // 27: ziti.ctrl.pb.Unroute + (*InspectRequest)(nil), // 28: ziti.ctrl.pb.InspectRequest + (*InspectResponse)(nil), // 29: ziti.ctrl.pb.InspectResponse + (*VerifyRouter)(nil), // 30: ziti.ctrl.pb.VerifyRouter + (*Listener)(nil), // 31: ziti.ctrl.pb.Listener + (*Listeners)(nil), // 32: ziti.ctrl.pb.Listeners + (*UpdateCtrlAddresses)(nil), // 33: ziti.ctrl.pb.UpdateCtrlAddresses + (*PeerStateChange)(nil), // 34: ziti.ctrl.pb.PeerStateChange + (*PeerStateChanges)(nil), // 35: ziti.ctrl.pb.PeerStateChanges + (*RouterMetadata)(nil), // 36: ziti.ctrl.pb.RouterMetadata + nil, // 37: ziti.ctrl.pb.Settings.DataEntry + nil, // 38: ziti.ctrl.pb.CircuitRequest.PeerDataEntry + nil, // 39: ziti.ctrl.pb.CreateTerminatorRequest.PeerDataEntry + nil, // 40: ziti.ctrl.pb.ValidateTerminatorsV2Response.StatesEntry + (*RouterLinks_RouterLink)(nil), // 41: ziti.ctrl.pb.RouterLinks.RouterLink + nil, // 42: ziti.ctrl.pb.Context.FieldsEntry + (*Route_Egress)(nil), // 43: ziti.ctrl.pb.Route.Egress + (*Route_Forward)(nil), // 44: ziti.ctrl.pb.Route.Forward + nil, // 45: ziti.ctrl.pb.Route.TagsEntry + nil, // 46: ziti.ctrl.pb.Route.Egress.PeerDataEntry + (*InspectResponse_InspectValue)(nil), // 47: ziti.ctrl.pb.InspectResponse.InspectValue } var file_ctrl_proto_depIdxs = []int32{ - 33, // 0: ziti.ctrl.pb.Settings.data:type_name -> ziti.ctrl.pb.Settings.DataEntry - 34, // 1: ziti.ctrl.pb.CircuitRequest.peerData:type_name -> ziti.ctrl.pb.CircuitRequest.PeerDataEntry - 35, // 2: ziti.ctrl.pb.CreateTerminatorRequest.peerData:type_name -> ziti.ctrl.pb.CreateTerminatorRequest.PeerDataEntry + 37, // 0: ziti.ctrl.pb.Settings.data:type_name -> ziti.ctrl.pb.Settings.DataEntry + 38, // 1: ziti.ctrl.pb.CircuitRequest.peerData:type_name -> ziti.ctrl.pb.CircuitRequest.PeerDataEntry + 39, // 2: ziti.ctrl.pb.CreateTerminatorRequest.peerData:type_name -> ziti.ctrl.pb.CreateTerminatorRequest.PeerDataEntry 3, // 3: ziti.ctrl.pb.CreateTerminatorRequest.precedence:type_name -> ziti.ctrl.pb.TerminatorPrecedence - 13, // 4: ziti.ctrl.pb.ValidateTerminatorsRequest.terminators:type_name -> ziti.ctrl.pb.Terminator - 3, // 5: ziti.ctrl.pb.UpdateTerminatorRequest.precedence:type_name -> ziti.ctrl.pb.TerminatorPrecedence - 17, // 6: ziti.ctrl.pb.LinkConnected.conns:type_name -> ziti.ctrl.pb.LinkConn - 36, // 7: ziti.ctrl.pb.RouterLinks.links:type_name -> ziti.ctrl.pb.RouterLinks.RouterLink - 4, // 8: ziti.ctrl.pb.Fault.subject:type_name -> ziti.ctrl.pb.FaultSubject - 37, // 9: ziti.ctrl.pb.Context.fields:type_name -> ziti.ctrl.pb.Context.FieldsEntry - 38, // 10: ziti.ctrl.pb.Route.egress:type_name -> ziti.ctrl.pb.Route.Egress - 39, // 11: ziti.ctrl.pb.Route.forwards:type_name -> ziti.ctrl.pb.Route.Forward - 21, // 12: ziti.ctrl.pb.Route.context:type_name -> ziti.ctrl.pb.Context - 40, // 13: ziti.ctrl.pb.Route.tags:type_name -> ziti.ctrl.pb.Route.TagsEntry - 42, // 14: ziti.ctrl.pb.InspectResponse.values:type_name -> ziti.ctrl.pb.InspectResponse.InspectValue - 27, // 15: ziti.ctrl.pb.Listeners.listeners:type_name -> ziti.ctrl.pb.Listener - 6, // 16: ziti.ctrl.pb.PeerStateChange.state:type_name -> ziti.ctrl.pb.PeerState - 27, // 17: ziti.ctrl.pb.PeerStateChange.listeners:type_name -> ziti.ctrl.pb.Listener - 30, // 18: ziti.ctrl.pb.PeerStateChanges.changes:type_name -> ziti.ctrl.pb.PeerStateChange - 1, // 19: ziti.ctrl.pb.RouterMetadata.capabilities:type_name -> ziti.ctrl.pb.RouterCapability - 41, // 20: ziti.ctrl.pb.Route.Egress.peerData:type_name -> ziti.ctrl.pb.Route.Egress.PeerDataEntry - 5, // 21: ziti.ctrl.pb.Route.Forward.dstType:type_name -> ziti.ctrl.pb.DestType - 22, // [22:22] is the sub-list for method output_type - 22, // [22:22] is the sub-list for method input_type - 22, // [22:22] is the sub-list for extension type_name - 22, // [22:22] is the sub-list for extension extendee - 0, // [0:22] is the sub-list for field type_name + 14, // 4: ziti.ctrl.pb.ValidateTerminatorsRequest.terminators:type_name -> ziti.ctrl.pb.Terminator + 14, // 5: ziti.ctrl.pb.ValidateTerminatorsV2Request.terminators:type_name -> ziti.ctrl.pb.Terminator + 4, // 6: ziti.ctrl.pb.RouterTerminatorState.reason:type_name -> ziti.ctrl.pb.TerminatorInvalidReason + 40, // 7: ziti.ctrl.pb.ValidateTerminatorsV2Response.states:type_name -> ziti.ctrl.pb.ValidateTerminatorsV2Response.StatesEntry + 3, // 8: ziti.ctrl.pb.UpdateTerminatorRequest.precedence:type_name -> ziti.ctrl.pb.TerminatorPrecedence + 21, // 9: ziti.ctrl.pb.LinkConnected.conns:type_name -> ziti.ctrl.pb.LinkConn + 41, // 10: ziti.ctrl.pb.RouterLinks.links:type_name -> ziti.ctrl.pb.RouterLinks.RouterLink + 5, // 11: ziti.ctrl.pb.Fault.subject:type_name -> ziti.ctrl.pb.FaultSubject + 42, // 12: ziti.ctrl.pb.Context.fields:type_name -> ziti.ctrl.pb.Context.FieldsEntry + 43, // 13: ziti.ctrl.pb.Route.egress:type_name -> ziti.ctrl.pb.Route.Egress + 44, // 14: ziti.ctrl.pb.Route.forwards:type_name -> ziti.ctrl.pb.Route.Forward + 25, // 15: ziti.ctrl.pb.Route.context:type_name -> ziti.ctrl.pb.Context + 45, // 16: ziti.ctrl.pb.Route.tags:type_name -> ziti.ctrl.pb.Route.TagsEntry + 47, // 17: ziti.ctrl.pb.InspectResponse.values:type_name -> ziti.ctrl.pb.InspectResponse.InspectValue + 31, // 18: ziti.ctrl.pb.Listeners.listeners:type_name -> ziti.ctrl.pb.Listener + 7, // 19: ziti.ctrl.pb.PeerStateChange.state:type_name -> ziti.ctrl.pb.PeerState + 31, // 20: ziti.ctrl.pb.PeerStateChange.listeners:type_name -> ziti.ctrl.pb.Listener + 34, // 21: ziti.ctrl.pb.PeerStateChanges.changes:type_name -> ziti.ctrl.pb.PeerStateChange + 1, // 22: ziti.ctrl.pb.RouterMetadata.capabilities:type_name -> ziti.ctrl.pb.RouterCapability + 17, // 23: ziti.ctrl.pb.ValidateTerminatorsV2Response.StatesEntry.value:type_name -> ziti.ctrl.pb.RouterTerminatorState + 46, // 24: ziti.ctrl.pb.Route.Egress.peerData:type_name -> ziti.ctrl.pb.Route.Egress.PeerDataEntry + 6, // 25: ziti.ctrl.pb.Route.Forward.dstType:type_name -> ziti.ctrl.pb.DestType + 26, // [26:26] is the sub-list for method output_type + 26, // [26:26] is the sub-list for method input_type + 26, // [26:26] is the sub-list for extension type_name + 26, // [26:26] is the sub-list for extension extendee + 0, // [0:26] is the sub-list for field type_name } func init() { file_ctrl_proto_init() } @@ -2803,7 +3072,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateTerminatorRequest); i { + switch v := v.(*ValidateTerminatorsV2Request); i { case 0: return &v.state case 1: @@ -2815,7 +3084,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Dial); i { + switch v := v.(*RouterTerminatorState); i { case 0: return &v.state case 1: @@ -2827,7 +3096,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LinkConn); i { + switch v := v.(*ValidateTerminatorsV2Response); i { case 0: return &v.state case 1: @@ -2839,7 +3108,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LinkConnected); i { + switch v := v.(*UpdateTerminatorRequest); i { case 0: return &v.state case 1: @@ -2851,7 +3120,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RouterLinks); i { + switch v := v.(*Dial); i { case 0: return &v.state case 1: @@ -2863,7 +3132,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Fault); i { + switch v := v.(*LinkConn); i { case 0: return &v.state case 1: @@ -2875,7 +3144,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Context); i { + switch v := v.(*LinkConnected); i { case 0: return &v.state case 1: @@ -2887,7 +3156,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Route); i { + switch v := v.(*RouterLinks); i { case 0: return &v.state case 1: @@ -2899,7 +3168,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Unroute); i { + switch v := v.(*Fault); i { case 0: return &v.state case 1: @@ -2911,7 +3180,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InspectRequest); i { + switch v := v.(*Context); i { case 0: return &v.state case 1: @@ -2923,7 +3192,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InspectResponse); i { + switch v := v.(*Route); i { case 0: return &v.state case 1: @@ -2935,7 +3204,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VerifyRouter); i { + switch v := v.(*Unroute); i { case 0: return &v.state case 1: @@ -2947,7 +3216,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Listener); i { + switch v := v.(*InspectRequest); i { case 0: return &v.state case 1: @@ -2959,7 +3228,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Listeners); i { + switch v := v.(*InspectResponse); i { case 0: return &v.state case 1: @@ -2971,7 +3240,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateCtrlAddresses); i { + switch v := v.(*VerifyRouter); i { case 0: return &v.state case 1: @@ -2983,7 +3252,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PeerStateChange); i { + switch v := v.(*Listener); i { case 0: return &v.state case 1: @@ -2995,7 +3264,7 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PeerStateChanges); i { + switch v := v.(*Listeners); i { case 0: return &v.state case 1: @@ -3007,6 +3276,42 @@ func file_ctrl_proto_init() { } } file_ctrl_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateCtrlAddresses); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ctrl_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeerStateChange); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ctrl_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeerStateChanges); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ctrl_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RouterMetadata); i { case 0: return &v.state @@ -3018,7 +3323,7 @@ func file_ctrl_proto_init() { return nil } } - file_ctrl_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + file_ctrl_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RouterLinks_RouterLink); i { case 0: return &v.state @@ -3030,7 +3335,7 @@ func file_ctrl_proto_init() { return nil } } - file_ctrl_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + file_ctrl_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Route_Egress); i { case 0: return &v.state @@ -3042,7 +3347,7 @@ func file_ctrl_proto_init() { return nil } } - file_ctrl_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + file_ctrl_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Route_Forward); i { case 0: return &v.state @@ -3054,7 +3359,7 @@ func file_ctrl_proto_init() { return nil } } - file_ctrl_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + file_ctrl_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InspectResponse_InspectValue); i { case 0: return &v.state @@ -3072,8 +3377,8 @@ func file_ctrl_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_ctrl_proto_rawDesc, - NumEnums: 7, - NumMessages: 36, + NumEnums: 8, + NumMessages: 40, NumExtensions: 0, NumServices: 0, }, diff --git a/common/pb/ctrl_pb/ctrl.proto b/common/pb/ctrl_pb/ctrl.proto index 5df7a40e2..a26a462b3 100644 --- a/common/pb/ctrl_pb/ctrl.proto +++ b/common/pb/ctrl_pb/ctrl.proto @@ -36,6 +36,8 @@ enum ContentType { RemoveTerminatorsRequestType = 1038; QuiesceRouterRequestType = 1039; DequiesceRouterRequestType = 1040; + ValidateTerminatorsV2RequestType = 1041; + ValidateTerminatorsV2ResponseType = 1042; PeerStateChangeRequestType = 1050; @@ -108,6 +110,27 @@ message ValidateTerminatorsRequest { repeated Terminator terminators = 1; } +message ValidateTerminatorsV2Request { + repeated Terminator terminators = 1; + bool fixInvalid = 2; +} + +enum TerminatorInvalidReason { + UnknownBinding = 0; + UnknownTerminator = 1; + BadState = 2; +} + +message RouterTerminatorState { + bool valid = 1; + TerminatorInvalidReason reason = 2; + string detail = 3; // inspect info if valid +} + +message ValidateTerminatorsV2Response { + map states = 1; +} + message UpdateTerminatorRequest { string terminatorId = 1; bool updatePrecedence = 2; diff --git a/common/pb/ctrl_pb/impl.go b/common/pb/ctrl_pb/impl.go index dfa89c98a..0b08aee27 100644 --- a/common/pb/ctrl_pb/impl.go +++ b/common/pb/ctrl_pb/impl.go @@ -50,6 +50,14 @@ func (request *ValidateTerminatorsRequest) GetContentType() int32 { return int32(ContentType_ValidateTerminatorsRequestType) } +func (request *ValidateTerminatorsV2Request) GetContentType() int32 { + return int32(ContentType_ValidateTerminatorsV2RequestType) +} + +func (request *ValidateTerminatorsV2Response) GetContentType() int32 { + return int32(ContentType_ValidateTerminatorsV2ResponseType) +} + func (request *Dial) GetContentType() int32 { return int32(ContentType_DialType) } diff --git a/common/pb/mgmt_pb/impl.go b/common/pb/mgmt_pb/impl.go index 931f6b355..78756b4b8 100644 --- a/common/pb/mgmt_pb/impl.go +++ b/common/pb/mgmt_pb/impl.go @@ -11,3 +11,15 @@ func (request *InspectResponse) GetContentType() int32 { func (request *RaftMemberListResponse) GetContentType() int32 { return int32(ContentType_RaftListMembersResponseType) } + +func (request *ValidateTerminatorsRequest) GetContentType() int32 { + return int32(ContentType_ValidateTerminatorsRequestType) +} + +func (request *ValidateTerminatorsResponse) GetContentType() int32 { + return int32(ContentType_ValidateTerminatorResponseType) +} + +func (request *TerminatorDetail) GetContentType() int32 { + return int32(ContentType_ValidateTerminatorResultType) +} diff --git a/common/pb/mgmt_pb/mgmt.pb.go b/common/pb/mgmt_pb/mgmt.pb.go index 833637ea2..fc5306911 100644 --- a/common/pb/mgmt_pb/mgmt.pb.go +++ b/common/pb/mgmt_pb/mgmt.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.27.1 +// protoc-gen-go v1.31.0 // protoc v3.19.1 // source: mgmt.proto @@ -54,6 +54,10 @@ const ( ContentType_RaftRemovePeerRequestType ContentType = 10083 ContentType_RaftTransferLeadershipRequestType ContentType = 10084 ContentType_RaftInitFromDb ContentType = 10085 + // Validate + ContentType_ValidateTerminatorsRequestType ContentType = 10100 + ContentType_ValidateTerminatorResponseType ContentType = 10101 + ContentType_ValidateTerminatorResultType ContentType = 10102 ) // Enum value maps for ContentType. @@ -83,6 +87,9 @@ var ( 10083: "RaftRemovePeerRequestType", 10084: "RaftTransferLeadershipRequestType", 10085: "RaftInitFromDb", + 10100: "ValidateTerminatorsRequestType", + 10101: "ValidateTerminatorResponseType", + 10102: "ValidateTerminatorResultType", } ContentType_value = map[string]int32{ "Zero": 0, @@ -109,6 +116,9 @@ var ( "RaftRemovePeerRequestType": 10083, "RaftTransferLeadershipRequestType": 10084, "RaftInitFromDb": 10085, + "ValidateTerminatorsRequestType": 10100, + "ValidateTerminatorResponseType": 10101, + "ValidateTerminatorResultType": 10102, } ) @@ -292,6 +302,61 @@ func (TraceFilterType) EnumDescriptor() ([]byte, []int) { return file_mgmt_proto_rawDescGZIP(), []int{3} } +type TerminatorState int32 + +const ( + TerminatorState_Valid TerminatorState = 0 + TerminatorState_Unknown TerminatorState = 1 + TerminatorState_InvalidUnknownBinding TerminatorState = 2 + TerminatorState_InvalidUnknownTerminator TerminatorState = 3 + TerminatorState_InvalidBadState TerminatorState = 4 +) + +// Enum value maps for TerminatorState. +var ( + TerminatorState_name = map[int32]string{ + 0: "Valid", + 1: "Unknown", + 2: "InvalidUnknownBinding", + 3: "InvalidUnknownTerminator", + 4: "InvalidBadState", + } + TerminatorState_value = map[string]int32{ + "Valid": 0, + "Unknown": 1, + "InvalidUnknownBinding": 2, + "InvalidUnknownTerminator": 3, + "InvalidBadState": 4, + } +) + +func (x TerminatorState) Enum() *TerminatorState { + p := new(TerminatorState) + *p = x + return p +} + +func (x TerminatorState) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (TerminatorState) Descriptor() protoreflect.EnumDescriptor { + return file_mgmt_proto_enumTypes[4].Descriptor() +} + +func (TerminatorState) Type() protoreflect.EnumType { + return &file_mgmt_proto_enumTypes[4] +} + +func (x TerminatorState) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use TerminatorState.Descriptor instead. +func (TerminatorState) EnumDescriptor() ([]byte, []int) { + return file_mgmt_proto_rawDescGZIP(), []int{4} +} + type StreamMetricsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -971,6 +1036,259 @@ func (x *RaftMemberListResponse) GetMembers() []*RaftMember { return nil } +type ValidateTerminatorsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Filter string `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + FixInvalid bool `protobuf:"varint,2,opt,name=fixInvalid,proto3" json:"fixInvalid,omitempty"` +} + +func (x *ValidateTerminatorsRequest) Reset() { + *x = ValidateTerminatorsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_mgmt_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ValidateTerminatorsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ValidateTerminatorsRequest) ProtoMessage() {} + +func (x *ValidateTerminatorsRequest) ProtoReflect() protoreflect.Message { + mi := &file_mgmt_proto_msgTypes[10] + 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 ValidateTerminatorsRequest.ProtoReflect.Descriptor instead. +func (*ValidateTerminatorsRequest) Descriptor() ([]byte, []int) { + return file_mgmt_proto_rawDescGZIP(), []int{10} +} + +func (x *ValidateTerminatorsRequest) GetFilter() string { + if x != nil { + return x.Filter + } + return "" +} + +func (x *ValidateTerminatorsRequest) GetFixInvalid() bool { + if x != nil { + return x.FixInvalid + } + return false +} + +type ValidateTerminatorsResponse 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"` + TerminatorCount uint64 `protobuf:"varint,3,opt,name=terminatorCount,proto3" json:"terminatorCount,omitempty"` +} + +func (x *ValidateTerminatorsResponse) Reset() { + *x = ValidateTerminatorsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_mgmt_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ValidateTerminatorsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ValidateTerminatorsResponse) ProtoMessage() {} + +func (x *ValidateTerminatorsResponse) ProtoReflect() protoreflect.Message { + mi := &file_mgmt_proto_msgTypes[11] + 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 ValidateTerminatorsResponse.ProtoReflect.Descriptor instead. +func (*ValidateTerminatorsResponse) Descriptor() ([]byte, []int) { + return file_mgmt_proto_rawDescGZIP(), []int{11} +} + +func (x *ValidateTerminatorsResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *ValidateTerminatorsResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *ValidateTerminatorsResponse) GetTerminatorCount() uint64 { + if x != nil { + return x.TerminatorCount + } + return 0 +} + +type TerminatorDetail struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TerminatorId string `protobuf:"bytes,1,opt,name=terminatorId,proto3" json:"terminatorId,omitempty"` + ServiceId string `protobuf:"bytes,2,opt,name=serviceId,proto3" json:"serviceId,omitempty"` + ServiceName string `protobuf:"bytes,3,opt,name=serviceName,proto3" json:"serviceName,omitempty"` + RouterId string `protobuf:"bytes,4,opt,name=routerId,proto3" json:"routerId,omitempty"` + RouterName string `protobuf:"bytes,5,opt,name=routerName,proto3" json:"routerName,omitempty"` + Binding string `protobuf:"bytes,6,opt,name=binding,proto3" json:"binding,omitempty"` + Address string `protobuf:"bytes,7,opt,name=address,proto3" json:"address,omitempty"` + HostId string `protobuf:"bytes,8,opt,name=hostId,proto3" json:"hostId,omitempty"` + CreateDate string `protobuf:"bytes,9,opt,name=createDate,proto3" json:"createDate,omitempty"` + State TerminatorState `protobuf:"varint,10,opt,name=state,proto3,enum=ziti.mgmt_pb.TerminatorState" json:"state,omitempty"` + Fixed bool `protobuf:"varint,11,opt,name=fixed,proto3" json:"fixed,omitempty"` + Detail string `protobuf:"bytes,12,opt,name=detail,proto3" json:"detail,omitempty"` +} + +func (x *TerminatorDetail) Reset() { + *x = TerminatorDetail{} + if protoimpl.UnsafeEnabled { + mi := &file_mgmt_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TerminatorDetail) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TerminatorDetail) ProtoMessage() {} + +func (x *TerminatorDetail) ProtoReflect() protoreflect.Message { + mi := &file_mgmt_proto_msgTypes[12] + 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 TerminatorDetail.ProtoReflect.Descriptor instead. +func (*TerminatorDetail) Descriptor() ([]byte, []int) { + return file_mgmt_proto_rawDescGZIP(), []int{12} +} + +func (x *TerminatorDetail) GetTerminatorId() string { + if x != nil { + return x.TerminatorId + } + return "" +} + +func (x *TerminatorDetail) GetServiceId() string { + if x != nil { + return x.ServiceId + } + return "" +} + +func (x *TerminatorDetail) GetServiceName() string { + if x != nil { + return x.ServiceName + } + return "" +} + +func (x *TerminatorDetail) GetRouterId() string { + if x != nil { + return x.RouterId + } + return "" +} + +func (x *TerminatorDetail) GetRouterName() string { + if x != nil { + return x.RouterName + } + return "" +} + +func (x *TerminatorDetail) GetBinding() string { + if x != nil { + return x.Binding + } + return "" +} + +func (x *TerminatorDetail) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *TerminatorDetail) GetHostId() string { + if x != nil { + return x.HostId + } + return "" +} + +func (x *TerminatorDetail) GetCreateDate() string { + if x != nil { + return x.CreateDate + } + return "" +} + +func (x *TerminatorDetail) GetState() TerminatorState { + if x != nil { + return x.State + } + return TerminatorState_Valid +} + +func (x *TerminatorDetail) GetFixed() bool { + if x != nil { + return x.Fixed + } + return false +} + +func (x *TerminatorDetail) GetDetail() string { + if x != nil { + return x.Detail + } + return "" +} + type StreamMetricsRequest_MetricMatcher struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -983,7 +1301,7 @@ type StreamMetricsRequest_MetricMatcher struct { func (x *StreamMetricsRequest_MetricMatcher) Reset() { *x = StreamMetricsRequest_MetricMatcher{} if protoimpl.UnsafeEnabled { - mi := &file_mgmt_proto_msgTypes[10] + mi := &file_mgmt_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -996,7 +1314,7 @@ func (x *StreamMetricsRequest_MetricMatcher) String() string { func (*StreamMetricsRequest_MetricMatcher) ProtoMessage() {} func (x *StreamMetricsRequest_MetricMatcher) ProtoReflect() protoreflect.Message { - mi := &file_mgmt_proto_msgTypes[10] + mi := &file_mgmt_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1040,7 +1358,7 @@ type StreamMetricsEvent_IntervalMetric struct { func (x *StreamMetricsEvent_IntervalMetric) Reset() { *x = StreamMetricsEvent_IntervalMetric{} if protoimpl.UnsafeEnabled { - mi := &file_mgmt_proto_msgTypes[14] + mi := &file_mgmt_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1053,7 +1371,7 @@ func (x *StreamMetricsEvent_IntervalMetric) String() string { func (*StreamMetricsEvent_IntervalMetric) ProtoMessage() {} func (x *StreamMetricsEvent_IntervalMetric) ProtoReflect() protoreflect.Message { - mi := &file_mgmt_proto_msgTypes[14] + mi := &file_mgmt_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1110,7 +1428,7 @@ type InspectResponse_InspectValue struct { func (x *InspectResponse_InspectValue) Reset() { *x = InspectResponse_InspectValue{} if protoimpl.UnsafeEnabled { - mi := &file_mgmt_proto_msgTypes[17] + mi := &file_mgmt_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1123,7 +1441,7 @@ func (x *InspectResponse_InspectValue) String() string { func (*InspectResponse_InspectValue) ProtoMessage() {} func (x *InspectResponse_InspectValue) ProtoReflect() protoreflect.Message { - mi := &file_mgmt_proto_msgTypes[17] + mi := &file_mgmt_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1325,74 +1643,126 @@ var file_mgmt_proto_rawDesc = []byte{ 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x6d, 0x67, 0x6d, 0x74, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x61, 0x66, 0x74, 0x4d, - 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x2a, 0xff, - 0x05, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, - 0x0a, 0x04, 0x5a, 0x65, 0x72, 0x6f, 0x10, 0x00, 0x12, 0x1c, 0x0a, 0x17, 0x53, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, - 0x79, 0x70, 0x65, 0x10, 0xb8, 0x4e, 0x12, 0x1a, 0x0a, 0x15, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, - 0xb9, 0x4e, 0x12, 0x20, 0x0a, 0x1b, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x50, 0x69, 0x70, 0x65, - 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, - 0x65, 0x10, 0xbc, 0x4e, 0x12, 0x23, 0x0a, 0x1e, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x69, - 0x72, 0x63, 0x75, 0x69, 0x74, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xbd, 0x4e, 0x12, 0x1c, 0x0a, 0x17, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x54, 0x79, 0x70, 0x65, 0x10, 0xbe, 0x4e, 0x12, 0x1a, 0x0a, 0x15, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, - 0x10, 0xbf, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xc0, 0x4e, 0x12, 0x18, 0x0a, 0x13, - 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x10, 0xc1, 0x4e, 0x12, 0x1a, 0x0a, 0x15, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, - 0x6f, 0x74, 0x44, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, - 0xd6, 0x4e, 0x12, 0x25, 0x0a, 0x20, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, 0x65, 0x62, 0x75, - 0x67, 0x46, 0x6f, 0x72, 0x67, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xd7, 0x4e, 0x12, 0x2c, 0x0a, 0x27, 0x52, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0x44, 0x65, 0x62, 0x75, 0x67, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x74, - 0x72, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x54, 0x79, 0x70, 0x65, 0x10, 0xd8, 0x4e, 0x12, 0x26, 0x0a, 0x21, 0x52, 0x6f, 0x75, 0x74, 0x65, - 0x72, 0x44, 0x65, 0x62, 0x75, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x75, 0x74, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xd9, 0x4e, 0x12, - 0x2e, 0x0a, 0x29, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x75, - 0x6d, 0x70, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x65, 0x72, 0x54, 0x61, 0x62, 0x6c, 0x65, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xda, 0x4e, 0x12, - 0x24, 0x0a, 0x1f, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x75, - 0x6d, 0x70, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x10, 0xdb, 0x4e, 0x12, 0x22, 0x0a, 0x1d, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, - 0x65, 0x62, 0x75, 0x67, 0x55, 0x6e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xdc, 0x4e, 0x12, 0x12, 0x0a, 0x0d, 0x52, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0x51, 0x75, 0x69, 0x65, 0x73, 0x63, 0x65, 0x10, 0xdd, 0x4e, 0x12, 0x14, 0x0a, - 0x0f, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, 0x65, 0x71, 0x75, 0x69, 0x65, 0x73, 0x63, 0x65, - 0x10, 0xde, 0x4e, 0x12, 0x1f, 0x0a, 0x1a, 0x52, 0x61, 0x66, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x4d, - 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, - 0x65, 0x10, 0xe0, 0x4e, 0x12, 0x20, 0x0a, 0x1b, 0x52, 0x61, 0x66, 0x74, 0x4c, 0x69, 0x73, 0x74, - 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x10, 0xe1, 0x4e, 0x12, 0x1b, 0x0a, 0x16, 0x52, 0x61, 0x66, 0x74, 0x41, 0x64, - 0x64, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, - 0x10, 0xe2, 0x4e, 0x12, 0x1e, 0x0a, 0x19, 0x52, 0x61, 0x66, 0x74, 0x52, 0x65, 0x6d, 0x6f, 0x76, - 0x65, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, - 0x10, 0xe3, 0x4e, 0x12, 0x26, 0x0a, 0x21, 0x52, 0x61, 0x66, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x66, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xe4, 0x4e, 0x12, 0x13, 0x0a, 0x0e, 0x52, - 0x61, 0x66, 0x74, 0x49, 0x6e, 0x69, 0x74, 0x46, 0x72, 0x6f, 0x6d, 0x44, 0x62, 0x10, 0xe5, 0x4e, - 0x2a, 0x53, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x6f, - 0x6e, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x0a, 0x12, - 0x12, 0x0a, 0x0e, 0x43, 0x74, 0x72, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x54, 0x6f, 0x67, 0x67, 0x6c, - 0x65, 0x10, 0x0b, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, - 0x72, 0x49, 0x64, 0x10, 0x0c, 0x2a, 0x78, 0x0a, 0x16, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, - 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x12, 0x0a, 0x0e, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x64, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x69, 0x72, 0x63, 0x75, - 0x69, 0x74, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x50, - 0x61, 0x74, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, - 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0x04, 0x2a, - 0x2b, 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x58, 0x43, 0x4c, 0x55, 0x44, 0x45, 0x10, 0x00, 0x12, - 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x43, 0x4c, 0x55, 0x44, 0x45, 0x10, 0x01, 0x42, 0x27, 0x5a, 0x25, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x7a, - 0x69, 0x74, 0x69, 0x2f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x6d, 0x67, - 0x6d, 0x74, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x22, 0x54, + 0x0a, 0x1a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x69, 0x78, 0x49, 0x6e, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x66, 0x69, 0x78, 0x49, 0x6e, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x22, 0x7b, 0x0a, 0x1b, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 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, 0x12, 0x28, 0x0a, 0x0f, 0x74, 0x65, 0x72, 0x6d, 0x69, + 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0f, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x22, 0x81, 0x03, 0x0a, 0x10, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, + 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x61, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x65, + 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, + 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, + 0x75, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x6f, 0x75, 0x74, + 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, + 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, + 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x6f, + 0x73, 0x74, 0x49, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x6f, 0x73, 0x74, + 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x61, 0x74, 0x65, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x61, + 0x74, 0x65, 0x12, 0x33, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x1d, 0x2e, 0x7a, 0x69, 0x74, 0x69, 0x2e, 0x6d, 0x67, 0x6d, 0x74, 0x5f, 0x70, 0x62, + 0x2e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x78, 0x65, 0x64, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x66, 0x69, 0x78, 0x65, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2a, 0xec, 0x06, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x5a, 0x65, 0x72, 0x6f, 0x10, 0x00, 0x12, + 0x1c, 0x0a, 0x17, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xb8, 0x4e, 0x12, 0x1a, 0x0a, + 0x15, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xb9, 0x4e, 0x12, 0x20, 0x0a, 0x1b, 0x54, 0x6f, 0x67, + 0x67, 0x6c, 0x65, 0x50, 0x69, 0x70, 0x65, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xbc, 0x4e, 0x12, 0x23, 0x0a, 0x1e, 0x54, + 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x54, 0x72, 0x61, 0x63, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xbd, 0x4e, + 0x12, 0x1c, 0x0a, 0x17, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xbe, 0x4e, 0x12, 0x1a, + 0x0a, 0x15, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xbf, 0x4e, 0x12, 0x17, 0x0a, 0x12, 0x49, 0x6e, + 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x10, 0xc0, 0x4e, 0x12, 0x18, 0x0a, 0x13, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x10, 0xc1, 0x4e, 0x12, 0x1a, 0x0a, + 0x15, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x44, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xd6, 0x4e, 0x12, 0x25, 0x0a, 0x20, 0x52, 0x6f, 0x75, + 0x74, 0x65, 0x72, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x6f, 0x72, 0x67, 0x65, 0x74, 0x4c, 0x69, + 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xd7, 0x4e, + 0x12, 0x2c, 0x0a, 0x27, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, 0x65, 0x62, 0x75, 0x67, 0x54, + 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x74, 0x72, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xd8, 0x4e, 0x12, 0x26, + 0x0a, 0x21, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, 0x65, 0x62, 0x75, 0x67, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, + 0x79, 0x70, 0x65, 0x10, 0xd9, 0x4e, 0x12, 0x2e, 0x0a, 0x29, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x75, 0x6d, 0x70, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, + 0x65, 0x72, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, + 0x79, 0x70, 0x65, 0x10, 0xda, 0x4e, 0x12, 0x24, 0x0a, 0x1f, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x75, 0x6d, 0x70, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xdb, 0x4e, 0x12, 0x22, 0x0a, 0x1d, + 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, 0x65, 0x62, 0x75, 0x67, 0x55, 0x6e, 0x72, 0x6f, 0x75, + 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xdc, 0x4e, + 0x12, 0x12, 0x0a, 0x0d, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x51, 0x75, 0x69, 0x65, 0x73, 0x63, + 0x65, 0x10, 0xdd, 0x4e, 0x12, 0x14, 0x0a, 0x0f, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x44, 0x65, + 0x71, 0x75, 0x69, 0x65, 0x73, 0x63, 0x65, 0x10, 0xde, 0x4e, 0x12, 0x1f, 0x0a, 0x1a, 0x52, 0x61, + 0x66, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xe0, 0x4e, 0x12, 0x20, 0x0a, 0x1b, 0x52, + 0x61, 0x66, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x10, 0xe1, 0x4e, 0x12, 0x1b, 0x0a, + 0x16, 0x52, 0x61, 0x66, 0x74, 0x41, 0x64, 0x64, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xe2, 0x4e, 0x12, 0x1e, 0x0a, 0x19, 0x52, 0x61, + 0x66, 0x74, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xe3, 0x4e, 0x12, 0x26, 0x0a, 0x21, 0x52, 0x61, + 0x66, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, + 0xe4, 0x4e, 0x12, 0x13, 0x0a, 0x0e, 0x52, 0x61, 0x66, 0x74, 0x49, 0x6e, 0x69, 0x74, 0x46, 0x72, + 0x6f, 0x6d, 0x44, 0x62, 0x10, 0xe5, 0x4e, 0x12, 0x23, 0x0a, 0x1e, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf4, 0x4e, 0x12, 0x23, 0x0a, 0x1e, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, + 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x10, 0xf5, + 0x4e, 0x12, 0x21, 0x0a, 0x1c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x72, + 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x10, 0xf6, 0x4e, 0x2a, 0x53, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x0e, + 0x0a, 0x0a, 0x4e, 0x6f, 0x6e, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x00, 0x12, 0x13, + 0x0a, 0x0f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x10, 0x0a, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x74, 0x72, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x54, + 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x10, 0x0b, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x64, 0x10, 0x0c, 0x2a, 0x78, 0x0a, 0x16, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x69, 0x72, 0x63, 0x75, + 0x69, 0x74, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x43, + 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x10, 0x02, 0x12, + 0x0f, 0x0a, 0x0b, 0x50, 0x61, 0x74, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x10, 0x03, + 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x69, 0x72, 0x63, 0x75, 0x69, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, + 0x64, 0x10, 0x04, 0x2a, 0x2b, 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x58, 0x43, 0x4c, 0x55, 0x44, + 0x45, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x43, 0x4c, 0x55, 0x44, 0x45, 0x10, 0x01, + 0x2a, 0x77, 0x0a, 0x0f, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x00, 0x12, 0x0b, + 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x01, 0x12, 0x19, 0x0a, 0x15, 0x49, + 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x42, 0x69, 0x6e, + 0x64, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, + 0x6f, 0x72, 0x10, 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x42, + 0x61, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x10, 0x04, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x7a, 0x69, 0x74, 0x69, + 0x2f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x6d, 0x67, 0x6d, 0x74, 0x5f, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1407,54 +1777,59 @@ func file_mgmt_proto_rawDescGZIP() []byte { return file_mgmt_proto_rawDescData } -var file_mgmt_proto_enumTypes = make([]protoimpl.EnumInfo, 4) -var file_mgmt_proto_msgTypes = make([]protoimpl.MessageInfo, 18) +var file_mgmt_proto_enumTypes = make([]protoimpl.EnumInfo, 5) +var file_mgmt_proto_msgTypes = make([]protoimpl.MessageInfo, 21) var file_mgmt_proto_goTypes = []interface{}{ (ContentType)(0), // 0: ziti.mgmt_pb.ContentType (Header)(0), // 1: ziti.mgmt_pb.Header (StreamCircuitEventType)(0), // 2: ziti.mgmt_pb.StreamCircuitEventType (TraceFilterType)(0), // 3: ziti.mgmt_pb.TraceFilterType - (*StreamMetricsRequest)(nil), // 4: ziti.mgmt_pb.StreamMetricsRequest - (*StreamMetricsEvent)(nil), // 5: ziti.mgmt_pb.StreamMetricsEvent - (*Path)(nil), // 6: ziti.mgmt_pb.Path - (*StreamCircuitsEvent)(nil), // 7: ziti.mgmt_pb.StreamCircuitsEvent - (*ToggleCircuitTracesRequest)(nil), // 8: ziti.mgmt_pb.ToggleCircuitTracesRequest - (*StreamTracesRequest)(nil), // 9: ziti.mgmt_pb.StreamTracesRequest - (*InspectRequest)(nil), // 10: ziti.mgmt_pb.InspectRequest - (*InspectResponse)(nil), // 11: ziti.mgmt_pb.InspectResponse - (*RaftMember)(nil), // 12: ziti.mgmt_pb.RaftMember - (*RaftMemberListResponse)(nil), // 13: ziti.mgmt_pb.RaftMemberListResponse - (*StreamMetricsRequest_MetricMatcher)(nil), // 14: ziti.mgmt_pb.StreamMetricsRequest.MetricMatcher - nil, // 15: ziti.mgmt_pb.StreamMetricsEvent.TagsEntry - nil, // 16: ziti.mgmt_pb.StreamMetricsEvent.IntMetricsEntry - nil, // 17: ziti.mgmt_pb.StreamMetricsEvent.FloatMetricsEntry - (*StreamMetricsEvent_IntervalMetric)(nil), // 18: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric - nil, // 19: ziti.mgmt_pb.StreamMetricsEvent.MetricGroupEntry - nil, // 20: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.ValuesEntry - (*InspectResponse_InspectValue)(nil), // 21: ziti.mgmt_pb.InspectResponse.InspectValue - (*timestamppb.Timestamp)(nil), // 22: google.protobuf.Timestamp + (TerminatorState)(0), // 4: ziti.mgmt_pb.TerminatorState + (*StreamMetricsRequest)(nil), // 5: ziti.mgmt_pb.StreamMetricsRequest + (*StreamMetricsEvent)(nil), // 6: ziti.mgmt_pb.StreamMetricsEvent + (*Path)(nil), // 7: ziti.mgmt_pb.Path + (*StreamCircuitsEvent)(nil), // 8: ziti.mgmt_pb.StreamCircuitsEvent + (*ToggleCircuitTracesRequest)(nil), // 9: ziti.mgmt_pb.ToggleCircuitTracesRequest + (*StreamTracesRequest)(nil), // 10: ziti.mgmt_pb.StreamTracesRequest + (*InspectRequest)(nil), // 11: ziti.mgmt_pb.InspectRequest + (*InspectResponse)(nil), // 12: ziti.mgmt_pb.InspectResponse + (*RaftMember)(nil), // 13: ziti.mgmt_pb.RaftMember + (*RaftMemberListResponse)(nil), // 14: ziti.mgmt_pb.RaftMemberListResponse + (*ValidateTerminatorsRequest)(nil), // 15: ziti.mgmt_pb.ValidateTerminatorsRequest + (*ValidateTerminatorsResponse)(nil), // 16: ziti.mgmt_pb.ValidateTerminatorsResponse + (*TerminatorDetail)(nil), // 17: ziti.mgmt_pb.TerminatorDetail + (*StreamMetricsRequest_MetricMatcher)(nil), // 18: ziti.mgmt_pb.StreamMetricsRequest.MetricMatcher + nil, // 19: ziti.mgmt_pb.StreamMetricsEvent.TagsEntry + nil, // 20: ziti.mgmt_pb.StreamMetricsEvent.IntMetricsEntry + nil, // 21: ziti.mgmt_pb.StreamMetricsEvent.FloatMetricsEntry + (*StreamMetricsEvent_IntervalMetric)(nil), // 22: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric + nil, // 23: ziti.mgmt_pb.StreamMetricsEvent.MetricGroupEntry + nil, // 24: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.ValuesEntry + (*InspectResponse_InspectValue)(nil), // 25: ziti.mgmt_pb.InspectResponse.InspectValue + (*timestamppb.Timestamp)(nil), // 26: google.protobuf.Timestamp } var file_mgmt_proto_depIdxs = []int32{ - 14, // 0: ziti.mgmt_pb.StreamMetricsRequest.matchers:type_name -> ziti.mgmt_pb.StreamMetricsRequest.MetricMatcher - 22, // 1: ziti.mgmt_pb.StreamMetricsEvent.timestamp:type_name -> google.protobuf.Timestamp - 15, // 2: ziti.mgmt_pb.StreamMetricsEvent.tags:type_name -> ziti.mgmt_pb.StreamMetricsEvent.TagsEntry - 16, // 3: ziti.mgmt_pb.StreamMetricsEvent.intMetrics:type_name -> ziti.mgmt_pb.StreamMetricsEvent.IntMetricsEntry - 17, // 4: ziti.mgmt_pb.StreamMetricsEvent.floatMetrics:type_name -> ziti.mgmt_pb.StreamMetricsEvent.FloatMetricsEntry - 18, // 5: ziti.mgmt_pb.StreamMetricsEvent.intervalMetrics:type_name -> ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric - 19, // 6: ziti.mgmt_pb.StreamMetricsEvent.metricGroup:type_name -> ziti.mgmt_pb.StreamMetricsEvent.MetricGroupEntry + 18, // 0: ziti.mgmt_pb.StreamMetricsRequest.matchers:type_name -> ziti.mgmt_pb.StreamMetricsRequest.MetricMatcher + 26, // 1: ziti.mgmt_pb.StreamMetricsEvent.timestamp:type_name -> google.protobuf.Timestamp + 19, // 2: ziti.mgmt_pb.StreamMetricsEvent.tags:type_name -> ziti.mgmt_pb.StreamMetricsEvent.TagsEntry + 20, // 3: ziti.mgmt_pb.StreamMetricsEvent.intMetrics:type_name -> ziti.mgmt_pb.StreamMetricsEvent.IntMetricsEntry + 21, // 4: ziti.mgmt_pb.StreamMetricsEvent.floatMetrics:type_name -> ziti.mgmt_pb.StreamMetricsEvent.FloatMetricsEntry + 22, // 5: ziti.mgmt_pb.StreamMetricsEvent.intervalMetrics:type_name -> ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric + 23, // 6: ziti.mgmt_pb.StreamMetricsEvent.metricGroup:type_name -> ziti.mgmt_pb.StreamMetricsEvent.MetricGroupEntry 2, // 7: ziti.mgmt_pb.StreamCircuitsEvent.eventType:type_name -> ziti.mgmt_pb.StreamCircuitEventType - 6, // 8: ziti.mgmt_pb.StreamCircuitsEvent.path:type_name -> ziti.mgmt_pb.Path + 7, // 8: ziti.mgmt_pb.StreamCircuitsEvent.path:type_name -> ziti.mgmt_pb.Path 3, // 9: ziti.mgmt_pb.StreamTracesRequest.filterType:type_name -> ziti.mgmt_pb.TraceFilterType - 21, // 10: ziti.mgmt_pb.InspectResponse.values:type_name -> ziti.mgmt_pb.InspectResponse.InspectValue - 12, // 11: ziti.mgmt_pb.RaftMemberListResponse.members:type_name -> ziti.mgmt_pb.RaftMember - 22, // 12: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.intervalStartUTC:type_name -> google.protobuf.Timestamp - 22, // 13: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.intervalEndUTC:type_name -> google.protobuf.Timestamp - 20, // 14: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.values:type_name -> ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.ValuesEntry - 15, // [15:15] is the sub-list for method output_type - 15, // [15:15] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name + 25, // 10: ziti.mgmt_pb.InspectResponse.values:type_name -> ziti.mgmt_pb.InspectResponse.InspectValue + 13, // 11: ziti.mgmt_pb.RaftMemberListResponse.members:type_name -> ziti.mgmt_pb.RaftMember + 4, // 12: ziti.mgmt_pb.TerminatorDetail.state:type_name -> ziti.mgmt_pb.TerminatorState + 26, // 13: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.intervalStartUTC:type_name -> google.protobuf.Timestamp + 26, // 14: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.intervalEndUTC:type_name -> google.protobuf.Timestamp + 24, // 15: ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.values:type_name -> ziti.mgmt_pb.StreamMetricsEvent.IntervalMetric.ValuesEntry + 16, // [16:16] is the sub-list for method output_type + 16, // [16:16] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_mgmt_proto_init() } @@ -1584,6 +1959,42 @@ func file_mgmt_proto_init() { } } file_mgmt_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ValidateTerminatorsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mgmt_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ValidateTerminatorsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mgmt_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TerminatorDetail); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mgmt_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StreamMetricsRequest_MetricMatcher); i { case 0: return &v.state @@ -1595,7 +2006,7 @@ func file_mgmt_proto_init() { return nil } } - file_mgmt_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_mgmt_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StreamMetricsEvent_IntervalMetric); i { case 0: return &v.state @@ -1607,7 +2018,7 @@ func file_mgmt_proto_init() { return nil } } - file_mgmt_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_mgmt_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InspectResponse_InspectValue); i { case 0: return &v.state @@ -1626,8 +2037,8 @@ func file_mgmt_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_mgmt_proto_rawDesc, - NumEnums: 4, - NumMessages: 18, + NumEnums: 5, + NumMessages: 21, NumExtensions: 0, NumServices: 0, }, diff --git a/common/pb/mgmt_pb/mgmt.proto b/common/pb/mgmt_pb/mgmt.proto index 204386dca..28efb9213 100644 --- a/common/pb/mgmt_pb/mgmt.proto +++ b/common/pb/mgmt_pb/mgmt.proto @@ -43,6 +43,11 @@ enum ContentType { RaftRemovePeerRequestType = 10083; RaftTransferLeadershipRequestType = 10084; RaftInitFromDb = 10085; + + // Validate + ValidateTerminatorsRequestType = 10100; + ValidateTerminatorResponseType = 10101; + ValidateTerminatorResultType = 10102; } enum Header { @@ -156,4 +161,38 @@ message RaftMember { message RaftMemberListResponse { repeated RaftMember members = 1; +} + +message ValidateTerminatorsRequest { + string filter = 1; + bool fixInvalid = 2; +} + +message ValidateTerminatorsResponse { + bool success = 1; + string message = 2; + uint64 terminatorCount = 3; +} + +enum TerminatorState { + Valid = 0; + Unknown = 1; + InvalidUnknownBinding = 2; + InvalidUnknownTerminator = 3; + InvalidBadState = 4; +} + +message TerminatorDetail { + string terminatorId = 1; + string serviceId = 2; + string serviceName = 3; + string routerId = 4; + string routerName = 5; + string binding = 6; + string address = 7; + string hostId = 8; + string createDate = 9; + TerminatorState state = 10; + bool fixed = 11; + string detail = 12; } \ No newline at end of file diff --git a/controller/api_impl/circuit_api_model.go b/controller/api_impl/circuit_api_model.go index f6e6de96e..0fc9bf0ca 100644 --- a/controller/api_impl/circuit_api_model.go +++ b/controller/api_impl/circuit_api_model.go @@ -17,7 +17,6 @@ package api_impl import ( - "github.com/go-openapi/strfmt" "github.com/openziti/ziti/controller/api" "github.com/openziti/ziti/controller/network" @@ -46,7 +45,7 @@ func (factory *CircuitLinkFactoryIml) Links(entity LinkEntity) rest_model.Links } func MapCircuitToRestModel(_ *network.Network, _ api.RequestContext, circuit *network.Circuit) (*rest_model.CircuitDetail, error) { - path := &rest_model.CircuitDetailPath{} + path := &rest_model.Path{} for _, node := range circuit.Path.Nodes { path.Nodes = append(path.Nodes, ToEntityRef(node.Name, node, RouterLinkFactory)) } @@ -54,14 +53,12 @@ func MapCircuitToRestModel(_ *network.Network, _ api.RequestContext, circuit *ne path.Links = append(path.Links, ToEntityRef(link.Id, link, LinkLinkFactory)) } - createdAt := strfmt.DateTime(circuit.CreatedAt) ret := &rest_model.CircuitDetail{ - ID: &circuit.Id, + BaseEntity: BaseEntityToRestModel(circuit, CircuitLinkFactory), ClientID: circuit.ClientId, Path: path, Service: ToEntityRef(circuit.Service.Name, circuit.Service, ServiceLinkFactory), Terminator: ToEntityRef(circuit.Terminator.GetId(), circuit.Terminator, TerminatorLinkFactory), - CreatedAt: &createdAt, } return ret, nil diff --git a/controller/api_impl/circuit_router.go b/controller/api_impl/circuit_router.go index 6cb9ef80a..964f15d2d 100644 --- a/controller/api_impl/circuit_router.go +++ b/controller/api_impl/circuit_router.go @@ -18,14 +18,13 @@ package api_impl import ( "github.com/go-openapi/runtime/middleware" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/controller/api" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/network" "github.com/openziti/ziti/controller/rest_model" "github.com/openziti/ziti/controller/rest_server/operations" "github.com/openziti/ziti/controller/rest_server/operations/circuit" - "github.com/openziti/storage/boltz" - "sort" ) func init() { @@ -59,10 +58,16 @@ func (r *CircuitRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper Re func (r *CircuitRouter) ListCircuits(n *network.Network, rc api.RequestContext) { ListWithEnvelopeFactory(rc, defaultToListEnvelope, func(rc api.RequestContext, queryOptions *PublicQueryOptions) (*QueryResult, error) { - circuits := n.GetAllCircuits() - sort.Slice(circuits, func(i, j int) bool { - return circuits[i].Id < circuits[j].Id - }) + query, err := queryOptions.getFullQuery(n.GetCircuitStore()) + if err != nil { + return nil, err + } + + circuits, count, err := n.GetCircuitStore().QueryEntitiesC(query) + if err != nil { + return nil, err + } + apiCircuits := make([]*rest_model.CircuitDetail, 0, len(circuits)) for _, modelCircuit := range circuits { apiCircuit, err := MapCircuitToRestModel(n, rc, modelCircuit) @@ -73,9 +78,9 @@ func (r *CircuitRouter) ListCircuits(n *network.Network, rc api.RequestContext) } result := &QueryResult{ Result: apiCircuits, - Count: int64(len(circuits)), - Limit: -1, - Offset: 0, + Count: count, + Limit: *query.GetLimit(), + Offset: *query.GetSkip(), FilterableFields: nil, } return result, nil diff --git a/controller/api_impl/link_router.go b/controller/api_impl/link_router.go index af3fcee87..910ee534d 100644 --- a/controller/api_impl/link_router.go +++ b/controller/api_impl/link_router.go @@ -18,6 +18,7 @@ package api_impl import ( "github.com/go-openapi/runtime/middleware" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/controller/api" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/fields" @@ -25,8 +26,6 @@ import ( "github.com/openziti/ziti/controller/rest_model" "github.com/openziti/ziti/controller/rest_server/operations" "github.com/openziti/ziti/controller/rest_server/operations/link" - "github.com/openziti/storage/boltz" - "sort" ) func init() { @@ -64,10 +63,16 @@ func (r *LinkRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper Reque func (r *LinkRouter) ListLinks(n *network.Network, rc api.RequestContext) { ListWithEnvelopeFactory(rc, defaultToListEnvelope, func(rc api.RequestContext, queryOptions *PublicQueryOptions) (*QueryResult, error) { - links := n.GetAllLinks() - sort.Slice(links, func(i, j int) bool { - return links[i].Id < links[j].Id - }) + query, err := queryOptions.getFullQuery(n.GetLinkStore()) + if err != nil { + return nil, err + } + + links, count, err := n.GetLinkStore().QueryEntitiesC(query) + if err != nil { + return nil, err + } + apiLinks := make([]*rest_model.LinkDetail, 0, len(links)) for _, modelLink := range links { apiLink, err := MapLinkToRestModel(n, rc, modelLink) @@ -78,9 +83,9 @@ func (r *LinkRouter) ListLinks(n *network.Network, rc api.RequestContext) { } result := &QueryResult{ Result: apiLinks, - Count: int64(len(links)), - Limit: -1, - Offset: 0, + Count: count, + Limit: *query.GetLimit(), + Offset: *query.GetSkip(), FilterableFields: nil, } return result, nil diff --git a/controller/api_impl/query_options.go b/controller/api_impl/query_options.go index 51fbf3c17..059ccfa79 100644 --- a/controller/api_impl/query_options.go +++ b/controller/api_impl/query_options.go @@ -43,18 +43,21 @@ func (qo *PublicQueryOptions) String() string { return fmt.Sprintf("[QueryOption Predicate: '%v', Sort: '%v', Paging: '%v']", qo.Predicate, qo.Sort, qo.Paging) } -func (qo *PublicQueryOptions) getFullQuery(store boltz.Store) (ast.Query, error) { +func (qo *PublicQueryOptions) getFullQuery(symbolTypes ast.SymbolTypes) (ast.Query, error) { if qo.Predicate == "" { qo.Predicate = "true" } - query, err := ast.Parse(store, qo.Predicate) + query, err := ast.Parse(symbolTypes, qo.Predicate) if err != nil { return nil, errorz.NewInvalidFilter(err) } - if err = boltz.ValidateSymbolsArePublic(query, store); err != nil { - return nil, errorz.NewInvalidFilter(err) + store, isStore := symbolTypes.(boltz.Store) + if isStore { + if err = boltz.ValidateSymbolsArePublic(query, store); err != nil { + return nil, errorz.NewInvalidFilter(err) + } } pfxlog.Logger().Debugf("query: %v", qo) @@ -78,13 +81,15 @@ func (qo *PublicQueryOptions) getFullQuery(store boltz.Store) (ast.Query, error) if len(sortFields) == 0 && qo.Sort != "" { sortQueryString := "true sort by " + qo.Sort - sortQuery, err := ast.Parse(store, sortQueryString) + sortQuery, err := ast.Parse(symbolTypes, sortQueryString) if err != nil { return nil, errorz.NewInvalidSort(err) } - if err = boltz.ValidateSymbolsArePublic(sortQuery, store); err != nil { - return nil, errorz.NewInvalidSort(err) + if isStore { + if err = boltz.ValidateSymbolsArePublic(sortQuery, store); err != nil { + return nil, errorz.NewInvalidSort(err) + } } if err = query.AdoptSortFields(sortQuery); err != nil { diff --git a/controller/change/context.go b/controller/change/context.go index b200ab9c0..b7364fe64 100644 --- a/controller/change/context.go +++ b/controller/change/context.go @@ -18,8 +18,8 @@ package change import ( "context" - "github.com/openziti/ziti/common/pb/cmd_pb" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/pb/cmd_pb" ) type ContextKeyType string @@ -51,6 +51,7 @@ const ( const ( SourceTypeControlChannel = "ctrl.channel" SourceTypeRest = "rest" + SourceTypeWebSocket = "websocket" SourceTypeXt = "xt" ) diff --git a/controller/persistence/api_session_certificate_store.go b/controller/db/api_session_certificate_store.go similarity index 99% rename from controller/persistence/api_session_certificate_store.go rename to controller/db/api_session_certificate_store.go index 6e74c894d..13d5fe9bf 100644 --- a/controller/persistence/api_session_certificate_store.go +++ b/controller/db/api_session_certificate_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/api_session_store.go b/controller/db/api_session_store.go similarity index 94% rename from controller/persistence/api_session_store.go rename to controller/db/api_session_store.go index e89d4c4c0..1aaad7937 100644 --- a/controller/persistence/api_session_store.go +++ b/controller/db/api_session_store.go @@ -14,16 +14,15 @@ limitations under the License. */ -package persistence +package db import ( "github.com/kataras/go-events" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/change" - "github.com/openziti/ziti/controller/db" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/change" "go.etcd.io/bbolt" "strings" "time" @@ -132,10 +131,10 @@ func (store *apiSessionStoreImpl) GetEventsEmitter() events.EventEmmiter { return store.eventsEmitter } -func (store *apiSessionStoreImpl) onEventualDelete(name string, apiSessionId []byte) { +func (store *apiSessionStoreImpl) onEventualDelete(db boltz.Db, name string, apiSessionId []byte) { idCollector := &sessionIdCollector{} - indexPath := []string{db.RootBucket, boltz.IndexesBucket, EntityTypeApiSessions, EntityTypeSessions} - err := store.stores.DbProvider.GetDb().View(func(tx *bbolt.Tx) error { + indexPath := []string{RootBucket, boltz.IndexesBucket, EntityTypeApiSessions, EntityTypeSessions} + err := db.View(func(tx *bbolt.Tx) error { path := append(indexPath, string(apiSessionId)) if bucket := boltz.Path(tx, path...); bucket != nil { boltz.Traverse(bucket.Bucket, "/"+strings.Join(path, "/"), idCollector) @@ -152,7 +151,7 @@ func (store *apiSessionStoreImpl) onEventualDelete(name string, apiSessionId []b for _, id := range idCollector.ids { changeContext := change.New().SetSourceType("events.emitter").SetChangeAuthorType(change.AuthorTypeController) - err = store.stores.DbProvider.GetDb().Update(changeContext.NewMutateContext(), func(ctx boltz.MutateContext) error { + err = db.Update(changeContext.NewMutateContext(), func(ctx boltz.MutateContext) error { if err := store.stores.session.DeleteById(ctx, id); err != nil { if boltz.IsErrNotFoundErr(err) { return nil @@ -172,7 +171,7 @@ func (store *apiSessionStoreImpl) onEventualDelete(name string, apiSessionId []b } changeContext := change.New().SetSourceType("events.emitter").SetChangeAuthorType(change.AuthorTypeController) - err = store.stores.DbProvider.GetDb().Update(changeContext.NewMutateContext(), func(ctx boltz.MutateContext) error { + err = db.Update(changeContext.NewMutateContext(), func(ctx boltz.MutateContext) error { if bucket := boltz.Path(ctx.Tx(), indexPath...); bucket != nil { if err := bucket.DeleteBucket(apiSessionId); err != nil { if err != bbolt.ErrBucketNotFound { @@ -264,7 +263,7 @@ func (store *apiSessionStoreImpl) LoadOneByToken(tx *bbolt.Tx, token string) (*A func (store *apiSessionStoreImpl) GetCachedSessionId(tx *bbolt.Tx, apiSessionId, sessionType, serviceId string) *string { bucket := boltz.Path(tx, - db.RootBucket, boltz.IndexesBucket, + RootBucket, boltz.IndexesBucket, EntityTypeApiSessions, EntityTypeSessions, apiSessionId, sessionType, ) diff --git a/controller/persistence/api_session_store_test.go b/controller/db/api_session_store_test.go similarity index 99% rename from controller/persistence/api_session_store_test.go rename to controller/db/api_session_store_test.go index 7f3c0ca2b..34fa8db7c 100644 --- a/controller/persistence/api_session_store_test.go +++ b/controller/db/api_session_store_test.go @@ -14,16 +14,16 @@ limitations under the License. */ -package persistence +package db import ( "fmt" "github.com/google/go-cmp/cmp" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/change" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/boltz" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/change" "go.etcd.io/bbolt" "testing" "time" diff --git a/controller/persistence/auth_policy_store.go b/controller/db/auth_policy_store.go similarity index 99% rename from controller/persistence/auth_policy_store.go rename to controller/db/auth_policy_store.go index a9abffcdc..1a1413628 100644 --- a/controller/persistence/auth_policy_store.go +++ b/controller/db/auth_policy_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/authenticator_store.go b/controller/db/authenticator_store.go similarity index 99% rename from controller/persistence/authenticator_store.go rename to controller/db/authenticator_store.go index aaf0cd0fc..eb24176fa 100644 --- a/controller/persistence/authenticator_store.go +++ b/controller/db/authenticator_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "fmt" diff --git a/controller/persistence/base_entity.go b/controller/db/base_entity.go similarity index 99% rename from controller/persistence/base_entity.go rename to controller/db/base_entity.go index 016e23502..0af89eda9 100644 --- a/controller/persistence/base_entity.go +++ b/controller/db/base_entity.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/db/base_store.go b/controller/db/base_store.go index f859e634c..dde2c136a 100644 --- a/controller/db/base_store.go +++ b/controller/db/base_store.go @@ -17,14 +17,129 @@ package db import ( + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "go.etcd.io/bbolt" + "strings" ) -const ( - FieldName = "name" -) +type initializableStore interface { + boltz.Store + initializeLocal() + initializeLinked() + initializeIndexes(tx *bbolt.Tx, errorHolder errorz.ErrorHolder) +} + +type Store[E boltz.ExtEntity] interface { + boltz.EntityStore[E] + initializableStore + LoadOneById(tx *bbolt.Tx, id string) (E, error) +} -type baseStore[T boltz.ExtEntity] struct { +type baseStore[E boltz.ExtEntity] struct { stores *stores - *boltz.BaseStore[T] + *boltz.BaseStore[E] +} + +func (store *baseStore[E]) addUniqueNameField() boltz.ReadIndex { + symbolName := store.AddSymbol(FieldName, ast.NodeTypeString) + return store.AddUniqueIndex(symbolName) +} + +func (store *baseStore[E]) initializeIndexes(tx *bbolt.Tx, errorHolder errorz.ErrorHolder) { + store.InitializeIndexes(tx, errorHolder) +} + +func (store *baseStore[E]) LoadOneById(tx *bbolt.Tx, id string) (E, error) { + entity := store.NewStoreEntity() + if err := store.baseLoadOneById(tx, id, entity); err != nil { + return *new(E), err + } + return entity, nil +} + +func (store *baseStore[E]) baseLoadOneById(tx *bbolt.Tx, id string, entity E) error { + found, err := store.LoadEntity(tx, id, entity) + if err != nil { + return err + } + if !found { + return boltz.NewNotFoundError(store.GetSingularEntityType(), "id", id) + } + return nil +} + +func (store *baseStore[E]) deleteEntityReferences(tx *bbolt.Tx, entity boltz.NamedExtEntity, rolesSymbol boltz.EntitySetSymbol) error { + idRef := entityRef(entity.GetId()) + + for _, policyHolderId := range store.GetRelatedEntitiesIdList(tx, entity.GetId(), rolesSymbol.GetStore().GetEntityType()) { + err := rolesSymbol.Map(tx, []byte(policyHolderId), func(ctx *boltz.MapContext) { + if ctx.ValueS() == idRef { + ctx.Delete() + } + }) + if err != nil { + return err + } + } + return nil +} + +func (store *baseStore[E]) getParentBucket(entity boltz.Entity, childBucket *boltz.TypedBucket) *boltz.TypedBucket { + parentBucket := store.GetParentStore().GetEntityBucket(childBucket.Tx(), []byte(entity.GetId())) + parentBucket.ErrorHolderImpl = childBucket.ErrorHolderImpl + return parentBucket +} + +type NameIndexed interface { + GetNameIndex() boltz.ReadIndex +} + +func (store *baseStore[E]) GetName(tx *bbolt.Tx, id string) *string { + symbol := store.GetSymbol(FieldName) + if symbol == nil { + return nil + } + _, val := symbol.Eval(tx, []byte(id)) + if val != nil { + result := string(val) + return &result + } + return nil +} + +func (store *baseStore[E]) getRoleAttributesCursorProvider(index boltz.SetReadIndex, values []string, semantic string) (ast.SetCursorProvider, error) { + if semantic == "" { + semantic = SemanticAllOf + } + + if !isSemanticValid(semantic) { + return nil, errorz.NewFieldError("invalid semantic", FieldSemantic, semantic) + } + + roles, ids, err := splitRolesAndIds(values) + if err != nil { + return nil, err + } + + return func(tx *bbolt.Tx, forward bool) ast.SetCursor { + validIds := ast.NewTreeSet(forward) + for _, id := range ids { + if store.IsEntityPresent(tx, id) { + validIds.Add([]byte(id)) + } + } + + var rolesCursor ast.SetCursor + if strings.EqualFold(semantic, SemanticAllOf) { + rolesCursor = store.IteratorMatchingAllOf(index, roles)(tx, forward) + } else { + rolesCursor = store.IteratorMatchingAnyOf(index, roles)(tx, forward) + } + if validIds.Size() == 0 { + return rolesCursor + } + return ast.NewUnionSetCursor(rolesCursor, validIds.ToCursor(), forward) + }, nil } diff --git a/controller/persistence/ca_store.go b/controller/db/ca_store.go similarity index 99% rename from controller/persistence/ca_store.go rename to controller/db/ca_store.go index 4a88f795c..6ebe2f54d 100644 --- a/controller/persistence/ca_store.go +++ b/controller/db/ca_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/config_store.go b/controller/db/config_store.go similarity index 97% rename from controller/persistence/config_store.go rename to controller/db/config_store.go index ec8b87145..1f34d73ab 100644 --- a/controller/persistence/config_store.go +++ b/controller/db/config_store.go @@ -14,14 +14,13 @@ limitations under the License. */ -package persistence +package db import ( - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" "go.etcd.io/bbolt" ) @@ -88,7 +87,7 @@ func (store *configStoreImpl) initializeLocal() { store.indexName = store.addUniqueNameField() store.symbolType = store.AddFkSymbol(FieldConfigType, store.stores.configType) store.AddMapSymbol(FieldConfigData, ast.NodeTypeAnyType, FieldConfigData) - store.symbolServices = store.AddFkSetSymbol(db.EntityTypeServices, store.stores.edgeService) + store.symbolServices = store.AddFkSetSymbol(EntityTypeServices, store.stores.edgeService) store.symbolIdentityServices = store.AddSetSymbol(FieldConfigIdentityService, ast.NodeTypeOther) store.identityServicesLinks = &boltz.LinkedSetSymbol{EntitySymbol: store.symbolIdentityServices} } diff --git a/controller/persistence/config_store_test.go b/controller/db/config_store_test.go similarity index 99% rename from controller/persistence/config_store_test.go rename to controller/db/config_store_test.go index 7d9ba8701..c61fbc8af 100644 --- a/controller/persistence/config_store_test.go +++ b/controller/db/config_store_test.go @@ -14,13 +14,13 @@ limitations under the License. */ -package persistence +package db import ( "encoding/json" "fmt" - "github.com/openziti/ziti/common/eid" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" "go.etcd.io/bbolt" "testing" "time" diff --git a/controller/persistence/config_type_store.go b/controller/db/config_type_store.go similarity index 99% rename from controller/persistence/config_type_store.go rename to controller/db/config_type_store.go index 63332f459..56345f14f 100644 --- a/controller/persistence/config_type_store.go +++ b/controller/db/config_type_store.go @@ -14,13 +14,13 @@ limitations under the License. */ -package persistence +package db import ( "encoding/json" - "github.com/openziti/ziti/common/eid" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" "github.com/pkg/errors" "go.etcd.io/bbolt" ) diff --git a/controller/persistence/config_type_store_test.go b/controller/db/config_type_store_test.go similarity index 99% rename from controller/persistence/config_type_store_test.go rename to controller/db/config_type_store_test.go index 27108fc84..27df91cf6 100644 --- a/controller/persistence/config_type_store_test.go +++ b/controller/db/config_type_store_test.go @@ -14,12 +14,12 @@ limitations under the License. */ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/common/eid" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" "go.etcd.io/bbolt" "testing" "time" diff --git a/controller/persistence/edge_router_policy_store.go b/controller/db/edge_router_policy_store.go similarity index 97% rename from controller/persistence/edge_router_policy_store.go rename to controller/db/edge_router_policy_store.go index 88850c9fb..b1cb6a14a 100644 --- a/controller/persistence/edge_router_policy_store.go +++ b/controller/db/edge_router_policy_store.go @@ -1,13 +1,12 @@ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" "sort" ) @@ -79,7 +78,7 @@ func (store *edgeRouterPolicyStoreImpl) initializeLocal() { store.symbolIdentityRoles = store.AddPublicSetSymbol(FieldIdentityRoles, ast.NodeTypeString) store.symbolEdgeRouterRoles = store.AddPublicSetSymbol(FieldEdgeRouterRoles, ast.NodeTypeString) store.symbolIdentities = store.AddFkSetSymbol(EntityTypeIdentities, store.stores.identity) - store.symbolEdgeRouters = store.AddFkSetSymbol(db.EntityTypeRouters, store.stores.edgeRouter) + store.symbolEdgeRouters = store.AddFkSetSymbol(EntityTypeRouters, store.stores.edgeRouter) store.AddConstraint(boltz.NewSystemEntityEnforcementConstraint(store)) } diff --git a/controller/persistence/edge_router_policy_store_test.go b/controller/db/edge_router_policy_store_test.go similarity index 98% rename from controller/persistence/edge_router_policy_store_test.go rename to controller/db/edge_router_policy_store_test.go index 6a8562478..b5d55c216 100644 --- a/controller/persistence/edge_router_policy_store_test.go +++ b/controller/db/edge_router_policy_store_test.go @@ -1,13 +1,12 @@ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/boltz" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" "github.com/sirupsen/logrus" "go.etcd.io/bbolt" "sort" @@ -36,7 +35,7 @@ func (ctx *TestContext) testCreateEdgeRouterPolicy(t *testing.T) { boltztest.ValidateBaseline(ctx, policy) err := ctx.GetDb().View(func(tx *bbolt.Tx) error { - ctx.Equal(0, len(ctx.stores.EdgeRouterPolicy.GetRelatedEntitiesIdList(tx, policy.Id, db.EntityTypeRouters))) + ctx.Equal(0, len(ctx.stores.EdgeRouterPolicy.GetRelatedEntitiesIdList(tx, policy.Id, EntityTypeRouters))) ctx.Equal(0, len(ctx.stores.EdgeRouterPolicy.GetRelatedEntitiesIdList(tx, policy.Id, EntityTypeIdentities))) testPolicy, err := ctx.stores.EdgeRouterPolicy.LoadOneById(tx, policy.Id) @@ -202,7 +201,7 @@ func (ctx *TestContext) testRouterIdentityDeleteTest(t *testing.T) { return nil } - c := ctx.stores.Identity.GetRefCountedLinkCollection(db.EntityTypeRouters) + c := ctx.stores.Identity.GetRefCountedLinkCollection(EntityTypeRouters) count := c.GetLinkCount(tx, []byte(edgeRouter.Id), []byte(edgeRouter.Id)) ctx.NotNil(count) ctx.Equal(int32(2), *count) @@ -300,7 +299,7 @@ func (ctx *TestContext) testEdgeRouterPolicyRoleEvaluation(t *testing.T) { policies := ctx.createEdgeRouterPolicies(identityRoles, edgeRouterRoles, identities, edgeRouters, true) for i := 0; i < 9; i++ { - relatedEdgeRouters := ctx.getRelatedIds(policies[i], db.EntityTypeRouters) + relatedEdgeRouters := ctx.getRelatedIds(policies[i], EntityTypeRouters) relatedIdentities := ctx.getRelatedIds(policies[i], EntityTypeIdentities) if i == 3 { ctx.Equal([]string{edgeRouters[0].Id}, relatedEdgeRouters) @@ -513,7 +512,7 @@ func (ctx *TestContext) validateEdgeRouterPolicyDenormalization() { func (ctx *TestContext) validateEdgeRouterPolicyEdgeRouters(edgeRouters []*EdgeRouter, policies []*EdgeRouterPolicy) { for _, policy := range policies { count := 0 - relatedEdgeRouters := ctx.getRelatedIds(policy, db.EntityTypeRouters) + relatedEdgeRouters := ctx.getRelatedIds(policy, EntityTypeRouters) for _, edgeRouter := range edgeRouters { relatedPolicies := ctx.getRelatedIds(edgeRouter, EntityTypeEdgeRouterPolicies) shouldContain := ctx.policyShouldMatch(policy.Semantic, policy.EdgeRouterRoles, edgeRouter, edgeRouter.RoleAttributes) diff --git a/controller/persistence/edge_router_store.go b/controller/db/edge_router_store.go similarity index 95% rename from controller/persistence/edge_router_store.go rename to controller/db/edge_router_store.go index 7851cf3af..a35ebbc0e 100644 --- a/controller/persistence/edge_router_store.go +++ b/controller/db/edge_router_store.go @@ -14,15 +14,14 @@ limitations under the License. */ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" "github.com/sirupsen/logrus" "go.etcd.io/bbolt" ) @@ -39,7 +38,7 @@ const ( func newEdgeRouter(name string, roleAttributes ...string) *EdgeRouter { return &EdgeRouter{ - Router: db.Router{ + Router: Router{ BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, Name: name, }, @@ -48,7 +47,7 @@ func newEdgeRouter(name string, roleAttributes ...string) *EdgeRouter { } type EdgeRouter struct { - db.Router + Router IsVerified bool `json:"isVerified"` CertPem *string `json:"certPem"` UnverifiedCertPem *string `json:"unverifiedCertPem"` @@ -80,10 +79,10 @@ func newEdgeRouterStore(stores *stores) *edgeRouterStoreImpl { } store := &edgeRouterStoreImpl{} - store.baseStore = newChildBaseStore[*EdgeRouter](stores, parentMapper, store, stores.Router, EdgeBucket) + store.baseStore = newChildBaseStore[*EdgeRouter](stores, parentMapper, store, stores.router, EdgeBucket) store.InitImpl(store) - stores.Router.RegisterChildStoreStrategy(store) // do cleanup first + stores.router.RegisterChildStoreStrategy(store) // do cleanup first return store } @@ -105,7 +104,7 @@ type edgeRouterStoreImpl struct { servicesCollection boltz.RefCountedLinkCollection } -func (store *edgeRouterStoreImpl) HandleUpdate(ctx boltz.MutateContext, entity *db.Router, checker boltz.FieldChecker) (bool, error) { +func (store *edgeRouterStoreImpl) HandleUpdate(ctx boltz.MutateContext, entity *Router, checker boltz.FieldChecker) (bool, error) { er, found, err := store.FindById(ctx.Tx(), entity.Id) if err != nil { return false, err @@ -118,7 +117,7 @@ func (store *edgeRouterStoreImpl) HandleUpdate(ctx boltz.MutateContext, entity * return true, store.Update(ctx, er, checker) } -func (store *edgeRouterStoreImpl) HandleDelete(ctx boltz.MutateContext, entity *db.Router) error { +func (store *edgeRouterStoreImpl) HandleDelete(ctx boltz.MutateContext, entity *Router) error { return store.cleanupEdgeRouter(ctx, entity.Id) } @@ -135,7 +134,7 @@ func (store *edgeRouterStoreImpl) initializeLocal() { store.symbolRoleAttributes = store.AddPublicSetSymbol(FieldRoleAttributes, ast.NodeTypeString) - store.indexName = store.GetParentStore().(db.RouterStore).GetNameIndex() + store.indexName = store.GetParentStore().(RouterStore).GetNameIndex() store.indexRoleAttributes = store.AddSetIndex(store.symbolRoleAttributes) store.AddSymbol(FieldEdgeRouterIsVerified, ast.NodeTypeBool) @@ -146,7 +145,7 @@ func (store *edgeRouterStoreImpl) initializeLocal() { store.symbolServiceEdgeRouterPolicies = store.AddFkSetSymbol(EntityTypeServiceEdgeRouterPolicies, store.stores.serviceEdgeRouterPolicy) store.symbolIdentities = store.AddFkSetSymbol(EntityTypeIdentities, store.stores.identity) - store.symbolServices = store.AddFkSetSymbol(db.EntityTypeServices, store.stores.edgeService) + store.symbolServices = store.AddFkSetSymbol(EntityTypeServices, store.stores.edgeService) store.indexRoleAttributes.AddListener(store.rolesChanged) } @@ -170,7 +169,7 @@ func (store *edgeRouterStoreImpl) NewEntity() *EdgeRouter { } func (store *edgeRouterStoreImpl) FillEntity(entity *EdgeRouter, bucket *boltz.TypedBucket) { - store.stores.Router.FillEntity(&entity.Router, store.getParentBucket(entity, bucket)) + store.stores.router.FillEntity(&entity.Router, store.getParentBucket(entity, bucket)) entity.CertPem = bucket.GetString(FieldEdgeRouterCertPEM) entity.IsVerified = bucket.GetBoolWithDefault(FieldEdgeRouterIsVerified, false) @@ -185,7 +184,7 @@ func (store *edgeRouterStoreImpl) FillEntity(entity *EdgeRouter, bucket *boltz.T } func (store *edgeRouterStoreImpl) PersistEntity(entity *EdgeRouter, ctx *boltz.PersistContext) { - store.stores.Router.PersistEntity(&entity.Router, ctx.GetParentContext()) + store.stores.router.PersistEntity(&entity.Router, ctx.GetParentContext()) ctx.SetStringP(FieldEdgeRouterCertPEM, entity.CertPem) ctx.SetBool(FieldEdgeRouterIsVerified, entity.IsVerified) diff --git a/controller/persistence/edge_router_store_test.go b/controller/db/edge_router_store_test.go similarity index 95% rename from controller/persistence/edge_router_store_test.go rename to controller/db/edge_router_store_test.go index 999a697ba..ea0ee11f2 100644 --- a/controller/persistence/edge_router_store_test.go +++ b/controller/db/edge_router_store_test.go @@ -1,8 +1,7 @@ -package persistence +package db import ( "github.com/google/uuid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/storage/boltz" "github.com/openziti/storage/boltztest" "testing" @@ -19,7 +18,7 @@ func Test_EdgeRouterEvents(t *testing.T) { fp := uuid.NewString() edgeRouter := &EdgeRouter{ - Router: db.Router{ + Router: Router{ BaseExtEntity: boltz.BaseExtEntity{ Id: uuid.NewString(), }, @@ -40,7 +39,7 @@ func Test_EdgeRouterEvents(t *testing.T) { boltztest.RequireUpdate(ctx, edgeRouter) entity := eventChecker.RequireEvent(boltz.TestEntityTypeParent, edgeRouter, boltz.EntityUpdated) - r, ok := entity.(*db.Router) + r, ok := entity.(*Router) ctx.True(ok) ctx.Equal(edgeRouter.Name, r.Name) ctx.NotNil(r.Fingerprint) @@ -62,7 +61,7 @@ func Test_EdgeRouterEvents(t *testing.T) { boltztest.RequireUpdate(ctx, &edgeRouter.Router) entity = eventChecker.RequireEvent(boltz.TestEntityTypeParent, edgeRouter, boltz.EntityUpdated) - r, ok = entity.(*db.Router) + r, ok = entity.(*Router) ctx.True(ok) ctx.Equal(edgeRouter.Name, r.Name) ctx.NotNil(r.Fingerprint) @@ -80,7 +79,7 @@ func Test_EdgeRouterEvents(t *testing.T) { boltztest.RequireUpdate(ctx, edgeRouter) entity = eventChecker.RequireEvent(boltz.TestEntityTypeParent, edgeRouter, boltz.EntityUpdated) - r, ok = entity.(*db.Router) + r, ok = entity.(*Router) ctx.True(ok) ctx.Equal(edgeRouter.Name, r.Name) ctx.Nil(edgeRouter.Fingerprint) @@ -101,7 +100,7 @@ func Test_EdgeRouterEvents(t *testing.T) { // check delete again, this time invoked from the child store fp = uuid.NewString() edgeRouter = &EdgeRouter{ - Router: db.Router{ + Router: Router{ BaseExtEntity: boltz.BaseExtEntity{ Id: uuid.NewString(), }, diff --git a/controller/persistence/edge_service_store.go b/controller/db/edge_service_store.go similarity index 95% rename from controller/persistence/edge_service_store.go rename to controller/db/edge_service_store.go index 1b5e05894..968f5726c 100644 --- a/controller/persistence/edge_service_store.go +++ b/controller/db/edge_service_store.go @@ -14,14 +14,13 @@ limitations under the License. */ -package persistence +package db import ( - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" "go.etcd.io/bbolt" ) @@ -32,7 +31,7 @@ const ( ) type EdgeService struct { - db.Service + Service RoleAttributes []string `json:"roleAttributes"` Configs []string `json:"configs"` EncryptionRequired bool `json:"encryptionRequired"` @@ -40,7 +39,7 @@ type EdgeService struct { func newEdgeService(name string, roleAttributes ...string) *EdgeService { return &EdgeService{ - Service: db.Service{ + Service: Service{ BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, Name: name, }, @@ -69,10 +68,10 @@ func newEdgeServiceStore(stores *stores) *edgeServiceStoreImpl { } store := &edgeServiceStoreImpl{} - store.baseStore = newChildBaseStore[*EdgeService](stores, parentMapper, store, stores.Service, EdgeBucket) + store.baseStore = newChildBaseStore[*EdgeService](stores, parentMapper, store, stores.service, EdgeBucket) store.InitImpl(store) - stores.Service.RegisterChildStoreStrategy(store) + stores.service.RegisterChildStoreStrategy(store) return store } @@ -98,7 +97,7 @@ type edgeServiceStoreImpl struct { edgeRoutersCollection boltz.RefCountedLinkCollection } -func (store *edgeServiceStoreImpl) HandleUpdate(ctx boltz.MutateContext, entity *db.Service, checker boltz.FieldChecker) (bool, error) { +func (store *edgeServiceStoreImpl) HandleUpdate(ctx boltz.MutateContext, entity *Service, checker boltz.FieldChecker) (bool, error) { edgeService, found, err := store.FindById(ctx.Tx(), entity.Id) if err != nil { return false, err @@ -111,7 +110,7 @@ func (store *edgeServiceStoreImpl) HandleUpdate(ctx boltz.MutateContext, entity return true, store.Update(ctx, edgeService, checker) } -func (store *edgeServiceStoreImpl) HandleDelete(ctx boltz.MutateContext, entity *db.Service) error { +func (store *edgeServiceStoreImpl) HandleDelete(ctx boltz.MutateContext, entity *Service) error { return store.cleanupEdgeService(ctx, entity.Id) } @@ -128,7 +127,7 @@ func (store *edgeServiceStoreImpl) initializeLocal() { store.symbolRoleAttributes = store.AddPublicSetSymbol(FieldRoleAttributes, ast.NodeTypeString) - store.indexName = store.GetParentStore().(db.ServiceStore).GetNameIndex() + store.indexName = store.GetParentStore().(ServiceStore).GetNameIndex() store.indexRoleAttributes = store.AddSetIndex(store.symbolRoleAttributes) store.symbolServiceEdgeRouterPolicies = store.AddFkSetSymbol(EntityTypeServiceEdgeRouterPolicies, store.stores.serviceEdgeRouterPolicy) @@ -160,7 +159,7 @@ func (self *edgeServiceStoreImpl) NewEntity() *EdgeService { } func (store *edgeServiceStoreImpl) FillEntity(entity *EdgeService, bucket *boltz.TypedBucket) { - store.stores.Service.FillEntity(&entity.Service, store.getParentBucket(entity, bucket)) + store.stores.service.FillEntity(&entity.Service, store.getParentBucket(entity, bucket)) entity.RoleAttributes = bucket.GetStringList(FieldRoleAttributes) entity.Configs = bucket.GetStringList(EntityTypeConfigs) @@ -170,7 +169,7 @@ func (store *edgeServiceStoreImpl) FillEntity(entity *EdgeService, bucket *boltz } func (store *edgeServiceStoreImpl) PersistEntity(entity *EdgeService, ctx *boltz.PersistContext) { - store.stores.Service.PersistEntity(&entity.Service, ctx.GetParentContext()) + store.stores.service.PersistEntity(&entity.Service, ctx.GetParentContext()) ctx.SetString(FieldName, entity.Name) store.validateRoleAttributes(entity.RoleAttributes, ctx.Bucket) diff --git a/controller/persistence/edge_service_store_test.go b/controller/db/edge_service_store_test.go similarity index 84% rename from controller/persistence/edge_service_store_test.go rename to controller/db/edge_service_store_test.go index 0397e1261..45a9c05e0 100644 --- a/controller/persistence/edge_service_store_test.go +++ b/controller/db/edge_service_store_test.go @@ -14,14 +14,13 @@ limitations under the License. */ -package persistence +package db import ( "fmt" + "github.com/openziti/storage/boltztest" "github.com/openziti/ziti/common/eid" "github.com/openziti/ziti/controller/change" - "github.com/openziti/ziti/controller/db" - "github.com/openziti/storage/boltztest" "testing" "time" @@ -36,16 +35,16 @@ func Test_EdgeServiceStore(t *testing.T) { defer ctx.Cleanup() ctx.Init() - t.Run("test service parent child relationship", ctx.testServiceParentChild) - t.Run("test create invalid api services", ctx.testCreateInvalidServices) - t.Run("test create service", ctx.testCreateServices) - t.Run("test load/query services", ctx.testLoadQueryServices) - t.Run("test update services", ctx.testUpdateServices) - t.Run("test delete services", ctx.testDeleteServices) + t.Run("test service parent child relationship", ctx.testEdgeServiceParentChild) + t.Run("test create invalid api services", ctx.testCreateInvalidEdgeServices) + t.Run("test create service", ctx.testCreateEdgeServices) + t.Run("test load/query services", ctx.testLoadQueryEdgeServices) + t.Run("test update services", ctx.testUpdateEdgeServices) + t.Run("test delete services", ctx.testDeleteEdgeServices) } -func (ctx *TestContext) testServiceParentChild(_ *testing.T) { - fabricService := &db.Service{ +func (ctx *TestContext) testEdgeServiceParentChild(_ *testing.T) { + fabricService := &Service{ BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, Name: eid.New(), } @@ -71,7 +70,7 @@ func (ctx *TestContext) testServiceParentChild(_ *testing.T) { // //err = ctx.GetDb().View(func(tx *bbolt.Tx) error { // query := fmt.Sprintf(`id = "%v" and name = "%v"`, fabricService.Id, edgeService.Name) - // ids, _, err := ctx.stores.EdgeService.QueryIds(tx, query) + // ids, _, err := ctx.stores.EdgeService.QueryEntities(tx, query) // if err != nil { // return err // } @@ -82,7 +81,7 @@ func (ctx *TestContext) testServiceParentChild(_ *testing.T) { //ctx.NoError(err) } -func (ctx *TestContext) testCreateInvalidServices(_ *testing.T) { +func (ctx *TestContext) testCreateInvalidEdgeServices(_ *testing.T) { defer ctx.CleanupAll() identity := ctx.RequireNewIdentity("test-user", false) @@ -90,7 +89,7 @@ func (ctx *TestContext) testCreateInvalidServices(_ *testing.T) { boltztest.RequireCreate(ctx, apiSession) edgeService := &EdgeService{ - Service: db.Service{ + Service: Service{ BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, Name: eid.New(), }, @@ -111,11 +110,11 @@ func (ctx *TestContext) testCreateInvalidServices(_ *testing.T) { ctx.EqualError(err, fmt.Sprintf("terminatorStrategy with name %v not found", edgeService.TerminatorStrategy)) } -func (ctx *TestContext) testCreateServices(_ *testing.T) { +func (ctx *TestContext) testCreateEdgeServices(_ *testing.T) { defer ctx.CleanupAll() edgeService := &EdgeService{ - Service: db.Service{ + Service: Service{ BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, Name: eid.New(), }, @@ -124,7 +123,7 @@ func (ctx *TestContext) testCreateServices(_ *testing.T) { boltztest.ValidateBaseline(ctx, edgeService) } -type serviceTestEntities struct { +type edgeServiceTestEntities struct { servicePolicy *ServicePolicy identity1 *Identity apiSession1 *ApiSession @@ -134,7 +133,7 @@ type serviceTestEntities struct { session2 *Session } -func (ctx *TestContext) createServiceTestEntities() *serviceTestEntities { +func (ctx *TestContext) createEdgeServiceTestEntities() *edgeServiceTestEntities { identity1 := ctx.RequireNewIdentity("admin1", true) apiSession1 := NewApiSession(identity1.Id) @@ -145,7 +144,7 @@ func (ctx *TestContext) createServiceTestEntities() *serviceTestEntities { servicePolicy := ctx.requireNewServicePolicy(PolicyTypeDial, ss(), ss(roleRef(role))) service1 := &EdgeService{ - Service: db.Service{ + Service: Service{ BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, Name: eid.New(), }, @@ -165,7 +164,7 @@ func (ctx *TestContext) createServiceTestEntities() *serviceTestEntities { session2 := NewSession(apiSession1.Id, service2.Id) boltztest.RequireCreate(ctx, session2) - return &serviceTestEntities{ + return &edgeServiceTestEntities{ servicePolicy: servicePolicy, identity1: identity1, apiSession1: apiSession1, @@ -176,10 +175,10 @@ func (ctx *TestContext) createServiceTestEntities() *serviceTestEntities { } } -func (ctx *TestContext) testLoadQueryServices(_ *testing.T) { +func (ctx *TestContext) testLoadQueryEdgeServices(_ *testing.T) { ctx.CleanupAll() - entities := ctx.createServiceTestEntities() + entities := ctx.createEdgeServiceTestEntities() err := ctx.GetDb().View(func(tx *bbolt.Tx) error { service, err := ctx.stores.EdgeService.LoadOneById(tx, entities.service1.Id) @@ -209,9 +208,9 @@ func (ctx *TestContext) testLoadQueryServices(_ *testing.T) { ctx.NoError(err) } -func (ctx *TestContext) testUpdateServices(_ *testing.T) { +func (ctx *TestContext) testUpdateEdgeServices(_ *testing.T) { ctx.CleanupAll() - entities := ctx.createServiceTestEntities() + entities := ctx.createEdgeServiceTestEntities() earlier := time.Now() time.Sleep(time.Millisecond * 50) @@ -248,9 +247,9 @@ func (ctx *TestContext) testUpdateServices(_ *testing.T) { ctx.NoError(err) } -func (ctx *TestContext) testDeleteServices(_ *testing.T) { +func (ctx *TestContext) testDeleteEdgeServices(_ *testing.T) { ctx.CleanupAll() - entities := ctx.createServiceTestEntities() + entities := ctx.createEdgeServiceTestEntities() boltztest.RequireDelete(ctx, entities.service1, apiSessionsSessionsIdxPath) boltztest.RequireDelete(ctx, entities.service2, apiSessionsSessionsIdxPath) } diff --git a/controller/persistence/enrollment_store.go b/controller/db/enrollment_store.go similarity index 99% rename from controller/persistence/enrollment_store.go rename to controller/db/enrollment_store.go index 6dd236004..06a5ad9e9 100644 --- a/controller/persistence/enrollment_store.go +++ b/controller/db/enrollment_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/eventual_event_store.go b/controller/db/eventual_event_store.go similarity index 99% rename from controller/persistence/eventual_event_store.go rename to controller/db/eventual_event_store.go index e8e892894..4bb8476c8 100644 --- a/controller/persistence/eventual_event_store.go +++ b/controller/db/eventual_event_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/eventual_eventer.go b/controller/db/eventual_eventer.go similarity index 97% rename from controller/persistence/eventual_eventer.go rename to controller/db/eventual_eventer.go index 6da91e45b..805853bad 100644 --- a/controller/persistence/eventual_eventer.go +++ b/controller/db/eventual_eventer.go @@ -14,15 +14,15 @@ limitations under the License. */ -package persistence +package db import ( "fmt" "github.com/kataras/go-events" "github.com/lucsky/cuid" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/change" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/change" cmap "github.com/orcaman/concurrent-map/v2" "github.com/pkg/errors" "go.etcd.io/bbolt" @@ -74,7 +74,7 @@ type EventualEventer interface { } // EventListenerFunc is a function handler that will be triggered asynchronously some point in the future -type EventListenerFunc func(name string, data []byte) +type EventListenerFunc func(db boltz.Db, name string, data []byte) type EventualEventAdded struct { // Id is a unique id for the event created @@ -287,10 +287,10 @@ type EventualEventerBbolt struct { waiters sync.Map //id -> chan struct{} - running atomic.Bool - batchSize int - dbProvider DbProvider - store EventualEventStore + running atomic.Bool + batchSize int + db DbProvider + store EventualEventStore } var _ EventualEventer = &EventualEventerBbolt{} @@ -303,7 +303,7 @@ func NewEventualEventerBbolt(dbProvider DbProvider, store EventualEventStore, in result := &EventualEventerBbolt{ EventEmmiter: events.New(), Interval: interval, - dbProvider: dbProvider, + db: dbProvider, store: store, batchSize: batchSize, trigger: make(chan struct{}, 1), @@ -315,7 +315,7 @@ func NewEventualEventerBbolt(dbProvider DbProvider, store EventualEventStore, in } func (a *EventualEventerBbolt) initOutstandingEventCount() { - err := a.dbProvider.GetDb().View(func(tx *bbolt.Tx) error { + err := a.db.GetDb().View(func(tx *bbolt.Tx) error { _, count, err := a.store.QueryIds(tx, "true limit 1") if err != nil { return err @@ -349,7 +349,7 @@ func (a *EventualEventerBbolt) AddEventualEventWithCtx(ctx boltz.MutateContext, var err error if ctx == nil { ctx = change.New().SetSourceType("eventual.eventer").SetChangeAuthorType(change.AuthorTypeController).NewMutateContext() - err = a.dbProvider.GetDb().Update(ctx, func(ctx boltz.MutateContext) error { + err = a.db.GetDb().Update(ctx, func(ctx boltz.MutateContext) error { return a.store.Create(ctx, event) }) } else { @@ -439,7 +439,7 @@ func (a *EventualEventerBbolt) Trigger() (<-chan struct{}, error) { // deleteEventualEvent removes an eventual event by id from the bbolt backend store. func (a *EventualEventerBbolt) deleteEventualEvent(id string) error { ctx := change.New().SetSourceType("eventual.eventer").SetChangeAuthorType(change.AuthorTypeController).NewMutateContext() - err := a.dbProvider.GetDb().Update(ctx, func(ctx boltz.MutateContext) error { + err := a.db.GetDb().Update(ctx, func(ctx boltz.MutateContext) error { return a.store.DeleteById(ctx, id) }) @@ -480,7 +480,7 @@ func (a *EventualEventerBbolt) notifyWaiters() { func (a *EventualEventerBbolt) getEventualEvents() ([]string, []*EventualEvent, error) { var ids []string var eventualEvents []*EventualEvent - err := a.dbProvider.GetDb().View(func(tx *bbolt.Tx) error { + err := a.db.GetDb().View(func(tx *bbolt.Tx) error { var err error ids, _, err = a.store.QueryIds(tx, fmt.Sprintf("limit %d", a.batchSize)) @@ -705,5 +705,5 @@ func (a *EventualEventerBbolt) executeHandler(info *runInfo, eventualEvent *Even StartTime: startTime, }) - handler(eventualEvent.Type, eventualEvent.Data) + handler(a.db.GetDb(), eventualEvent.Type, eventualEvent.Data) } diff --git a/controller/persistence/external_jwt_signer_store.go b/controller/db/external_jwt_signer_store.go similarity index 99% rename from controller/persistence/external_jwt_signer_store.go rename to controller/db/external_jwt_signer_store.go index d71e51610..71a968708 100644 --- a/controller/persistence/external_jwt_signer_store.go +++ b/controller/db/external_jwt_signer_store.go @@ -14,14 +14,14 @@ limitations under the License. */ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/controller/apierror" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/apierror" "strings" "time" ) diff --git a/controller/persistence/generate_symbols_test.go b/controller/db/generate_symbols_test.go similarity index 94% rename from controller/persistence/generate_symbols_test.go rename to controller/db/generate_symbols_test.go index 1b8ecf910..b5c15bcb6 100644 --- a/controller/persistence/generate_symbols_test.go +++ b/controller/db/generate_symbols_test.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "fmt" diff --git a/controller/persistence/identity_store.go b/controller/db/identity_store.go similarity index 98% rename from controller/persistence/identity_store.go rename to controller/db/identity_store.go index 7aa700518..991a57318 100644 --- a/controller/persistence/identity_store.go +++ b/controller/db/identity_store.go @@ -14,16 +14,15 @@ limitations under the License. */ -package persistence +package db import ( "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" "github.com/pkg/errors" "go.etcd.io/bbolt" "strings" @@ -184,7 +183,7 @@ func (store *identityStoreImpl) initializeLocal() { store.indexRoleAttributes = store.AddSetIndex(store.symbolRoleAttributes) store.indexName = store.addUniqueNameField() - store.symbolEdgeRouters = store.AddFkSetSymbol(db.EntityTypeRouters, store.stores.edgeRouter) + store.symbolEdgeRouters = store.AddFkSetSymbol(EntityTypeRouters, store.stores.edgeRouter) store.symbolBindServices = store.AddFkSetSymbol(FieldIdentityBindServices, store.stores.edgeService) store.symbolDialServices = store.AddFkSetSymbol(FieldIdentityDialServices, store.stores.edgeService) store.symbolEdgeRouterPolicies = store.AddFkSetSymbol(EntityTypeEdgeRouterPolicies, store.stores.edgeRouterPolicy) @@ -318,7 +317,7 @@ func (store *identityStoreImpl) PersistEntity(entity *Identity, ctx *boltz.Persi ctx.SetString(FieldIdentitySdkInfoAppVersion, entity.SdkInfo.AppVersion) } - serviceStore := store.stores.Service + serviceStore := store.stores.service if ctx.ProceedWithSet(FieldIdentityServiceHostingPrecedences) { mapBucket, err := ctx.Bucket.EmptyBucket(FieldIdentityServiceHostingPrecedences) @@ -399,7 +398,7 @@ func (store *identityStoreImpl) DeleteById(ctx boltz.MutateContext, id string) e } if entity.IdentityTypeId == RouterIdentityType { if !ctx.IsSystemContext() { - router, err := store.stores.Router.FindByName(ctx.Tx(), entity.Name) + router, err := store.stores.router.FindByName(ctx.Tx(), entity.Name) if err != nil { return errorz.NewEntityCanNotBeDeletedFrom(err) } diff --git a/controller/persistence/identity_store_test.go b/controller/db/identity_store_test.go similarity index 99% rename from controller/persistence/identity_store_test.go rename to controller/db/identity_store_test.go index 7e10e3966..db35c7c5d 100644 --- a/controller/persistence/identity_store_test.go +++ b/controller/db/identity_store_test.go @@ -1,11 +1,11 @@ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/change" "github.com/openziti/storage/boltz" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/change" "github.com/pkg/errors" "go.etcd.io/bbolt" "testing" diff --git a/controller/persistence/identity_type_store.go b/controller/db/identity_type_store.go similarity index 99% rename from controller/persistence/identity_type_store.go rename to controller/db/identity_type_store.go index 9a8d6387e..03f4d89c0 100644 --- a/controller/persistence/identity_type_store.go +++ b/controller/db/identity_type_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/mfa_store.go b/controller/db/mfa_store.go similarity index 99% rename from controller/persistence/mfa_store.go rename to controller/db/mfa_store.go index a1a4cec52..e72cac583 100644 --- a/controller/persistence/mfa_store.go +++ b/controller/db/mfa_store.go @@ -14,12 +14,12 @@ limitations under the License. */ -package persistence +package db import ( "github.com/google/uuid" - "github.com/openziti/ziti/common/eid" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" ) const ( diff --git a/controller/db/migration.go b/controller/db/migration.go index e92fe97a4..d2ba512c8 100644 --- a/controller/db/migration.go +++ b/controller/db/migration.go @@ -1,167 +1,9 @@ package db import ( - "github.com/openziti/ziti/controller/xt_smartrouting" - "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" - "github.com/pkg/errors" - log "github.com/sirupsen/logrus" - "strings" - "time" ) -const CurrentDbVersion = 5 - -func (stores *stores) migrate(step *boltz.MigrationStep) int { - if step.CurrentVersion > CurrentDbVersion { - step.SetError(errors.Errorf("unsupported fabric datastore version: %v", step.CurrentVersion)) - return 0 - } - - if step.CurrentVersion < 1 { - stores.migrateToV1(step) - } - - if step.CurrentVersion < 2 { - stores.extractTerminators(step) - } - - if step.CurrentVersion < 3 { - stores.setNames(step, stores.service) - stores.setNames(step, stores.router) - } - - if step.CurrentVersion < 4 { - stores.fixNameIndexes(step) - } - - if step.CurrentVersion < 5 { - stores.migrateTerminatorIdentityFields(step) - } - - if step.CurrentVersion <= CurrentDbVersion { - return CurrentDbVersion - } - - step.SetError(errors.Errorf("unsupported fabric datastore version: %v", step.CurrentVersion)) - return 0 -} - -func (stores *stores) migrateToV1(step *boltz.MigrationStep) { - now := time.Now() - stores.initCreatedAtUpdatedAt(step, now, stores.service) - stores.initCreatedAtUpdatedAt(step, now, stores.router) -} - -func (stores *stores) initCreatedAtUpdatedAt(step *boltz.MigrationStep, now time.Time, store boltz.Store) { - ids, _, err := store.QueryIds(step.Ctx.Tx(), "true") - step.SetError(err) - for _, id := range ids { - entityBucket := store.GetEntityBucket(step.Ctx.Tx(), []byte(id)) - if entityBucket == nil { - step.SetError(errors.Errorf("could not get entity bucket for %v with id %v", store.GetSingularEntityType(), id)) - return - } - entityBucket.SetTime(boltz.FieldCreatedAt, now, nil) - entityBucket.SetTime(boltz.FieldUpdatedAt, now, nil) - if step.SetError(entityBucket.GetError()) { - return - } - } -} - -func (stores *stores) setNames(step *boltz.MigrationStep, store boltz.Store) { - ids, _, err := store.QueryIds(step.Ctx.Tx(), "true") - step.SetError(err) - for _, id := range ids { - entityBucket := store.GetEntityBucket(step.Ctx.Tx(), []byte(id)) - if entityBucket == nil { - step.SetError(errors.Errorf("could not get entity bucket for %v with id %v", store.GetSingularEntityType(), id)) - return - } - if name := entityBucket.GetString(FieldName); name == nil || len(*name) == 0 { - entityBucket.SetString(FieldName, id, nil) - step.SetError(entityBucket.GetError()) - } - } -} - -func (stores *stores) fixNameIndexes(step *boltz.MigrationStep) { - c := stores.service.indexName.(boltz.Constraint) - step.SetError(c.CheckIntegrity(step.Ctx, true, func(err error, fixed bool) { - log.WithError(err).Debugf("Fixing service name index. Fixed? %v", fixed) - })) - - c = stores.router.indexName.(boltz.Constraint) - step.SetError(c.CheckIntegrity(step.Ctx, true, func(err error, fixed bool) { - log.WithError(err).Debugf("Fixing router name index. Fixed? %v", fixed) - })) -} - -const ( - FieldServiceEgress = "egress" - FieldServiceBinding = "binding" - FieldServiceEndpoint = "endpoint" -) - -func (stores *stores) extractTerminators(step *boltz.MigrationStep) { - serviceIds, _, err := stores.service.QueryIds(step.Ctx.Tx(), "true") - step.SetError(err) - - symbolEgress := stores.service.AddSymbol(FieldServiceEgress, ast.NodeTypeString) - symbolBinding := stores.service.AddSymbol(FieldServiceBinding, ast.NodeTypeString) - symbolEndpoint := stores.service.AddSymbol(FieldServiceEndpoint, ast.NodeTypeString) - - for _, serviceId := range serviceIds { - service, _, err := stores.service.FindById(step.Ctx.Tx(), serviceId) - if step.SetError(err) { - return - } - - if service.TerminatorStrategy == "" { - service.TerminatorStrategy = xt_smartrouting.Name - if step.SetError(stores.service.Update(step.Ctx, service, nil)) { - return - } - } - - hasTerminators := stores.service.GetRelatedEntitiesCursor(step.Ctx.Tx(), serviceId, EntityTypeTerminators, true).IsValid() - if hasTerminators { - continue - } - routerId := boltz.FieldToString(symbolEgress.Eval(step.Ctx.Tx(), []byte(serviceId))) - binding := boltz.FieldToString(symbolBinding.Eval(step.Ctx.Tx(), []byte(serviceId))) - address := boltz.FieldToString(symbolEndpoint.Eval(step.Ctx.Tx(), []byte(serviceId))) - - if routerId == nil || *routerId == "" || !stores.router.IsEntityPresent(step.Ctx.Tx(), *routerId) { - continue - } - - if address == nil || *address == "" { - continue - } - - if binding == nil || *binding == "" { - if strings.HasPrefix(*address, "udp:") { - val := "udp" - binding = &val - } else { - val := "transport" - binding = &val - } - } - - terminator := &Terminator{ - Service: serviceId, - Router: *routerId, - Binding: *binding, - Address: *address, - } - - step.SetError(stores.terminator.Create(step.Ctx, terminator)) - } -} - func (stores *stores) migrateTerminatorIdentityFields(step *boltz.MigrationStep) { terminatorIds, _, err := stores.terminator.QueryIds(step.Ctx.Tx(), "true") step.SetError(err) diff --git a/controller/persistence/migration_initialize.go b/controller/db/migration_initialize.go similarity index 99% rename from controller/persistence/migration_initialize.go rename to controller/db/migration_initialize.go index 5fe97bf5e..61eeaf3e9 100644 --- a/controller/persistence/migration_initialize.go +++ b/controller/db/migration_initialize.go @@ -14,18 +14,17 @@ limitations under the License. */ -package persistence +package db import ( "fmt" "github.com/openziti/storage/boltz" - "github.com/openziti/ziti/controller/db" "math" "time" ) func (m *Migrations) initialize(step *boltz.MigrationStep) int { - versionBucket := boltz.GetOrCreatePath(step.Ctx.Tx(), db.RootBucket) + versionBucket := boltz.GetOrCreatePath(step.Ctx.Tx(), RootBucket) if step.SetError(versionBucket.GetError()) { return 0 } diff --git a/controller/persistence/migration_v14.go b/controller/db/migration_v14.go similarity index 97% rename from controller/persistence/migration_v14.go rename to controller/db/migration_v14.go index e763cf6e4..85130c283 100644 --- a/controller/persistence/migration_v14.go +++ b/controller/db/migration_v14.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/migration_v16.go b/controller/db/migration_v16.go similarity index 98% rename from controller/persistence/migration_v16.go rename to controller/db/migration_v16.go index 0a160364b..5894f9041 100644 --- a/controller/persistence/migration_v16.go +++ b/controller/db/migration_v16.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "fmt" diff --git a/controller/persistence/migration_v17.go b/controller/db/migration_v17.go similarity index 83% rename from controller/persistence/migration_v17.go rename to controller/db/migration_v17.go index 66ce4c9ad..633b77cce 100644 --- a/controller/persistence/migration_v17.go +++ b/controller/db/migration_v17.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "fmt" @@ -6,8 +6,8 @@ import ( "github.com/openziti/storage/boltz" ) -//Removes all ApiSession and Session from the edge. Necessary from 0.18 -> 0.19 -//as the id format changed and API Session sync'ing depends on monotonic ids. +// Removes all ApiSession and Session from the edge. Necessary from 0.18 -> 0.19 +// as the id format changed and API Session sync'ing depends on monotonic ids. func (m *Migrations) removeAllSessions(step *boltz.MigrationStep) { for cursor := m.stores.Session.IterateIds(step.Ctx.Tx(), ast.BoolNodeTrue); cursor.IsValid(); cursor.Next() { current := cursor.Current() diff --git a/controller/persistence/migration_v18.go b/controller/db/migration_v18.go similarity index 97% rename from controller/persistence/migration_v18.go rename to controller/db/migration_v18.go index 98f191451..d99b96ed3 100644 --- a/controller/persistence/migration_v18.go +++ b/controller/db/migration_v18.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/migration_v19.go b/controller/db/migration_v19.go similarity index 99% rename from controller/persistence/migration_v19.go rename to controller/db/migration_v19.go index 09b18d480..189665ecf 100644 --- a/controller/persistence/migration_v19.go +++ b/controller/db/migration_v19.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/migration_v23.go b/controller/db/migration_v23.go similarity index 97% rename from controller/persistence/migration_v23.go rename to controller/db/migration_v23.go index d25f7d5cf..a7163662b 100644 --- a/controller/persistence/migration_v23.go +++ b/controller/db/migration_v23.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/migration_v24.go b/controller/db/migration_v24.go similarity index 98% rename from controller/persistence/migration_v24.go rename to controller/db/migration_v24.go index 62412896b..a043c2af2 100644 --- a/controller/persistence/migration_v24.go +++ b/controller/db/migration_v24.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "fmt" diff --git a/controller/persistence/migration_v25.go b/controller/db/migration_v25.go similarity index 98% rename from controller/persistence/migration_v25.go rename to controller/db/migration_v25.go index b4c77ad98..8dce99016 100644 --- a/controller/persistence/migration_v25.go +++ b/controller/db/migration_v25.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/migration_v33.go b/controller/db/migration_v33.go similarity index 98% rename from controller/persistence/migration_v33.go rename to controller/db/migration_v33.go index 5878e9b46..020edd8af 100644 --- a/controller/persistence/migration_v33.go +++ b/controller/db/migration_v33.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/migrations.go b/controller/db/migrations.go similarity index 93% rename from controller/persistence/migrations.go rename to controller/db/migrations.go index 235b7e3a8..92557c85f 100644 --- a/controller/persistence/migrations.go +++ b/controller/db/migrations.go @@ -14,12 +14,11 @@ limitations under the License. */ -package persistence +package db import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/storage/boltz" - "github.com/openziti/ziti/controller/db" "github.com/pkg/errors" ) @@ -128,6 +127,11 @@ func (m *Migrations) migrate(step *boltz.MigrationStep) int { if step.CurrentVersion < 29 { m.dropEntity(step, "geoRegions") m.dropEntity(step, "eventLogs") + + // migrateTerminatorIdentityFields was first added in fabric 0.19.0, which was released in 0.26.0 + // The change to remove event logs and geolocations was done in edge v0.22.7 was also released in 0.26.0 + // so we can call this in the same version update + m.stores.internal.migrateTerminatorIdentityFields(step) } if step.CurrentVersion < 30 { @@ -171,7 +175,7 @@ func (m *Migrations) migrate(step *boltz.MigrationStep) int { } func (m *Migrations) dropEntity(step *boltz.MigrationStep, entityType string) { - rootBucket := step.Ctx.Tx().Bucket([]byte(db.RootBucket)) + rootBucket := step.Ctx.Tx().Bucket([]byte(RootBucket)) if rootBucket == nil { return } diff --git a/controller/persistence/policy_common.go b/controller/db/policy_common.go similarity index 99% rename from controller/persistence/policy_common.go rename to controller/db/policy_common.go index 0ab1f9b10..7607d3ac9 100644 --- a/controller/persistence/policy_common.go +++ b/controller/db/policy_common.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "bytes" diff --git a/controller/persistence/posture_check_mac.go b/controller/db/posture_check_mac.go similarity index 98% rename from controller/persistence/posture_check_mac.go rename to controller/db/posture_check_mac.go index 148af077d..ba2de13c4 100644 --- a/controller/persistence/posture_check_mac.go +++ b/controller/db/posture_check_mac.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/posture_check_mfa.go b/controller/db/posture_check_mfa.go similarity index 99% rename from controller/persistence/posture_check_mfa.go rename to controller/db/posture_check_mfa.go index 75c7e0b1e..71cfb5562 100644 --- a/controller/persistence/posture_check_mfa.go +++ b/controller/db/posture_check_mfa.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/posture_check_os.go b/controller/db/posture_check_os.go similarity index 99% rename from controller/persistence/posture_check_os.go rename to controller/db/posture_check_os.go index d298dc524..5a002f2f0 100644 --- a/controller/persistence/posture_check_os.go +++ b/controller/db/posture_check_os.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/michaelquigley/pfxlog" diff --git a/controller/persistence/posture_check_process.go b/controller/db/posture_check_process.go similarity index 99% rename from controller/persistence/posture_check_process.go rename to controller/db/posture_check_process.go index ff2e5042c..82cd460b1 100644 --- a/controller/persistence/posture_check_process.go +++ b/controller/db/posture_check_process.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/posture_check_process_multi.go b/controller/db/posture_check_process_multi.go similarity index 99% rename from controller/persistence/posture_check_process_multi.go rename to controller/db/posture_check_process_multi.go index 4d8839432..0de2ed5f1 100644 --- a/controller/persistence/posture_check_process_multi.go +++ b/controller/db/posture_check_process_multi.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/michaelquigley/pfxlog" diff --git a/controller/persistence/posture_check_store.go b/controller/db/posture_check_store.go similarity index 99% rename from controller/persistence/posture_check_store.go rename to controller/db/posture_check_store.go index 472ed6c6a..8e8890e6f 100644 --- a/controller/persistence/posture_check_store.go +++ b/controller/db/posture_check_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/michaelquigley/pfxlog" diff --git a/controller/persistence/posture_check_type_store.go b/controller/db/posture_check_type_store.go similarity index 99% rename from controller/persistence/posture_check_type_store.go rename to controller/db/posture_check_type_store.go index a6dd17d1a..d4ec0e4fa 100644 --- a/controller/persistence/posture_check_type_store.go +++ b/controller/db/posture_check_type_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/posture_check_windows_domain.go b/controller/db/posture_check_windows_domain.go similarity index 98% rename from controller/persistence/posture_check_windows_domain.go rename to controller/db/posture_check_windows_domain.go index 5ecc24c05..ffc4d2356 100644 --- a/controller/persistence/posture_check_windows_domain.go +++ b/controller/db/posture_check_windows_domain.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/boltz" diff --git a/controller/persistence/revocation_store.go b/controller/db/revocation_store.go similarity index 98% rename from controller/persistence/revocation_store.go rename to controller/db/revocation_store.go index f18476a9a..05cd5cb64 100644 --- a/controller/persistence/revocation_store.go +++ b/controller/db/revocation_store.go @@ -14,7 +14,7 @@ limitations under the License. */ -package persistence +package db import ( "github.com/openziti/storage/ast" diff --git a/controller/persistence/service_edge_router_policy_store.go b/controller/db/service_edge_router_policy_store.go similarity index 96% rename from controller/persistence/service_edge_router_policy_store.go rename to controller/db/service_edge_router_policy_store.go index 859bac789..28ddf12cc 100644 --- a/controller/persistence/service_edge_router_policy_store.go +++ b/controller/db/service_edge_router_policy_store.go @@ -1,13 +1,12 @@ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/eid" "sort" ) @@ -82,8 +81,8 @@ func (store *serviceEdgeRouterPolicyStoreImpl) initializeLocal() { store.symbolSemantic = store.AddSymbol(FieldSemantic, ast.NodeTypeString) store.symbolServiceRoles = store.AddPublicSetSymbol(FieldServiceRoles, ast.NodeTypeString) store.symbolEdgeRouterRoles = store.AddPublicSetSymbol(FieldEdgeRouterRoles, ast.NodeTypeString) - store.symbolServices = store.AddFkSetSymbol(db.EntityTypeServices, store.stores.edgeService) - store.symbolEdgeRouters = store.AddFkSetSymbol(db.EntityTypeRouters, store.stores.edgeRouter) + store.symbolServices = store.AddFkSetSymbol(EntityTypeServices, store.stores.edgeService) + store.symbolEdgeRouters = store.AddFkSetSymbol(EntityTypeRouters, store.stores.edgeRouter) } func (store *serviceEdgeRouterPolicyStoreImpl) initializeLinked() { diff --git a/controller/persistence/service_edge_router_policy_store_test.go b/controller/db/service_edge_router_policy_store_test.go similarity index 97% rename from controller/persistence/service_edge_router_policy_store_test.go rename to controller/db/service_edge_router_policy_store_test.go index 2243596ce..8af741bf0 100644 --- a/controller/persistence/service_edge_router_policy_store_test.go +++ b/controller/db/service_edge_router_policy_store_test.go @@ -1,12 +1,11 @@ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" "go.etcd.io/bbolt" "sort" "testing" @@ -31,8 +30,8 @@ func (ctx *TestContext) testCreateServiceEdgeRouterPolicy(_ *testing.T) { boltztest.ValidateBaseline(ctx, policy) err := ctx.GetDb().View(func(tx *bbolt.Tx) error { - ctx.Equal(0, len(ctx.stores.ServiceEdgeRouterPolicy.GetRelatedEntitiesIdList(tx, policy.Id, db.EntityTypeRouters))) - ctx.Equal(0, len(ctx.stores.ServiceEdgeRouterPolicy.GetRelatedEntitiesIdList(tx, policy.Id, db.EntityTypeServices))) + ctx.Equal(0, len(ctx.stores.ServiceEdgeRouterPolicy.GetRelatedEntitiesIdList(tx, policy.Id, EntityTypeRouters))) + ctx.Equal(0, len(ctx.stores.ServiceEdgeRouterPolicy.GetRelatedEntitiesIdList(tx, policy.Id, EntityTypeServices))) testPolicy, err := ctx.stores.ServiceEdgeRouterPolicy.LoadOneById(tx, policy.Id) ctx.NoError(err) @@ -206,8 +205,8 @@ func (ctx *TestContext) testServiceEdgeRouterPolicyRoleEvaluation(_ *testing.T) policies := ctx.createServiceEdgeRouterPolicies(serviceRoles, edgeRouterRoles, services, edgeRouters, true) for i := 0; i < 9; i++ { - relatedEdgeRouters := ctx.getRelatedIds(policies[i], db.EntityTypeRouters) - relatedServices := ctx.getRelatedIds(policies[i], db.EntityTypeServices) + relatedEdgeRouters := ctx.getRelatedIds(policies[i], EntityTypeRouters) + relatedServices := ctx.getRelatedIds(policies[i], EntityTypeServices) if i == 3 { ctx.Equal([]string{edgeRouters[0].Id}, relatedEdgeRouters) ctx.Equal([]string{services[0].Id}, relatedServices) @@ -387,7 +386,7 @@ func (ctx *TestContext) validateServiceEdgeRouterPolicies(services []*EdgeServic func (ctx *TestContext) validateServiceEdgeRouterPolicyServices(services []*EdgeService, policies []*ServiceEdgeRouterPolicy) { for _, policy := range policies { count := 0 - relatedServices := ctx.getRelatedIds(policy, db.EntityTypeServices) + relatedServices := ctx.getRelatedIds(policy, EntityTypeServices) for _, service := range services { relatedPolicies := ctx.getRelatedIds(service, EntityTypeServiceEdgeRouterPolicies) shouldContain := ctx.policyShouldMatch(policy.Semantic, policy.ServiceRoles, service, service.RoleAttributes) @@ -409,7 +408,7 @@ func (ctx *TestContext) validateServiceEdgeRouterPolicyServices(services []*Edge func (ctx *TestContext) validateServiceEdgeRouterPolicyEdgeRouters(edgeRouters []*EdgeRouter, policies []*ServiceEdgeRouterPolicy) { for _, policy := range policies { count := 0 - relatedEdgeRouters := ctx.getRelatedIds(policy, db.EntityTypeRouters) + relatedEdgeRouters := ctx.getRelatedIds(policy, EntityTypeRouters) for _, edgeRouter := range edgeRouters { relatedPolicies := ctx.getRelatedIds(edgeRouter, EntityTypeServiceEdgeRouterPolicies) shouldContain := ctx.policyShouldMatch(policy.Semantic, policy.EdgeRouterRoles, edgeRouter, edgeRouter.RoleAttributes) diff --git a/controller/persistence/service_events.go b/controller/db/service_events.go similarity index 99% rename from controller/persistence/service_events.go rename to controller/db/service_events.go index 18f58b155..e5310a801 100644 --- a/controller/persistence/service_events.go +++ b/controller/db/service_events.go @@ -1,4 +1,4 @@ -package persistence +package db import ( "fmt" diff --git a/controller/persistence/service_policy_store.go b/controller/db/service_policy_store.go similarity index 98% rename from controller/persistence/service_policy_store.go rename to controller/db/service_policy_store.go index ff916e81b..28c70e185 100644 --- a/controller/persistence/service_policy_store.go +++ b/controller/db/service_policy_store.go @@ -1,8 +1,7 @@ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/ast" @@ -124,7 +123,7 @@ func (store *servicePolicyStoreImpl) initializeLocal() { store.symbolPostureCheckRoles = store.AddPublicSetSymbol(FieldPostureCheckRoles, ast.NodeTypeString) store.symbolIdentities = store.AddFkSetSymbol(EntityTypeIdentities, store.stores.identity) - store.symbolServices = store.AddFkSetSymbol(db.EntityTypeServices, store.stores.edgeService) + store.symbolServices = store.AddFkSetSymbol(EntityTypeServices, store.stores.edgeService) store.symbolPostureChecks = store.AddFkSetSymbol(EntityTypePostureChecks, store.stores.postureCheck) } diff --git a/controller/persistence/service_policy_store_test.go b/controller/db/service_policy_store_test.go similarity index 98% rename from controller/persistence/service_policy_store_test.go rename to controller/db/service_policy_store_test.go index 4304f362f..87e170a79 100644 --- a/controller/persistence/service_policy_store_test.go +++ b/controller/db/service_policy_store_test.go @@ -1,13 +1,12 @@ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/boltz" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" "go.etcd.io/bbolt" "math/rand" "sort" @@ -47,7 +46,7 @@ func (ctx *TestContext) testCreateServicePolicy(_ *testing.T) { err := ctx.GetDb().View(func(tx *bbolt.Tx) error { boltztest.ValidateBaseline(ctx, policy) - ctx.Equal(0, len(ctx.stores.ServicePolicy.GetRelatedEntitiesIdList(tx, policy.Id, db.EntityTypeServices))) + ctx.Equal(0, len(ctx.stores.ServicePolicy.GetRelatedEntitiesIdList(tx, policy.Id, EntityTypeServices))) ctx.Equal(0, len(ctx.stores.ServicePolicy.GetRelatedEntitiesIdList(tx, policy.Id, EntityTypeIdentities))) testPolicy, err := ctx.stores.ServicePolicy.LoadOneById(tx, policy.Id) @@ -226,7 +225,7 @@ func (ctx *TestContext) testServicePolicyRoleEvaluation(_ *testing.T) { policies := ctx.createServicePolicies(identityRoles, serviceRoles, identities, services, true) for i := 0; i < 9; i++ { - relatedServices := ctx.getRelatedIds(policies[i], db.EntityTypeServices) + relatedServices := ctx.getRelatedIds(policies[i], EntityTypeServices) relatedIdentities := ctx.getRelatedIds(policies[i], EntityTypeIdentities) if i == 3 { ctx.Equal([]string{services[0].Id}, relatedServices) @@ -427,7 +426,7 @@ func (ctx *TestContext) validateServicePolicyIdentities(identities []*Identity, func (ctx *TestContext) validateServicePolicyServices(services []*EdgeService, policies []*ServicePolicy) { for _, policy := range policies { count := 0 - relatedServices := ctx.getRelatedIds(policy, db.EntityTypeServices) + relatedServices := ctx.getRelatedIds(policy, EntityTypeServices) for _, service := range services { relatedPolicies := ctx.getRelatedIds(service, EntityTypeServicePolicies) shouldContain := ctx.policyShouldMatch(policy.Semantic, policy.ServiceRoles, service, service.RoleAttributes) diff --git a/controller/persistence/session_store.go b/controller/db/session_store.go similarity index 98% rename from controller/persistence/session_store.go rename to controller/db/session_store.go index 6f4462869..c24689275 100644 --- a/controller/persistence/session_store.go +++ b/controller/db/session_store.go @@ -14,10 +14,9 @@ limitations under the License. */ -package persistence +package db import ( - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/ast" @@ -180,7 +179,7 @@ func (self *sessionApiSessionIndex) ProcessAfterUpdate(ctx *boltz.IndexingContex } bucket := boltz.GetOrCreatePath(ctx.Tx(), - db.RootBucket, + RootBucket, boltz.IndexesBucket, EntityTypeApiSessions, EntityTypeSessions, diff --git a/controller/persistence/session_store_test.go b/controller/db/session_store_test.go similarity index 97% rename from controller/persistence/session_store_test.go rename to controller/db/session_store_test.go index 6003cdee9..8cea0cca2 100644 --- a/controller/persistence/session_store_test.go +++ b/controller/db/session_store_test.go @@ -14,24 +14,23 @@ limitations under the License. */ -package persistence +package db import ( "fmt" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/change" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/boltz" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/change" "go.etcd.io/bbolt" "testing" "time" ) -const apiSessionsSessionsIdxPath = "/" + db.RootBucket + "/" + boltz.IndexesBucket + "/" + EntityTypeApiSessions + "/" + EntityTypeSessions +const apiSessionsSessionsIdxPath = "/" + RootBucket + "/" + boltz.IndexesBucket + "/" + EntityTypeApiSessions + "/" + EntityTypeSessions func Test_SessionStore(t *testing.T) { ctx := NewTestContext(t) diff --git a/controller/db/stores.go b/controller/db/stores.go index ff03f41bb..89b67ec31 100644 --- a/controller/db/stores.go +++ b/controller/db/stores.go @@ -18,11 +18,17 @@ package db import ( "context" + "errors" "github.com/michaelquigley/pfxlog" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/change" "go.etcd.io/bbolt" + "go4.org/sort" "reflect" "sync" + "time" ) func NewStoreDefinition[E boltz.ExtEntity](strategy boltz.EntityStrategy[E]) boltz.StoreDefinition[E] { @@ -37,35 +43,12 @@ func NewStoreDefinition[E boltz.ExtEntity](strategy boltz.EntityStrategy[E]) bol } } -type Stores struct { - Terminator TerminatorStore - Router RouterStore - Service ServiceStore - storeMap map[string]boltz.Store - lock sync.Mutex - checkables []boltz.Checkable -} - func (store *Stores) AddCheckable(checkable boltz.Checkable) { store.lock.Lock() defer store.lock.Unlock() store.checkables = append(store.checkables, checkable) } -func (stores *Stores) buildStoreMap() { - stores.storeMap = map[string]boltz.Store{} - val := reflect.ValueOf(stores).Elem() - for i := 0; i < val.NumField(); i++ { - f := val.Field(i) - if f.CanInterface() { - if store, ok := f.Interface().(boltz.Store); ok { - stores.storeMap[store.GetEntityType()] = store - stores.AddCheckable(store) - } - } - } -} - func (stores *Stores) GetStoreList() []boltz.Store { var result []boltz.Store for _, store := range stores.storeMap { @@ -74,16 +57,7 @@ func (stores *Stores) GetStoreList() []boltz.Store { return result } -func (stores *Stores) GetStoreForEntity(entity boltz.Entity) boltz.Store { - return stores.storeMap[entity.GetEntityType()] -} - -func (stores *Stores) GetStoreForEntityType(entityType string) boltz.Store { - return stores.storeMap[entityType] -} - func (stores *Stores) CheckIntegrity(db boltz.Db, ctx context.Context, fix bool, errorHandler func(error, bool)) error { - if fix { changeCtx := boltz.NewMutateContext(ctx) return db.Update(changeCtx, func(changeCtx boltz.MutateContext) error { @@ -113,39 +87,289 @@ func (stores *Stores) CheckIntegrityInTx(db boltz.Db, ctx boltz.MutateContext, f return nil } +type Stores struct { + EventualEventer EventualEventer + internal *stores + + Router RouterStore + Service ServiceStore + Terminator TerminatorStore + ApiSession ApiSessionStore + ApiSessionCertificate ApiSessionCertificateStore + AuthPolicy AuthPolicyStore + EventualEvent EventualEventStore + ExternalJwtSigner ExternalJwtSignerStore + Ca CaStore + Config ConfigStore + ConfigType ConfigTypeStore + EdgeRouter EdgeRouterStore + EdgeRouterPolicy EdgeRouterPolicyStore + EdgeService EdgeServiceStore + Identity IdentityStore + IdentityType IdentityTypeStore + Index boltz.Store + Session SessionStore + Revocation RevocationStore + ServiceEdgeRouterPolicy ServiceEdgeRouterPolicyStore + ServicePolicy ServicePolicyStore + TransitRouter TransitRouterStore + Enrollment EnrollmentStore + Authenticator AuthenticatorStore + PostureCheck PostureCheckStore + PostureCheckType PostureCheckTypeStore + Mfa MfaStore + storeMap map[reflect.Type]boltz.Store + lock sync.Mutex + checkables []boltz.Checkable +} + +func (stores *Stores) buildStoreMap() { + stores.storeMap = map[reflect.Type]boltz.Store{} + val := reflect.ValueOf(stores).Elem() + for i := 0; i < val.NumField(); i++ { + f := val.Field(i) + if f.CanInterface() { + if store, ok := f.Interface().(boltz.Store); ok && store.GetEntityType() != "indexes" { + entityType := store.GetEntityReflectType() + stores.storeMap[entityType] = store + stores.AddCheckable(store) + } + } + } +} + +func (stores *Stores) GetEntityCounts(db boltz.Db) (map[string]int64, error) { + result := map[string]int64{} + for _, store := range stores.storeMap { + err := db.View(func(tx *bbolt.Tx) error { + key := store.GetEntityType() + if store.IsChildStore() { + if _, ok := store.(TransitRouterStore); ok { + // skip transit routers, since count will be == fabric routers + return nil + } else { + key = store.GetEntityType() + ".edge" + } + } + + _, count, err := store.QueryIds(tx, "true limit 1") + if err != nil { + return err + } + result[key] = count + return nil + }) + + if err != nil { + return nil, err + } + } + return result, nil +} + +func (stores *Stores) getStoresForInit() []initializableStore { + var result []initializableStore + for _, crudStore := range stores.storeMap { + if store, ok := crudStore.(initializableStore); ok { + result = append(result, store) + } + } + return result +} + +func (stores *Stores) GetStoreForEntity(entity boltz.Entity) boltz.Store { + key := reflect.TypeOf(entity) + return stores.storeMap[key] +} + +func (stores *Stores) GetStores() []boltz.Store { + var result []boltz.Store + for _, store := range stores.storeMap { + result = append(result, store) + } + return result +} + type stores struct { - terminator *terminatorStoreImpl - router *routerStoreImpl - service *serviceStoreImpl + EventualEventer EventualEventer + + terminator *terminatorStoreImpl + router *routerStoreImpl + service *serviceStoreImpl + apiSession *apiSessionStoreImpl + authPolicy *AuthPolicyStoreImpl + eventualEvent *eventualEventStoreImpl + ca *caStoreImpl + config *configStoreImpl + configType *configTypeStoreImpl + edgeRouter *edgeRouterStoreImpl + edgeRouterPolicy *edgeRouterPolicyStoreImpl + edgeService *edgeServiceStoreImpl + externalJwtSigner *externalJwtSignerStoreImpl + identity *identityStoreImpl + identityType *IdentityTypeStoreImpl + revocation *revocationStoreImpl + serviceEdgeRouterPolicy *serviceEdgeRouterPolicyStoreImpl + servicePolicy *servicePolicyStoreImpl + session *sessionStoreImpl + transitRouter *transitRouterStoreImpl + enrollment *enrollmentStoreImpl + authenticator *authenticatorStoreImpl + postureCheck *postureCheckStoreImpl + postureCheckType *postureCheckTypeStoreImpl + apiSessionCertificate *ApiSessionCertificateStoreImpl + mfa *MfaStoreImpl +} + +type DbProvider interface { + GetDb() boltz.Db +} + +type DbProviderF func() boltz.Db + +func (f DbProviderF) GetDb() boltz.Db { + return f() } func InitStores(db boltz.Db) (*Stores, error) { + dbProvider := DbProviderF(func() boltz.Db { + return db + }) + errorHolder := &errorz.ErrorHolderImpl{} + internalStores := &stores{} - internalStores.terminator = newTerminatorStore(internalStores) + internalStores.eventualEvent = newEventualEventStore(internalStores) + internalStores.EventualEventer = NewEventualEventerBbolt(dbProvider, internalStores.eventualEvent, 2*time.Second, 1000) + internalStores.router = newRouterStore(internalStores) internalStores.service = newServiceStore(internalStores) + internalStores.terminator = newTerminatorStore(internalStores) + + internalStores.apiSession = newApiSessionStore(internalStores) + internalStores.apiSessionCertificate = newApiSessionCertificateStore(internalStores) + internalStores.authenticator = newAuthenticatorStore(internalStores) + internalStores.authPolicy = newAuthPolicyStore(internalStores) + internalStores.ca = newCaStore(internalStores) + internalStores.config = newConfigsStore(internalStores) + internalStores.configType = newConfigTypesStore(internalStores) + internalStores.edgeRouter = newEdgeRouterStore(internalStores) + internalStores.edgeRouterPolicy = newEdgeRouterPolicyStore(internalStores) + internalStores.edgeService = newEdgeServiceStore(internalStores) + internalStores.externalJwtSigner = newExternalJwtSignerStore(internalStores) + internalStores.transitRouter = newTransitRouterStore(internalStores) + internalStores.identity = newIdentityStore(internalStores) + internalStores.identityType = newIdentityTypeStore(internalStores) + internalStores.enrollment = newEnrollmentStore(internalStores) + internalStores.revocation = newRevocationStore(internalStores) + internalStores.serviceEdgeRouterPolicy = newServiceEdgeRouterPolicyStore(internalStores) + internalStores.servicePolicy = newServicePolicyStore(internalStores) + internalStores.session = newSessionStore(internalStores) + internalStores.postureCheck = newPostureCheckStore(internalStores) + internalStores.postureCheckType = newPostureCheckTypeStore(internalStores) + internalStores.mfa = newMfaStore(internalStores) + + externalStores := &Stores{ + internal: internalStores, - stores := &Stores{ Terminator: internalStores.terminator, Router: internalStores.router, Service: internalStores.service, + + ApiSession: internalStores.apiSession, + ApiSessionCertificate: internalStores.apiSessionCertificate, + AuthPolicy: internalStores.authPolicy, + EventualEvent: internalStores.eventualEvent, + Ca: internalStores.ca, + Config: internalStores.config, + ConfigType: internalStores.configType, + EdgeRouter: internalStores.edgeRouter, + EdgeRouterPolicy: internalStores.edgeRouterPolicy, + EdgeService: internalStores.edgeService, + ExternalJwtSigner: internalStores.externalJwtSigner, + TransitRouter: internalStores.transitRouter, + Identity: internalStores.identity, + IdentityType: internalStores.identityType, + Revocation: internalStores.revocation, + ServiceEdgeRouterPolicy: internalStores.serviceEdgeRouterPolicy, + ServicePolicy: internalStores.servicePolicy, + Session: internalStores.session, + Authenticator: internalStores.authenticator, + Enrollment: internalStores.enrollment, + PostureCheck: internalStores.postureCheck, + PostureCheckType: internalStores.postureCheckType, + Mfa: internalStores.mfa, + + storeMap: make(map[reflect.Type]boltz.Store), + } + + externalStores.EventualEventer = internalStores.EventualEventer + + // The Index store is used for querying indexes. It's a convenient store with only a single value (id), which + // is only ever queried using an index set cursor + indexStoreDef := boltz.StoreDefinition[boltz.ExtEntity]{ + EntityType: "indexes", + BasePath: []string{RootBucket}, + EntityNotFoundF: func(id string) error { + panic(errors.New("programming error")) + }, } - stores.buildStoreMap() + indexStore := boltz.NewBaseStore(indexStoreDef) + indexStore.AddIdSymbol("id", ast.NodeTypeString) + + externalStores.Index = indexStore + + externalStores.buildStoreMap() + storeList := externalStores.getStoresForInit() + + sort.Slice(storeList, func(i, j int) bool { + if storeList[i].IsChildStore() == storeList[j].IsChildStore() { + return storeList[i].GetEntityType() < storeList[j].GetEntityType() + } + return !storeList[i].IsChildStore() + }) - internalStores.terminator.initializeLocal() - internalStores.router.initializeLocal() - internalStores.service.initializeLocal() + mutateCtx := change.New().SetSourceType("system.initialization").SetChangeAuthorType(change.AuthorTypeController).NewMutateContext() + err := dbProvider.GetDb().Update(mutateCtx, func(ctx boltz.MutateContext) error { + for _, store := range storeList { + store.initializeLocal() + } + for _, store := range storeList { + store.initializeLinked() + } + for _, store := range storeList { + store.initializeIndexes(ctx.Tx(), errorHolder) + } + return nil + }) - internalStores.terminator.initializeLinked() - internalStores.router.initializeLinked() - internalStores.service.initializeLinked() + errorHolder.SetError(err) + if errorHolder.HasError() { + return nil, errorHolder.GetError() + } - mm := boltz.NewMigratorManager(db) - if err := mm.Migrate("fabric", CurrentDbVersion, internalStores.migrate); err != nil { + if err = RunMigrations(db, externalStores); err != nil { return nil, err } - return stores, nil + return externalStores, nil +} + +func newBaseStore[E boltz.ExtEntity](stores *stores, strategy boltz.EntityStrategy[E]) *baseStore[E] { + return &baseStore[E]{ + stores: stores, + BaseStore: boltz.NewBaseStore(NewStoreDefinition[E](strategy)), + } +} + +func newChildBaseStore[E boltz.ExtEntity](stores *stores, parentMapper func(entity boltz.Entity) boltz.Entity, strategy boltz.EntityStrategy[E], parent boltz.Store, path string) *baseStore[E] { + def := NewStoreDefinition[E](strategy) + def.BasePath = []string{path} + def.Parent = parent + def.ParentMapper = parentMapper + return &baseStore[E]{ + stores: stores, + BaseStore: boltz.NewBaseStore[E](def), + } } diff --git a/controller/db/testing.go b/controller/db/testing.go index c45d5d1a3..47dbfb1f7 100644 --- a/controller/db/testing.go +++ b/controller/db/testing.go @@ -3,25 +3,33 @@ package db import ( "github.com/google/uuid" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/xt" - "github.com/openziti/ziti/controller/xt_smartrouting" "github.com/openziti/storage/boltz" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/xt" + "github.com/openziti/ziti/controller/xt_smartrouting" + "github.com/pkg/errors" + "go.etcd.io/bbolt" "testing" ) func NewTestContext(t testing.TB) *TestContext { xt.GlobalRegistry().RegisterFactory(xt_smartrouting.NewFactory()) - context := &TestContext{} + context := &TestContext{ + closeNotify: make(chan struct{}, 1), + } context.BaseTestContext = boltztest.NewTestContext(t, context.GetStoreForEntity) context.Init() return context } type TestContext struct { - stores *Stores *boltztest.BaseTestContext + stores *Stores + // n *network.Network + closeNotify chan struct{} } func (ctx *TestContext) GetStoreForEntity(entity boltz.Entity) boltz.Store { @@ -34,8 +42,31 @@ func (ctx *TestContext) Init() { var err error ctx.stores, err = InitStores(ctx.GetDb()) ctx.NoError(err) + + ctx.NoError(RunMigrations(ctx.GetDb(), ctx.stores)) + ctx.NoError(ctx.stores.EventualEventer.Start(ctx.closeNotify)) } +//func (ctx *TestContext) Init() { +// ctx.BaseTestContext.InitDb(Open) +// +// //db := ctx.GetDbProvider() +// // +// //config := newTestConfig(ctx) +// //var err error +// //ctx.n, err = network.NewNetwork(config) +// //ctx.NoError(err) +// // +// //// TODO: setup up single node raft cluster or mock? +// //ctx.stores, err = NewBoltStores(db) +// //ctx.NoError(err) +// +// ctx.NoError(RunMigrations(ctx.GetDb(), ctx.stores)) +// +// ctx.NoError(ctx.stores.EventualEventer.Start(ctx.closeNotify)) +// +//} + func (ctx *TestContext) requireNewService() *Service { entity := &Service{ BaseExtEntity: boltz.BaseExtEntity{Id: uuid.New().String()}, @@ -65,3 +96,120 @@ func (ctx *TestContext) cleanupAll() { return nil }) } + +func (ctx *TestContext) newViewTestCtx(tx *bbolt.Tx) boltz.MutateContext { + return boltz.NewTxMutateContext(change.New().SetChangeAuthorType("test").GetContext(), tx) +} + +//func (ctx *TestContext) GetNetwork() *network.Network { +// return ctx.n +//} + +func (ctx *TestContext) Cleanup() { + close(ctx.closeNotify) + ctx.BaseTestContext.Cleanup() +} + +func (ctx *TestContext) GetStores() *Stores { + return ctx.stores +} + +func (ctx *TestContext) GetDb() boltz.Db { + return ctx.BaseTestContext.GetDb() +} + +//func (ctx *TestContext) GetDbProvider() DbProvider { +// return &testDbProvider{ctx: ctx} +//} + +func (ctx *TestContext) requireNewServicePolicy(policyType PolicyType, identityRoles []string, serviceRoles []string) *ServicePolicy { + entity := &ServicePolicy{ + BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, + Name: eid.New(), + PolicyType: policyType, + Semantic: SemanticAnyOf, + IdentityRoles: identityRoles, + ServiceRoles: serviceRoles, + } + boltztest.RequireCreate(ctx, entity) + return entity +} + +func (ctx *TestContext) RequireNewIdentity(name string, isAdmin bool) *Identity { + identityEntity := &Identity{ + BaseExtEntity: *boltz.NewExtEntity(eid.New(), nil), + Name: name, + IsAdmin: isAdmin, + } + boltztest.RequireCreate(ctx, identityEntity) + return identityEntity +} + +func (ctx *TestContext) RequireNewService(name string) *EdgeService { + edgeService := &EdgeService{ + Service: Service{ + BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, + Name: name, + }, + } + boltztest.RequireCreate(ctx, edgeService) + return edgeService +} + +func (ctx *TestContext) getRelatedIds(entity boltz.Entity, field string) []string { + var result []string + err := ctx.GetDb().View(func(tx *bbolt.Tx) error { + store := ctx.stores.GetStoreForEntity(entity) + if store == nil { + return errors.Errorf("no store for entity of type '%v'", entity.GetEntityType()) + } + result = store.GetRelatedEntitiesIdList(tx, entity.GetId(), field) + return nil + }) + ctx.NoError(err) + return result +} + +func (ctx *TestContext) CleanupAll() { + stores := []boltz.Store{ + ctx.stores.Session, + ctx.stores.ApiSession, + ctx.stores.Service, + ctx.stores.EdgeService, + ctx.stores.Identity, + ctx.stores.EdgeRouter, + ctx.stores.Config, + ctx.stores.Identity, + ctx.stores.EdgeRouterPolicy, + ctx.stores.ServicePolicy, + ctx.stores.ServiceEdgeRouterPolicy, + } + + _ = ctx.GetDb().Update(change.New().NewMutateContext(), func(mutateCtx boltz.MutateContext) error { + for _, store := range stores { + if err := store.DeleteWhere(mutateCtx, `true limit none`); err != nil { + pfxlog.Logger().WithError(err).Errorf("failure while cleaning up %v", store.GetEntityType()) + return err + } + } + return nil + }) +} + +func (ctx *TestContext) getIdentityTypeId() string { + var result string + err := ctx.GetDb().View(func(tx *bbolt.Tx) error { + ids, _, err := ctx.stores.IdentityType.QueryIds(tx, "true") + if err != nil { + return err + } + result = ids[0] + return nil + }) + ctx.NoError(err) + return result +} + +func ss(vals ...string) []string { + return vals +} diff --git a/controller/persistence/transit_router_store.go b/controller/db/transit_router_store.go similarity index 90% rename from controller/persistence/transit_router_store.go rename to controller/db/transit_router_store.go index aa6d07424..8ede0de8b 100644 --- a/controller/persistence/transit_router_store.go +++ b/controller/db/transit_router_store.go @@ -14,11 +14,10 @@ limitations under the License. */ -package persistence +package db import ( "fmt" - "github.com/openziti/ziti/controller/db" "github.com/openziti/storage/boltz" ) @@ -29,7 +28,7 @@ const ( ) type TransitRouter struct { - db.Router + Router IsVerified bool `json:"isVerified"` Enrollments []string `json:"enrollments"` IsBase bool `json:"-"` @@ -57,7 +56,7 @@ func newTransitRouterStore(stores *stores) *transitRouterStoreImpl { } store := &transitRouterStoreImpl{} - store.baseStore = newChildBaseStore[*TransitRouter](stores, parentMapper, store, stores.Router, TransitRouterPath) + store.baseStore = newChildBaseStore[*TransitRouter](stores, parentMapper, store, stores.router, TransitRouterPath) store.Extended() store.InitImpl(store) @@ -71,7 +70,7 @@ type transitRouterStoreImpl struct { symbolEnrollments boltz.EntitySetSymbol } -func (store *transitRouterStoreImpl) HandleUpdate(ctx boltz.MutateContext, entity *db.Router, checker boltz.FieldChecker) (bool, error) { +func (store *transitRouterStoreImpl) HandleUpdate(ctx boltz.MutateContext, entity *Router, checker boltz.FieldChecker) (bool, error) { er, found, err := store.FindById(ctx.Tx(), entity.Id) if err != nil { return false, err @@ -84,7 +83,7 @@ func (store *transitRouterStoreImpl) HandleUpdate(ctx boltz.MutateContext, entit return true, store.Update(ctx, er, checker) } -func (store *transitRouterStoreImpl) HandleDelete(ctx boltz.MutateContext, entity *db.Router) error { +func (store *transitRouterStoreImpl) HandleDelete(ctx boltz.MutateContext, entity *Router) error { return store.cleanupEnrollments(ctx, entity.Id) } @@ -98,7 +97,7 @@ func (store *transitRouterStoreImpl) NewEntity() *TransitRouter { func (store *transitRouterStoreImpl) initializeLocal() { store.GetParentStore().GrantSymbols(store) - store.indexName = store.GetParentStore().(db.RouterStore).GetNameIndex() + store.indexName = store.GetParentStore().(RouterStore).GetNameIndex() store.symbolEnrollments = store.AddFkSetSymbol(FieldTransitRouterEnrollments, store.stores.enrollment) } @@ -110,7 +109,7 @@ func (store *transitRouterStoreImpl) GetNameIndex() boltz.ReadIndex { } func (store *transitRouterStoreImpl) FillEntity(entity *TransitRouter, bucket *boltz.TypedBucket) { - store.stores.Router.FillEntity(&entity.Router, store.getParentBucket(entity, bucket)) + store.stores.router.FillEntity(&entity.Router, store.getParentBucket(entity, bucket)) if bucket.Bucket == nil { entity.IsVerified = true @@ -125,7 +124,7 @@ func (store *transitRouterStoreImpl) FillEntity(entity *TransitRouter, bucket *b } func (store *transitRouterStoreImpl) PersistEntity(entity *TransitRouter, ctx *boltz.PersistContext) { - store.stores.Router.PersistEntity(&entity.Router, ctx.GetParentContext()) + store.stores.router.PersistEntity(&entity.Router, ctx.GetParentContext()) if ctx.Bucket != nil { ctx.SetBool(FieldTransitRouterIsVerified, entity.IsVerified) ctx.SetStringP(FieldEdgeRouterUnverifiedFingerprint, entity.UnverifiedFingerprint) diff --git a/controller/persistence/util.go b/controller/db/util.go similarity index 99% rename from controller/persistence/util.go rename to controller/db/util.go index ca28c3279..e0512c05c 100644 --- a/controller/persistence/util.go +++ b/controller/db/util.go @@ -14,13 +14,13 @@ limitations under the License. */ -package persistence +package db import ( "fmt" - "github.com/openziti/storage/boltz" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/storage/boltz" "github.com/pkg/errors" "strings" ) diff --git a/controller/env/appenv.go b/controller/env/appenv.go index b9aa85d1b..d538e1bf4 100644 --- a/controller/env/appenv.go +++ b/controller/env/appenv.go @@ -49,6 +49,7 @@ import ( "github.com/openziti/ziti/common/eid" "github.com/openziti/ziti/controller/api" edgeConfig "github.com/openziti/ziti/controller/config" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/event" "github.com/openziti/ziti/controller/events" "github.com/openziti/ziti/controller/internal/permissions" @@ -57,7 +58,6 @@ import ( "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" "github.com/openziti/ziti/controller/oidc_auth" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/response" "github.com/openziti/ziti/controller/xctrl" "github.com/openziti/ziti/controller/xmgmt" @@ -75,9 +75,8 @@ var _ model.Env = &AppEnv{} const ZitiSession = "zt-session" type AppEnv struct { - BoltStores *persistence.Stores - Managers *model.Managers - Config *edgeConfig.Config + Managers *model.Managers + Config *edgeConfig.Config Versions *ziti.Versions @@ -162,12 +161,12 @@ func (ae *AppEnv) GetJwtSigner() jwtsigner.Signer { return ae.enrollmentSigner } -func (ae *AppEnv) GetDbProvider() persistence.DbProvider { +func (ae *AppEnv) GetDbProvider() network.DbProvider { return ae.HostController.GetNetwork() } -func (ae *AppEnv) GetStores() *persistence.Stores { - return ae.BoltStores +func (ae *AppEnv) GetStores() *db.Stores { + return ae.HostController.GetNetwork().GetStores() } func (ae *AppEnv) GetAuthRegistry() model.AuthRegistry { @@ -606,35 +605,28 @@ func NewAppEnv(c *edgeConfig.Config, host HostController) *AppEnv { func (ae *AppEnv) InitPersistence() error { var err error - ae.BoltStores, err = persistence.NewBoltStores(ae.HostController.GetNetwork()) - if err != nil { - return err - } - - if err = persistence.RunMigrations(ae.GetDbProvider().GetDb(), ae.BoltStores); err != nil { - return err - } + stores := ae.HostController.GetNetwork().GetStores() - ae.BoltStores.EventualEventer.AddListener(persistence.EventualEventAddedName, func(i ...interface{}) { + stores.EventualEventer.AddListener(db.EventualEventAddedName, func(i ...interface{}) { if len(i) == 0 { pfxlog.Logger().Errorf("could not update metrics for %s gauge on add, event argument length was 0", EventualEventsGauge) return } - if event, ok := i[0].(*persistence.EventualEventAdded); ok { + if event, ok := i[0].(*db.EventualEventAdded); ok { gauge := ae.GetHostController().GetNetwork().GetMetricsRegistry().Gauge(EventualEventsGauge) gauge.Update(event.Total) } else { pfxlog.Logger().Errorf("could not update metrics for %s gauge on add, event argument was %T expected *EventualEventAdded", EventualEventsGauge, i[0]) } }) - ae.BoltStores.EventualEventer.AddListener(persistence.EventualEventRemovedName, func(i ...interface{}) { + stores.EventualEventer.AddListener(db.EventualEventRemovedName, func(i ...interface{}) { if len(i) == 0 { pfxlog.Logger().Errorf("could not update metrics for %s gauge on remove, event argument length was 0", EventualEventsGauge) return } - if event, ok := i[0].(*persistence.EventualEventRemoved); ok { + if event, ok := i[0].(*db.EventualEventRemoved); ok { gauge := ae.GetHostController().GetNetwork().GetMetricsRegistry().Gauge(EventualEventsGauge) gauge.Update(event.Total) } else { @@ -643,10 +635,10 @@ func (ae *AppEnv) InitPersistence() error { }) ae.Managers = model.InitEntityManagers(ae) - ae.GetHostController().GetNetwork().GetEventDispatcher().(*events.Dispatcher).InitializeEdgeEvents(ae.BoltStores) + ae.GetHostController().GetNetwork().GetEventDispatcher().(*events.Dispatcher).InitializeEdgeEvents(stores) - persistence.ServiceEvents.AddServiceEventHandler(ae.HandleServiceEvent) - ae.BoltStores.Identity.AddEntityIdListener(ae.IdentityRefreshMap.Remove, boltz.EntityDeletedAsync) + db.ServiceEvents.AddServiceEventHandler(ae.HandleServiceEvent) + stores.Identity.AddEntityIdListener(ae.IdentityRefreshMap.Remove, boltz.EntityDeletedAsync) return err } @@ -838,7 +830,7 @@ func (ae *AppEnv) IsAllowed(responderFunc func(ae *AppEnv, rc *response.RequestC }) } -func (ae *AppEnv) HandleServiceEvent(event *persistence.ServiceEvent) { +func (ae *AppEnv) HandleServiceEvent(event *db.ServiceEvent) { ae.HandleServiceUpdatedEventForIdentityId(event.IdentityId) } diff --git a/controller/env/broker.go b/controller/env/broker.go index f26616eab..172b62fde 100644 --- a/controller/env/broker.go +++ b/controller/env/broker.go @@ -19,11 +19,11 @@ package env import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/network" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/event" - "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/network" "go.etcd.io/bbolt" ) @@ -66,7 +66,7 @@ func NewBroker(ae *AppEnv, synchronizer RouterSyncStrategy) *Broker { broker.ae.GetStores().Session.AddEntityEventListenerF(broker.routerSyncStrategy.SessionDeleted, boltz.EntityDeletedAsync) broker.ae.GetStores().ApiSession.AddEntityEventListenerF(broker.routerSyncStrategy.ApiSessionDeleted, boltz.EntityDeletedAsync) - broker.ae.GetStores().ApiSession.GetEventsEmitter().AddListener(persistence.EventFullyAuthenticated, broker.apiSessionFullyAuthenticated) + broker.ae.GetStores().ApiSession.GetEventsEmitter().AddListener(db.EventFullyAuthenticated, broker.apiSessionFullyAuthenticated) broker.ae.GetStores().ApiSessionCertificate.AddEntityEventListenerF(broker.apiSessionCertificateCreated, boltz.EntityCreatedAsync) broker.ae.GetStores().ApiSessionCertificate.AddEntityEventListenerF(broker.apiSessionCertificateDeleted, boltz.EntityDeletedAsync) @@ -121,9 +121,9 @@ func (broker *Broker) RouterDisconnected(r *network.Router) { } func (broker *Broker) apiSessionFullyAuthenticated(args ...interface{}) { - var apiSession *persistence.ApiSession + var apiSession *db.ApiSession if len(args) == 1 { - apiSession, _ = args[0].(*persistence.ApiSession) + apiSession, _ = args[0].(*db.ApiSession) } if apiSession == nil { @@ -133,16 +133,16 @@ func (broker *Broker) apiSessionFullyAuthenticated(args ...interface{}) { go broker.routerSyncStrategy.ApiSessionAdded(apiSession) } -func (broker *Broker) apiSessionCertificateCreated(entity *persistence.ApiSessionCertificate) { +func (broker *Broker) apiSessionCertificateCreated(entity *db.ApiSessionCertificate) { go broker.apiSessionCertificateHandler(false, entity) } -func (broker *Broker) apiSessionCertificateDeleted(entity *persistence.ApiSessionCertificate) { +func (broker *Broker) apiSessionCertificateDeleted(entity *db.ApiSessionCertificate) { go broker.apiSessionCertificateHandler(true, entity) } -func (broker *Broker) apiSessionCertificateHandler(delete bool, apiSessionCert *persistence.ApiSessionCertificate) { - var apiSession *persistence.ApiSession +func (broker *Broker) apiSessionCertificateHandler(delete bool, apiSessionCert *db.ApiSessionCertificate) { + var apiSession *db.ApiSession var err error err = broker.ae.GetDbProvider().GetDb().View(func(tx *bbolt.Tx) error { apiSession, err = broker.ae.GetStores().ApiSession.LoadOneById(tx, apiSessionCert.ApiSessionId) diff --git a/controller/env/sync.go b/controller/env/sync.go index 390183309..016c74982 100644 --- a/controller/env/sync.go +++ b/controller/env/sync.go @@ -18,11 +18,11 @@ package env import ( "github.com/openziti/channel/v2" + "github.com/openziti/foundation/v2/versions" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/event" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/controller/event" - "github.com/openziti/foundation/v2/versions" "sync" ) @@ -74,11 +74,11 @@ type RouterConnectionHandler interface { // RouterSynchronizerEventHandler is responsible for keeping Edge Routers up to date on API Sessions type RouterSynchronizerEventHandler interface { - ApiSessionAdded(apiSession *persistence.ApiSession) - ApiSessionUpdated(apiSession *persistence.ApiSession, apiSessionCert *persistence.ApiSessionCertificate) - ApiSessionDeleted(apiSession *persistence.ApiSession) + ApiSessionAdded(apiSession *db.ApiSession) + ApiSessionUpdated(apiSession *db.ApiSession, apiSessionCert *db.ApiSessionCertificate) + ApiSessionDeleted(apiSession *db.ApiSession) - SessionDeleted(session *persistence.Session) + SessionDeleted(session *db.Session) } // RouterState provides a thread save mechanism to access and set router status information that may be influx diff --git a/controller/events/dispatcher.go b/controller/events/dispatcher.go index c0c0905c2..6eede14a9 100644 --- a/controller/events/dispatcher.go +++ b/controller/events/dispatcher.go @@ -19,8 +19,8 @@ package events import ( "fmt" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/event" - "github.com/openziti/ziti/controller/persistence" "io" "strings" @@ -105,7 +105,7 @@ type Dispatcher struct { formatterFactories concurrenz.CopyOnWriteMap[string, event.FormatterFactory] network *network.Network - stores *persistence.Stores + stores *db.Stores entityChangeEventsDispatcher entityChangeEventDispatcher entityTypes []string @@ -125,7 +125,7 @@ func (self *Dispatcher) InitializeNetworkEvents(n *network.Network) { self.AddMetricsMapper((&linkMetricsMapper{network: n}).mapMetrics) } -func (self *Dispatcher) InitializeEdgeEvents(stores *persistence.Stores) { +func (self *Dispatcher) InitializeEdgeEvents(stores *db.Stores) { self.stores = stores self.initApiSessionEvents(self.stores) self.initSessionEvents(self.stores) diff --git a/controller/events/dispatcher_api_session.go b/controller/events/dispatcher_api_session.go index 5084cc401..ca5d6a067 100644 --- a/controller/events/dispatcher_api_session.go +++ b/controller/events/dispatcher_api_session.go @@ -20,8 +20,8 @@ import ( "fmt" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/event" - "github.com/openziti/ziti/controller/persistence" "github.com/pkg/errors" "reflect" "time" @@ -43,12 +43,12 @@ func (self *Dispatcher) RemoveApiSessionEventHandler(handler event.ApiSessionEve }) } -func (self *Dispatcher) initApiSessionEvents(stores *persistence.Stores) { +func (self *Dispatcher) initApiSessionEvents(stores *db.Stores) { stores.ApiSession.AddEntityEventListenerF(self.apiSessionCreated, boltz.EntityCreated) stores.ApiSession.AddEntityEventListenerF(self.apiSessionDeleted, boltz.EntityDeleted) } -func (self *Dispatcher) apiSessionCreated(apiSession *persistence.ApiSession) { +func (self *Dispatcher) apiSessionCreated(apiSession *db.ApiSession) { event := &event.ApiSessionEvent{ Namespace: event.ApiSessionEventNS, EventType: event.ApiSessionEventTypeCreated, @@ -64,7 +64,7 @@ func (self *Dispatcher) apiSessionCreated(apiSession *persistence.ApiSession) { } } -func (self *Dispatcher) apiSessionDeleted(apiSession *persistence.ApiSession) { +func (self *Dispatcher) apiSessionDeleted(apiSession *db.ApiSession) { event := &event.ApiSessionEvent{ Namespace: event.ApiSessionEventNS, EventType: event.ApiSessionEventTypeDeleted, diff --git a/controller/events/dispatcher_session.go b/controller/events/dispatcher_session.go index 4b5b8593c..040354197 100644 --- a/controller/events/dispatcher_session.go +++ b/controller/events/dispatcher_session.go @@ -20,8 +20,8 @@ import ( "fmt" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/event" - "github.com/openziti/ziti/controller/persistence" "github.com/pkg/errors" "reflect" "time" @@ -43,12 +43,12 @@ func (self *Dispatcher) RemoveSessionEventHandler(handler event.SessionEventHand }) } -func (self *Dispatcher) initSessionEvents(stores *persistence.Stores) { +func (self *Dispatcher) initSessionEvents(stores *db.Stores) { stores.Session.AddEntityEventListenerF(self.sessionCreated, boltz.EntityCreated) stores.Session.AddEntityEventListenerF(self.sessionDeleted, boltz.EntityDeleted) } -func (self *Dispatcher) sessionCreated(session *persistence.Session) { +func (self *Dispatcher) sessionCreated(session *db.Session) { evt := &event.SessionEvent{ Namespace: event.SessionEventNS, EventType: event.SessionEventTypeCreated, @@ -66,7 +66,7 @@ func (self *Dispatcher) sessionCreated(session *persistence.Session) { } } -func (self *Dispatcher) sessionDeleted(session *persistence.Session) { +func (self *Dispatcher) sessionDeleted(session *db.Session) { evt := &event.SessionEvent{ Namespace: event.SessionEventNS, EventType: event.SessionEventTypeDeleted, diff --git a/controller/handler_edge_ctrl/common_tunnel.go b/controller/handler_edge_ctrl/common_tunnel.go index 636bd0872..ab5e12f5a 100644 --- a/controller/handler_edge_ctrl/common_tunnel.go +++ b/controller/handler_edge_ctrl/common_tunnel.go @@ -5,12 +5,12 @@ import ( "encoding/json" "github.com/google/uuid" lru "github.com/hashicorp/golang-lru/v2" - "github.com/openziti/ziti/common/pb/edge_ctrl_pb" - "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/common/logcontext" "github.com/openziti/foundation/v2/concurrenz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/logcontext" + "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/model" "github.com/sirupsen/logrus" "sync" "time" @@ -70,7 +70,7 @@ func (self *baseTunnelRequestContext) loadIdentity() { return } - if self.identity.IdentityTypeId != persistence.RouterIdentityType { + if self.identity.IdentityTypeId != db.RouterIdentityType { self.err = TunnelingNotEnabledError{} return } diff --git a/controller/handler_edge_ctrl/create_circuit.go b/controller/handler_edge_ctrl/create_circuit.go index 207502e22..a012da9c5 100644 --- a/controller/handler_edge_ctrl/create_circuit.go +++ b/controller/handler_edge_ctrl/create_circuit.go @@ -20,8 +20,8 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" - "github.com/openziti/ziti/controller/persistence" "google.golang.org/protobuf/proto" ) @@ -82,7 +82,7 @@ func (self *createCircuitHandler) CreateCircuit(ctx *CreateCircuitRequestContext return } ctx.loadSession(ctx.req.SessionToken) - ctx.checkSessionType(persistence.SessionTypeDial) + ctx.checkSessionType(db.SessionTypeDial) ctx.checkSessionFingerprints(ctx.req.Fingerprints) ctx.verifyEdgeRouterAccess() ctx.loadService() diff --git a/controller/handler_edge_ctrl/create_terminator.go b/controller/handler_edge_ctrl/create_terminator.go index e3fc54720..be606078b 100644 --- a/controller/handler_edge_ctrl/create_terminator.go +++ b/controller/handler_edge_ctrl/create_terminator.go @@ -22,10 +22,10 @@ import ( "github.com/openziti/channel/v2" "github.com/openziti/ziti/common" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" - "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/idgen" + "github.com/openziti/ziti/controller/model" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" "google.golang.org/protobuf/proto" @@ -75,7 +75,7 @@ func (self *createTerminatorHandler) CreateTerminator(ctx *CreateTerminatorReque return } ctx.loadSession(ctx.req.SessionToken) - ctx.checkSessionType(persistence.SessionTypeBind) + ctx.checkSessionType(db.SessionTypeBind) ctx.checkSessionFingerprints(ctx.req.Fingerprints) ctx.verifyEdgeRouterAccess() ctx.loadService() diff --git a/controller/handler_edge_ctrl/create_terminator_v2.go b/controller/handler_edge_ctrl/create_terminator_v2.go index 27c585773..be396e450 100644 --- a/controller/handler_edge_ctrl/create_terminator_v2.go +++ b/controller/handler_edge_ctrl/create_terminator_v2.go @@ -21,13 +21,14 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" "github.com/openziti/channel/v2/protobufs" - "github.com/openziti/ziti/controller/models" - "github.com/openziti/ziti/controller/network" "github.com/openziti/ziti/common" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" + "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/models" + "github.com/openziti/ziti/controller/network" "github.com/pkg/errors" "github.com/sirupsen/logrus" "google.golang.org/protobuf/proto" @@ -80,7 +81,7 @@ func (self *createTerminatorV2Handler) CreateTerminatorV2(ctx *CreateTerminatorV return } ctx.loadSession(ctx.req.SessionToken) - ctx.checkSessionType(persistence.SessionTypeBind) + ctx.checkSessionType(db.SessionTypeBind) ctx.checkSessionFingerprints(ctx.req.Fingerprints) ctx.verifyEdgeRouterAccess() ctx.loadService() @@ -104,6 +105,21 @@ func (self *createTerminatorV2Handler) CreateTerminatorV2(ctx *CreateTerminatorV self.returnError(ctx, edge_ctrl_pb.CreateTerminatorResult_FailedIdConflict, ctx.err, logger) return } + + // if the precedence or cost has changed, update the terminator + if terminator.Precedence != ctx.req.GetXtPrecedence() || terminator.Cost != uint16(ctx.req.Cost) { + terminator.Precedence = ctx.req.GetXtPrecedence() + terminator.Cost = uint16(ctx.req.Cost) + err := self.appEnv.GetHostController().GetNetwork().Terminators.Update(terminator, fields.UpdatedFieldsMap{ + db.FieldTerminatorPrecedence: struct{}{}, + db.FieldTerminatorCost: struct{}{}, + }, ctx.newChangeContext()) + + if err != nil { + self.returnError(ctx, edge_ctrl_pb.CreateTerminatorResult_FailedOther, err, logger) + return + } + } } else { terminator = &network.Terminator{ BaseEntity: models.BaseEntity{ @@ -161,7 +177,7 @@ func (self *createTerminatorV2Handler) CreateTerminatorV2(ctx *CreateTerminatorV logger.WithError(err).Error("failed to send CreateTunnelTerminatorResponse") } - logger.Info("completed create tunnel terminator operation") + logger.Info("completed create terminator v2 operation") } func (self *createTerminatorV2Handler) returnError(ctx *CreateTerminatorV2RequestContext, resultType edge_ctrl_pb.CreateTerminatorResult, err error, logger *logrus.Entry) { diff --git a/controller/handler_edge_ctrl/create_tunnel_circuit.go b/controller/handler_edge_ctrl/create_tunnel_circuit.go index 0a5a9450d..9545c22e7 100644 --- a/controller/handler_edge_ctrl/create_tunnel_circuit.go +++ b/controller/handler_edge_ctrl/create_tunnel_circuit.go @@ -20,8 +20,8 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" - "github.com/openziti/ziti/controller/persistence" "google.golang.org/protobuf/proto" ) @@ -89,7 +89,7 @@ func (self *createCircuitForServiceHandler) CreateCircuit(ctx *CreateCircuitForS ctx.loadIdentity() newApiSession := ctx.ensureApiSession(nil) ctx.loadServiceForName(ctx.req.ServiceName) - ctx.ensureSessionForService(ctx.req.SessionId, persistence.SessionTypeDial) + ctx.ensureSessionForService(ctx.req.SessionId, db.SessionTypeDial) ctx.verifyEdgeRouterAccess() circuitInfo, peerData := ctx.createCircuit(ctx.req.TerminatorInstanceId, ctx.req.PeerData) diff --git a/controller/handler_edge_ctrl/create_tunnel_terminator.go b/controller/handler_edge_ctrl/create_tunnel_terminator.go index d12c77e35..adcda7021 100644 --- a/controller/handler_edge_ctrl/create_tunnel_terminator.go +++ b/controller/handler_edge_ctrl/create_tunnel_terminator.go @@ -22,8 +22,8 @@ import ( "github.com/openziti/channel/v2" "github.com/openziti/ziti/common" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" "github.com/pkg/errors" @@ -89,7 +89,7 @@ func (self *createTunnelTerminatorHandler) CreateTerminator(ctx *CreateTunnelTer ctx.loadIdentity() newApiSession := ctx.ensureApiSession(nil) ctx.loadServiceForName(ctx.req.ServiceName) - ctx.ensureSessionForService(ctx.req.SessionId, persistence.SessionTypeBind) + ctx.ensureSessionForService(ctx.req.SessionId, db.SessionTypeBind) ctx.verifyEdgeRouterAccess() if ctx.err != nil { diff --git a/controller/handler_edge_ctrl/health_event.go b/controller/handler_edge_ctrl/health_event.go index c538227d2..eea7e8abe 100644 --- a/controller/handler_edge_ctrl/health_event.go +++ b/controller/handler_edge_ctrl/health_event.go @@ -19,10 +19,10 @@ package handler_edge_ctrl import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" + "github.com/openziti/metrics" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/metrics" "google.golang.org/protobuf/proto" "time" ) @@ -74,7 +74,7 @@ func (self *healthEventHandler) handleHealthEvent(ctx *HealthEventRequestContext } ctx.loadSession(ctx.req.SessionToken) - ctx.checkSessionType(persistence.SessionTypeBind) + ctx.checkSessionType(db.SessionTypeBind) ctx.checkSessionFingerprints(ctx.req.Fingerprints) if ctx.err == nil { diff --git a/controller/handler_edge_ctrl/list_tunnel_services.go b/controller/handler_edge_ctrl/list_tunnel_services.go index 089355820..6a86548bb 100644 --- a/controller/handler_edge_ctrl/list_tunnel_services.go +++ b/controller/handler_edge_ctrl/list_tunnel_services.go @@ -3,9 +3,9 @@ package handler_edge_ctrl import ( "encoding/json" "github.com/openziti/channel/v2" + "github.com/openziti/storage/ast" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" "github.com/openziti/ziti/controller/env" - "github.com/openziti/storage/ast" "github.com/sirupsen/logrus" "google.golang.org/protobuf/proto" "time" @@ -86,7 +86,7 @@ func (self *listTunnelServicesHandler) listServices(ctx *listTunnelServicesReque return } - query, err := ast.Parse(self.appEnv.BoltStores.EdgeService, "limit none") + query, err := ast.Parse(self.appEnv.GetStores().EdgeService, "limit none") if err != nil { logger.WithError(err).Error("could not create service list query") return diff --git a/controller/handler_edge_ctrl/update_terminator.go b/controller/handler_edge_ctrl/update_terminator.go index 1604e954d..cca50fa91 100644 --- a/controller/handler_edge_ctrl/update_terminator.go +++ b/controller/handler_edge_ctrl/update_terminator.go @@ -21,8 +21,8 @@ import ( "github.com/openziti/channel/v2" "github.com/openziti/ziti/common" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" - "github.com/openziti/ziti/controller/persistence" "github.com/sirupsen/logrus" "google.golang.org/protobuf/proto" ) @@ -80,7 +80,7 @@ func (self *updateTerminatorHandler) UpdateTerminator(ctx *UpdateTerminatorReque logger.Debug("update request received") ctx.loadSession(ctx.req.SessionToken) - ctx.checkSessionType(persistence.SessionTypeBind) + ctx.checkSessionType(db.SessionTypeBind) ctx.checkSessionFingerprints(ctx.req.Fingerprints) terminator := ctx.verifyTerminator(ctx.req.TerminatorId, common.EdgeBinding) diff --git a/controller/handler_edge_ctrl/validate_sessions.go b/controller/handler_edge_ctrl/validate_sessions.go index cfe38b201..8327a5046 100644 --- a/controller/handler_edge_ctrl/validate_sessions.go +++ b/controller/handler_edge_ctrl/validate_sessions.go @@ -57,7 +57,7 @@ func (self *validateSessionsHandler) HandleReceive(msg *channel.Message, ch chan } func (self *validateSessionsHandler) validateSessions(req *edge_ctrl_pb.ValidateSessionsRequest) { - sessionStore := self.getAppEnv().BoltStores.Session + sessionStore := self.getAppEnv().GetStores().Session tokenIndex := sessionStore.GetTokenIndex() var invalidTokens []string diff --git a/controller/handler_mgmt/bind.go b/controller/handler_mgmt/bind.go index 2dbd639fc..251f09d77 100644 --- a/controller/handler_mgmt/bind.go +++ b/controller/handler_mgmt/bind.go @@ -18,9 +18,9 @@ package handler_mgmt import ( "github.com/openziti/channel/v2" + "github.com/openziti/ziti/common/trace" "github.com/openziti/ziti/controller/network" "github.com/openziti/ziti/controller/xmgmt" - "github.com/openziti/ziti/common/trace" ) type BindHandler struct { @@ -33,7 +33,17 @@ func NewBindHandler(network *network.Network, xmgmts []xmgmt.Xmgmt) channel.Bind } func (bindHandler *BindHandler) BindChannel(binding channel.Binding) error { - binding.AddTypedReceiveHandler(newInspectHandler(bindHandler.network)) + inspectRequestHandler := newInspectHandler(bindHandler.network) + binding.AddTypedReceiveHandler(&channel.AsyncFunctionReceiveAdapter{ + Type: inspectRequestHandler.ContentType(), + Handler: inspectRequestHandler.HandleReceive, + }) + + validateTerminatorsRequestHandler := newValidateTerminatorsHandler(bindHandler.network) + binding.AddTypedReceiveHandler(&channel.AsyncFunctionReceiveAdapter{ + Type: validateTerminatorsRequestHandler.ContentType(), + Handler: validateTerminatorsRequestHandler.HandleReceive, + }) tracesHandler := newStreamTracesHandler(bindHandler.network) binding.AddTypedReceiveHandler(tracesHandler) diff --git a/controller/handler_mgmt/inspect.go b/controller/handler_mgmt/inspect.go index f508db948..c0bcd6c29 100644 --- a/controller/handler_mgmt/inspect.go +++ b/controller/handler_mgmt/inspect.go @@ -20,8 +20,8 @@ import ( "fmt" "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" - "github.com/openziti/ziti/controller/network" "github.com/openziti/ziti/common/pb/mgmt_pb" + "github.com/openziti/ziti/controller/network" "google.golang.org/protobuf/proto" ) @@ -38,35 +38,33 @@ func (*inspectHandler) ContentType() int32 { } func (handler *inspectHandler) HandleReceive(msg *channel.Message, ch channel.Channel) { - go func() { - response := &mgmt_pb.InspectResponse{} - request := &mgmt_pb.InspectRequest{} - if err := proto.Unmarshal(msg.Body, request); err != nil { - response.Success = false - response.Errors = append(response.Errors, fmt.Sprintf("%v: %v", handler.network.GetAppId(), err)) - } else { - result := handler.network.Managers.Inspections.Inspect(request.AppRegex, request.RequestedValues) - response.Success = result.Success - response.Errors = result.Errors - for _, val := range result.Results { - response.Values = append(response.Values, &mgmt_pb.InspectResponse_InspectValue{ - AppId: val.AppId, - Name: val.Name, - Value: val.Value, - }) - } + response := &mgmt_pb.InspectResponse{} + request := &mgmt_pb.InspectRequest{} + if err := proto.Unmarshal(msg.Body, request); err != nil { + response.Success = false + response.Errors = append(response.Errors, fmt.Sprintf("%v: %v", handler.network.GetAppId(), err)) + } else { + result := handler.network.Managers.Inspections.Inspect(request.AppRegex, request.RequestedValues) + response.Success = result.Success + response.Errors = result.Errors + for _, val := range result.Results { + response.Values = append(response.Values, &mgmt_pb.InspectResponse_InspectValue{ + AppId: val.AppId, + Name: val.Name, + Value: val.Value, + }) } + } - body, err := proto.Marshal(response) - if err != nil { - pfxlog.Logger().Errorf("unexpected error serializing InspectResponse (%s)", err) - return - } + body, err := proto.Marshal(response) + if err != nil { + pfxlog.Logger().Errorf("unexpected error serializing InspectResponse (%s)", err) + return + } - responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_InspectResponseType), body) - responseMsg.ReplyTo(msg) - if err := ch.Send(responseMsg); err != nil { - pfxlog.Logger().Errorf("unexpected error sending InspectResponse (%s)", err) - } - }() + responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_InspectResponseType), body) + responseMsg.ReplyTo(msg) + if err = ch.Send(responseMsg); err != nil { + pfxlog.Logger().Errorf("unexpected error sending InspectResponse (%s)", err) + } } diff --git a/controller/handler_mgmt/validate_terminators.go b/controller/handler_mgmt/validate_terminators.go new file mode 100644 index 000000000..07023c320 --- /dev/null +++ b/controller/handler_mgmt/validate_terminators.go @@ -0,0 +1,84 @@ +/* + Copyright NetFoundry Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package handler_mgmt + +import ( + "fmt" + "github.com/michaelquigley/pfxlog" + "github.com/openziti/channel/v2" + "github.com/openziti/channel/v2/protobufs" + "github.com/openziti/ziti/common/pb/mgmt_pb" + "github.com/openziti/ziti/controller/network" + "google.golang.org/protobuf/proto" + "time" +) + +type validateTerminatorsHandler struct { + network *network.Network +} + +func newValidateTerminatorsHandler(network *network.Network) *validateTerminatorsHandler { + return &validateTerminatorsHandler{network: network} +} + +func (*validateTerminatorsHandler) ContentType() int32 { + return int32(mgmt_pb.ContentType_ValidateTerminatorsRequestType) +} + +func (handler *validateTerminatorsHandler) HandleReceive(msg *channel.Message, ch channel.Channel) { + log := pfxlog.ContextLogger(ch.Label()) + request := &mgmt_pb.ValidateTerminatorsRequest{} + + var err error + var terminatorCount uint64 + + if err = proto.Unmarshal(msg.Body, request); err == nil { + terminatorCount, err = handler.network.Managers.Terminators.ValidateTerminators(request.Filter, request.FixInvalid, func(detail *mgmt_pb.TerminatorDetail) { + if !ch.IsClosed() { + if sendErr := protobufs.MarshalTyped(detail).WithTimeout(15 * time.Second).SendAndWaitForWire(ch); sendErr != nil { + log.WithError(sendErr).Error("send of terminator detail failed, closing channel") + if closeErr := ch.Close(); closeErr != nil { + log.WithError(closeErr).Error("failed to close channel") + } + } + } else { + log.Info("channel closed, unable to send terminator detail") + } + }) + } + + response := &mgmt_pb.ValidateTerminatorsResponse{} + if err == nil { + response.Success = true + response.TerminatorCount = terminatorCount + } else { + response.Success = false + response.Message = fmt.Sprintf("%v: failed to unmarshall request: %v", handler.network.GetAppId(), err) + } + + body, err := proto.Marshal(response) + if err != nil { + pfxlog.Logger().WithError(err).Error("unexpected error serializing ValidateTerminatorsResponse") + return + } + + responseMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ValidateTerminatorResponseType), body) + responseMsg.ReplyTo(msg) + if err = ch.Send(responseMsg); err != nil { + pfxlog.Logger().WithError(err).Error("unexpected error sending ValidateTerminatorsResponse") + } +} diff --git a/controller/internal/policy/service_policy_enforcer.go b/controller/internal/policy/service_policy_enforcer.go index c9abcbf50..9b0189b35 100644 --- a/controller/internal/policy/service_policy_enforcer.go +++ b/controller/internal/policy/service_policy_enforcer.go @@ -21,10 +21,10 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/ziti/common/runner" "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" "time" "github.com/openziti/ziti/controller/env" - "github.com/openziti/ziti/controller/persistence" "go.etcd.io/bbolt" ) @@ -48,19 +48,19 @@ func NewServicePolicyEnforcer(appEnv *env.AppEnv, f time.Duration) *ServicePolic notify: make(chan struct{}, 1), } result.notify <- struct{}{} // ensure we do a full scan on startup - persistence.ServiceEvents.AddServiceEventHandler(result.handleServiceEvent) + db.ServiceEvents.AddServiceEventHandler(result.handleServiceEvent) return result } -func (enforcer *ServicePolicyEnforcer) handleServiceEvent(event *persistence.ServiceEvent) { +func (enforcer *ServicePolicyEnforcer) handleServiceEvent(event *db.ServiceEvent) { policyType := "" - if event.Type == persistence.ServiceDialAccessLost { - policyType = persistence.PolicyTypeDialName + if event.Type == db.ServiceDialAccessLost { + policyType = db.PolicyTypeDialName } - if event.Type == persistence.ServiceBindAccessLost { - policyType = persistence.PolicyTypeBindName + if event.Type == db.ServiceBindAccessLost { + policyType = db.PolicyTypeBindName } if policyType == "" { @@ -148,9 +148,9 @@ func (enforcer *ServicePolicyEnforcer) Run() error { continue } - policyType := persistence.PolicyTypeDial - if session.Type == persistence.SessionTypeBind { - policyType = persistence.PolicyTypeBind + policyType := db.PolicyTypeDial + if session.Type == db.SessionTypeBind { + policyType = db.PolicyTypeBind } query := fmt.Sprintf(`id = "%v" and not isEmpty(from servicePolicies where type = %v and anyOf(services) = "%v")`, identity.Id, policyType.Id(), session.ServiceId) _, count, err := enforcer.appEnv.GetStores().Identity.QueryIds(tx, query) diff --git a/controller/internal/policy/session_enforcer_test.go b/controller/internal/policy/session_enforcer_test.go index ff57c2433..96a750ac0 100644 --- a/controller/internal/policy/session_enforcer_test.go +++ b/controller/internal/policy/session_enforcer_test.go @@ -18,11 +18,11 @@ package policy import ( "github.com/google/go-cmp/cmp/cmpopts" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/storage/boltz" "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/model" "github.com/sirupsen/logrus" "testing" "time" @@ -46,10 +46,10 @@ func (ctx *enforcerTestContext) testSessionsCleanup() { logrus.SetLevel(logrus.DebugLevel) ctx.CleanupAll() - compareOpts := cmpopts.IgnoreFields(persistence.Session{}, "ApiSession") + compareOpts := cmpopts.IgnoreFields(db.Session{}, "ApiSession") identity := ctx.RequireNewIdentity("Jojo", false) - apiSession := persistence.NewApiSession(identity.Id) + apiSession := db.NewApiSession(identity.Id) boltztest.RequireCreate(ctx, apiSession) service := ctx.RequireNewService("test-service") session := NewSession(apiSession.Id, service.Id) @@ -57,7 +57,7 @@ func (ctx *enforcerTestContext) testSessionsCleanup() { boltztest.ValidateBaseline(ctx, session, compareOpts) session2 := NewSession(apiSession.Id, service.Id) - session2.Type = persistence.PolicyTypeBindName + session2.Type = db.PolicyTypeBindName boltztest.RequireCreate(ctx, session2) boltztest.ValidateBaseline(ctx, session2, compareOpts) @@ -92,12 +92,12 @@ func (ctx *enforcerTestContext) testSessionsCleanup() { boltztest.ValidateDeleted(ctx, session3.Id) } -func NewSession(apiSessionId, serviceId string) *persistence.Session { - return &persistence.Session{ +func NewSession(apiSessionId, serviceId string) *db.Session { + return &db.Session{ BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, Token: eid.New(), ApiSessionId: apiSessionId, ServiceId: serviceId, - Type: persistence.SessionTypeDial, + Type: db.SessionTypeDial, } } diff --git a/controller/internal/routes/authenticator_api_model.go b/controller/internal/routes/authenticator_api_model.go index d59885a95..63ae6010c 100644 --- a/controller/internal/routes/authenticator_api_model.go +++ b/controller/internal/routes/authenticator_api_model.go @@ -18,13 +18,13 @@ package routes import ( "github.com/openziti/edge-api/rest_model" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/response" "github.com/openziti/ziti/controller/models" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/ziti/controller/response" ) const EntityNameAuthenticator = "authenticators" @@ -62,7 +62,7 @@ func MapCreateToAuthenticatorModel(in *rest_model.AuthenticatorCreate) (*model.A var subType interface{} switch result.Method { - case persistence.MethodAuthenticatorCert: + case db.MethodAuthenticatorCert: if in.CertPem == "" { return nil, errorz.NewFieldError("certPem is required", "certPem", in.CertPem) } @@ -70,7 +70,7 @@ func MapCreateToAuthenticatorModel(in *rest_model.AuthenticatorCreate) (*model.A subType = &model.AuthenticatorCert{ Pem: in.CertPem, } - case persistence.MethodAuthenticatorUpdb: + case db.MethodAuthenticatorUpdb: if in.Username == "" { return nil, errorz.NewFieldError("username is required", "username", in.Username) } @@ -100,7 +100,7 @@ func MapUpdateAuthenticatorToModel(id string, in *rest_model.AuthenticatorUpdate Id: id, Tags: TagsOrDefault(in.Tags), }, - Method: persistence.MethodAuthenticatorUpdb, + Method: db.MethodAuthenticatorUpdb, } result.SubType = &model.AuthenticatorUpdb{ @@ -119,7 +119,7 @@ func MapPatchAuthenticatorToModel(id string, in *rest_model.AuthenticatorPatch) Id: id, Tags: TagsOrDefault(in.Tags), }, - Method: persistence.MethodAuthenticatorUpdb, + Method: db.MethodAuthenticatorUpdb, } subType := &model.AuthenticatorUpdb{ @@ -160,10 +160,10 @@ func MapAuthenticatorToRestModel(ae *env.AppEnv, i *model.Authenticator) (*rest_ } switch i.Method { - case persistence.MethodAuthenticatorUpdb: + case db.MethodAuthenticatorUpdb: subType := i.SubType.(*model.AuthenticatorUpdb) result.Username = subType.Username - case persistence.MethodAuthenticatorCert: + case db.MethodAuthenticatorCert: subType := i.SubType.(*model.AuthenticatorCert) result.CertPem = subType.Pem result.Fingerprint = subType.Fingerprint diff --git a/controller/internal/routes/current_identity_router.go b/controller/internal/routes/current_identity_router.go index 153138f33..a5577fc73 100644 --- a/controller/internal/routes/current_identity_router.go +++ b/controller/internal/routes/current_identity_router.go @@ -22,15 +22,15 @@ import ( clientCurrentIdentity "github.com/openziti/edge-api/rest_client_api_server/operations/current_identity" managementCurrentIdentity "github.com/openziti/edge-api/rest_management_api_server/operations/current_identity" "github.com/openziti/edge-api/rest_model" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/controller/apierror" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" "github.com/openziti/ziti/controller/internal/permissions" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/response" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "net/http" ) @@ -177,7 +177,7 @@ func (r *CurrentIdentityRouter) verifyMfa(ae *env.AppEnv, rc *response.RequestCo rc.ApiSession.MfaComplete = true rc.ApiSession.MfaRequired = true - if err := ae.Managers.ApiSession.UpdateWithFieldChecker(rc.ApiSession, boltz.MapFieldChecker{persistence.FieldApiSessionMfaComplete: struct{}{}, persistence.FieldApiSessionMfaRequired: struct{}{}}, changeCtx); err != nil { + if err := ae.Managers.ApiSession.UpdateWithFieldChecker(rc.ApiSession, boltz.MapFieldChecker{db.FieldApiSessionMfaComplete: struct{}{}, db.FieldApiSessionMfaRequired: struct{}{}}, changeCtx); err != nil { pfxlog.Logger().Errorf("could not update API Session with new MFA status: %v", err) } diff --git a/controller/internal/routes/enroll_router.go b/controller/internal/routes/enroll_router.go index 97c9babe9..74199e6fb 100644 --- a/controller/internal/routes/enroll_router.go +++ b/controller/internal/routes/enroll_router.go @@ -28,13 +28,13 @@ import ( client_well_known "github.com/openziti/edge-api/rest_client_api_server/operations/well_known" management_well_known "github.com/openziti/edge-api/rest_management_api_server/operations/well_known" "github.com/openziti/edge-api/rest_model" + "github.com/openziti/foundation/v2/errorz" cert2 "github.com/openziti/ziti/common/cert" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" "github.com/openziti/ziti/controller/internal/permissions" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/response" - "github.com/openziti/foundation/v2/errorz" "net/http" "strings" ) @@ -169,7 +169,7 @@ func (ro *EnrollRouter) enrollHandler(ae *env.AppEnv, rc *response.RequestContex // for non ott enrollment, always return JSON //prefer JSON if explicitly acceptable - if enrollContext.GetMethod() != persistence.MethodEnrollOtt || explicitJsonAccept { + if enrollContext.GetMethod() != db.MethodEnrollOtt || explicitJsonAccept { rc.SetProducer(runtime.JSONProducer()) } diff --git a/controller/internal/routes/external_jwt_signer_router.go b/controller/internal/routes/external_jwt_signer_router.go index cb3b5911b..35785aa9a 100644 --- a/controller/internal/routes/external_jwt_signer_router.go +++ b/controller/internal/routes/external_jwt_signer_router.go @@ -20,12 +20,12 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/michaelquigley/pfxlog" "github.com/openziti/edge-api/rest_management_api_server/operations/external_jwt_signer" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" + "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/internal/permissions" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/response" - "github.com/openziti/ziti/controller/fields" ) func init() { @@ -102,11 +102,11 @@ func (r *ExternalJwtSignerRouter) Update(ae *env.AppEnv, rc *response.RequestCon func (r *ExternalJwtSignerRouter) Patch(ae *env.AppEnv, rc *response.RequestContext, params external_jwt_signer.PatchExternalJWTSignerParams) { Patch(rc, func(id string, fields fields.UpdatedFields) error { - if fields.IsUpdated(persistence.FieldExternalJwtSignerCertPem) { - fields.AddField(persistence.FieldExternalJwtSignerCommonName) - fields.AddField(persistence.FieldExternalJwtSignerNotBefore) - fields.AddField(persistence.FieldExternalJwtSignerNotAfter) - fields.AddField(persistence.FieldExternalJwtSignerFingerprint) + if fields.IsUpdated(db.FieldExternalJwtSignerCertPem) { + fields.AddField(db.FieldExternalJwtSignerCommonName) + fields.AddField(db.FieldExternalJwtSignerNotBefore) + fields.AddField(db.FieldExternalJwtSignerNotAfter) + fields.AddField(db.FieldExternalJwtSignerFingerprint) } externalJwtSigner := MapPatchExternalJwtSignerToModel(params.ID, params.ExternalJWTSigner) diff --git a/controller/internal/routes/identity_api_model.go b/controller/internal/routes/identity_api_model.go index 79dd2dde6..0f292e81e 100644 --- a/controller/internal/routes/identity_api_model.go +++ b/controller/internal/routes/identity_api_model.go @@ -22,13 +22,13 @@ import ( "github.com/google/uuid" "github.com/michaelquigley/pfxlog" "github.com/openziti/edge-api/rest_model" + "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/sdk-golang/ziti" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/response" "github.com/openziti/ziti/controller/models" - "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/sdk-golang/ziti" + "github.com/openziti/ziti/controller/response" "strings" ) @@ -118,7 +118,7 @@ func MapCreateIdentityToModel(identity *rest_model.IdentityCreate, identityTypeI Tags: TagsOrDefault(identity.Tags), }, Name: stringz.OrEmpty(identity.Name), - IdentityTypeId: persistence.DefaultIdentityType, + IdentityTypeId: db.DefaultIdentityType, IsDefaultAdmin: false, IsAdmin: *identity.IsAdmin, RoleAttributes: AttributesOrDefault(identity.RoleAttributes), @@ -135,14 +135,14 @@ func MapCreateIdentityToModel(identity *rest_model.IdentityCreate, identityTypeI if identity.Enrollment.Ott { enrollments = append(enrollments, &model.Enrollment{ BaseEntity: models.BaseEntity{}, - Method: persistence.MethodEnrollOtt, + Method: db.MethodEnrollOtt, Token: uuid.New().String(), }) } else if identity.Enrollment.Ottca != "" { caId := identity.Enrollment.Ottca enrollments = append(enrollments, &model.Enrollment{ BaseEntity: models.BaseEntity{}, - Method: persistence.MethodEnrollOttCa, + Method: db.MethodEnrollOttCa, Token: uuid.New().String(), CaId: &caId, }) @@ -150,7 +150,7 @@ func MapCreateIdentityToModel(identity *rest_model.IdentityCreate, identityTypeI username := identity.Enrollment.Updb enrollments = append(enrollments, &model.Enrollment{ BaseEntity: models.BaseEntity{}, - Method: persistence.MethodEnrollUpdb, + Method: db.MethodEnrollUpdb, Token: uuid.New().String(), Username: &username, }) @@ -301,14 +301,14 @@ func MapIdentityToRestModel(ae *env.AppEnv, identity *model.Identity) (*rest_mod ret.Authenticators = &rest_model.IdentityAuthenticators{} if err = ae.GetManagers().Identity.CollectAuthenticators(identity.Id, func(entity *model.Authenticator) error { - if entity.Method == persistence.MethodAuthenticatorUpdb { + if entity.Method == db.MethodAuthenticatorUpdb { ret.Authenticators.Updb = &rest_model.IdentityAuthenticatorsUpdb{ ID: entity.Id, Username: entity.ToUpdb().Username, } } - if entity.Method == persistence.MethodAuthenticatorCert { + if entity.Method == db.MethodAuthenticatorCert { ret.Authenticators.Cert = &rest_model.IdentityAuthenticatorsCert{ ID: entity.Id, Fingerprint: entity.ToCert().Fingerprint, @@ -326,7 +326,7 @@ func MapIdentityToRestModel(ae *env.AppEnv, identity *model.Identity) (*rest_mod expiresAt = strfmt.DateTime(*entity.ExpiresAt) } - if entity.Method == persistence.MethodEnrollUpdb { + if entity.Method == db.MethodEnrollUpdb { ret.Enrollment.Updb = &rest_model.IdentityEnrollmentsUpdb{ ID: entity.Id, @@ -336,7 +336,7 @@ func MapIdentityToRestModel(ae *env.AppEnv, identity *model.Identity) (*rest_mod } } - if entity.Method == persistence.MethodEnrollOtt { + if entity.Method == db.MethodEnrollOtt { ret.Enrollment.Ott = &rest_model.IdentityEnrollmentsOtt{ ID: entity.Id, JWT: entity.Jwt, @@ -345,7 +345,7 @@ func MapIdentityToRestModel(ae *env.AppEnv, identity *model.Identity) (*rest_mod } } - if entity.Method == persistence.MethodEnrollOttCa { + if entity.Method == db.MethodEnrollOttCa { if ca, err := ae.Managers.Ca.Read(*entity.CaId); err == nil { ret.Enrollment.Ottca = &rest_model.IdentityEnrollmentsOttca{ ID: entity.Id, diff --git a/controller/internal/routes/identity_router.go b/controller/internal/routes/identity_router.go index 8ba9e48bd..033c55c28 100644 --- a/controller/internal/routes/identity_router.go +++ b/controller/internal/routes/identity_router.go @@ -24,18 +24,18 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/edge-api/rest_management_api_server/operations/identity" "github.com/openziti/edge-api/rest_model" - "github.com/openziti/ziti/controller/env" - "github.com/openziti/ziti/controller/internal/permissions" - "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/response" - "github.com/openziti/ziti/controller/fields" - "github.com/openziti/ziti/controller/models" - "github.com/openziti/ziti/common/logcontext" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/logcontext" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/env" + "github.com/openziti/ziti/controller/fields" + "github.com/openziti/ziti/controller/internal/permissions" + "github.com/openziti/ziti/controller/model" + "github.com/openziti/ziti/controller/models" + "github.com/openziti/ziti/controller/response" "github.com/sirupsen/logrus" "time" ) @@ -193,7 +193,7 @@ func (r *IdentityRouter) Detail(ae *env.AppEnv, rc *response.RequestContext) { func getIdentityTypeId(ae *env.AppEnv, identityType rest_model.IdentityType) string { //todo: Remove this, should be identityTypeId coming in through the API so we can defer this lookup and subsequent checks to the handlers if identityType == rest_model.IdentityTypeDevice || identityType == rest_model.IdentityTypeService || identityType == rest_model.IdentityTypeUser { - return persistence.DefaultIdentityType + return db.DefaultIdentityType } identityTypeId := "" if identityType, err := ae.Managers.IdentityType.ReadByName(string(identityType)); identityType != nil && err == nil { @@ -226,7 +226,7 @@ func (r *IdentityRouter) Update(ae *env.AppEnv, rc *response.RequestContext, par func (r *IdentityRouter) Patch(ae *env.AppEnv, rc *response.RequestContext, params identity.PatchIdentityParams) { Patch(rc, func(id string, fields fields.UpdatedFields) error { - fields = fields.FilterMaps(boltz.FieldTags, persistence.FieldIdentityAppData, persistence.FieldIdentityServiceHostingCosts, persistence.FieldIdentityServiceHostingPrecedences) + fields = fields.FilterMaps(boltz.FieldTags, db.FieldIdentityAppData, db.FieldIdentityServiceHostingCosts, db.FieldIdentityServiceHostingPrecedences) return ae.Managers.Identity.Update(MapPatchIdentityToModel(params.ID, params.Identity, getIdentityTypeId(ae, params.Identity.Type)), fields, rc.NewChangeContext()) }) } diff --git a/controller/internal/routes/posture_check_router.go b/controller/internal/routes/posture_check_router.go index abe509fb2..9f9842926 100644 --- a/controller/internal/routes/posture_check_router.go +++ b/controller/internal/routes/posture_check_router.go @@ -19,13 +19,13 @@ package routes import ( "github.com/go-openapi/runtime/middleware" "github.com/openziti/edge-api/rest_management_api_server/operations/posture_checks" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" + "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/internal/permissions" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/response" - "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" + "github.com/openziti/ziti/controller/response" ) func init() { @@ -138,30 +138,30 @@ func (r *PostureCheckRouter) Patch(ae *env.AppEnv, rc *response.RequestContext, check := MapPatchPostureCheckToModel(params.ID, params.PostureCheck) if fields.IsUpdated("operatingSystems") { - fields.AddField(persistence.FieldPostureCheckOsType) - fields.AddField(persistence.FieldPostureCheckOsVersions) + fields.AddField(db.FieldPostureCheckOsType) + fields.AddField(db.FieldPostureCheckOsVersions) } if fields.IsUpdated("process.hashes") { - fields.AddField(persistence.FieldPostureCheckProcessHashes) + fields.AddField(db.FieldPostureCheckProcessHashes) } if fields.IsUpdated("process.path") { - fields.AddField(persistence.FieldPostureCheckProcessPath) + fields.AddField(db.FieldPostureCheckProcessPath) } if fields.IsUpdated("process.osType") { - fields.AddField(persistence.FieldPostureCheckProcessOs) + fields.AddField(db.FieldPostureCheckProcessOs) } if fields.IsUpdated("process.signerFingerprint") { - fields.AddField(persistence.FieldPostureCheckProcessFingerprint) + fields.AddField(db.FieldPostureCheckProcessFingerprint) } if fields.IsUpdated("processes") { - fields.AddField(persistence.FieldPostureCheckProcessMultiPath) - fields.AddField(persistence.FieldPostureCheckProcessMultiOsType) - fields.AddField(persistence.FieldPostureCheckProcessMultiSignerFingerprints) - fields.AddField(persistence.FieldPostureCheckProcessMultiHashes) + fields.AddField(db.FieldPostureCheckProcessMultiPath) + fields.AddField(db.FieldPostureCheckProcessMultiOsType) + fields.AddField(db.FieldPostureCheckProcessMultiSignerFingerprints) + fields.AddField(db.FieldPostureCheckProcessMultiHashes) } return ae.Managers.PostureCheck.Update(check, fields.FilterMaps("tags"), rc.NewChangeContext()) diff --git a/controller/internal/routes/service_api_model.go b/controller/internal/routes/service_api_model.go index 871c06ba8..4eb12f32c 100644 --- a/controller/internal/routes/service_api_model.go +++ b/controller/internal/routes/service_api_model.go @@ -19,12 +19,12 @@ package routes import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/edge-api/rest_model" + "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/response" "github.com/openziti/ziti/controller/models" - "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/ziti/controller/response" "strings" ) @@ -151,9 +151,9 @@ func MapServiceToRestModel(ae *env.AppEnv, rc *response.RequestContext, service PostureQueries: []*rest_model.PostureQuery{}, } - if policyPostureChecks.PolicyType == persistence.PolicyTypeBind { + if policyPostureChecks.PolicyType == db.PolicyTypeBind { querySet.PolicyType = rest_model.DialBindBind - } else if policyPostureChecks.PolicyType == persistence.PolicyTypeDial { + } else if policyPostureChecks.PolicyType == db.PolicyTypeDial { querySet.PolicyType = rest_model.DialBindDial } else { pfxlog.Logger().Errorf("attempting to render API response for policy type [%s] for policy id [%s], unknown type expected dial/bind", policyPostureChecks.PolicyType, policyId) diff --git a/controller/model/api_session_certificate_manager.go b/controller/model/api_session_certificate_manager.go index 3a00e194a..e02d0d01b 100644 --- a/controller/model/api_session_certificate_manager.go +++ b/controller/model/api_session_certificate_manager.go @@ -21,8 +21,8 @@ import ( "fmt" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "time" @@ -30,7 +30,7 @@ import ( func NewApiSessionCertificateManager(env Env) *ApiSessionCertificateManager { manager := &ApiSessionCertificateManager{ - baseEntityManager: newBaseEntityManager[*ApiSessionCertificate, *persistence.ApiSessionCertificate](env, env.GetStores().ApiSessionCertificate), + baseEntityManager: newBaseEntityManager[*ApiSessionCertificate, *db.ApiSessionCertificate](env, env.GetStores().ApiSessionCertificate), } manager.impl = manager @@ -38,7 +38,7 @@ func NewApiSessionCertificateManager(env Env) *ApiSessionCertificateManager { } type ApiSessionCertificateManager struct { - baseEntityManager[*ApiSessionCertificate, *persistence.ApiSessionCertificate] + baseEntityManager[*ApiSessionCertificate, *db.ApiSessionCertificate] } func (self *ApiSessionCertificateManager) newModelEntity() *ApiSessionCertificate { diff --git a/controller/model/api_session_certificate_model.go b/controller/model/api_session_certificate_model.go index 3cff8f51e..6f2d32553 100644 --- a/controller/model/api_session_certificate_model.go +++ b/controller/model/api_session_certificate_model.go @@ -18,11 +18,11 @@ package model import ( "crypto/x509" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" nfpem "github.com/openziti/foundation/v2/pem" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "time" ) @@ -51,12 +51,12 @@ func NewApiSessionCertificate(cert *x509.Certificate) *ApiSessionCertificate { return ret } -func (entity *ApiSessionCertificate) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.ApiSessionCertificate, error) { +func (entity *ApiSessionCertificate) toBoltEntity(tx *bbolt.Tx, env Env) (*db.ApiSessionCertificate, error) { if !env.GetStores().ApiSession.IsEntityPresent(tx, entity.ApiSessionId) { return nil, errorz.NewFieldError("api session not found", "ApiSessionId", entity.ApiSessionId) } - boltEntity := &persistence.ApiSessionCertificate{ + boltEntity := &db.ApiSessionCertificate{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), ApiSessionId: entity.ApiSessionId, Subject: entity.Subject, @@ -69,15 +69,15 @@ func (entity *ApiSessionCertificate) toBoltEntity(tx *bbolt.Tx, env Env) (*persi return boltEntity, nil } -func (entity *ApiSessionCertificate) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.ApiSessionCertificate, error) { +func (entity *ApiSessionCertificate) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*db.ApiSessionCertificate, error) { return entity.toBoltEntity(tx, env) } -func (entity *ApiSessionCertificate) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*persistence.ApiSessionCertificate, error) { +func (entity *ApiSessionCertificate) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*db.ApiSessionCertificate, error) { return entity.toBoltEntity(tx, env) } -func (entity *ApiSessionCertificate) fillFrom(env Env, tx *bbolt.Tx, boltApiSessionCertificate *persistence.ApiSessionCertificate) error { +func (entity *ApiSessionCertificate) fillFrom(env Env, tx *bbolt.Tx, boltApiSessionCertificate *db.ApiSessionCertificate) error { entity.FillCommon(boltApiSessionCertificate) entity.Subject = boltApiSessionCertificate.Subject entity.Fingerprint = boltApiSessionCertificate.Fingerprint diff --git a/controller/model/api_session_manager.go b/controller/model/api_session_manager.go index 935af1981..61f6378e7 100644 --- a/controller/model/api_session_manager.go +++ b/controller/model/api_session_manager.go @@ -20,11 +20,11 @@ import ( "fmt" "github.com/lucsky/cuid" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/change" - "github.com/openziti/ziti/controller/models" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "github.com/pkg/errors" "go.etcd.io/bbolt" "time" @@ -32,7 +32,7 @@ import ( func NewApiSessionManager(env Env) *ApiSessionManager { manager := &ApiSessionManager{ - baseEntityManager: newBaseEntityManager[*ApiSession, *persistence.ApiSession](env, env.GetStores().ApiSession), + baseEntityManager: newBaseEntityManager[*ApiSession, *db.ApiSession](env, env.GetStores().ApiSession), } manager.HeartbeatCollector = NewHeartbeatCollector(env, env.GetConfig().Api.ActivityUpdateBatchSize, env.GetConfig().Api.ActivityUpdateInterval, manager.heartbeatFlush) @@ -43,7 +43,7 @@ func NewApiSessionManager(env Env) *ApiSessionManager { } type ApiSessionManager struct { - baseEntityManager[*ApiSession, *persistence.ApiSession] + baseEntityManager[*ApiSession, *db.ApiSession] HeartbeatCollector *HeartbeatCollector } @@ -123,7 +123,7 @@ func (self *ApiSessionManager) UpdateWithFieldChecker(apiSession *ApiSession, fi func (self *ApiSessionManager) MfaCompleted(apiSession *ApiSession, ctx *change.Context) error { apiSession.MfaComplete = true - return self.updateEntity(apiSession, &OrFieldChecker{NewFieldChecker(persistence.FieldApiSessionMfaComplete), self}, ctx.NewMutateContext()) + return self.updateEntity(apiSession, &OrFieldChecker{NewFieldChecker(db.FieldApiSessionMfaComplete), self}, ctx.NewMutateContext()) } func (self *ApiSessionManager) Delete(id string, ctx *change.Context) error { @@ -148,7 +148,7 @@ func (self *ApiSessionManager) MarkLastActivityByTokens(tokens ...string) ([]str var notFoundTokens []string store := self.env.GetStores().ApiSession - var apiSessions []*persistence.ApiSession + var apiSessions []*db.ApiSession identityIds := map[string]struct{}{} err := self.GetDb().View(func(tx *bbolt.Tx) error { @@ -186,12 +186,12 @@ func (self *ApiSessionManager) heartbeatFlush(beats []*Heartbeat) { store := self.env.GetStores().ApiSession for _, beat := range beats { - err := store.Update(ctx, &persistence.ApiSession{ + err := store.Update(ctx, &db.ApiSession{ BaseExtEntity: boltz.BaseExtEntity{ Id: beat.ApiSessionId, }, LastActivityAt: beat.LastActivityAt, - }, persistence.UpdateLastActivityAtChecker{}) + }, db.UpdateLastActivityAtChecker{}) if err != nil { pfxlog.Logger().Errorf("could not flush heartbeat activity for api session id %s: %v", beat.ApiSessionId, err) @@ -289,7 +289,7 @@ func (self *ApiSessionManager) VisitFingerprintsForApiSession(tx *bbolt.Tx, iden func (self *ApiSessionManager) DeleteByIdentityId(identityId string, changeCtx *change.Context) error { return self.GetEnv().GetDbProvider().GetDb().Update(changeCtx.NewMutateContext(), func(ctx boltz.MutateContext) error { - query := fmt.Sprintf(`%s = "%s"`, persistence.FieldApiSessionIdentity, identityId) + query := fmt.Sprintf(`%s = "%s"`, db.FieldApiSessionIdentity, identityId) return self.Store.DeleteWhere(ctx, query) }) } diff --git a/controller/model/api_session_model.go b/controller/model/api_session_model.go index 461c5c766..039c8a463 100644 --- a/controller/model/api_session_model.go +++ b/controller/model/api_session_model.go @@ -17,11 +17,11 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "time" ) @@ -41,12 +41,12 @@ type ApiSession struct { AuthenticatorId string } -func (entity *ApiSession) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.ApiSession, error) { +func (entity *ApiSession) toBoltEntity(tx *bbolt.Tx, env Env) (*db.ApiSession, error) { if !env.GetStores().Identity.IsEntityPresent(tx, entity.IdentityId) { return nil, errorz.NewFieldError("identity not found", "IdentityId", entity.IdentityId) } - boltEntity := &persistence.ApiSession{ + boltEntity := &db.ApiSession{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Token: entity.Token, IdentityId: entity.IdentityId, @@ -61,15 +61,15 @@ func (entity *ApiSession) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.ApiS return boltEntity, nil } -func (entity *ApiSession) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.ApiSession, error) { +func (entity *ApiSession) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*db.ApiSession, error) { return entity.toBoltEntity(tx, env) } -func (entity *ApiSession) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*persistence.ApiSession, error) { +func (entity *ApiSession) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*db.ApiSession, error) { return entity.toBoltEntity(tx, env) } -func (entity *ApiSession) fillFrom(env Env, tx *bbolt.Tx, boltApiSession *persistence.ApiSession) error { +func (entity *ApiSession) fillFrom(env Env, tx *bbolt.Tx, boltApiSession *db.ApiSession) error { entity.FillCommon(boltApiSession) entity.Token = boltApiSession.Token entity.IdentityId = boltApiSession.IdentityId diff --git a/controller/model/auth_policy_manager.go b/controller/model/auth_policy_manager.go index 37c0a6e60..8b0a4aaa2 100644 --- a/controller/model/auth_policy_manager.go +++ b/controller/model/auth_policy_manager.go @@ -18,22 +18,22 @@ package model import ( "fmt" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "google.golang.org/protobuf/proto" ) func NewAuthPolicyManager(env Env) *AuthPolicyManager { manager := &AuthPolicyManager{ - baseEntityManager: newBaseEntityManager[*AuthPolicy, *persistence.AuthPolicy](env, env.GetStores().AuthPolicy), + baseEntityManager: newBaseEntityManager[*AuthPolicy, *db.AuthPolicy](env, env.GetStores().AuthPolicy), } manager.impl = manager @@ -43,7 +43,7 @@ func NewAuthPolicyManager(env Env) *AuthPolicyManager { } type AuthPolicyManager struct { - baseEntityManager[*AuthPolicy, *persistence.AuthPolicy] + baseEntityManager[*AuthPolicy, *db.AuthPolicy] } func (self *AuthPolicyManager) Create(entity *AuthPolicy, ctx *change.Context) error { diff --git a/controller/model/auth_policy_model.go b/controller/model/auth_policy_model.go index 16e32a8ed..244e49f8b 100644 --- a/controller/model/auth_policy_model.go +++ b/controller/model/auth_policy_model.go @@ -17,9 +17,9 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -62,7 +62,7 @@ type AuthPolicyUpdb struct { LockoutDurationMinutes int64 } -func (entity *AuthPolicy) fillFrom(_ Env, _ *bbolt.Tx, boltAuthPolicy *persistence.AuthPolicy) error { +func (entity *AuthPolicy) fillFrom(_ Env, _ *bbolt.Tx, boltAuthPolicy *db.AuthPolicy) error { entity.FillCommon(boltAuthPolicy) entity.Name = boltAuthPolicy.Name entity.Primary = AuthPolicyPrimary{ @@ -92,16 +92,16 @@ func (entity *AuthPolicy) fillFrom(_ Env, _ *bbolt.Tx, boltAuthPolicy *persisten return nil } -func (entity *AuthPolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.AuthPolicy, error) { - boltEntity := &persistence.AuthPolicy{ +func (entity *AuthPolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.AuthPolicy, error) { + boltEntity := &db.AuthPolicy{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, - Primary: persistence.AuthPolicyPrimary{ - Cert: persistence.AuthPolicyCert{ + Primary: db.AuthPolicyPrimary{ + Cert: db.AuthPolicyCert{ Allowed: entity.Primary.Cert.Allowed, AllowExpiredCerts: entity.Primary.Cert.AllowExpiredCerts, }, - Updb: persistence.AuthPolicyUpdb{ + Updb: db.AuthPolicyUpdb{ Allowed: entity.Primary.Updb.Allowed, MinPasswordLength: entity.Primary.Updb.MinPasswordLength, RequireSpecialChar: entity.Primary.Updb.RequireSpecialChar, @@ -110,12 +110,12 @@ func (entity *AuthPolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.Au MaxAttempts: entity.Primary.Updb.MaxAttempts, LockoutDurationMinutes: entity.Primary.Updb.LockoutDurationMinutes, }, - ExtJwt: persistence.AuthPolicyExtJwt{ + ExtJwt: db.AuthPolicyExtJwt{ Allowed: entity.Primary.ExtJwt.Allowed, AllowedExtJwtSigners: entity.Primary.ExtJwt.AllowedExtJwtSigners, }, }, - Secondary: persistence.AuthPolicySecondary{ + Secondary: db.AuthPolicySecondary{ RequireTotp: entity.Secondary.RequireTotp, RequiredExtJwtSigner: entity.Secondary.RequiredExtJwtSigner, }, @@ -124,6 +124,6 @@ func (entity *AuthPolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.Au return boltEntity, nil } -func (entity *AuthPolicy) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*persistence.AuthPolicy, error) { +func (entity *AuthPolicy) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*db.AuthPolicy, error) { return entity.toBoltEntityForCreate(tx, env) } diff --git a/controller/model/authenticator_manager.go b/controller/model/authenticator_manager.go index acf0c3c8e..55cc6030b 100644 --- a/controller/model/authenticator_manager.go +++ b/controller/model/authenticator_manager.go @@ -22,20 +22,20 @@ import ( "fmt" "github.com/google/uuid" "github.com/michaelquigley/pfxlog" + "github.com/openziti/foundation/v2/errorz" + nfpem "github.com/openziti/foundation/v2/pem" + "github.com/openziti/storage/ast" + "github.com/openziti/storage/boltz" edgeCert "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/common/eid" "github.com/openziti/ziti/common/pb/edge_cmd_pb" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/foundation/v2/errorz" - nfpem "github.com/openziti/foundation/v2/pem" - "github.com/openziti/storage/ast" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" @@ -47,13 +47,13 @@ import ( const updateUnrestricted = 1 type AuthenticatorManager struct { - baseEntityManager[*Authenticator, *persistence.Authenticator] - authStore persistence.AuthenticatorStore + baseEntityManager[*Authenticator, *db.Authenticator] + authStore db.AuthenticatorStore } func NewAuthenticatorManager(env Env) *AuthenticatorManager { manager := &AuthenticatorManager{ - baseEntityManager: newBaseEntityManager[*Authenticator, *persistence.Authenticator](env, env.GetStores().Authenticator), + baseEntityManager: newBaseEntityManager[*Authenticator, *db.Authenticator](env, env.GetStores().Authenticator), authStore: env.GetStores().Authenticator, } @@ -83,9 +83,9 @@ func (self *AuthenticatorManager) Authorize(authContext AuthContext) (AuthResult } func (self *AuthenticatorManager) ReadFingerprints(authenticatorId string) ([]string, error) { - var authenticator *persistence.Authenticator + var authenticator *db.Authenticator - err := self.env.GetStores().DbProvider.GetDb().View(func(tx *bbolt.Tx) error { + err := self.env.GetDbProvider().GetDb().View(func(tx *bbolt.Tx) error { var err error authenticator, err = self.authStore.LoadOneById(tx, authenticatorId) return err @@ -112,7 +112,7 @@ func (self *AuthenticatorManager) Create(entity *Authenticator, ctx *change.Cont func (self *AuthenticatorManager) ApplyCreate(cmd *command.CreateEntityCommand[*Authenticator], ctx boltz.MutateContext) error { authenticator := cmd.Entity - if authenticator.Method != persistence.MethodAuthenticatorUpdb && authenticator.Method != persistence.MethodAuthenticatorCert { + if authenticator.Method != db.MethodAuthenticatorUpdb && authenticator.Method != db.MethodAuthenticatorCert { return errorz.NewFieldError("method must be updb or cert", "method", authenticator.Method) } @@ -131,7 +131,7 @@ func (self *AuthenticatorManager) ApplyCreate(cmd *command.CreateEntityCommand[* return apierror.NewAuthenticatorMethodMax() } - if authenticator.Method == persistence.MethodAuthenticatorUpdb { + if authenticator.Method == db.MethodAuthenticatorUpdb { if updb, ok := authenticator.SubType.(*AuthenticatorUpdb); ok { hashResult := self.HashPassword(updb.Password) updb.Password = hashResult.Password @@ -139,7 +139,7 @@ func (self *AuthenticatorManager) ApplyCreate(cmd *command.CreateEntityCommand[* } } - if authenticator.Method == persistence.MethodAuthenticatorCert { + if authenticator.Method == db.MethodAuthenticatorCert { certs := nfpem.PemStringToCertificates(authenticator.ToCert().Pem) if len(certs) != 1 { @@ -193,7 +193,7 @@ func (self *AuthenticatorManager) ApplyUpdate(cmd *command.UpdateEntityCommand[* } if cert := authenticator.ToCert(); cert != nil { - if cert.Pem != "" && (cmd.UpdatedFields == nil || cmd.UpdatedFields.IsUpdated(persistence.FieldAuthenticatorCertPem)) { + if cert.Pem != "" && (cmd.UpdatedFields == nil || cmd.UpdatedFields.IsUpdated(db.FieldAuthenticatorCertPem)) { if cert.Fingerprint = edgeCert.NewFingerprintGenerator().FromPem([]byte(cert.Pem)); cert.Fingerprint == "" { return apierror.NewCouldNotParsePem() } @@ -238,7 +238,7 @@ func (self *AuthenticatorManager) getRootPool() *x509.CertPool { } func (self *AuthenticatorManager) ReadByUsername(username string) (*Authenticator, error) { - query := fmt.Sprintf("%s = \"%v\"", persistence.FieldAuthenticatorUpdbUsername, username) + query := fmt.Sprintf("%s = \"%v\"", db.FieldAuthenticatorUpdbUsername, username) entity, err := self.readEntityByQuery(query) @@ -260,7 +260,7 @@ func (self *AuthenticatorManager) ReadByUsername(username string) (*Authenticato } func (self *AuthenticatorManager) ReadByFingerprint(fingerprint string) (*Authenticator, error) { - query := fmt.Sprintf("%s = \"%v\"", persistence.FieldAuthenticatorCertFingerprint, fingerprint) + query := fmt.Sprintf("%s = \"%v\"", db.FieldAuthenticatorCertFingerprint, fingerprint) entity, err := self.readEntityByQuery(query) @@ -425,7 +425,7 @@ func (self *AuthenticatorManager) ExtendCertForIdentity(identityId string, authe return nil, errorz.NewNotFound() } - if authenticator.Method != persistence.MethodAuthenticatorCert { + if authenticator.Method != db.MethodAuthenticatorCert { return nil, apierror.NewAuthenticatorCannotBeUpdated() } @@ -519,8 +519,8 @@ func (self *AuthenticatorManager) ExtendCertForIdentity(identityId string, authe authenticatorCert.UnverifiedFingerprint = newFingerprint err = self.env.GetManagers().Authenticator.Update(authenticatorCert.Authenticator, false, fields.UpdatedFieldsMap{ - persistence.FieldAuthenticatorUnverifiedCertPem: struct{}{}, - persistence.FieldAuthenticatorUnverifiedCertFingerprint: struct{}{}, + db.FieldAuthenticatorUnverifiedCertPem: struct{}{}, + db.FieldAuthenticatorUnverifiedCertFingerprint: struct{}{}, }, ctx) if err != nil { @@ -537,7 +537,7 @@ func (self *AuthenticatorManager) VerifyExtendCertForIdentity(apiSessionId, iden return errorz.NewNotFound() } - if authenticator.Method != persistence.MethodAuthenticatorCert { + if authenticator.Method != db.MethodAuthenticatorCert { return apierror.NewAuthenticatorCannotBeUpdated() } @@ -578,19 +578,19 @@ func (self *AuthenticatorManager) VerifyExtendCertForIdentity(apiSessionId, iden authenticatorCert.UnverifiedPem = "" err := self.env.GetManagers().Authenticator.Update(authenticatorCert.Authenticator, true, fields.UpdatedFieldsMap{ - "fingerprint": struct{}{}, - persistence.FieldAuthenticatorUnverifiedCertPem: struct{}{}, - persistence.FieldAuthenticatorUnverifiedCertFingerprint: struct{}{}, + "fingerprint": struct{}{}, + db.FieldAuthenticatorUnverifiedCertPem: struct{}{}, + db.FieldAuthenticatorUnverifiedCertFingerprint: struct{}{}, - persistence.FieldAuthenticatorCertPem: struct{}{}, - persistence.FieldAuthenticatorCertFingerprint: struct{}{}, + db.FieldAuthenticatorCertPem: struct{}{}, + db.FieldAuthenticatorCertFingerprint: struct{}{}, }, ctx) if err != nil { return err } - sessionCert := &persistence.ApiSessionCertificate{ + sessionCert := &db.ApiSessionCertificate{ BaseExtEntity: boltz.BaseExtEntity{ Id: eid.New(), }, @@ -606,7 +606,7 @@ func (self *AuthenticatorManager) VerifyExtendCertForIdentity(apiSessionId, iden if err = self.env.GetStores().ApiSessionCertificate.Create(mutateCtx, sessionCert); err != nil { return err } - return self.env.GetStores().ApiSessionCertificate.DeleteWhere(mutateCtx, fmt.Sprintf("%s=\"%s\"", persistence.FieldApiSessionCertificateFingerprint, oldFingerprint)) + return self.env.GetStores().ApiSessionCertificate.DeleteWhere(mutateCtx, fmt.Sprintf("%s=\"%s\"", db.FieldApiSessionCertificateFingerprint, oldFingerprint)) }) } @@ -628,21 +628,21 @@ func (self *AuthenticatorManager) ReEnroll(id string, expiresAt time.Time, ctx * Token: uuid.NewString(), } switch authenticator.Method { - case persistence.MethodAuthenticatorCert: + case db.MethodAuthenticatorCert: certAuth := authenticator.ToCert() caId := getCaId(self.env, certAuth) if caId != "" { - enrollment.Method = persistence.MethodEnrollOttCa + enrollment.Method = db.MethodEnrollOttCa enrollment.CaId = &caId } else { - enrollment.Method = persistence.MethodEnrollOtt + enrollment.Method = db.MethodEnrollOtt } - case persistence.MethodAuthenticatorUpdb: + case db.MethodAuthenticatorUpdb: updbAuthenticator := authenticator.ToUpdb() - enrollment.Method = persistence.MethodEnrollUpdb + enrollment.Method = db.MethodEnrollUpdb enrollment.IdentityId = &updbAuthenticator.IdentityId enrollment.Username = &updbAuthenticator.Username enrollment.Token = uuid.NewString() @@ -782,7 +782,7 @@ func (self *AuthenticatorManager) ProtobufToAuthenticator(msg *edge_cmd_pb.Authe UnverifiedFingerprint: st.Cert.UnverifiedFingerprint, UnverifiedPem: st.Cert.UnverifiedPem, } - authenticator.Method = persistence.MethodAuthenticatorCert + authenticator.Method = db.MethodAuthenticatorCert case *edge_cmd_pb.Authenticator_Updb_: if st.Updb == nil { return nil, errors.Errorf("no updb data provided for authenticator with id: %v", msg.Id) @@ -794,7 +794,7 @@ func (self *AuthenticatorManager) ProtobufToAuthenticator(msg *edge_cmd_pb.Authe Password: st.Updb.Password, Salt: st.Updb.Salt, } - authenticator.Method = persistence.MethodAuthenticatorUpdb + authenticator.Method = db.MethodAuthenticatorUpdb } return authenticator, nil diff --git a/controller/model/authenticator_mod_cert.go b/controller/model/authenticator_mod_cert.go index 000352dc7..329428899 100644 --- a/controller/model/authenticator_mod_cert.go +++ b/controller/model/authenticator_mod_cert.go @@ -21,14 +21,14 @@ import ( "encoding/base64" "encoding/pem" "github.com/michaelquigley/pfxlog" + "github.com/openziti/foundation/v2/errorz" + nfpem "github.com/openziti/foundation/v2/pem" + "github.com/openziti/foundation/v2/stringz" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" - "github.com/openziti/foundation/v2/errorz" - nfpem "github.com/openziti/foundation/v2/pem" - "github.com/openziti/foundation/v2/stringz" cmap "github.com/orcaman/concurrent-map/v2" "net/http" "time" @@ -52,7 +52,7 @@ type AuthModuleCert struct { func NewAuthModuleCert(env Env, caChain []byte) *AuthModuleCert { return &AuthModuleCert{ env: env, - method: persistence.MethodAuthenticatorCert, + method: db.MethodAuthenticatorCert, fingerprintGenerator: cert.NewFingerprintGenerator(), staticCaCerts: nfpem.PemBytesToCertificates(caChain), dynamicCaCache: cmap.New[[]*x509.Certificate](), @@ -220,7 +220,7 @@ func (module *AuthModuleCert) Process(context AuthContext) (AuthResult, error) { } } - if authenticator.Method == persistence.MethodAuthenticatorCert { + if authenticator.Method == db.MethodAuthenticatorCert { module.ensureAuthenticatorCertPem(authenticator, clientCert, context.GetChangeContext()) } @@ -350,7 +350,7 @@ func (module *AuthModuleCert) authenticatorExternalId(identityId string, clientC Tags: nil, IsSystem: true, }, - Method: persistence.MethodAuthenticatorCertCaExternalId, + Method: db.MethodAuthenticatorCertCaExternalId, IdentityId: identityId, } diff --git a/controller/model/authenticator_mod_ext_jwt.go b/controller/model/authenticator_mod_ext_jwt.go index 51b32e591..591ccb795 100644 --- a/controller/model/authenticator_mod_ext_jwt.go +++ b/controller/model/authenticator_mod_ext_jwt.go @@ -22,12 +22,12 @@ import ( "fmt" "github.com/golang-jwt/jwt/v5" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" nfPem "github.com/openziti/foundation/v2/pem" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/jwks" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/apierror" + "github.com/openziti/ziti/controller/db" cmap "github.com/orcaman/concurrent-map/v2" "github.com/pkg/errors" "go.etcd.io/bbolt" @@ -76,7 +76,7 @@ type signerRecord struct { kidToPubKey map[string]pubKey jwksResponse *jwks.Response - externalJwtSigner *persistence.ExternalJwtSigner + externalJwtSigner *db.ExternalJwtSigner jwksResolver jwks.Resolver } @@ -268,7 +268,7 @@ func (a *AuthModuleExtJwt) ProcessSecondary(context AuthContext) (AuthResult, er type AuthResultJwt struct { AuthResultBase externalJwtSignerId string - externalJwtSigner *persistence.ExternalJwtSigner + externalJwtSigner *db.ExternalJwtSigner } func (a *AuthResultJwt) IsSuccessful() bool { @@ -312,7 +312,7 @@ func (a *AuthModuleExtJwt) process(context AuthContext, isPrimary bool) (AuthRes if err == nil && jwtToken.Valid { mapClaims := jwtToken.Claims.(jwt.MapClaims) - extJwt := mapClaims[ExtJwtInternalClaim].(*persistence.ExternalJwtSigner) + extJwt := mapClaims[ExtJwtInternalClaim].(*db.ExternalJwtSigner) if extJwt == nil { logger.Error("no external jwt signer found for internal claims") @@ -489,7 +489,7 @@ func (a *AuthModuleExtJwt) process(context AuthContext, isPrimary bool) (AuthRes } func (a *AuthModuleExtJwt) onExternalSignerCreate(args ...interface{}) { - signer, ok := args[0].(*persistence.ExternalJwtSigner) + signer, ok := args[0].(*db.ExternalJwtSigner) if !ok { pfxlog.Logger().Errorf("error on external signature create for authentication module %T: expected %T got %T", a, signer, args[0]) @@ -499,7 +499,7 @@ func (a *AuthModuleExtJwt) onExternalSignerCreate(args ...interface{}) { a.addSigner(signer) } -func (a *AuthModuleExtJwt) onExternalSignerUpdate(signer *persistence.ExternalJwtSigner) { +func (a *AuthModuleExtJwt) onExternalSignerUpdate(signer *db.ExternalJwtSigner) { //read on update because patches can pass partial data err := a.env.GetDbProvider().GetDb().View(func(tx *bbolt.Tx) error { var err error @@ -514,7 +514,7 @@ func (a *AuthModuleExtJwt) onExternalSignerUpdate(signer *persistence.ExternalJw a.addSigner(signer) } -func (a *AuthModuleExtJwt) addSigner(signer *persistence.ExternalJwtSigner) { +func (a *AuthModuleExtJwt) addSigner(signer *db.ExternalJwtSigner) { logger := pfxlog.Logger().WithFields(map[string]interface{}{ "id": signer.Id, "name": signer.Name, @@ -541,7 +541,7 @@ func (a *AuthModuleExtJwt) addSigner(signer *persistence.ExternalJwtSigner) { } -func (a *AuthModuleExtJwt) onExternalSignerDelete(signer *persistence.ExternalJwtSigner) { +func (a *AuthModuleExtJwt) onExternalSignerDelete(signer *db.ExternalJwtSigner) { logger := pfxlog.Logger().WithFields(map[string]interface{}{ "id": signer.Id, "name": signer.Name, diff --git a/controller/model/authenticator_mod_ext_jwt_test.go b/controller/model/authenticator_mod_ext_jwt_test.go index fe7879970..373037992 100644 --- a/controller/model/authenticator_mod_ext_jwt_test.go +++ b/controller/model/authenticator_mod_ext_jwt_test.go @@ -3,9 +3,9 @@ package model import ( "encoding/json" "github.com/Jeffail/gabs/v2" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/jwks" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" "github.com/stretchr/testify/require" "testing" "time" @@ -74,7 +74,7 @@ func Test_signerRecord_Resolve(t *testing.T) { signerRec := &signerRecord{ kidToPubKey: map[string]pubKey{}, - externalJwtSigner: &persistence.ExternalJwtSigner{ + externalJwtSigner: &db.ExternalJwtSigner{ BaseExtEntity: boltz.BaseExtEntity{ Id: "fake-id", CreatedAt: time.Now(), diff --git a/controller/model/authenticator_mod_updb.go b/controller/model/authenticator_mod_updb.go index a036e6f25..3c4f03bd2 100644 --- a/controller/model/authenticator_mod_updb.go +++ b/controller/model/authenticator_mod_updb.go @@ -20,9 +20,9 @@ import ( "encoding/base64" "errors" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/ziti/controller/apierror" + "github.com/openziti/ziti/controller/db" cmap "github.com/orcaman/concurrent-map/v2" "time" ) @@ -122,7 +122,7 @@ func (module *AuthModuleUpdb) Process(context AuthContext) (AuthResult, error) { return 0 }) - if authPolicy.Primary.Updb.MaxAttempts != persistence.UpdbUnlimitedAttemptsLimit && attempts > authPolicy.Primary.Updb.MaxAttempts { + if authPolicy.Primary.Updb.MaxAttempts != db.UpdbUnlimitedAttemptsLimit && attempts > authPolicy.Primary.Updb.MaxAttempts { logger.WithField("attempts", attempts).WithField("maxAttempts", authPolicy.Primary.Updb.MaxAttempts).Error("updb auth failed, max attempts exceeded") duration := time.Duration(authPolicy.Primary.Updb.LockoutDurationMinutes) * time.Minute diff --git a/controller/model/authenticator_model.go b/controller/model/authenticator_model.go index fac8e76ed..60374199b 100644 --- a/controller/model/authenticator_model.go +++ b/controller/model/authenticator_model.go @@ -19,9 +19,9 @@ package model import ( "encoding/base64" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "reflect" ) @@ -51,7 +51,7 @@ func (entity *Authenticator) Fingerprints() []string { } } -func (entity *Authenticator) fillFrom(_ Env, _ *bbolt.Tx, boltAuthenticator *persistence.Authenticator) error { +func (entity *Authenticator) fillFrom(_ Env, _ *bbolt.Tx, boltAuthenticator *db.Authenticator) error { entity.FillCommon(boltAuthenticator) entity.Method = boltAuthenticator.Type entity.IdentityId = boltAuthenticator.IdentityId @@ -59,14 +59,14 @@ func (entity *Authenticator) fillFrom(_ Env, _ *bbolt.Tx, boltAuthenticator *per boltSubType := boltAuthenticator.ToSubType() switch boltAuth := boltSubType.(type) { - case *persistence.AuthenticatorUpdb: + case *db.AuthenticatorUpdb: entity.SubType = &AuthenticatorUpdb{ Authenticator: entity, Username: boltAuth.Username, Password: boltAuth.Password, Salt: boltAuth.Salt, } - case *persistence.AuthenticatorCert: + case *db.AuthenticatorCert: entity.SubType = &AuthenticatorCert{ Authenticator: entity, Fingerprint: boltAuth.Fingerprint, @@ -82,14 +82,14 @@ func (entity *Authenticator) fillFrom(_ Env, _ *bbolt.Tx, boltAuthenticator *per return nil } -func (entity *Authenticator) toBoltEntity() (*persistence.Authenticator, error) { - boltEntity := &persistence.Authenticator{ +func (entity *Authenticator) toBoltEntity() (*db.Authenticator, error) { + boltEntity := &db.Authenticator{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Type: entity.Method, IdentityId: entity.IdentityId, } - var subType persistence.AuthenticatorSubType + var subType db.AuthenticatorSubType switch entity.SubType.(type) { case *AuthenticatorUpdb: @@ -99,7 +99,7 @@ func (entity *Authenticator) toBoltEntity() (*persistence.Authenticator, error) pfxlog.Logger().Panicf("unexpected type assertion failure to updb authenticator conversion to bolt model for type %s", reflect.TypeOf(entity.SubType)) } - subType = &persistence.AuthenticatorUpdb{ + subType = &db.AuthenticatorUpdb{ Authenticator: *boltEntity, Username: updbModel.Username, Password: updbModel.Password, @@ -112,7 +112,7 @@ func (entity *Authenticator) toBoltEntity() (*persistence.Authenticator, error) pfxlog.Logger().Panicf("unexpected type assertion failure to cert authenticator conversion to bolt model for type %s", reflect.TypeOf(entity.SubType)) } - subType = &persistence.AuthenticatorCert{ + subType = &db.AuthenticatorCert{ Authenticator: *boltEntity, Fingerprint: certModel.Fingerprint, Pem: certModel.Pem, @@ -129,11 +129,11 @@ func (entity *Authenticator) toBoltEntity() (*persistence.Authenticator, error) return boltEntity, nil } -func (entity *Authenticator) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.Authenticator, error) { +func (entity *Authenticator) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.Authenticator, error) { return entity.toBoltEntity() } -func (entity *Authenticator) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.Authenticator, error) { +func (entity *Authenticator) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.Authenticator, error) { return entity.toBoltEntity() } diff --git a/controller/model/ca_manager.go b/controller/model/ca_manager.go index a6629692e..a8119c146 100644 --- a/controller/model/ca_manager.go +++ b/controller/model/ca_manager.go @@ -18,15 +18,15 @@ package model import ( "fmt" + "github.com/openziti/storage/ast" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/ast" - "github.com/openziti/storage/boltz" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" "strings" @@ -34,7 +34,7 @@ import ( func NewCaManager(env Env) *CaManager { manager := &CaManager{ - baseEntityManager: newBaseEntityManager[*Ca, *persistence.Ca](env, env.GetStores().Ca), + baseEntityManager: newBaseEntityManager[*Ca, *db.Ca](env, env.GetStores().Ca), } manager.impl = manager @@ -44,7 +44,7 @@ func NewCaManager(env Env) *CaManager { } type CaManager struct { - baseEntityManager[*Ca, *persistence.Ca] + baseEntityManager[*Ca, *db.Ca] } func (self *CaManager) newModelEntity() *Ca { @@ -62,7 +62,7 @@ func (self *CaManager) ApplyCreate(cmd *command.CreateEntityCommand[*Ca], ctx bo func (self *CaManager) Update(entity *Ca, checker fields.UpdatedFields, ctx *change.Context) error { if checker != nil { - checker.RemoveFields(persistence.FieldCaIsVerified) + checker.RemoveFields(db.FieldCaIsVerified) } return network.DispatchUpdate[*Ca](self, entity, checker, ctx) } @@ -73,7 +73,7 @@ func (self *CaManager) ApplyUpdate(cmd *command.UpdateEntityCommand[*Ca], ctx bo // isVerified should only be set by the Verified method. We remove isVerified // from updated fields coming through Update method if cmd.UpdatedFields != nil { - if cmd.UpdatedFields.IsUpdated(persistence.FieldCaIsVerified) { + if cmd.UpdatedFields.IsUpdated(db.FieldCaIsVerified) { checker = cmd.UpdatedFields } else { checker = &AndFieldChecker{first: self, second: cmd.UpdatedFields} @@ -100,20 +100,20 @@ func (self *CaManager) readInTx(tx *bbolt.Tx, id string) (*Ca, error) { } func (self *CaManager) IsUpdated(field string) bool { - return strings.EqualFold(field, persistence.FieldName) || + return strings.EqualFold(field, db.FieldName) || strings.EqualFold(field, boltz.FieldTags) || - strings.EqualFold(field, persistence.FieldCaIsAutoCaEnrollmentEnabled) || - strings.EqualFold(field, persistence.FieldCaIsOttCaEnrollmentEnabled) || - strings.EqualFold(field, persistence.FieldCaIsAuthEnabled) || - strings.EqualFold(field, persistence.FieldIdentityRoles) || - strings.EqualFold(field, persistence.FieldCaIdentityNameFormat) || - strings.HasPrefix(field, persistence.FieldCaExternalIdClaim+".") + strings.EqualFold(field, db.FieldCaIsAutoCaEnrollmentEnabled) || + strings.EqualFold(field, db.FieldCaIsOttCaEnrollmentEnabled) || + strings.EqualFold(field, db.FieldCaIsAuthEnabled) || + strings.EqualFold(field, db.FieldIdentityRoles) || + strings.EqualFold(field, db.FieldCaIdentityNameFormat) || + strings.HasPrefix(field, db.FieldCaExternalIdClaim+".") } func (self *CaManager) Verified(ca *Ca, ctx *change.Context) error { ca.IsVerified = true checker := &fields.UpdatedFieldsMap{ - persistence.FieldCaIsVerified: struct{}{}, + db.FieldCaIsVerified: struct{}{}, } return network.DispatchUpdate[*Ca](self, ca, checker, ctx) } diff --git a/controller/model/ca_model.go b/controller/model/ca_model.go index b259197e9..b734842fb 100644 --- a/controller/model/ca_model.go +++ b/controller/model/ca_model.go @@ -19,14 +19,14 @@ package model import ( "crypto/x509" "fmt" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/storage/boltz" + "github.com/openziti/x509-claims/x509claims" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/common/eid" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/storage/boltz" - "github.com/openziti/x509-claims/x509claims" "github.com/pkg/errors" "go.etcd.io/bbolt" "net/url" @@ -58,7 +58,7 @@ type ExternalIdClaim struct { type ExternalIdFieldType string -func (entity *Ca) fillFrom(_ Env, _ *bbolt.Tx, boltCa *persistence.Ca) error { +func (entity *Ca) fillFrom(_ Env, _ *bbolt.Tx, boltCa *db.Ca) error { entity.FillCommon(boltCa) entity.Name = boltCa.Name entity.Fingerprint = boltCa.Fingerprint @@ -84,13 +84,13 @@ func (entity *Ca) fillFrom(_ Env, _ *bbolt.Tx, boltCa *persistence.Ca) error { return nil } -func (entity *Ca) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.Ca, error) { +func (entity *Ca) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*db.Ca, error) { if entity.IdentityNameFormat == "" { entity.IdentityNameFormat = DefaultCaIdentityNameFormat } if entity.ExternalIdClaim != nil { - if entity.ExternalIdClaim.Matcher == persistence.ExternalIdClaimMatcherScheme && entity.ExternalIdClaim.Location != persistence.ExternalIdClaimLocSanUri { + if entity.ExternalIdClaim.Matcher == db.ExternalIdClaimMatcherScheme && entity.ExternalIdClaim.Location != db.ExternalIdClaimLocSanUri { return nil, apierror.NewBadRequestFieldError(*errorz.NewFieldError("scheme matcher can only be used with URI locations", "matcher", entity.ExternalIdClaim.Matcher)) } } @@ -141,7 +141,7 @@ func (entity *Ca) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.Ca, return nil, errorz.NewFieldError(fmt.Sprintf("certificate already used as CA %s", queryResults[0]), "certPem", entity.CertPem) } - boltEntity := &persistence.Ca{ + boltEntity := &db.Ca{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, CertPem: entity.CertPem, @@ -156,7 +156,7 @@ func (entity *Ca) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.Ca, } if entity.ExternalIdClaim != nil { - boltEntity.ExternalIdClaim = &persistence.ExternalIdClaim{ + boltEntity.ExternalIdClaim = &db.ExternalIdClaim{ Location: entity.ExternalIdClaim.Location, Matcher: entity.ExternalIdClaim.Matcher, MatcherCriteria: entity.ExternalIdClaim.MatcherCriteria, @@ -169,12 +169,12 @@ func (entity *Ca) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.Ca, return boltEntity, nil } -func (entity *Ca) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.Ca, error) { +func (entity *Ca) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.Ca, error) { if entity.IdentityNameFormat == "" { entity.IdentityNameFormat = DefaultCaIdentityNameFormat } - boltEntity := &persistence.Ca{ + boltEntity := &db.Ca{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, IsAuthEnabled: entity.IsAuthEnabled, @@ -186,7 +186,7 @@ func (entity *Ca) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*pe } if entity.ExternalIdClaim != nil { - boltEntity.ExternalIdClaim = &persistence.ExternalIdClaim{ + boltEntity.ExternalIdClaim = &db.ExternalIdClaim{ Location: entity.ExternalIdClaim.Location, Matcher: entity.ExternalIdClaim.Matcher, MatcherCriteria: entity.ExternalIdClaim.MatcherCriteria, @@ -211,7 +211,7 @@ func (entity *Ca) GetExternalId(cert *x509.Certificate) (string, error) { } switch entity.ExternalIdClaim.Location { - case persistence.ExternalIdClaimLocCommonName: + case db.ExternalIdClaimLocCommonName: definition, err := getStringDefinition(entity.ExternalIdClaim) definition.Locator = &x509claims.LocatorCommonName{} if err != nil { @@ -220,7 +220,7 @@ func (entity *Ca) GetExternalId(cert *x509.Certificate) (string, error) { provider.Definitions = append(provider.Definitions, definition) - case persistence.ExternalIdClaimLocSanUri: + case db.ExternalIdClaimLocSanUri: definition, err := getUriDefinition(entity.ExternalIdClaim) definition.Locator = &x509claims.LocatorSanUri{} if err != nil { @@ -228,7 +228,7 @@ func (entity *Ca) GetExternalId(cert *x509.Certificate) (string, error) { } provider.Definitions = append(provider.Definitions, definition) - case persistence.ExternalIdClaimLocSanEmail: + case db.ExternalIdClaimLocSanEmail: definition, err := getStringDefinition(entity.ExternalIdClaim) definition.Locator = &x509claims.LocatorSanEmail{} if err != nil { @@ -252,9 +252,9 @@ func getUriDefinition(externalIdClaim *ExternalIdClaim) (*x509claims.DefinitionL definition := &x509claims.DefinitionLMP[*url.URL]{} switch externalIdClaim.Matcher { - case persistence.ExternalIdClaimMatcherAll: + case db.ExternalIdClaimMatcherAll: definition.Matcher = &x509claims.MatcherAll[*url.URL]{} - case persistence.ExternalIdClaimMatcherScheme: + case db.ExternalIdClaimMatcherScheme: if externalIdClaim.MatcherCriteria == "" { return nil, fmt.Errorf("invalid criteria [%s] for matcher [%s]", externalIdClaim.MatcherCriteria, externalIdClaim.Matcher) } @@ -279,15 +279,15 @@ func getStringDefinition(externalIdClaim *ExternalIdClaim) (*x509claims.Definiti definition := &x509claims.DefinitionLMP[string]{} switch externalIdClaim.Matcher { - case persistence.ExternalIdClaimMatcherAll: + case db.ExternalIdClaimMatcherAll: definition.Matcher = &x509claims.MatcherAll[string]{} - case persistence.ExternalIdClaimMatcherPrefix: + case db.ExternalIdClaimMatcherPrefix: if externalIdClaim.MatcherCriteria == "" { return nil, fmt.Errorf("invalid criteria [%s] for matcher [%s]", externalIdClaim.MatcherCriteria, externalIdClaim.Matcher) } definition.Matcher = &x509claims.MatcherPrefix{Prefix: externalIdClaim.MatcherCriteria} - case persistence.ExternalIdClaimMatcherSuffix: + case db.ExternalIdClaimMatcherSuffix: if externalIdClaim.MatcherCriteria == "" { return nil, fmt.Errorf("invalid criteria [%s] for matcher [%s]", externalIdClaim.MatcherCriteria, externalIdClaim.Matcher) } @@ -310,9 +310,9 @@ func getStringDefinition(externalIdClaim *ExternalIdClaim) (*x509claims.Definiti // getStringParser returns a x509claims.Parser that parses string values into claims func getStringParser(externalIdClaim *ExternalIdClaim) (x509claims.Parser, error) { switch externalIdClaim.Parser { - case persistence.ExternalIdClaimParserNone: + case db.ExternalIdClaimParserNone: return &x509claims.ParserNoOp{}, nil - case persistence.ExternalIdClaimParserSplit: + case db.ExternalIdClaimParserSplit: if externalIdClaim.ParserCriteria == "" { return nil, fmt.Errorf("invalid criteria [%s] for parser [%s]", externalIdClaim.ParserCriteria, externalIdClaim.Parser) } diff --git a/controller/model/config_manager.go b/controller/model/config_manager.go index 970102434..277e93b5e 100644 --- a/controller/model/config_manager.go +++ b/controller/model/config_manager.go @@ -18,14 +18,14 @@ package model import ( "encoding/json" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/boltz" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" "strings" @@ -33,7 +33,7 @@ import ( func NewConfigManager(env Env) *ConfigManager { manager := &ConfigManager{ - baseEntityManager: newBaseEntityManager[*Config, *persistence.Config](env, env.GetStores().Config), + baseEntityManager: newBaseEntityManager[*Config, *db.Config](env, env.GetStores().Config), } manager.impl = manager @@ -43,7 +43,7 @@ func NewConfigManager(env Env) *ConfigManager { } type ConfigManager struct { - baseEntityManager[*Config, *persistence.Config] + baseEntityManager[*Config, *db.Config] } func (self *ConfigManager) newModelEntity() *Config { diff --git a/controller/model/config_model.go b/controller/model/config_model.go index c52346a29..712269b14 100644 --- a/controller/model/config_model.go +++ b/controller/model/config_model.go @@ -17,11 +17,11 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/apierror" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "github.com/xeipuuv/gojsonschema" "go.etcd.io/bbolt" ) @@ -33,12 +33,12 @@ type Config struct { Data map[string]interface{} } -func (entity *Config) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.Config, error) { +func (entity *Config) toBoltEntity(tx *bbolt.Tx, env Env) (*db.Config, error) { if entity.TypeId != "" { providedType := entity.TypeId configTypeStore := env.GetStores().ConfigType if !configTypeStore.IsEntityPresent(tx, entity.TypeId) { - return nil, errorz.NewFieldError("invalid config type", persistence.FieldConfigType, providedType) + return nil, errorz.NewFieldError("invalid config type", db.FieldConfigType, providedType) } } @@ -65,7 +65,7 @@ func (entity *Config) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.Config, } } - return &persistence.Config{ + return &db.Config{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, Type: entity.TypeId, @@ -73,18 +73,18 @@ func (entity *Config) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.Config, }, nil } -func (entity *Config) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.Config, error) { +func (entity *Config) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*db.Config, error) { if entity.TypeId == "" { - return nil, errorz.NewFieldError("config type must be specified", persistence.FieldConfigType, entity.TypeId) + return nil, errorz.NewFieldError("config type must be specified", db.FieldConfigType, entity.TypeId) } return entity.toBoltEntity(tx, env) } -func (entity *Config) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*persistence.Config, error) { +func (entity *Config) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*db.Config, error) { return entity.toBoltEntity(tx, env) } -func (entity *Config) fillFrom(_ Env, _ *bbolt.Tx, boltConfig *persistence.Config) error { +func (entity *Config) fillFrom(_ Env, _ *bbolt.Tx, boltConfig *db.Config) error { entity.FillCommon(boltConfig) entity.Name = boltConfig.Name entity.TypeId = boltConfig.Type diff --git a/controller/model/config_type_manager.go b/controller/model/config_type_manager.go index 3b2139ec5..78a2599c9 100644 --- a/controller/model/config_type_manager.go +++ b/controller/model/config_type_manager.go @@ -19,15 +19,15 @@ package model import ( "encoding/json" "github.com/michaelquigley/pfxlog" + "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/storage/boltz" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" ) @@ -38,7 +38,7 @@ const ( func NewConfigTypeManager(env Env) *ConfigTypeManager { manager := &ConfigTypeManager{ - baseEntityManager: newBaseEntityManager[*ConfigType, *persistence.ConfigType](env, env.GetStores().ConfigType), + baseEntityManager: newBaseEntityManager[*ConfigType, *db.ConfigType](env, env.GetStores().ConfigType), } manager.impl = manager @@ -48,7 +48,7 @@ func NewConfigTypeManager(env Env) *ConfigTypeManager { } type ConfigTypeManager struct { - baseEntityManager[*ConfigType, *persistence.ConfigType] + baseEntityManager[*ConfigType, *db.ConfigType] } func (self *ConfigTypeManager) newModelEntity() *ConfigType { diff --git a/controller/model/config_type_model.go b/controller/model/config_type_model.go index 4a2abaeff..d71f83542 100644 --- a/controller/model/config_type_model.go +++ b/controller/model/config_type_model.go @@ -18,10 +18,10 @@ package model import ( "fmt" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "github.com/pkg/errors" "github.com/xeipuuv/gojsonschema" "go.etcd.io/bbolt" @@ -42,7 +42,7 @@ func (entity *ConfigType) GetCompiledSchema() (*gojsonschema.Schema, error) { return schemaLoader.Compile(entitySchemaLoader) } -func (entity *ConfigType) toBoltEntity() (*persistence.ConfigType, error) { +func (entity *ConfigType) toBoltEntity() (*db.ConfigType, error) { if entity.Name == ConfigTypeAll { return nil, errorz.NewFieldError(fmt.Sprintf("%v is a keyword and may not be used as a config type name", entity.Name), "name", entity.Name) } @@ -55,22 +55,22 @@ func (entity *ConfigType) toBoltEntity() (*persistence.ConfigType, error) { return nil, errorz.NewFieldError("invalid config type schema, root type must be object", "schema", entity.Schema) } } - return &persistence.ConfigType{ + return &db.ConfigType{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, Schema: entity.Schema, }, nil } -func (entity *ConfigType) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.ConfigType, error) { +func (entity *ConfigType) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.ConfigType, error) { return entity.toBoltEntity() } -func (entity *ConfigType) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.ConfigType, error) { +func (entity *ConfigType) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.ConfigType, error) { return entity.toBoltEntity() } -func (entity *ConfigType) fillFrom(_ Env, _ *bbolt.Tx, boltConfigType *persistence.ConfigType) error { +func (entity *ConfigType) fillFrom(_ Env, _ *bbolt.Tx, boltConfigType *db.ConfigType) error { entity.FillCommon(boltConfigType) entity.Name = boltConfigType.Name entity.Schema = boltConfigType.Schema diff --git a/controller/model/create_terminator_cmd.go b/controller/model/create_terminator_cmd.go index 12b7cfd94..5cb1955d1 100644 --- a/controller/model/create_terminator_cmd.go +++ b/controller/model/create_terminator_cmd.go @@ -2,14 +2,14 @@ package model import ( "github.com/michaelquigley/pfxlog" + "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common" "github.com/openziti/ziti/common/pb/cmd_pb" + "github.com/openziti/ziti/common/pb/edge_cmd_pb" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/boltz" - "github.com/openziti/ziti/common" - "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/pkg/errors" "github.com/sirupsen/logrus" "go.etcd.io/bbolt" @@ -71,7 +71,7 @@ type terminator interface { GetAddress() string } -func (self *CreateEdgeTerminatorCmd) getTerminatorSession(tx *bbolt.Tx, terminator terminator, context string) (*persistence.Session, error) { +func (self *CreateEdgeTerminatorCmd) getTerminatorSession(tx *bbolt.Tx, terminator terminator, context string) (*db.Session, error) { if terminator.GetBinding() != common.EdgeBinding { return nil, errors.Errorf("%vterminator %v with identity %v is not edge terminator. Can't share identity", context, terminator.GetId(), terminator.GetInstanceId()) } diff --git a/controller/model/edge_router_manager.go b/controller/model/edge_router_manager.go index 2a36dca8c..c66f99d1e 100644 --- a/controller/model/edge_router_manager.go +++ b/controller/model/edge_router_manager.go @@ -21,36 +21,35 @@ import ( "fmt" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/common/pb/cmd_pb" "github.com/openziti/ziti/common/pb/edge_cmd_pb" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/common/pb/cmd_pb" "google.golang.org/protobuf/proto" "strconv" "github.com/michaelquigley/pfxlog" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "go.etcd.io/bbolt" ) func NewEdgeRouterManager(env Env) *EdgeRouterManager { manager := &EdgeRouterManager{ - baseEntityManager: newBaseEntityManager[*EdgeRouter, *persistence.EdgeRouter](env, env.GetStores().EdgeRouter), + baseEntityManager: newBaseEntityManager[*EdgeRouter, *db.EdgeRouter](env, env.GetStores().EdgeRouter), allowedFieldsChecker: fields.UpdatedFieldsMap{ - persistence.FieldName: struct{}{}, - persistence.FieldEdgeRouterIsTunnelerEnabled: struct{}{}, - persistence.FieldRoleAttributes: struct{}{}, - boltz.FieldTags: struct{}{}, - db.FieldRouterCost: struct{}{}, - db.FieldRouterNoTraversal: struct{}{}, - db.FieldRouterDisabled: struct{}{}, + db.FieldName: struct{}{}, + db.FieldEdgeRouterIsTunnelerEnabled: struct{}{}, + db.FieldRoleAttributes: struct{}{}, + boltz.FieldTags: struct{}{}, + db.FieldRouterCost: struct{}{}, + db.FieldRouterNoTraversal: struct{}{}, + db.FieldRouterDisabled: struct{}{}, }, } @@ -64,7 +63,7 @@ func NewEdgeRouterManager(env Env) *EdgeRouterManager { } type EdgeRouterManager struct { - baseEntityManager[*EdgeRouter, *persistence.EdgeRouter] + baseEntityManager[*EdgeRouter, *db.EdgeRouter] allowedFieldsChecker fields.UpdatedFieldsMap } @@ -221,7 +220,7 @@ func (self *EdgeRouterManager) IsAccessToEdgeRouterAllowed(identityId, serviceId var result bool err := self.GetDb().View(func(tx *bbolt.Tx) error { identityEdgeRouters := self.env.GetStores().Identity.GetRefCountedLinkCollection(db.EntityTypeRouters) - serviceEdgeRouters := self.env.GetStores().EdgeService.GetRefCountedLinkCollection(persistence.FieldEdgeRouters) + serviceEdgeRouters := self.env.GetStores().EdgeService.GetRefCountedLinkCollection(db.FieldEdgeRouters) identityCount := identityEdgeRouters.GetLinkCount(tx, []byte(identityId), []byte(edgeRouterId)) serviceCount := serviceEdgeRouters.GetLinkCount(tx, []byte(serviceId), []byte(edgeRouterId)) @@ -238,7 +237,7 @@ func (self *EdgeRouterManager) IsSharedEdgeRouterPresent(identityId, serviceId s var result bool err := self.GetDb().View(func(tx *bbolt.Tx) error { identityEdgeRouters := self.env.GetStores().Identity.GetRefCountedLinkCollection(db.EntityTypeRouters) - serviceEdgeRouters := self.env.GetStores().EdgeService.GetRefCountedLinkCollection(persistence.FieldEdgeRouters) + serviceEdgeRouters := self.env.GetStores().EdgeService.GetRefCountedLinkCollection(db.FieldEdgeRouters) cursor := identityEdgeRouters.IterateLinks(tx, []byte(identityId), true) for cursor.IsValid() { @@ -273,7 +272,7 @@ func (self *EdgeRouterManager) collectEnrollmentsInTx(tx *bbolt.Tx, id string, c return err } - associationIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, persistence.EntityTypeEnrollments) + associationIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, db.EntityTypeEnrollments) for _, enrollmentId := range associationIds { enrollment, err := self.env.GetManagers().Enrollment.readInTx(tx, enrollmentId) if err != nil { @@ -318,9 +317,9 @@ func (self *EdgeRouterManager) ReEnroll(router *EdgeRouter, ctx *change.Context) router.IsVerified = false if err := self.Update(router, true, fields.UpdatedFieldsMap{ - db.FieldRouterFingerprint: struct{}{}, - persistence.FieldEdgeRouterCertPEM: struct{}{}, - persistence.FieldEdgeRouterIsVerified: struct{}{}, + db.FieldRouterFingerprint: struct{}{}, + db.FieldEdgeRouterCertPEM: struct{}{}, + db.FieldEdgeRouterIsVerified: struct{}{}, }, ctx); err != nil { log.WithError(err).Error("unable to patch re-enrolling edge router") return errors.Wrap(err, "unable to patch re-enrolling edge router") @@ -375,8 +374,8 @@ func (self *EdgeRouterManager) ExtendEnrollment(router *EdgeRouter, clientCsrPem router.CertPem = &clientPemString err = self.Update(router, true, &fields.UpdatedFieldsMap{ - persistence.FieldEdgeRouterCertPEM: struct{}{}, - db.FieldRouterFingerprint: struct{}{}, + db.FieldEdgeRouterCertPEM: struct{}{}, + db.FieldRouterFingerprint: struct{}{}, }, ctx) if err != nil { @@ -420,8 +419,8 @@ func (self *EdgeRouterManager) ExtendEnrollmentWithVerify(router *EdgeRouter, cl router.UnverifiedCertPem = &clientPemString err = self.Update(router, true, &fields.UpdatedFieldsMap{ - persistence.FieldEdgeRouterUnverifiedCertPEM: struct{}{}, - persistence.FieldEdgeRouterUnverifiedFingerprint: struct{}{}, + db.FieldEdgeRouterUnverifiedCertPEM: struct{}{}, + db.FieldEdgeRouterUnverifiedFingerprint: struct{}{}, }, ctx) if err != nil { @@ -435,7 +434,7 @@ func (self *EdgeRouterManager) ExtendEnrollmentWithVerify(router *EdgeRouter, cl } func (self *EdgeRouterManager) ReadOneByUnverifiedFingerprint(fingerprint string) (*EdgeRouter, error) { - return self.ReadOneByQuery(fmt.Sprintf(`%s = "%v"`, persistence.FieldEdgeRouterUnverifiedFingerprint, fingerprint)) + return self.ReadOneByQuery(fmt.Sprintf(`%s = "%v"`, db.FieldEdgeRouterUnverifiedFingerprint, fingerprint)) } func (self *EdgeRouterManager) ExtendEnrollmentVerify(router *EdgeRouter, ctx *change.Context) error { @@ -447,10 +446,10 @@ func (self *EdgeRouterManager) ExtendEnrollmentVerify(router *EdgeRouter, ctx *c router.UnverifiedCertPem = nil return self.Update(router, true, fields.UpdatedFieldsMap{ - db.FieldRouterFingerprint: struct{}{}, - persistence.FieldCaCertPem: struct{}{}, - persistence.FieldEdgeRouterUnverifiedCertPEM: struct{}{}, - persistence.FieldEdgeRouterUnverifiedFingerprint: struct{}{}, + db.FieldRouterFingerprint: struct{}{}, + db.FieldCaCertPem: struct{}{}, + db.FieldEdgeRouterUnverifiedCertPEM: struct{}{}, + db.FieldEdgeRouterUnverifiedFingerprint: struct{}{}, }, ctx) } diff --git a/controller/model/edge_router_model.go b/controller/model/edge_router_model.go index f060c0b0e..b0a3619c3 100644 --- a/controller/model/edge_router_model.go +++ b/controller/model/edge_router_model.go @@ -17,11 +17,10 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/db" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/versions" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -47,8 +46,8 @@ func (self *EdgeRouter) GetName() string { return self.Name } -func (entity *EdgeRouter) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.EdgeRouter, error) { - boltEntity := &persistence.EdgeRouter{ +func (entity *EdgeRouter) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.EdgeRouter, error) { + boltEntity := &db.EdgeRouter{ Router: db.Router{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, @@ -65,8 +64,8 @@ func (entity *EdgeRouter) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.Ed return boltEntity, nil } -func (entity *EdgeRouter) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.EdgeRouter, error) { - return &persistence.EdgeRouter{ +func (entity *EdgeRouter) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.EdgeRouter, error) { + return &db.EdgeRouter{ Router: db.Router{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, @@ -85,7 +84,7 @@ func (entity *EdgeRouter) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldCheck }, nil } -func (entity *EdgeRouter) fillFrom(_ Env, _ *bbolt.Tx, boltEdgeRouter *persistence.EdgeRouter) error { +func (entity *EdgeRouter) fillFrom(_ Env, _ *bbolt.Tx, boltEdgeRouter *db.EdgeRouter) error { entity.FillCommon(boltEdgeRouter) entity.Name = boltEdgeRouter.Name entity.RoleAttributes = boltEdgeRouter.RoleAttributes diff --git a/controller/model/edge_router_policy_manager.go b/controller/model/edge_router_policy_manager.go index bf841e349..412562d00 100644 --- a/controller/model/edge_router_policy_manager.go +++ b/controller/model/edge_router_policy_manager.go @@ -17,20 +17,20 @@ package model import ( + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/boltz" "google.golang.org/protobuf/proto" ) func NewEdgeRouterPolicyManager(env Env) *EdgeRouterPolicyManager { manager := &EdgeRouterPolicyManager{ - baseEntityManager: newBaseEntityManager[*EdgeRouterPolicy, *persistence.EdgeRouterPolicy](env, env.GetStores().EdgeRouterPolicy), + baseEntityManager: newBaseEntityManager[*EdgeRouterPolicy, *db.EdgeRouterPolicy](env, env.GetStores().EdgeRouterPolicy), } manager.impl = manager @@ -40,7 +40,7 @@ func NewEdgeRouterPolicyManager(env Env) *EdgeRouterPolicyManager { } type EdgeRouterPolicyManager struct { - baseEntityManager[*EdgeRouterPolicy, *persistence.EdgeRouterPolicy] + baseEntityManager[*EdgeRouterPolicy, *db.EdgeRouterPolicy] } func (self *EdgeRouterPolicyManager) newModelEntity() *EdgeRouterPolicy { diff --git a/controller/model/edge_router_policy_model.go b/controller/model/edge_router_policy_model.go index 01f9fb2c3..38001cba6 100644 --- a/controller/model/edge_router_policy_model.go +++ b/controller/model/edge_router_policy_model.go @@ -17,9 +17,9 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -31,8 +31,8 @@ type EdgeRouterPolicy struct { EdgeRouterRoles []string } -func (entity *EdgeRouterPolicy) toBoltEntity() (*persistence.EdgeRouterPolicy, error) { - return &persistence.EdgeRouterPolicy{ +func (entity *EdgeRouterPolicy) toBoltEntity() (*db.EdgeRouterPolicy, error) { + return &db.EdgeRouterPolicy{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, Semantic: entity.Semantic, @@ -41,15 +41,15 @@ func (entity *EdgeRouterPolicy) toBoltEntity() (*persistence.EdgeRouterPolicy, e }, nil } -func (entity *EdgeRouterPolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.EdgeRouterPolicy, error) { +func (entity *EdgeRouterPolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.EdgeRouterPolicy, error) { return entity.toBoltEntity() } -func (entity *EdgeRouterPolicy) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.EdgeRouterPolicy, error) { +func (entity *EdgeRouterPolicy) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.EdgeRouterPolicy, error) { return entity.toBoltEntity() } -func (entity *EdgeRouterPolicy) fillFrom(_ Env, _ *bbolt.Tx, boltEdgeRouterPolicy *persistence.EdgeRouterPolicy) error { +func (entity *EdgeRouterPolicy) fillFrom(_ Env, _ *bbolt.Tx, boltEdgeRouterPolicy *db.EdgeRouterPolicy) error { entity.FillCommon(boltEdgeRouterPolicy) entity.Name = boltEdgeRouterPolicy.Name entity.Semantic = boltEdgeRouterPolicy.Semantic diff --git a/controller/model/edge_service_manager.go b/controller/model/edge_service_manager.go index 09c3170bd..9182157bc 100644 --- a/controller/model/edge_service_manager.go +++ b/controller/model/edge_service_manager.go @@ -27,14 +27,13 @@ import ( "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/controller/persistence" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" ) func NewEdgeServiceManager(env Env) *EdgeServiceManager { manager := &EdgeServiceManager{ - baseEntityManager: newBaseEntityManager[*Service, *persistence.EdgeService](env, env.GetStores().EdgeService), + baseEntityManager: newBaseEntityManager[*Service, *db.EdgeService](env, env.GetStores().EdgeService), detailLister: &ServiceDetailLister{}, } manager.impl = manager @@ -46,7 +45,7 @@ func NewEdgeServiceManager(env Env) *EdgeServiceManager { } type EdgeServiceManager struct { - baseEntityManager[*Service, *persistence.EdgeService] + baseEntityManager[*Service, *db.EdgeService] detailLister *ServiceDetailLister } @@ -129,7 +128,7 @@ func (self *EdgeServiceManager) ReadForIdentityInTx(tx *bbolt.Tx, id string, ide if identity.IsAdmin { service, err = self.readInTx(tx, id) if err == nil && service != nil { - service.Permissions = []string{persistence.PolicyTypeBindName, persistence.PolicyTypeDialName} + service.Permissions = []string{db.PolicyTypeBindName, db.PolicyTypeDialName} } } else { service, err = self.ReadForNonAdminIdentityInTx(tx, id, identityId) @@ -158,10 +157,10 @@ func (self *EdgeServiceManager) ReadForNonAdminIdentityInTx(tx *bbolt.Tx, id str return nil, boltz.NewNotFoundError(self.GetStore().GetSingularEntityType(), "id", id) } if isBindable { - result.Permissions = append(result.Permissions, persistence.PolicyTypeBindName) + result.Permissions = append(result.Permissions, db.PolicyTypeBindName) } if isDialable { - result.Permissions = append(result.Permissions, persistence.PolicyTypeDialName) + result.Permissions = append(result.Permissions, db.PolicyTypeDialName) } return result, nil } @@ -262,7 +261,7 @@ func (result *ServiceListResult) collect(tx *bbolt.Tx, ids []string, queryMetaDa } else { service, err = result.manager.readInTx(tx, key) if service != nil && result.isAdmin { - service.Permissions = []string{persistence.PolicyTypeBindName, persistence.PolicyTypeDialName} + service.Permissions = []string{db.PolicyTypeBindName, db.PolicyTypeDialName} } } if err != nil { @@ -321,7 +320,7 @@ func (self *EdgeServiceManager) mergeConfigs(tx *bbolt.Tx, configTypes map[strin type PolicyPostureChecks struct { PostureChecks []*PostureCheck - PolicyType persistence.PolicyType + PolicyType db.PolicyType PolicyName string } @@ -330,14 +329,14 @@ func (self *EdgeServiceManager) GetPolicyPostureChecks(identityId, serviceId str postureCheckCache := map[string]*PostureCheck{} servicePolicyStore := self.env.GetStores().ServicePolicy - postureCheckLinks := servicePolicyStore.GetLinkCollection(persistence.EntityTypePostureChecks) + postureCheckLinks := servicePolicyStore.GetLinkCollection(db.EntityTypePostureChecks) serviceLinks := servicePolicyStore.GetLinkCollection(db.EntityTypeServices) - policyNameSymbol := self.env.GetStores().ServicePolicy.GetSymbol(persistence.FieldName) - policyTypeSymbol := self.env.GetStores().ServicePolicy.GetSymbol(persistence.FieldServicePolicyType) + policyNameSymbol := self.env.GetStores().ServicePolicy.GetSymbol(db.FieldName) + policyTypeSymbol := self.env.GetStores().ServicePolicy.GetSymbol(db.FieldServicePolicyType) _ = self.GetDb().View(func(tx *bbolt.Tx) error { - policyCursor := self.env.GetStores().Identity.GetRelatedEntitiesCursor(tx, identityId, persistence.EntityTypeServicePolicies, true) + policyCursor := self.env.GetStores().Identity.GetRelatedEntitiesCursor(tx, identityId, db.EntityTypeServicePolicies, true) policyCursor = ast.NewFilteredCursor(policyCursor, func(policyId []byte) bool { return serviceLinks.IsLinked(tx, policyId, []byte(serviceId)) }) @@ -348,9 +347,9 @@ func (self *EdgeServiceManager) GetPolicyPostureChecks(identityId, serviceId str policyCursor.Next() policyName := boltz.FieldToString(policyNameSymbol.Eval(tx, policyIdBytes)) - policyType := persistence.PolicyTypeDial + policyType := db.PolicyTypeDial if fieldType, policyTypeValue := policyTypeSymbol.Eval(tx, policyIdBytes); fieldType == boltz.TypeInt32 { - policyType = persistence.GetPolicyTypeForId(*boltz.BytesToInt32(policyTypeValue)) + policyType = db.GetPolicyTypeForId(*boltz.BytesToInt32(policyTypeValue)) } //required to provide an entry for policies w/ no checks diff --git a/controller/model/edge_service_model.go b/controller/model/edge_service_model.go index 9c8e5c183..a192569e3 100644 --- a/controller/model/edge_service_model.go +++ b/controller/model/edge_service_model.go @@ -18,11 +18,10 @@ package model import ( "fmt" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/db" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -35,12 +34,12 @@ type Service struct { EncryptionRequired bool `json:"encryptionRequired"` } -func (entity *Service) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.EdgeService, error) { +func (entity *Service) toBoltEntity(tx *bbolt.Tx, env Env) (*db.EdgeService, error) { if err := entity.validateConfigs(tx, env); err != nil { return nil, err } - edgeService := &persistence.EdgeService{ + edgeService := &db.EdgeService{ Service: db.Service{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, @@ -53,17 +52,17 @@ func (entity *Service) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.EdgeSer return edgeService, nil } -func (entity *Service) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.EdgeService, error) { +func (entity *Service) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*db.EdgeService, error) { return entity.toBoltEntity(tx, env) } func (entity *Service) validateConfigs(tx *bbolt.Tx, env Env) error { - typeMap := map[string]*persistence.Config{} + typeMap := map[string]*db.Config{} configStore := env.GetStores().Config for _, id := range entity.Configs { config, _ := configStore.LoadOneById(tx, id) if config == nil { - return boltz.NewNotFoundError(persistence.EntityTypeConfigs, "id", id) + return boltz.NewNotFoundError(db.EntityTypeConfigs, "id", id) } conflictConfig, found := typeMap[config.Type] if found { @@ -80,11 +79,11 @@ func (entity *Service) validateConfigs(tx *bbolt.Tx, env Env) error { return nil } -func (entity *Service) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*persistence.EdgeService, error) { +func (entity *Service) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*db.EdgeService, error) { return entity.toBoltEntity(tx, env) } -func (entity *Service) fillFrom(_ Env, _ *bbolt.Tx, boltService *persistence.EdgeService) error { +func (entity *Service) fillFrom(_ Env, _ *bbolt.Tx, boltService *db.EdgeService) error { entity.FillCommon(boltService) entity.Name = boltService.Name entity.TerminatorStrategy = boltService.TerminatorStrategy @@ -105,15 +104,15 @@ type ServiceDetail struct { EncryptionRequired bool `json:"encryptionRequired"` } -func (entity *ServiceDetail) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.EdgeService, error) { +func (entity *ServiceDetail) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.EdgeService, error) { panic("should never be called") } -func (entity *ServiceDetail) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.EdgeService, error) { +func (entity *ServiceDetail) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.EdgeService, error) { panic("should never be called") } -func (entity *ServiceDetail) fillFrom(_ Env, _ *bbolt.Tx, boltService *persistence.EdgeService) error { +func (entity *ServiceDetail) fillFrom(_ Env, _ *bbolt.Tx, boltService *db.EdgeService) error { entity.FillCommon(boltService) entity.Name = boltService.Name entity.TerminatorStrategy = boltService.TerminatorStrategy diff --git a/controller/model/enrollment_manager.go b/controller/model/enrollment_manager.go index fdf119884..ba91831eb 100644 --- a/controller/model/enrollment_manager.go +++ b/controller/model/enrollment_manager.go @@ -20,31 +20,31 @@ import ( "crypto/x509" "fmt" "github.com/michaelquigley/pfxlog" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/cert" + "github.com/openziti/ziti/common/pb/cmd_pb" "github.com/openziti/ziti/common/pb/edge_cmd_pb" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/common/pb/cmd_pb" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/storage/boltz" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" "time" ) type EnrollmentManager struct { - baseEntityManager[*Enrollment, *persistence.Enrollment] - enrollmentStore persistence.EnrollmentStore + baseEntityManager[*Enrollment, *db.Enrollment] + enrollmentStore db.EnrollmentStore } func NewEnrollmentManager(env Env) *EnrollmentManager { manager := &EnrollmentManager{ - baseEntityManager: newBaseEntityManager[*Enrollment, *persistence.Enrollment](env, env.GetStores().Enrollment), + baseEntityManager: newBaseEntityManager[*Enrollment, *db.Enrollment](env, env.GetStores().Enrollment), enrollmentStore: env.GetStores().Enrollment, } @@ -86,7 +86,7 @@ func (self *EnrollmentManager) ApplyCreate(cmd *command.CreateEntityCommand[*Enr model.ExpiresAt = &expiresAt switch model.Method { - case persistence.MethodEnrollOttCa: + case db.MethodEnrollOttCa: if model.CaId == nil { return apierror.NewBadRequestFieldError(*errorz.NewFieldError("ca not found", "caId", model.CaId)) } @@ -96,11 +96,11 @@ func (self *EnrollmentManager) ApplyCreate(cmd *command.CreateEntityCommand[*Enr if err != nil || ca == nil { return apierror.NewBadRequestFieldError(*errorz.NewFieldError("ca not found", "caId", model.CaId)) } - case persistence.MethodAuthenticatorUpdb: + case db.MethodAuthenticatorUpdb: if model.Username == nil || *model.Username == "" { return apierror.NewBadRequestFieldError(*errorz.NewFieldError("username not provided", "username", model.Username)) } - case persistence.MethodEnrollOtt: + case db.MethodEnrollOtt: default: return apierror.NewBadRequestFieldError(*errorz.NewFieldError("unsupported enrollment method", "method", model.Method)) } @@ -140,7 +140,7 @@ func (self *EnrollmentManager) newModelEntity() *Enrollment { func (self *EnrollmentManager) getEnrollmentMethod(ctx EnrollmentContext) (string, error) { method := ctx.GetMethod() - if method == persistence.MethodEnrollCa { + if method == db.MethodEnrollCa { return method, nil } @@ -284,9 +284,9 @@ func (self *EnrollmentManager) RefreshJwt(id string, expiresAt time.Time, ctx *c } return self.Update(enrollment, fields.UpdatedFieldsMap{ - persistence.FieldEnrollmentJwt: struct{}{}, - persistence.FieldEnrollmentExpiresAt: struct{}{}, - persistence.FieldEnrollmentIssuedAt: struct{}{}, + db.FieldEnrollmentJwt: struct{}{}, + db.FieldEnrollmentExpiresAt: struct{}{}, + db.FieldEnrollmentIssuedAt: struct{}{}, }, ctx) } diff --git a/controller/model/enrollment_mod_ca.go b/controller/model/enrollment_mod_ca.go index 890836a93..aad45ce00 100644 --- a/controller/model/enrollment_mod_ca.go +++ b/controller/model/enrollment_mod_ca.go @@ -24,7 +24,7 @@ import ( "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/common/eid" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" "github.com/sirupsen/logrus" ) @@ -38,7 +38,7 @@ type EnrollModuleCa struct { func NewEnrollModuleCa(env Env) *EnrollModuleCa { return &EnrollModuleCa{ env: env, - method: persistence.MethodEnrollCa, + method: db.MethodEnrollCa, fingerprintGenerator: cert.NewFingerprintGenerator(), } } @@ -180,7 +180,7 @@ func (module *EnrollModuleCa) completeCertAuthenticatorEnrollment(log *logrus.En Id: identityId, }, Name: identityName, - IdentityTypeId: persistence.DefaultIdentityType, + IdentityTypeId: db.DefaultIdentityType, IsDefaultAdmin: false, IsAdmin: false, RoleAttributes: ca.IdentityRoles, @@ -188,7 +188,7 @@ func (module *EnrollModuleCa) completeCertAuthenticatorEnrollment(log *logrus.En newAuthenticator := &Authenticator{ BaseEntity: models.BaseEntity{}, - Method: persistence.MethodAuthenticatorCert, + Method: db.MethodAuthenticatorCert, IdentityId: identity.Id, SubType: &AuthenticatorCert{ Fingerprint: fingerprint, @@ -246,7 +246,7 @@ func (module *EnrollModuleCa) completeExternalIdEnrollment(log *logrus.Entry, co Id: identityId, }, Name: identityName, - IdentityTypeId: persistence.DefaultIdentityType, + IdentityTypeId: db.DefaultIdentityType, IsDefaultAdmin: false, IsAdmin: false, RoleAttributes: ca.IdentityRoles, @@ -295,7 +295,7 @@ func (module *EnrollModuleCa) getIdentityName(ca *Ca, enrollmentCert *x509.Certi suffixCount := 0 for !identityNameIsValid { //check for name collisions append 4 digit incrementing number to end till ok - entity, _ := module.env.GetManagers().Identity.readEntityByQuery(fmt.Sprintf(`%s="%s"`, persistence.FieldName, identityName)) + entity, _ := module.env.GetManagers().Identity.readEntityByQuery(fmt.Sprintf(`%s="%s"`, db.FieldName, identityName)) if entity != nil { suffixCount = suffixCount + 1 diff --git a/controller/model/enrollment_mod_ott.go b/controller/model/enrollment_mod_ott.go index e61b0fdfc..af5080d0b 100644 --- a/controller/model/enrollment_mod_ott.go +++ b/controller/model/enrollment_mod_ott.go @@ -22,8 +22,8 @@ import ( "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/common/eid" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" ) @@ -36,7 +36,7 @@ type EnrollModuleOtt struct { func NewEnrollModuleOtt(env Env) *EnrollModuleOtt { return &EnrollModuleOtt{ env: env, - method: persistence.MethodEnrollOtt, + method: db.MethodEnrollOtt, fingerprintGenerator: cert.NewFingerprintGenerator(), } } @@ -106,7 +106,7 @@ func (module *EnrollModuleOtt) Process(ctx EnrollmentContext) (*EnrollmentResult BaseEntity: models.BaseEntity{ Id: eid.New(), }, - Method: persistence.MethodAuthenticatorCert, + Method: db.MethodAuthenticatorCert, IdentityId: *enrollment.IdentityId, SubType: &AuthenticatorCert{ Fingerprint: fp, diff --git a/controller/model/enrollment_mod_ottca.go b/controller/model/enrollment_mod_ottca.go index 6a1de4e76..35d36b5fe 100644 --- a/controller/model/enrollment_mod_ottca.go +++ b/controller/model/enrollment_mod_ottca.go @@ -21,9 +21,9 @@ import ( "encoding/pem" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" fabricApiError "github.com/openziti/ziti/controller/apierror" "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" ) @@ -36,7 +36,7 @@ type EnrollModuleOttCa struct { func NewEnrollModuleOttCa(env Env) *EnrollModuleOttCa { return &EnrollModuleOttCa{ env: env, - method: persistence.MethodEnrollOttCa, + method: db.MethodEnrollOttCa, fingerprintGenerator: cert.NewFingerprintGenerator(), } } @@ -132,7 +132,7 @@ func (module *EnrollModuleOttCa) Process(ctx EnrollmentContext) (*EnrollmentResu newAuthenticator := &Authenticator{ BaseEntity: models.BaseEntity{}, - Method: persistence.MethodAuthenticatorCert, + Method: db.MethodAuthenticatorCert, IdentityId: identity.Id, SubType: &AuthenticatorCert{ Fingerprint: fingerprint, diff --git a/controller/model/enrollment_mod_updb.go b/controller/model/enrollment_mod_updb.go index 781e72aec..1384064bd 100644 --- a/controller/model/enrollment_mod_updb.go +++ b/controller/model/enrollment_mod_updb.go @@ -19,13 +19,13 @@ package model import ( "encoding/base64" "errors" + "github.com/openziti/foundation/v2/errorz" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/common/eid" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" - "github.com/openziti/foundation/v2/errorz" ) type EnrollModuleUpdb struct { @@ -37,7 +37,7 @@ type EnrollModuleUpdb struct { func NewEnrollModuleUpdb(env Env) *EnrollModuleUpdb { return &EnrollModuleUpdb{ env: env, - method: persistence.MethodEnrollUpdb, + method: db.MethodEnrollUpdb, fingerprintGenerator: cert.NewFingerprintGenerator(), } } @@ -90,7 +90,7 @@ func (module *EnrollModuleUpdb) Process(ctx EnrollmentContext) (*EnrollmentResul BaseEntity: models.BaseEntity{ Id: eid.New(), }, - Method: persistence.MethodAuthenticatorUpdb, + Method: db.MethodAuthenticatorUpdb, IdentityId: *enrollment.IdentityId, SubType: &AuthenticatorUpdb{ Username: *enrollment.Username, diff --git a/controller/model/enrollment_model.go b/controller/model/enrollment_model.go index 1840c3f29..4696e91d6 100644 --- a/controller/model/enrollment_model.go +++ b/controller/model/enrollment_model.go @@ -20,11 +20,11 @@ import ( "fmt" "github.com/golang-jwt/jwt/v5" "github.com/google/uuid" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "time" ) @@ -81,7 +81,7 @@ func (entity *Enrollment) FillJwtInfoWithExpiresAt(env Env, subject string, expi return nil } -func (entity *Enrollment) fillFrom(_ Env, _ *bbolt.Tx, boltEnrollment *persistence.Enrollment) error { +func (entity *Enrollment) fillFrom(_ Env, _ *bbolt.Tx, boltEnrollment *db.Enrollment) error { entity.FillCommon(boltEnrollment) entity.Method = boltEnrollment.Method entity.IdentityId = boltEnrollment.IdentityId @@ -97,8 +97,8 @@ func (entity *Enrollment) fillFrom(_ Env, _ *bbolt.Tx, boltEnrollment *persisten return nil } -func (entity *Enrollment) toBoltEntity(env Env) (*persistence.Enrollment, error) { - if entity.Method == persistence.MethodEnrollOttCa { +func (entity *Enrollment) toBoltEntity(env Env) (*db.Enrollment, error) { + if entity.Method == db.MethodEnrollOttCa { if entity.CaId == nil || *entity.CaId == "" { apiErr := errorz.NewNotFound() apiErr.Cause = errorz.NewFieldError("ca not found", "caId", *entity.CaId) @@ -116,7 +116,7 @@ func (entity *Enrollment) toBoltEntity(env Env) (*persistence.Enrollment, error) } } - boltEntity := &persistence.Enrollment{ + boltEntity := &db.Enrollment{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Method: entity.Method, IdentityId: entity.IdentityId, @@ -133,10 +133,10 @@ func (entity *Enrollment) toBoltEntity(env Env) (*persistence.Enrollment, error) return boltEntity, nil } -func (entity *Enrollment) toBoltEntityForCreate(_ *bbolt.Tx, env Env) (*persistence.Enrollment, error) { +func (entity *Enrollment) toBoltEntityForCreate(_ *bbolt.Tx, env Env) (*db.Enrollment, error) { return entity.toBoltEntity(env) } -func (entity *Enrollment) toBoltEntityForUpdate(_ *bbolt.Tx, env Env, _ boltz.FieldChecker) (*persistence.Enrollment, error) { +func (entity *Enrollment) toBoltEntityForUpdate(_ *bbolt.Tx, env Env, _ boltz.FieldChecker) (*db.Enrollment, error) { return entity.toBoltEntity(env) } diff --git a/controller/model/env.go b/controller/model/env.go index 0e1321431..006a131d7 100644 --- a/controller/model/env.go +++ b/controller/model/env.go @@ -20,13 +20,13 @@ import ( "crypto/tls" "crypto/x509" "github.com/golang-jwt/jwt/v5" + "github.com/openziti/identity" + "github.com/openziti/metrics" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/controller/config" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/jwtsigner" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/network" - "github.com/openziti/identity" - "github.com/openziti/metrics" "github.com/xeipuuv/gojsonschema" ) @@ -34,8 +34,8 @@ type Env interface { GetManagers() *Managers GetConfig() *config.Config GetJwtSigner() jwtsigner.Signer - GetDbProvider() persistence.DbProvider - GetStores() *persistence.Stores + GetDbProvider() network.DbProvider + GetStores() *db.Stores GetAuthRegistry() AuthRegistry GetEnrollRegistry() EnrollmentRegistry GetApiClientCsrSigner() cert.Signer diff --git a/controller/model/external_jwt_signer_manager.go b/controller/model/external_jwt_signer_manager.go index a3239707e..be9bacf85 100644 --- a/controller/model/external_jwt_signer_manager.go +++ b/controller/model/external_jwt_signer_manager.go @@ -17,15 +17,15 @@ package model import ( + "github.com/openziti/storage/ast" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/ast" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" @@ -33,7 +33,7 @@ import ( func NewExternalJwtSignerManager(env Env) *ExternalJwtSignerManager { manager := &ExternalJwtSignerManager{ - baseEntityManager: newBaseEntityManager[*ExternalJwtSigner, *persistence.ExternalJwtSigner](env, env.GetStores().ExternalJwtSigner), + baseEntityManager: newBaseEntityManager[*ExternalJwtSigner, *db.ExternalJwtSigner](env, env.GetStores().ExternalJwtSigner), } manager.impl = manager @@ -43,7 +43,7 @@ func NewExternalJwtSignerManager(env Env) *ExternalJwtSignerManager { } type ExternalJwtSignerManager struct { - baseEntityManager[*ExternalJwtSigner, *persistence.ExternalJwtSigner] + baseEntityManager[*ExternalJwtSigner, *db.ExternalJwtSigner] } func (self *ExternalJwtSignerManager) newModelEntity() *ExternalJwtSigner { diff --git a/controller/model/external_jwt_signer_model.go b/controller/model/external_jwt_signer_model.go index e1c7ee68a..3898bdd32 100644 --- a/controller/model/external_jwt_signer_model.go +++ b/controller/model/external_jwt_signer_model.go @@ -17,11 +17,11 @@ package model import ( - "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" nfpem "github.com/openziti/foundation/v2/pem" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/apierror" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "time" ) @@ -45,8 +45,8 @@ type ExternalJwtSigner struct { NotBefore time.Time } -func (entity *ExternalJwtSigner) toBoltEntity() (*persistence.ExternalJwtSigner, error) { - signer := &persistence.ExternalJwtSigner{ +func (entity *ExternalJwtSigner) toBoltEntity() (*db.ExternalJwtSigner, error) { + signer := &db.ExternalJwtSigner{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, CertPem: entity.CertPem, @@ -78,15 +78,15 @@ func (entity *ExternalJwtSigner) toBoltEntity() (*persistence.ExternalJwtSigner, return signer, nil } -func (entity *ExternalJwtSigner) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.ExternalJwtSigner, error) { +func (entity *ExternalJwtSigner) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.ExternalJwtSigner, error) { return entity.toBoltEntity() } -func (entity *ExternalJwtSigner) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.ExternalJwtSigner, error) { +func (entity *ExternalJwtSigner) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.ExternalJwtSigner, error) { return entity.toBoltEntity() } -func (entity *ExternalJwtSigner) fillFrom(_ Env, _ *bbolt.Tx, boltExternalJwtSigner *persistence.ExternalJwtSigner) error { +func (entity *ExternalJwtSigner) fillFrom(_ Env, _ *bbolt.Tx, boltExternalJwtSigner *db.ExternalJwtSigner) error { entity.FillCommon(boltExternalJwtSigner) entity.Name = boltExternalJwtSigner.Name entity.CommonName = boltExternalJwtSigner.CommonName diff --git a/controller/model/identity_manager.go b/controller/model/identity_manager.go index 9d9d314f3..c34f95022 100644 --- a/controller/model/identity_manager.go +++ b/controller/model/identity_manager.go @@ -21,19 +21,19 @@ import ( "errors" "fmt" "github.com/michaelquigley/pfxlog" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/metrics" + "github.com/openziti/sdk-golang/ziti" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/common/pb/cmd_pb" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/common/pb/cmd_pb" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/metrics" - "github.com/openziti/sdk-golang/ziti" - "github.com/openziti/storage/boltz" cmap "github.com/orcaman/concurrent-map/v2" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" @@ -53,14 +53,14 @@ const ( ) type IdentityManager struct { - baseEntityManager[*Identity, *persistence.Identity] + baseEntityManager[*Identity, *db.Identity] updateSdkInfoTimer metrics.Timer identityStatusMap *identityStatusMap } func NewIdentityManager(env Env) *IdentityManager { manager := &IdentityManager{ - baseEntityManager: newBaseEntityManager[*Identity, *persistence.Identity](env, env.GetStores().Identity), + baseEntityManager: newBaseEntityManager[*Identity, *db.Identity](env, env.GetStores().Identity), updateSdkInfoTimer: env.GetMetricsRegistry().Timer("identity.update-sdk-info"), identityStatusMap: newIdentityStatusMap(IdentityActiveIntervalSeconds * time.Second), } @@ -150,7 +150,7 @@ func (self *IdentityManager) ApplyUpdate(cmd *command.UpdateEntityCommand[*Ident } func (self *IdentityManager) IsUpdated(field string) bool { - return field != persistence.FieldIdentityAuthenticators && field != persistence.FieldIdentityEnrollments && field != persistence.FieldIdentityIsDefaultAdmin + return field != db.FieldIdentityAuthenticators && field != db.FieldIdentityEnrollments && field != db.FieldIdentityIsDefaultAdmin } func (self *IdentityManager) ReadByName(name string) (*Identity, error) { @@ -208,7 +208,7 @@ func (self *IdentityManager) InitializeDefaultAdmin(username, password, name str return errorz.NewFieldError(fmt.Sprintf("name must be at most %v characters", maxDefaultAdminNameLength), "name", name) } - identityType, err := self.env.GetManagers().IdentityType.ReadByName(persistence.DefaultIdentityType) + identityType, err := self.env.GetManagers().IdentityType.ReadByName(db.DefaultIdentityType) if err != nil { return err @@ -231,7 +231,7 @@ func (self *IdentityManager) InitializeDefaultAdmin(username, password, name str BaseEntity: models.BaseEntity{ Id: authenticatorId, }, - Method: persistence.MethodAuthenticatorUpdb, + Method: db.MethodAuthenticatorUpdb, IdentityId: identityId, SubType: &AuthenticatorUpdb{ Username: username, @@ -257,7 +257,7 @@ func (self *IdentityManager) CollectAuthenticators(id string, collector func(ent if err != nil { return err } - authenticatorIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, persistence.FieldIdentityAuthenticators) + authenticatorIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, db.FieldIdentityAuthenticators) for _, authenticatorId := range authenticatorIds { authenticator := &Authenticator{} err := self.env.GetManagers().Authenticator.readEntityInTx(tx, authenticatorId, authenticator) @@ -277,7 +277,7 @@ func (self *IdentityManager) visitAuthenticators(tx *bbolt.Tx, id string, visito if err != nil { return err } - authenticatorIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, persistence.FieldIdentityAuthenticators) + authenticatorIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, db.FieldIdentityAuthenticators) for _, authenticatorId := range authenticatorIds { authenticator := &Authenticator{} if err := self.env.GetManagers().Authenticator.readEntityInTx(tx, authenticatorId, authenticator); err != nil { @@ -303,7 +303,7 @@ func (self *IdentityManager) collectEnrollmentsInTx(tx *bbolt.Tx, id string, col return err } - associationIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, persistence.FieldIdentityEnrollments) + associationIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, db.FieldIdentityEnrollments) for _, enrollmentId := range associationIds { enrollment, err := self.env.GetManagers().Enrollment.readInTx(tx, enrollmentId) if err != nil { @@ -444,16 +444,16 @@ func (self *IdentityManager) QueryRoleAttributes(queryString string) ([]string, func (self *IdentityManager) PatchInfo(identity *Identity, changeCtx *change.Context) error { start := time.Now() checker := boltz.MapFieldChecker{ - persistence.FieldIdentityEnvInfoArch: struct{}{}, - persistence.FieldIdentityEnvInfoOs: struct{}{}, - persistence.FieldIdentityEnvInfoOsRelease: struct{}{}, - persistence.FieldIdentityEnvInfoOsVersion: struct{}{}, - persistence.FieldIdentitySdkInfoBranch: struct{}{}, - persistence.FieldIdentitySdkInfoRevision: struct{}{}, - persistence.FieldIdentitySdkInfoType: struct{}{}, - persistence.FieldIdentitySdkInfoVersion: struct{}{}, - persistence.FieldIdentitySdkInfoAppId: struct{}{}, - persistence.FieldIdentitySdkInfoAppVersion: struct{}{}, + db.FieldIdentityEnvInfoArch: struct{}{}, + db.FieldIdentityEnvInfoOs: struct{}{}, + db.FieldIdentityEnvInfoOsRelease: struct{}{}, + db.FieldIdentityEnvInfoOsVersion: struct{}{}, + db.FieldIdentitySdkInfoBranch: struct{}{}, + db.FieldIdentitySdkInfoRevision: struct{}{}, + db.FieldIdentitySdkInfoType: struct{}{}, + db.FieldIdentitySdkInfoVersion: struct{}{}, + db.FieldIdentitySdkInfoAppId: struct{}{}, + db.FieldIdentitySdkInfoAppVersion: struct{}{}, } err := self.updateEntityBatch(identity, checker, changeCtx) @@ -489,7 +489,7 @@ func (self *IdentityManager) VisitIdentityAuthenticatorFingerprints(tx *bbolt.Tx } func (self *IdentityManager) ReadByExternalId(externalId string) (*Identity, error) { - query := fmt.Sprintf("%s = \"%v\"", persistence.FieldIdentityExternalId, externalId) + query := fmt.Sprintf("%s = \"%v\"", db.FieldIdentityExternalId, externalId) entity, err := self.readEntityByQuery(query) @@ -516,8 +516,8 @@ func (self *IdentityManager) Disable(identityId string, duration time.Duration, } fieldMap := fields.UpdatedFieldsMap{ - persistence.FieldIdentityDisabledAt: struct{}{}, - persistence.FieldIdentityDisabledUntil: struct{}{}, + db.FieldIdentityDisabledAt: struct{}{}, + db.FieldIdentityDisabledUntil: struct{}{}, } lockedAt := time.Now() @@ -545,8 +545,8 @@ func (self *IdentityManager) Disable(identityId string, duration time.Duration, func (self *IdentityManager) Enable(identityId string, ctx *change.Context) error { fieldMap := fields.UpdatedFieldsMap{ - persistence.FieldIdentityDisabledAt: struct{}{}, - persistence.FieldIdentityDisabledUntil: struct{}{}, + db.FieldIdentityDisabledAt: struct{}{}, + db.FieldIdentityDisabledUntil: struct{}{}, } return self.Update(&Identity{ diff --git a/controller/model/identity_model.go b/controller/model/identity_model.go index 09e15ebeb..b9a54ac44 100644 --- a/controller/model/identity_model.go +++ b/controller/model/identity_model.go @@ -17,11 +17,11 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "time" ) @@ -92,7 +92,7 @@ type Identity struct { DisabledUntil *time.Time } -func (entity *Identity) toBoltEntityForCreate(_ *bbolt.Tx, env Env) (*persistence.Identity, error) { +func (entity *Identity) toBoltEntityForCreate(_ *bbolt.Tx, env Env) (*db.Identity, error) { identityType, err := env.GetManagers().IdentityType.ReadByIdOrName(entity.IdentityTypeId) if err != nil && !boltz.IsErrNotFoundErr(err) { @@ -106,14 +106,14 @@ func (entity *Identity) toBoltEntityForCreate(_ *bbolt.Tx, env Env) (*persistenc return nil, apiErr } - if identityType.Name == persistence.RouterIdentityType { + if identityType.Name == db.RouterIdentityType { fieldErr := errorz.NewFieldError("may not create identities with given typeId", "typeId", entity.IdentityTypeId) return nil, errorz.NewFieldApiError(fieldErr) } entity.IdentityTypeId = identityType.Id - boltEntity := &persistence.Identity{ + boltEntity := &db.Identity{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, IdentityTypeId: entity.IdentityTypeId, @@ -132,7 +132,7 @@ func (entity *Identity) toBoltEntityForCreate(_ *bbolt.Tx, env Env) (*persistenc } if entity.EnvInfo != nil { - boltEntity.EnvInfo = &persistence.EnvInfo{ + boltEntity.EnvInfo = &db.EnvInfo{ Arch: entity.EnvInfo.Arch, Os: entity.EnvInfo.Os, OsRelease: entity.EnvInfo.OsRelease, @@ -141,7 +141,7 @@ func (entity *Identity) toBoltEntityForCreate(_ *bbolt.Tx, env Env) (*persistenc } if entity.SdkInfo != nil { - boltEntity.SdkInfo = &persistence.SdkInfo{ + boltEntity.SdkInfo = &db.SdkInfo{ Branch: entity.SdkInfo.Branch, Revision: entity.SdkInfo.Revision, Type: entity.SdkInfo.Type, @@ -155,7 +155,7 @@ func (entity *Identity) toBoltEntityForCreate(_ *bbolt.Tx, env Env) (*persistenc return boltEntity, nil } -func fillModelInfo(identity *Identity, envInfo *persistence.EnvInfo, sdkInfo *persistence.SdkInfo) { +func fillModelInfo(identity *Identity, envInfo *db.EnvInfo, sdkInfo *db.SdkInfo) { if envInfo != nil { identity.EnvInfo = &EnvInfo{ Arch: envInfo.Arch, @@ -177,9 +177,9 @@ func fillModelInfo(identity *Identity, envInfo *persistence.EnvInfo, sdkInfo *pe } } -func fillPersistenceInfo(identity *persistence.Identity, envInfo *EnvInfo, sdkInfo *SdkInfo) { +func fillPersistenceInfo(identity *db.Identity, envInfo *EnvInfo, sdkInfo *SdkInfo) { if envInfo != nil { - identity.EnvInfo = &persistence.EnvInfo{ + identity.EnvInfo = &db.EnvInfo{ Arch: envInfo.Arch, Os: envInfo.Os, OsRelease: envInfo.OsRelease, @@ -188,7 +188,7 @@ func fillPersistenceInfo(identity *persistence.Identity, envInfo *EnvInfo, sdkIn } if sdkInfo != nil { - identity.SdkInfo = &persistence.SdkInfo{ + identity.SdkInfo = &db.SdkInfo{ Branch: sdkInfo.Branch, Revision: sdkInfo.Revision, Type: sdkInfo.Type, @@ -199,7 +199,7 @@ func fillPersistenceInfo(identity *persistence.Identity, envInfo *EnvInfo, sdkIn } } -func (entity *Identity) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, checker boltz.FieldChecker) (*persistence.Identity, error) { +func (entity *Identity) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, checker boltz.FieldChecker) (*db.Identity, error) { if checker == nil || checker.IsUpdated("type") { identityType, err := env.GetManagers().IdentityType.ReadByIdOrName(entity.IdentityTypeId) @@ -217,7 +217,7 @@ func (entity *Identity) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, checker bol entity.IdentityTypeId = identityType.Id } - boltEntity := &persistence.Identity{ + boltEntity := &db.Identity{ Name: entity.Name, IdentityTypeId: entity.IdentityTypeId, AuthPolicyId: entity.AuthPolicyId, @@ -235,19 +235,19 @@ func (entity *Identity) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, checker bol } identityStore := env.GetManagers().Identity.GetStore() - _, currentType := identityStore.GetSymbol(persistence.FieldIdentityType).Eval(tx, []byte(entity.Id)) - if string(currentType) == persistence.RouterIdentityType { - if (checker == nil || checker.IsUpdated("identityTypeId")) && entity.IdentityTypeId != persistence.RouterIdentityType { + _, currentType := identityStore.GetSymbol(db.FieldIdentityType).Eval(tx, []byte(entity.Id)) + if string(currentType) == db.RouterIdentityType { + if (checker == nil || checker.IsUpdated("identityTypeId")) && entity.IdentityTypeId != db.RouterIdentityType { fieldErr := errorz.NewFieldError("may not change type of router identities", "typeId", entity.IdentityTypeId) return nil, errorz.NewFieldApiError(fieldErr) } - _, currentName := identityStore.GetSymbol(persistence.FieldName).Eval(tx, []byte(entity.Id)) - if (checker == nil || checker.IsUpdated(persistence.FieldName)) && string(currentName) != entity.Name { + _, currentName := identityStore.GetSymbol(db.FieldName).Eval(tx, []byte(entity.Id)) + if (checker == nil || checker.IsUpdated(db.FieldName)) && string(currentName) != entity.Name { fieldErr := errorz.NewFieldError("may not change name of router identities", "name", entity.Name) return nil, errorz.NewFieldApiError(fieldErr) } - } else if (checker == nil || checker.IsUpdated("identityTypeId")) && entity.IdentityTypeId == persistence.RouterIdentityType { + } else if (checker == nil || checker.IsUpdated("identityTypeId")) && entity.IdentityTypeId == db.RouterIdentityType { fieldErr := errorz.NewFieldError("may not change type to router", "typeId", entity.IdentityTypeId) return nil, errorz.NewFieldApiError(fieldErr) } @@ -257,7 +257,7 @@ func (entity *Identity) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, checker bol return boltEntity, nil } -func (entity *Identity) fillFrom(env Env, _ *bbolt.Tx, boltIdentity *persistence.Identity) error { +func (entity *Identity) fillFrom(env Env, _ *bbolt.Tx, boltIdentity *db.Identity) error { entity.FillCommon(boltIdentity) entity.Name = boltIdentity.Name entity.IdentityTypeId = boltIdentity.IdentityTypeId @@ -285,11 +285,11 @@ type ServiceConfig struct { Config string } -func toBoltServiceConfigs(tx *bbolt.Tx, env Env, serviceConfigs []ServiceConfig) ([]persistence.ServiceConfig, error) { +func toBoltServiceConfigs(tx *bbolt.Tx, env Env, serviceConfigs []ServiceConfig) ([]db.ServiceConfig, error) { serviceStore := env.GetStores().EdgeService configStore := env.GetStores().Config - var boltServiceConfigs []persistence.ServiceConfig + var boltServiceConfigs []db.ServiceConfig for _, serviceConfig := range serviceConfigs { if !serviceStore.IsEntityPresent(tx, serviceConfig.Service) { return nil, boltz.NewNotFoundError(serviceStore.GetSingularEntityType(), "id or name", serviceConfig.Service) @@ -299,7 +299,7 @@ func toBoltServiceConfigs(tx *bbolt.Tx, env Env, serviceConfigs []ServiceConfig) return nil, boltz.NewNotFoundError(configStore.GetSingularEntityType(), "id or name", serviceConfig.Config) } - boltServiceConfigs = append(boltServiceConfigs, persistence.ServiceConfig{ + boltServiceConfigs = append(boltServiceConfigs, db.ServiceConfig{ ServiceId: serviceConfig.Service, ConfigId: serviceConfig.Config, }) diff --git a/controller/model/identity_type_manager.go b/controller/model/identity_type_manager.go index d8ef0b11b..210550504 100644 --- a/controller/model/identity_type_manager.go +++ b/controller/model/identity_type_manager.go @@ -17,13 +17,13 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" ) func NewIdentityTypeManager(env Env) *IdentityTypeManager { manager := &IdentityTypeManager{ - baseEntityManager: newBaseEntityManager[*IdentityType, *persistence.IdentityType](env, env.GetStores().IdentityType), + baseEntityManager: newBaseEntityManager[*IdentityType, *db.IdentityType](env, env.GetStores().IdentityType), } manager.impl = manager @@ -31,7 +31,7 @@ func NewIdentityTypeManager(env Env) *IdentityTypeManager { } type IdentityTypeManager struct { - baseEntityManager[*IdentityType, *persistence.IdentityType] + baseEntityManager[*IdentityType, *db.IdentityType] } func (self *IdentityTypeManager) newModelEntity() *IdentityType { diff --git a/controller/model/identity_type_model.go b/controller/model/identity_type_model.go index 6a4904312..ab1278eac 100644 --- a/controller/model/identity_type_model.go +++ b/controller/model/identity_type_model.go @@ -17,9 +17,9 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -28,22 +28,22 @@ type IdentityType struct { Name string `json:"name"` } -func (entity *IdentityType) toBoltEntity() (*persistence.IdentityType, error) { - return &persistence.IdentityType{ +func (entity *IdentityType) toBoltEntity() (*db.IdentityType, error) { + return &db.IdentityType{ Name: entity.Name, BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), }, nil } -func (entity *IdentityType) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.IdentityType, error) { +func (entity *IdentityType) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.IdentityType, error) { return entity.toBoltEntity() } -func (entity *IdentityType) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.IdentityType, error) { +func (entity *IdentityType) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.IdentityType, error) { return entity.toBoltEntity() } -func (entity *IdentityType) fillFrom(_ Env, _ *bbolt.Tx, boltIdentityType *persistence.IdentityType) error { +func (entity *IdentityType) fillFrom(_ Env, _ *bbolt.Tx, boltIdentityType *db.IdentityType) error { entity.FillCommon(boltIdentityType) entity.Name = boltIdentityType.Name return nil diff --git a/controller/model/mfa_manager.go b/controller/model/mfa_manager.go index b7c869816..3aa2250c8 100644 --- a/controller/model/mfa_manager.go +++ b/controller/model/mfa_manager.go @@ -21,16 +21,16 @@ import ( "encoding/base32" "fmt" "github.com/dgryski/dgoogauth" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "github.com/skip2/go-qrcode" "go.etcd.io/bbolt" @@ -44,7 +44,7 @@ const ( func NewMfaManager(env Env) *MfaManager { manager := &MfaManager{ - baseEntityManager: newBaseEntityManager[*Mfa, *persistence.Mfa](env, env.GetStores().Mfa), + baseEntityManager: newBaseEntityManager[*Mfa, *db.Mfa](env, env.GetStores().Mfa), } manager.impl = manager @@ -54,7 +54,7 @@ func NewMfaManager(env Env) *MfaManager { } type MfaManager struct { - baseEntityManager[*Mfa, *persistence.Mfa] + baseEntityManager[*Mfa, *db.Mfa] } func (self *MfaManager) newModelEntity() *Mfa { @@ -123,7 +123,7 @@ func (self *MfaManager) ApplyUpdate(cmd *command.UpdateEntityCommand[*Mfa], ctx } func (self *MfaManager) IsUpdated(field string) bool { - return field == persistence.FieldMfaIsVerified || field == persistence.FieldMfaRecoveryCodes + return field == db.FieldMfaIsVerified || field == db.FieldMfaRecoveryCodes } func (self *MfaManager) Query(query string) (*MfaListResult, error) { diff --git a/controller/model/mfa_model.go b/controller/model/mfa_model.go index 249063a81..93d8cd372 100644 --- a/controller/model/mfa_model.go +++ b/controller/model/mfa_model.go @@ -17,10 +17,10 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -38,12 +38,12 @@ type Mfa struct { RecoveryCodes []string } -func (entity *Mfa) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.Mfa, error) { +func (entity *Mfa) toBoltEntity(tx *bbolt.Tx, env Env) (*db.Mfa, error) { if !env.GetStores().Identity.IsEntityPresent(tx, entity.IdentityId) { return nil, errorz.NewFieldError("identity not found", "IdentityId", entity.IdentityId) } - boltEntity := &persistence.Mfa{ + boltEntity := &db.Mfa{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), IsVerified: entity.IsVerified, IdentityId: entity.IdentityId, @@ -54,15 +54,15 @@ func (entity *Mfa) toBoltEntity(tx *bbolt.Tx, env Env) (*persistence.Mfa, error) return boltEntity, nil } -func (entity *Mfa) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.Mfa, error) { +func (entity *Mfa) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*db.Mfa, error) { return entity.toBoltEntity(tx, env) } -func (entity *Mfa) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*persistence.Mfa, error) { +func (entity *Mfa) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*db.Mfa, error) { return entity.toBoltEntity(tx, env) } -func (entity *Mfa) fillFrom(env Env, tx *bbolt.Tx, boltMfa *persistence.Mfa) error { +func (entity *Mfa) fillFrom(env Env, tx *bbolt.Tx, boltMfa *db.Mfa) error { entity.FillCommon(boltMfa) entity.IsVerified = boltMfa.IsVerified entity.IdentityId = boltMfa.IdentityId diff --git a/controller/model/policy_advisor.go b/controller/model/policy_advisor.go index 246745c65..a41a3e6cc 100644 --- a/controller/model/policy_advisor.go +++ b/controller/model/policy_advisor.go @@ -1,9 +1,8 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/db" "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/ziti/controller/db" "go.etcd.io/bbolt" ) @@ -63,8 +62,8 @@ func (advisor *PolicyAdvisor) AnalyzeServiceReachability(identityId, serviceId s result := &AdvisorServiceReachability{ Identity: identity, Service: service, - IsBindAllowed: stringz.Contains(permissions, persistence.PolicyTypeBindName), - IsDialAllowed: stringz.Contains(permissions, persistence.PolicyTypeDialName), + IsBindAllowed: stringz.Contains(permissions, db.PolicyTypeBindName), + IsDialAllowed: stringz.Contains(permissions, db.PolicyTypeDialName), IdentityRouterCount: len(edgeRouters), ServiceRouterCount: len(serviceEdgeRouters), } @@ -95,7 +94,7 @@ func (advisor *PolicyAdvisor) getServicePermissions(identityId, serviceId string return nil } - if err := advisor.env.GetManagers().Identity.iterateRelatedEntities(identityId, persistence.EntityTypeServicePolicies, servicePolicyIterator); err != nil { + if err := advisor.env.GetManagers().Identity.iterateRelatedEntities(identityId, db.EntityTypeServicePolicies, servicePolicyIterator); err != nil { return nil, err } @@ -125,7 +124,7 @@ func (advisor *PolicyAdvisor) getIdentityEdgeRouters(identityId string) (map[str return advisor.env.GetManagers().EdgeRouterPolicy.iterateRelatedEntitiesInTx(tx, edgeRouterPolicyId, db.EntityTypeRouters, edgeRouterIterator) } - if err := advisor.env.GetManagers().Identity.iterateRelatedEntities(identityId, persistence.EntityTypeEdgeRouterPolicies, edgeRouterPolicyIterator); err != nil { + if err := advisor.env.GetManagers().Identity.iterateRelatedEntities(identityId, db.EntityTypeEdgeRouterPolicies, edgeRouterPolicyIterator); err != nil { return nil, err } @@ -143,7 +142,7 @@ func (advisor *PolicyAdvisor) getServiceEdgeRouters(serviceId string) (map[strin return advisor.env.GetManagers().ServiceEdgeRouterPolicy.iterateRelatedEntitiesInTx(tx, policyId, db.EntityTypeRouters, edgeRouterIterator) } - if err := advisor.env.GetManagers().EdgeService.iterateRelatedEntities(serviceId, persistence.EntityTypeServiceEdgeRouterPolicies, serviceEdgeRouterPolicyIterator); err != nil { + if err := advisor.env.GetManagers().EdgeService.iterateRelatedEntities(serviceId, db.EntityTypeServiceEdgeRouterPolicies, serviceEdgeRouterPolicyIterator); err != nil { return nil, err } @@ -196,7 +195,7 @@ func (advisor *PolicyAdvisor) getEdgeRouterPolicies(identityId, edgeRouterId str return nil } - if err := advisor.env.GetManagers().Identity.iterateRelatedEntities(identityId, persistence.EntityTypeEdgeRouterPolicies, policyIterator); err != nil { + if err := advisor.env.GetManagers().Identity.iterateRelatedEntities(identityId, db.EntityTypeEdgeRouterPolicies, policyIterator); err != nil { return nil, err } @@ -249,7 +248,7 @@ func (advisor *PolicyAdvisor) getServicePolicies(identityId, serviceId string) ( return nil } - if err := advisor.env.GetManagers().Identity.iterateRelatedEntities(identityId, persistence.EntityTypeServicePolicies, policyIterator); err != nil { + if err := advisor.env.GetManagers().Identity.iterateRelatedEntities(identityId, db.EntityTypeServicePolicies, policyIterator); err != nil { return nil, err } @@ -302,7 +301,7 @@ func (advisor *PolicyAdvisor) getServiceEdgeRouterPolicies(serviceId, edgeRouter return nil } - if err := advisor.env.GetManagers().EdgeService.iterateRelatedEntities(serviceId, persistence.EntityTypeServiceEdgeRouterPolicies, policyIterator); err != nil { + if err := advisor.env.GetManagers().EdgeService.iterateRelatedEntities(serviceId, db.EntityTypeServiceEdgeRouterPolicies, policyIterator); err != nil { return nil, err } diff --git a/controller/model/posture_check_manager.go b/controller/model/posture_check_manager.go index 0a881939e..f398fcea2 100644 --- a/controller/model/posture_check_manager.go +++ b/controller/model/posture_check_manager.go @@ -19,15 +19,15 @@ package model import ( "fmt" lru "github.com/hashicorp/golang-lru/v2" + "github.com/openziti/storage/ast" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/ast" - "github.com/openziti/storage/boltz" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" "strings" @@ -43,7 +43,7 @@ func NewPostureCheckManager(env Env) *PostureCheckManager { panic(err) } manager := &PostureCheckManager{ - baseEntityManager: newBaseEntityManager[*PostureCheck, *persistence.PostureCheck](env, env.GetStores().PostureCheck), + baseEntityManager: newBaseEntityManager[*PostureCheck, *db.PostureCheck](env, env.GetStores().PostureCheck), cache: cache, } manager.impl = manager @@ -59,7 +59,7 @@ func NewPostureCheckManager(env Env) *PostureCheckManager { } type PostureCheckManager struct { - baseEntityManager[*PostureCheck, *persistence.PostureCheck] + baseEntityManager[*PostureCheck, *db.PostureCheck] cache *lru.Cache[string, *PostureCheck] } @@ -114,27 +114,27 @@ func (self *PostureCheckManager) readInTx(tx *bbolt.Tx, id string) (*PostureChec } func (self *PostureCheckManager) IsUpdated(field string) bool { - return strings.EqualFold(field, persistence.FieldName) || + return strings.EqualFold(field, db.FieldName) || strings.EqualFold(field, boltz.FieldTags) || - strings.EqualFold(field, persistence.FieldRoleAttributes) || - strings.EqualFold(field, persistence.FieldPostureCheckOsType) || - strings.EqualFold(field, persistence.FieldPostureCheckOsVersions) || - strings.EqualFold(field, persistence.FieldPostureCheckMacAddresses) || - strings.EqualFold(field, persistence.FieldPostureCheckDomains) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessFingerprint) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessOs) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessPath) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessHashes) || - strings.EqualFold(field, persistence.FieldPostureCheckMfaPromptOnWake) || - strings.EqualFold(field, persistence.FieldPostureCheckMfaPromptOnUnlock) || - strings.EqualFold(field, persistence.FieldPostureCheckMfaTimeoutSeconds) || - strings.EqualFold(field, persistence.FieldPostureCheckMfaIgnoreLegacyEndpoints) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessMultiOsType) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessMultiHashes) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessMultiPath) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessMultiSignerFingerprints) || - strings.EqualFold(field, persistence.FieldPostureCheckProcessMultiProcesses) || - strings.EqualFold(field, persistence.FieldSemantic) + strings.EqualFold(field, db.FieldRoleAttributes) || + strings.EqualFold(field, db.FieldPostureCheckOsType) || + strings.EqualFold(field, db.FieldPostureCheckOsVersions) || + strings.EqualFold(field, db.FieldPostureCheckMacAddresses) || + strings.EqualFold(field, db.FieldPostureCheckDomains) || + strings.EqualFold(field, db.FieldPostureCheckProcessFingerprint) || + strings.EqualFold(field, db.FieldPostureCheckProcessOs) || + strings.EqualFold(field, db.FieldPostureCheckProcessPath) || + strings.EqualFold(field, db.FieldPostureCheckProcessHashes) || + strings.EqualFold(field, db.FieldPostureCheckMfaPromptOnWake) || + strings.EqualFold(field, db.FieldPostureCheckMfaPromptOnUnlock) || + strings.EqualFold(field, db.FieldPostureCheckMfaTimeoutSeconds) || + strings.EqualFold(field, db.FieldPostureCheckMfaIgnoreLegacyEndpoints) || + strings.EqualFold(field, db.FieldPostureCheckProcessMultiOsType) || + strings.EqualFold(field, db.FieldPostureCheckProcessMultiHashes) || + strings.EqualFold(field, db.FieldPostureCheckProcessMultiPath) || + strings.EqualFold(field, db.FieldPostureCheckProcessMultiSignerFingerprints) || + strings.EqualFold(field, db.FieldPostureCheckProcessMultiProcesses) || + strings.EqualFold(field, db.FieldSemantic) } func (self *PostureCheckManager) Query(query string) (*PostureCheckListResult, error) { diff --git a/controller/model/posture_check_model.go b/controller/model/posture_check_model.go index f1890c185..38f3604c2 100644 --- a/controller/model/posture_check_model.go +++ b/controller/model/posture_check_model.go @@ -18,10 +18,10 @@ package model import ( "fmt" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" - "github.com/openziti/storage/boltz" "go.etcd.io/bbolt" "time" ) @@ -37,8 +37,8 @@ type PostureCheck struct { type PostureCheckSubType interface { TypeId() string - toBoltEntityForCreate(tx *bbolt.Tx, env Env) (persistence.PostureCheckSubType, error) - fillFrom(env Env, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error + toBoltEntityForCreate(tx *bbolt.Tx, env Env) (db.PostureCheckSubType, error) + fillFrom(env Env, tx *bbolt.Tx, check *db.PostureCheck, subType db.PostureCheckSubType) error Evaluate(apiSessionId string, pd *PostureData) bool FailureValues(_ string, pd *PostureData) PostureCheckFailureValues GetTimeoutSeconds() int64 @@ -83,7 +83,7 @@ func newSubType(typeId string) PostureCheckSubType { return nil } -func (entity *PostureCheck) fillFrom(env Env, tx *bbolt.Tx, boltPostureCheck *persistence.PostureCheck) error { +func (entity *PostureCheck) fillFrom(env Env, tx *bbolt.Tx, boltPostureCheck *db.PostureCheck) error { entity.FillCommon(boltPostureCheck) entity.Name = boltPostureCheck.Name entity.TypeId = boltPostureCheck.TypeId @@ -105,8 +105,8 @@ func (entity *PostureCheck) fillFrom(env Env, tx *bbolt.Tx, boltPostureCheck *pe return nil } -func (entity *PostureCheck) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.PostureCheck, error) { - boltEntity := &persistence.PostureCheck{ +func (entity *PostureCheck) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*db.PostureCheck, error) { + boltEntity := &db.PostureCheck{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, TypeId: entity.TypeId, @@ -122,7 +122,7 @@ func (entity *PostureCheck) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persi return boltEntity, nil } -func (entity *PostureCheck) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*persistence.PostureCheck, error) { +func (entity *PostureCheck) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, _ boltz.FieldChecker) (*db.PostureCheck, error) { return entity.toBoltEntityForCreate(tx, env) } diff --git a/controller/model/posture_check_model_mac.go b/controller/model/posture_check_model_mac.go index 384baf2e4..287a2f8b0 100644 --- a/controller/model/posture_check_model_mac.go +++ b/controller/model/posture_check_model_mac.go @@ -19,7 +19,7 @@ package model import ( "fmt" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/pkg/errors" "go.etcd.io/bbolt" "time" @@ -32,7 +32,7 @@ type PostureCheckMacAddresses struct { } func (p *PostureCheckMacAddresses) TypeId() string { - return persistence.PostureCheckTypeMAC + return db.PostureCheckTypeMAC } func (p *PostureCheckMacAddresses) fillProtobuf(msg *edge_cmd_pb.PostureCheck) { @@ -96,8 +96,8 @@ func newPostureCheckMacAddresses() PostureCheckSubType { return &PostureCheckMacAddresses{} } -func (p *PostureCheckMacAddresses) fillFrom(_ Env, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error { - subCheck := subType.(*persistence.PostureCheckMacAddresses) +func (p *PostureCheckMacAddresses) fillFrom(_ Env, tx *bbolt.Tx, check *db.PostureCheck, subType db.PostureCheckSubType) error { + subCheck := subType.(*db.PostureCheckMacAddresses) if subCheck == nil { return fmt.Errorf("could not covert mac address check to bolt type") @@ -107,8 +107,8 @@ func (p *PostureCheckMacAddresses) fillFrom(_ Env, tx *bbolt.Tx, check *persiste return nil } -func (p *PostureCheckMacAddresses) toBoltEntityForCreate(*bbolt.Tx, Env) (persistence.PostureCheckSubType, error) { - return &persistence.PostureCheckMacAddresses{ +func (p *PostureCheckMacAddresses) toBoltEntityForCreate(*bbolt.Tx, Env) (db.PostureCheckSubType, error) { + return &db.PostureCheckMacAddresses{ MacAddresses: p.MacAddresses, }, nil } diff --git a/controller/model/posture_check_model_mfa.go b/controller/model/posture_check_model_mfa.go index 0bea606e4..69ed9a36c 100644 --- a/controller/model/posture_check_model_mfa.go +++ b/controller/model/posture_check_model_mfa.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/blang/semver" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/pkg/errors" "go.etcd.io/bbolt" "time" @@ -44,7 +44,7 @@ type PostureCheckMfa struct { } func (p *PostureCheckMfa) TypeId() string { - return persistence.PostureCheckTypeMFA + return db.PostureCheckTypeMFA } func (p *PostureCheckMfa) fillProtobuf(msg *edge_cmd_pb.PostureCheck) { @@ -316,8 +316,8 @@ func newPostureCheckMfa() PostureCheckSubType { return &PostureCheckMfa{} } -func (p *PostureCheckMfa) fillFrom(_ Env, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error { - subCheck := subType.(*persistence.PostureCheckMfa) +func (p *PostureCheckMfa) fillFrom(_ Env, tx *bbolt.Tx, check *db.PostureCheck, subType db.PostureCheckSubType) error { + subCheck := subType.(*db.PostureCheckMfa) if subCheck == nil { return fmt.Errorf("could not covert mfa check to bolt type") @@ -331,8 +331,8 @@ func (p *PostureCheckMfa) fillFrom(_ Env, tx *bbolt.Tx, check *persistence.Postu return nil } -func (p *PostureCheckMfa) toBoltEntityForCreate(*bbolt.Tx, Env) (persistence.PostureCheckSubType, error) { - return &persistence.PostureCheckMfa{ +func (p *PostureCheckMfa) toBoltEntityForCreate(*bbolt.Tx, Env) (db.PostureCheckSubType, error) { + return &db.PostureCheckMfa{ TimeoutSeconds: p.TimeoutSeconds, PromptOnWake: p.PromptOnWake, PromptOnUnlock: p.PromptOnUnlock, diff --git a/controller/model/posture_check_model_os.go b/controller/model/posture_check_model_os.go index 0ca64b3ab..0dc25cddc 100644 --- a/controller/model/posture_check_model_os.go +++ b/controller/model/posture_check_model_os.go @@ -20,9 +20,9 @@ import ( "fmt" "github.com/blang/semver" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/ziti/common/pb/edge_cmd_pb" + "github.com/openziti/ziti/controller/db" "github.com/pkg/errors" "go.etcd.io/bbolt" "strings" @@ -36,7 +36,7 @@ type PostureCheckOperatingSystem struct { } func (p *PostureCheckOperatingSystem) TypeId() string { - return persistence.PostureCheckTypeOs + return db.PostureCheckTypeOs } func (p *PostureCheckOperatingSystem) fillProtobuf(msg *edge_cmd_pb.PostureCheck) { @@ -148,8 +148,8 @@ func newPostureCheckOperatingSystem() PostureCheckSubType { return &PostureCheckOperatingSystem{} } -func (p *PostureCheckOperatingSystem) fillFrom(_ Env, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error { - subCheck := subType.(*persistence.PostureCheckOperatingSystem) +func (p *PostureCheckOperatingSystem) fillFrom(_ Env, tx *bbolt.Tx, check *db.PostureCheck, subType db.PostureCheckSubType) error { + subCheck := subType.(*db.PostureCheckOperatingSystem) if subCheck == nil { return fmt.Errorf("could not covert os check to bolt type") @@ -178,9 +178,9 @@ func (p *PostureCheckOperatingSystem) validateOsVersions() error { return nil } -func (p *PostureCheckOperatingSystem) toBoltEntityForCreate(*bbolt.Tx, Env) (persistence.PostureCheckSubType, error) { - ret := &persistence.PostureCheckOperatingSystem{ - OperatingSystems: []persistence.OperatingSystem{}, +func (p *PostureCheckOperatingSystem) toBoltEntityForCreate(*bbolt.Tx, Env) (db.PostureCheckSubType, error) { + ret := &db.PostureCheckOperatingSystem{ + OperatingSystems: []db.OperatingSystem{}, } if err := p.validateOsVersions(); err != nil { @@ -188,7 +188,7 @@ func (p *PostureCheckOperatingSystem) toBoltEntityForCreate(*bbolt.Tx, Env) (per } for _, osMatch := range p.OperatingSystems { - ret.OperatingSystems = append(ret.OperatingSystems, persistence.OperatingSystem{ + ret.OperatingSystems = append(ret.OperatingSystems, db.OperatingSystem{ OsType: osMatch.OsType, OsVersions: osMatch.OsVersions, }) diff --git a/controller/model/posture_check_model_process.go b/controller/model/posture_check_model_process.go index 168ead8fe..c9e3b8b90 100644 --- a/controller/model/posture_check_model_process.go +++ b/controller/model/posture_check_model_process.go @@ -19,7 +19,7 @@ package model import ( "fmt" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/pkg/errors" "go.etcd.io/bbolt" "strings" @@ -37,7 +37,7 @@ type PostureCheckProcess struct { } func (p *PostureCheckProcess) TypeId() string { - return persistence.PostureCheckTypeProcess + return db.PostureCheckTypeProcess } func (p *PostureCheckProcess) fillProtobuf(msg *edge_cmd_pb.PostureCheck) { @@ -148,8 +148,8 @@ func newPostureCheckProcess() PostureCheckSubType { return &PostureCheckProcess{} } -func (p *PostureCheckProcess) fillFrom(_ Env, tx *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error { - subCheck := subType.(*persistence.PostureCheckProcess) +func (p *PostureCheckProcess) fillFrom(_ Env, tx *bbolt.Tx, check *db.PostureCheck, subType db.PostureCheckSubType) error { + subCheck := subType.(*db.PostureCheckProcess) if subCheck == nil { return fmt.Errorf("could not covert process check to bolt type") @@ -163,8 +163,8 @@ func (p *PostureCheckProcess) fillFrom(_ Env, tx *bbolt.Tx, check *persistence.P return nil } -func (p *PostureCheckProcess) toBoltEntityForCreate(*bbolt.Tx, Env) (persistence.PostureCheckSubType, error) { - return &persistence.PostureCheckProcess{ +func (p *PostureCheckProcess) toBoltEntityForCreate(*bbolt.Tx, Env) (db.PostureCheckSubType, error) { + return &db.PostureCheckProcess{ OperatingSystem: p.OsType, Path: p.Path, Hashes: p.Hashes, diff --git a/controller/model/posture_check_model_process_multi.go b/controller/model/posture_check_model_process_multi.go index fdcfef598..1f2881dca 100644 --- a/controller/model/posture_check_model_process_multi.go +++ b/controller/model/posture_check_model_process_multi.go @@ -21,7 +21,7 @@ import ( "fmt" "github.com/michaelquigley/pfxlog" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/pkg/errors" "go.etcd.io/bbolt" "time" @@ -36,7 +36,7 @@ type PostureCheckProcessMulti struct { } func (p *PostureCheckProcessMulti) TypeId() string { - return persistence.PostureCheckTypeProcessMulti + return db.PostureCheckTypeProcessMulti } func (p *PostureCheckProcessMulti) fillProtobuf(msg *edge_cmd_pb.PostureCheck) { @@ -118,12 +118,12 @@ func (p *PostureCheckProcessMulti) Evaluate(_ string, pd *PostureData) bool { func (p *PostureCheckProcessMulti) evaluate(pd *PostureData) PostureCheckFailureValues { switch p.Semantic { - case persistence.SemanticAllOf: + case db.SemanticAllOf: return p.requireAll(pd) - case persistence.SemanticAnyOf: + case db.SemanticAnyOf: return p.requireOne(pd) default: - pfxlog.Logger().Panicf("invalid semantic, expected %s or %s got [%s]", persistence.SemanticAllOf, persistence.SemanticAnyOf, p.Semantic) + pfxlog.Logger().Panicf("invalid semantic, expected %s or %s got [%s]", db.SemanticAllOf, db.SemanticAnyOf, p.Semantic) return nil } } @@ -184,8 +184,8 @@ func newPostureCheckProcessMulti() PostureCheckSubType { return &PostureCheckProcessMulti{} } -func (p *PostureCheckProcessMulti) fillFrom(_ Env, _ *bbolt.Tx, check *persistence.PostureCheck, subType persistence.PostureCheckSubType) error { - subCheck := subType.(*persistence.PostureCheckProcessMulti) +func (p *PostureCheckProcessMulti) fillFrom(_ Env, _ *bbolt.Tx, check *db.PostureCheck, subType db.PostureCheckSubType) error { + subCheck := subType.(*db.PostureCheckProcessMulti) if subCheck == nil { return fmt.Errorf("could not covert process check process multi to bolt type") @@ -208,13 +208,13 @@ func (p *PostureCheckProcessMulti) fillFrom(_ Env, _ *bbolt.Tx, check *persisten return nil } -func (p *PostureCheckProcessMulti) toBoltEntityForCreate(_ *bbolt.Tx, _ Env) (persistence.PostureCheckSubType, error) { - ret := &persistence.PostureCheckProcessMulti{ +func (p *PostureCheckProcessMulti) toBoltEntityForCreate(_ *bbolt.Tx, _ Env) (db.PostureCheckSubType, error) { + ret := &db.PostureCheckProcessMulti{ Semantic: p.Semantic, } for _, process := range p.Processes { - newProc := &persistence.ProcessMulti{ + newProc := &db.ProcessMulti{ OsType: process.OsType, Path: process.Path, Hashes: process.Hashes, diff --git a/controller/model/posture_check_model_process_multi_test.go b/controller/model/posture_check_model_process_multi_test.go index 7a18bd279..9ffb9e7cb 100644 --- a/controller/model/posture_check_model_process_multi_test.go +++ b/controller/model/posture_check_model_process_multi_test.go @@ -17,7 +17,7 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/stretchr/testify/require" "strings" "testing" @@ -177,7 +177,7 @@ func newMatchingProcessMultiCheckAndData() (*PostureCheckProcessMulti, *PostureD processCheck := &PostureCheckProcessMulti{ PostureCheckId: postureCheckId, - Semantic: persistence.SemanticAllOf, + Semantic: db.SemanticAllOf, Processes: []*ProcessMulti{ { OsType: "Windows", diff --git a/controller/model/posture_check_model_windows_domain.go b/controller/model/posture_check_model_windows_domain.go index 3b09a7862..4ea1b5342 100644 --- a/controller/model/posture_check_model_windows_domain.go +++ b/controller/model/posture_check_model_windows_domain.go @@ -19,7 +19,7 @@ package model import ( "fmt" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/pkg/errors" "go.etcd.io/bbolt" "strings" @@ -33,7 +33,7 @@ type PostureCheckDomains struct { } func (p *PostureCheckDomains) TypeId() string { - return persistence.PostureCheckTypeDomain + return db.PostureCheckTypeDomain } func (p *PostureCheckDomains) fillProtobuf(msg *edge_cmd_pb.PostureCheck) { @@ -102,8 +102,8 @@ func newPostureCheckWindowsDomains() PostureCheckSubType { return &PostureCheckDomains{} } -func (p *PostureCheckDomains) fillFrom(_ Env, _ *bbolt.Tx, _ *persistence.PostureCheck, subType persistence.PostureCheckSubType) error { - subCheck := subType.(*persistence.PostureCheckWindowsDomains) +func (p *PostureCheckDomains) fillFrom(_ Env, _ *bbolt.Tx, _ *db.PostureCheck, subType db.PostureCheckSubType) error { + subCheck := subType.(*db.PostureCheckWindowsDomains) if subCheck == nil { return fmt.Errorf("could not covert domain check to bolt type") @@ -113,8 +113,8 @@ func (p *PostureCheckDomains) fillFrom(_ Env, _ *bbolt.Tx, _ *persistence.Postur return nil } -func (p *PostureCheckDomains) toBoltEntityForCreate(*bbolt.Tx, Env) (persistence.PostureCheckSubType, error) { - return &persistence.PostureCheckWindowsDomains{ +func (p *PostureCheckDomains) toBoltEntityForCreate(*bbolt.Tx, Env) (db.PostureCheckSubType, error) { + return &db.PostureCheckWindowsDomains{ Domains: p.Domains, }, nil } diff --git a/controller/model/posture_check_type_manager.go b/controller/model/posture_check_type_manager.go index fb0d09a85..4b07f2372 100644 --- a/controller/model/posture_check_type_manager.go +++ b/controller/model/posture_check_type_manager.go @@ -16,18 +16,20 @@ package model -import "github.com/openziti/ziti/controller/persistence" +import ( + "github.com/openziti/ziti/controller/db" +) func NewPostureCheckTypeManager(env Env) *PostureCheckTypeManager { manager := &PostureCheckTypeManager{ - baseEntityManager: newBaseEntityManager[*PostureCheckType, *persistence.PostureCheckType](env, env.GetStores().PostureCheckType), + baseEntityManager: newBaseEntityManager[*PostureCheckType, *db.PostureCheckType](env, env.GetStores().PostureCheckType), } manager.impl = manager return manager } type PostureCheckTypeManager struct { - baseEntityManager[*PostureCheckType, *persistence.PostureCheckType] + baseEntityManager[*PostureCheckType, *db.PostureCheckType] } func (self *PostureCheckTypeManager) newModelEntity() *PostureCheckType { diff --git a/controller/model/posture_check_type_model.go b/controller/model/posture_check_type_model.go index 0f0876841..caeb1c0fb 100644 --- a/controller/model/posture_check_type_model.go +++ b/controller/model/posture_check_type_model.go @@ -17,9 +17,9 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -29,32 +29,32 @@ type PostureCheckType struct { OperatingSystems []OperatingSystem } -func (entity *PostureCheckType) toBoltEntity() (*persistence.PostureCheckType, error) { - var operatingSystems []persistence.OperatingSystem +func (entity *PostureCheckType) toBoltEntity() (*db.PostureCheckType, error) { + var operatingSystems []db.OperatingSystem for _, os := range entity.OperatingSystems { - operatingSystems = append(operatingSystems, persistence.OperatingSystem{ + operatingSystems = append(operatingSystems, db.OperatingSystem{ OsType: os.OsType, OsVersions: os.OsVersions, }) } - return &persistence.PostureCheckType{ + return &db.PostureCheckType{ Name: entity.Name, OperatingSystems: operatingSystems, BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), }, nil } -func (entity *PostureCheckType) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.PostureCheckType, error) { +func (entity *PostureCheckType) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.PostureCheckType, error) { return entity.toBoltEntity() } -func (entity *PostureCheckType) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.PostureCheckType, error) { +func (entity *PostureCheckType) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.PostureCheckType, error) { return entity.toBoltEntity() } -func (entity *PostureCheckType) fillFrom(_ Env, _ *bbolt.Tx, boltPostureCheckType *persistence.PostureCheckType) error { +func (entity *PostureCheckType) fillFrom(_ Env, _ *bbolt.Tx, boltPostureCheckType *db.PostureCheckType) error { var operatingSystems []OperatingSystem for _, os := range boltPostureCheckType.OperatingSystems { diff --git a/controller/model/posture_response_manager.go b/controller/model/posture_response_manager.go index 640e82136..d6353948b 100644 --- a/controller/model/posture_response_manager.go +++ b/controller/model/posture_response_manager.go @@ -19,10 +19,9 @@ package model import ( "fmt" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/storage/ast" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/db" - "github.com/openziti/storage/ast" "go.etcd.io/bbolt" "runtime/debug" "time" @@ -260,7 +259,7 @@ type ServiceWithTimeout struct { Timeout int64 } -func shouldPostureCheckTimeoutBeAltered(mfaCheck *persistence.PostureCheckMfa, timeSinceLastMfa, gracePeriod time.Duration, onWake, onUnlock bool) bool { +func shouldPostureCheckTimeoutBeAltered(mfaCheck *db.PostureCheckMfa, timeSinceLastMfa, gracePeriod time.Duration, onWake, onUnlock bool) bool { if mfaCheck == nil { return false } @@ -281,7 +280,7 @@ func shouldPostureCheckTimeoutBeAltered(mfaCheck *persistence.PostureCheckMfa, t func (self *PostureResponseManager) GetEndpointStateChangeAffectedServices(timeSinceLastMfa, gracePeriod time.Duration, onWake bool, onUnlock bool) []*ServiceWithTimeout { affectedChecks := map[string]int64{} //check id -> timeout if onWake || onUnlock { - queryStr := fmt.Sprintf("%s=true or %s=true", persistence.FieldPostureCheckMfaPromptOnUnlock, persistence.FieldPostureCheckMfaPromptOnWake) + queryStr := fmt.Sprintf("%s=true or %s=true", db.FieldPostureCheckMfaPromptOnUnlock, db.FieldPostureCheckMfaPromptOnWake) query, err := ast.Parse(self.env.GetStores().PostureCheck, queryStr) if err != nil { pfxlog.Logger().Errorf("error querying for onWake/onUnlock posture checks: %v", err) @@ -291,7 +290,7 @@ func (self *PostureResponseManager) GetEndpointStateChangeAffectedServices(timeS for cursor.IsValid() { if check, err := self.env.GetStores().PostureCheck.LoadOneById(tx, string(cursor.Current())); err == nil { - if mfaCheck, ok := check.SubType.(*persistence.PostureCheckMfa); ok { + if mfaCheck, ok := check.SubType.(*db.PostureCheckMfa); ok { if shouldPostureCheckTimeoutBeAltered(mfaCheck, timeSinceLastMfa, gracePeriod, onWake, onUnlock) { affectedChecks[check.Id] = mfaCheck.TimeoutSeconds } @@ -315,7 +314,7 @@ func (self *PostureResponseManager) GetEndpointStateChangeAffectedServices(timeS if len(affectedChecks) > 0 { _ = self.env.GetDbProvider().GetDb().View(func(tx *bbolt.Tx) error { for checkId, timeout := range affectedChecks { - policyCursor := self.env.GetStores().PostureCheck.GetRelatedEntitiesCursor(tx, checkId, persistence.EntityTypeServicePolicies, true) + policyCursor := self.env.GetStores().PostureCheck.GetRelatedEntitiesCursor(tx, checkId, db.EntityTypeServicePolicies, true) for policyCursor.IsValid() { serviceCursor := self.env.GetStores().ServicePolicy.GetRelatedEntitiesCursor(tx, string(policyCursor.Current()), db.EntityTypeServices, true) diff --git a/controller/model/posture_response_manager_test.go b/controller/model/posture_response_manager_test.go index ee372481e..915783f76 100644 --- a/controller/model/posture_response_manager_test.go +++ b/controller/model/posture_response_manager_test.go @@ -17,7 +17,7 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/stretchr/testify/require" "testing" "time" @@ -42,7 +42,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if no prompts (all false), timeout remaining is greater than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnWake: false, PromptOnUnlock: false, @@ -59,7 +59,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi // promptOnWake = true, wake = true t.Run("returns true if promptOnWake=true, wake=true, timeout remaining is greater than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnWake: true, PromptOnUnlock: false, @@ -75,7 +75,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if promptOnWake=true, wake=true, timeout remaining is less than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnWake: true, PromptOnUnlock: false, @@ -91,7 +91,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if promptOnWake=true, wake=true, timeout remaining equals grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnWake: true, PromptOnUnlock: false, @@ -108,7 +108,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi // promptOnWake = true, wake = false t.Run("returns false if promptOnWake=true, wake=false, timeout remaining is greater than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnWake: true, PromptOnUnlock: false, @@ -124,7 +124,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if promptOnWake=true, wake=false, timeout remaining is less than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnWake: true, PromptOnUnlock: false, @@ -140,7 +140,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if promptOnWake=true, wake=false, timeout remaining equals grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnWake: true, PromptOnUnlock: false, @@ -157,7 +157,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi // promptOnUnlock = true, unlock = true t.Run("returns true if promptOnUnlock=true, unlock=true, timeout remaining is greater than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnUnlock: true, PromptOnWake: false, @@ -173,7 +173,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if promptOnUnlock=true, unlock=true, timeout remaining is less than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnUnlock: true, PromptOnWake: false, @@ -189,7 +189,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if promptOnUnlock=true, unlock=true, timeout remaining equals grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnUnlock: true, PromptOnWake: false, @@ -206,7 +206,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi // promptOnUnlock = true, unlock = false t.Run("returns false if promptOnUnlock=true, unlock=false, timeout remaining is greater than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnUnlock: true, PromptOnWake: false, @@ -222,7 +222,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if promptOnUnlock=true, unlock=false, timeout remaining is less than grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnUnlock: true, PromptOnWake: false, @@ -238,7 +238,7 @@ func TestPostureCheckResponseManager_shouldPostureCheckTimeoutBeAltered(t *testi }) t.Run("returns false if promptOnUnlock=true, unlock=false, timeout remaining equals grace", func(t *testing.T) { - mfaCheck := &persistence.PostureCheckMfa{ + mfaCheck := &db.PostureCheckMfa{ TimeoutSeconds: int64(mustParseDuration("10m").Seconds()), PromptOnUnlock: true, PromptOnWake: false, diff --git a/controller/model/posture_response_model.go b/controller/model/posture_response_model.go index 9e98a4236..4897d0382 100644 --- a/controller/model/posture_response_model.go +++ b/controller/model/posture_response_model.go @@ -21,10 +21,10 @@ import ( "github.com/jinzhu/copier" "github.com/kataras/go-events" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/change" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" cmap "github.com/orcaman/concurrent-map/v2" "go.etcd.io/bbolt" "regexp" @@ -107,7 +107,7 @@ func (pc *PostureCache) evaluate() { // Chunk data in maxToDelete bunches to limit how many sessions we are deleting in a transaction. // Requires tracking of which session was last evaluated, kept in lastId. for !done { - var sessions []*persistence.Session + var sessions []*db.Session _ = pc.env.GetDbProvider().GetDb().View(func(tx *bbolt.Tx) error { cursor := pc.env.GetStores().Session.IterateIds(tx, ast.BoolNodeTrue) @@ -277,11 +277,11 @@ func (pc *PostureCache) WithPostureData(identityId string, f func(data *PostureD }) } -func (pc *PostureCache) ApiSessionCreated(apiSession *persistence.ApiSession) { +func (pc *PostureCache) ApiSessionCreated(apiSession *db.ApiSession) { pc.apiSessionIdToIdentityId.Set(apiSession.Id, apiSession.IdentityId) } -func (pc *PostureCache) ApiSessionDeleted(apiSession *persistence.ApiSession) { +func (pc *PostureCache) ApiSessionDeleted(apiSession *db.ApiSession) { pc.identityToPostureData.Upsert(apiSession.IdentityId, newPostureData(), func(exist bool, valueInMap *PostureData, newValue *PostureData) *PostureData { if exist { if valueInMap != nil && valueInMap.ApiSessions != nil { @@ -297,14 +297,14 @@ func (pc *PostureCache) ApiSessionDeleted(apiSession *persistence.ApiSession) { pc.apiSessionIdToIdentityId.Remove(apiSession.Id) } -func (pc *PostureCache) IdentityDeleted(identity *persistence.Identity) { +func (pc *PostureCache) IdentityDeleted(identity *db.Identity) { pc.identityToPostureData.Remove(identity.Id) } // PostureCheckChanged notifies all associated identities that posture configuration has changed // and that endpoints may need to reevaluate posture queries. func (pc *PostureCache) PostureCheckChanged(entity boltz.Entity) { - servicePolicyLinks := pc.env.GetStores().PostureCheck.GetLinkCollection(persistence.EntityTypeServicePolicies) + servicePolicyLinks := pc.env.GetStores().PostureCheck.GetLinkCollection(db.EntityTypeServicePolicies) if servicePolicyLinks == nil { pfxlog.Logger().Error("posture checks had no links to service policies") @@ -317,7 +317,7 @@ func (pc *PostureCache) PostureCheckChanged(entity boltz.Entity) { servicePolicyCursor := servicePolicyLinks.IterateLinks(tx, []byte(entity.GetId())) for servicePolicyCursor.IsValid() { - identityLink := pc.env.GetStores().ServicePolicy.GetLinkCollection(persistence.EntityTypeIdentities) + identityLink := pc.env.GetStores().ServicePolicy.GetLinkCollection(db.EntityTypeIdentities) if identityLink == nil { pfxlog.Logger().Error("service policies had no link to identities") diff --git a/controller/model/revocation_manager.go b/controller/model/revocation_manager.go index 96d88eaf1..f8fbf4637 100644 --- a/controller/model/revocation_manager.go +++ b/controller/model/revocation_manager.go @@ -17,20 +17,20 @@ package model import ( + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "google.golang.org/protobuf/proto" ) func NewRevocationManager(env Env) *RevocationManager { manager := &RevocationManager{ - baseEntityManager: newBaseEntityManager[*Revocation, *persistence.Revocation](env, env.GetStores().Revocation), + baseEntityManager: newBaseEntityManager[*Revocation, *db.Revocation](env, env.GetStores().Revocation), } manager.impl = manager @@ -40,7 +40,7 @@ func NewRevocationManager(env Env) *RevocationManager { } type RevocationManager struct { - baseEntityManager[*Revocation, *persistence.Revocation] + baseEntityManager[*Revocation, *db.Revocation] } func (self *RevocationManager) ApplyUpdate(_ *command.UpdateEntityCommand[*Revocation], ctx boltz.MutateContext) error { diff --git a/controller/model/revocation_model.go b/controller/model/revocation_model.go index 967961216..51404e3ae 100644 --- a/controller/model/revocation_model.go +++ b/controller/model/revocation_model.go @@ -17,9 +17,9 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "time" ) @@ -29,19 +29,19 @@ type Revocation struct { ExpiresAt time.Time } -func (entity *Revocation) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, checker boltz.FieldChecker) (*persistence.Revocation, error) { +func (entity *Revocation) toBoltEntityForUpdate(tx *bbolt.Tx, env Env, checker boltz.FieldChecker) (*db.Revocation, error) { return entity.toBoltEntityForCreate(tx, env) } -func (entity *Revocation) fillFrom(_ Env, _ *bbolt.Tx, boltRevocation *persistence.Revocation) error { +func (entity *Revocation) fillFrom(_ Env, _ *bbolt.Tx, boltRevocation *db.Revocation) error { entity.FillCommon(boltRevocation) entity.ExpiresAt = boltRevocation.ExpiresAt return nil } -func (entity *Revocation) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.Revocation, error) { - boltEntity := &persistence.Revocation{ +func (entity *Revocation) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.Revocation, error) { + boltEntity := &db.Revocation{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), ExpiresAt: entity.ExpiresAt, } diff --git a/controller/model/service_edge_router_policy_manager.go b/controller/model/service_edge_router_policy_manager.go index 92549c061..6e1fea60b 100644 --- a/controller/model/service_edge_router_policy_manager.go +++ b/controller/model/service_edge_router_policy_manager.go @@ -17,20 +17,20 @@ package model import ( + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/boltz" "google.golang.org/protobuf/proto" ) func NewServiceEdgeRouterPolicyManager(env Env) *ServiceEdgeRouterPolicyManager { manager := &ServiceEdgeRouterPolicyManager{ - baseEntityManager: newBaseEntityManager[*ServiceEdgeRouterPolicy, *persistence.ServiceEdgeRouterPolicy](env, env.GetStores().ServiceEdgeRouterPolicy), + baseEntityManager: newBaseEntityManager[*ServiceEdgeRouterPolicy, *db.ServiceEdgeRouterPolicy](env, env.GetStores().ServiceEdgeRouterPolicy), } manager.impl = manager @@ -40,7 +40,7 @@ func NewServiceEdgeRouterPolicyManager(env Env) *ServiceEdgeRouterPolicyManager } type ServiceEdgeRouterPolicyManager struct { - baseEntityManager[*ServiceEdgeRouterPolicy, *persistence.ServiceEdgeRouterPolicy] + baseEntityManager[*ServiceEdgeRouterPolicy, *db.ServiceEdgeRouterPolicy] } func (self *ServiceEdgeRouterPolicyManager) newModelEntity() *ServiceEdgeRouterPolicy { diff --git a/controller/model/service_edge_router_policy_model.go b/controller/model/service_edge_router_policy_model.go index 6ea823be7..61925b190 100644 --- a/controller/model/service_edge_router_policy_model.go +++ b/controller/model/service_edge_router_policy_model.go @@ -17,9 +17,9 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -31,8 +31,8 @@ type ServiceEdgeRouterPolicy struct { EdgeRouterRoles []string } -func (entity *ServiceEdgeRouterPolicy) toBoltEntity() (*persistence.ServiceEdgeRouterPolicy, error) { - return &persistence.ServiceEdgeRouterPolicy{ +func (entity *ServiceEdgeRouterPolicy) toBoltEntity() (*db.ServiceEdgeRouterPolicy, error) { + return &db.ServiceEdgeRouterPolicy{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, Semantic: entity.Semantic, @@ -41,15 +41,15 @@ func (entity *ServiceEdgeRouterPolicy) toBoltEntity() (*persistence.ServiceEdgeR }, nil } -func (entity *ServiceEdgeRouterPolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.ServiceEdgeRouterPolicy, error) { +func (entity *ServiceEdgeRouterPolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.ServiceEdgeRouterPolicy, error) { return entity.toBoltEntity() } -func (entity *ServiceEdgeRouterPolicy) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.ServiceEdgeRouterPolicy, error) { +func (entity *ServiceEdgeRouterPolicy) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.ServiceEdgeRouterPolicy, error) { return entity.toBoltEntity() } -func (entity *ServiceEdgeRouterPolicy) fillFrom(_ Env, _ *bbolt.Tx, boltServiceEdgeRouterPolicy *persistence.ServiceEdgeRouterPolicy) error { +func (entity *ServiceEdgeRouterPolicy) fillFrom(_ Env, _ *bbolt.Tx, boltServiceEdgeRouterPolicy *db.ServiceEdgeRouterPolicy) error { entity.FillCommon(boltServiceEdgeRouterPolicy) entity.Name = boltServiceEdgeRouterPolicy.Name entity.Semantic = boltServiceEdgeRouterPolicy.Semantic diff --git a/controller/model/service_policy_manager.go b/controller/model/service_policy_manager.go index 123227a7d..08776bcca 100644 --- a/controller/model/service_policy_manager.go +++ b/controller/model/service_policy_manager.go @@ -17,20 +17,20 @@ package model import ( + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/pb/edge_cmd_pb" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/storage/boltz" "google.golang.org/protobuf/proto" ) func NewServicePolicyManager(env Env) *ServicePolicyManager { manager := &ServicePolicyManager{ - baseEntityManager: newBaseEntityManager[*ServicePolicy, *persistence.ServicePolicy](env, env.GetStores().ServicePolicy), + baseEntityManager: newBaseEntityManager[*ServicePolicy, *db.ServicePolicy](env, env.GetStores().ServicePolicy), } manager.impl = manager @@ -40,7 +40,7 @@ func NewServicePolicyManager(env Env) *ServicePolicyManager { } type ServicePolicyManager struct { - baseEntityManager[*ServicePolicy, *persistence.ServicePolicy] + baseEntityManager[*ServicePolicy, *db.ServicePolicy] } func (self *ServicePolicyManager) newModelEntity() *ServicePolicy { diff --git a/controller/model/service_policy_model.go b/controller/model/service_policy_model.go index 9863dc3e4..c6ea382e2 100644 --- a/controller/model/service_policy_model.go +++ b/controller/model/service_policy_model.go @@ -18,10 +18,10 @@ package model import ( "fmt" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "strings" ) @@ -37,28 +37,28 @@ type ServicePolicy struct { } func (entity *ServicePolicy) validatePolicyType() error { - if !strings.EqualFold(entity.PolicyType, persistence.PolicyTypeDialName) && !strings.EqualFold(entity.PolicyType, persistence.PolicyTypeBindName) { - msg := fmt.Sprintf("invalid policy type. valid types are '%v' and '%v'", persistence.PolicyTypeDialName, persistence.PolicyTypeBindName) + if !strings.EqualFold(entity.PolicyType, db.PolicyTypeDialName) && !strings.EqualFold(entity.PolicyType, db.PolicyTypeBindName) { + msg := fmt.Sprintf("invalid policy type. valid types are '%v' and '%v'", db.PolicyTypeDialName, db.PolicyTypeBindName) return errorz.NewFieldError(msg, "policyType", entity.PolicyType) } return nil } -func (entity *ServicePolicy) toBoltEntity(checker boltz.FieldChecker) (*persistence.ServicePolicy, error) { - if checker == nil || checker.IsUpdated(persistence.FieldServicePolicyType) { +func (entity *ServicePolicy) toBoltEntity(checker boltz.FieldChecker) (*db.ServicePolicy, error) { + if checker == nil || checker.IsUpdated(db.FieldServicePolicyType) { if err := entity.validatePolicyType(); err != nil { return nil, err } } - policyType := persistence.PolicyTypeInvalid - if strings.EqualFold(entity.PolicyType, persistence.PolicyTypeDialName) { - policyType = persistence.PolicyTypeDial - } else if strings.EqualFold(entity.PolicyType, persistence.PolicyTypeBindName) { - policyType = persistence.PolicyTypeBind + policyType := db.PolicyTypeInvalid + if strings.EqualFold(entity.PolicyType, db.PolicyTypeDialName) { + policyType = db.PolicyTypeDial + } else if strings.EqualFold(entity.PolicyType, db.PolicyTypeBindName) { + policyType = db.PolicyTypeBind } - return &persistence.ServicePolicy{ + return &db.ServicePolicy{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, PolicyType: policyType, @@ -69,15 +69,15 @@ func (entity *ServicePolicy) toBoltEntity(checker boltz.FieldChecker) (*persiste }, nil } -func (entity *ServicePolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.ServicePolicy, error) { +func (entity *ServicePolicy) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.ServicePolicy, error) { return entity.toBoltEntity(nil) } -func (entity *ServicePolicy) toBoltEntityForUpdate(_ *bbolt.Tx, _ Env, checker boltz.FieldChecker) (*persistence.ServicePolicy, error) { +func (entity *ServicePolicy) toBoltEntityForUpdate(_ *bbolt.Tx, _ Env, checker boltz.FieldChecker) (*db.ServicePolicy, error) { return entity.toBoltEntity(checker) } -func (entity *ServicePolicy) fillFrom(_ Env, _ *bbolt.Tx, boltServicePolicy *persistence.ServicePolicy) error { +func (entity *ServicePolicy) fillFrom(_ Env, _ *bbolt.Tx, boltServicePolicy *db.ServicePolicy) error { entity.FillCommon(boltServicePolicy) entity.Name = boltServicePolicy.Name entity.PolicyType = string(boltServicePolicy.PolicyType) diff --git a/controller/model/session_manager.go b/controller/model/session_manager.go index aad63c541..371af19bb 100644 --- a/controller/model/session_manager.go +++ b/controller/model/session_manager.go @@ -19,29 +19,29 @@ package model import ( "fmt" "github.com/lucsky/cuid" - "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" - fabricApiError "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/change" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/foundation/v2/stringz" "github.com/openziti/storage/ast" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/apierror" + fabricApiError "github.com/openziti/ziti/controller/apierror" + "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" "time" ) func NewSessionManager(env Env) *SessionManager { manager := &SessionManager{ - baseEntityManager: newBaseEntityManager[*Session, *persistence.Session](env, env.GetStores().Session), + baseEntityManager: newBaseEntityManager[*Session, *db.Session](env, env.GetStores().Session), } manager.impl = manager return manager } type SessionManager struct { - baseEntityManager[*Session, *persistence.Session] + baseEntityManager[*Session, *db.Session] } func (self *SessionManager) newModelEntity() *Session { @@ -172,14 +172,14 @@ func (self *SessionManager) Create(entity *Session, ctx *change.Context) (string } if entity.Type == "" { - entity.Type = persistence.SessionTypeDial + entity.Type = db.SessionTypeDial } - if persistence.SessionTypeDial == entity.Type && !stringz.Contains(service.Permissions, persistence.PolicyTypeDialName) { + if db.SessionTypeDial == entity.Type && !stringz.Contains(service.Permissions, db.PolicyTypeDialName) { return "", errorz.NewFieldError("service not found", "ServiceId", entity.ServiceId) } - if persistence.SessionTypeBind == entity.Type && !stringz.Contains(service.Permissions, persistence.PolicyTypeBindName) { + if db.SessionTypeBind == entity.Type && !stringz.Contains(service.Permissions, db.PolicyTypeBindName) { return "", errorz.NewFieldError("service not found", "ServiceId", entity.ServiceId) } diff --git a/controller/model/session_manager_test.go b/controller/model/session_manager_test.go index 05fde6745..4b8e41449 100644 --- a/controller/model/session_manager_test.go +++ b/controller/model/session_manager_test.go @@ -1,10 +1,10 @@ package model import ( + "github.com/openziti/storage/boltztest" "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" - "github.com/openziti/storage/boltztest" + "github.com/openziti/ziti/controller/db" "github.com/stretchr/testify/require" "testing" "time" @@ -26,26 +26,26 @@ func (ctx *TestContext) testSessionIdempotency(t *testing.T) { service.RoleAttributes = []string{eid.New()} ctx.NoError(ctx.managers.EdgeService.Update(service, nil, change.New())) - ctx.requireNewServicePolicy(persistence.PolicyTypeDialName, ss("#all"), ss("#all")) - ctx.requireNewServicePolicy(persistence.PolicyTypeBindName, ss("#all"), ss("#all")) + ctx.requireNewServicePolicy(db.PolicyTypeDialName, ss("#all"), ss("#all")) + ctx.requireNewServicePolicy(db.PolicyTypeBindName, ss("#all"), ss("#all")) ctx.requireNewEdgeRouterPolicy(ss("#all"), ss("#all")) ctx.requireNewServiceNewEdgeRouterPolicy(ss("#all"), ss("#all")) apiSession := ctx.requireNewApiSession(identity) - sessSvc1Dial := ctx.requireNewSession(apiSession, service.Id, persistence.SessionTypeDial) - sessSvc1Bind := ctx.requireNewSession(apiSession, service.Id, persistence.SessionTypeBind) + sessSvc1Dial := ctx.requireNewSession(apiSession, service.Id, db.SessionTypeDial) + sessSvc1Bind := ctx.requireNewSession(apiSession, service.Id, db.SessionTypeBind) req := require.New(t) req.NotEqual(sessSvc1Dial.Id, sessSvc1Bind.Id) - sessSvc1Dial2 := ctx.requireNewSession(apiSession, service.Id, persistence.SessionTypeDial) - sessSvc1Bind2 := ctx.requireNewSession(apiSession, service.Id, persistence.SessionTypeBind) + sessSvc1Dial2 := ctx.requireNewSession(apiSession, service.Id, db.SessionTypeDial) + sessSvc1Bind2 := ctx.requireNewSession(apiSession, service.Id, db.SessionTypeBind) req.Equal(sessSvc1Dial.Id, sessSvc1Dial2.Id) req.Equal(sessSvc1Bind.Id, sessSvc1Bind2.Id) - sessSvc2Dial1 := ctx.requireNewSession(apiSession, service2.Id, persistence.SessionTypeDial) - sessSvc2Bind1 := ctx.requireNewSession(apiSession, service2.Id, persistence.SessionTypeBind) + sessSvc2Dial1 := ctx.requireNewSession(apiSession, service2.Id, db.SessionTypeDial) + sessSvc2Bind1 := ctx.requireNewSession(apiSession, service2.Id, db.SessionTypeBind) req.NotEqual(sessSvc1Dial2.Id, sessSvc1Bind2.Id) req.NotEqual(sessSvc1Dial.Id, sessSvc2Dial1.Id) @@ -57,14 +57,14 @@ func (ctx *TestContext) testSessionIdempotency(t *testing.T) { req.NotEqual(sessSvc1Bind2.Id, sessSvc2Dial1.Id) req.NotEqual(sessSvc1Bind2.Id, sessSvc2Bind1.Id) - sessSvc2Dial2 := ctx.requireNewSession(apiSession, service2.Id, persistence.SessionTypeDial) - sessSvc2Bind2 := ctx.requireNewSession(apiSession, service2.Id, persistence.SessionTypeBind) + sessSvc2Dial2 := ctx.requireNewSession(apiSession, service2.Id, db.SessionTypeDial) + sessSvc2Bind2 := ctx.requireNewSession(apiSession, service2.Id, db.SessionTypeBind) req.Equal(sessSvc2Dial1.Id, sessSvc2Dial2.Id) req.Equal(sessSvc2Bind1.Id, sessSvc2Bind2.Id) - sessSvc1Dial3 := ctx.requireNewSession(apiSession, service.Id, persistence.SessionTypeDial) - sessSvc1Bind3 := ctx.requireNewSession(apiSession, service.Id, persistence.SessionTypeBind) + sessSvc1Dial3 := ctx.requireNewSession(apiSession, service.Id, db.SessionTypeDial) + sessSvc1Bind3 := ctx.requireNewSession(apiSession, service.Id, db.SessionTypeBind) req.Equal(sessSvc1Dial.Id, sessSvc1Dial3.Id) req.Equal(sessSvc1Bind.Id, sessSvc1Bind3.Id) diff --git a/controller/model/session_model.go b/controller/model/session_model.go index 7bb56eb49..64518dc91 100644 --- a/controller/model/session_model.go +++ b/controller/model/session_model.go @@ -17,10 +17,10 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/models" "go.etcd.io/bbolt" ) @@ -34,7 +34,7 @@ type Session struct { ServicePolicies []string } -func (entity *Session) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistence.Session, error) { +func (entity *Session) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*db.Session, error) { apiSession, err := env.GetStores().ApiSession.LoadOneById(tx, entity.ApiSessionId) if err != nil { return nil, err @@ -43,7 +43,7 @@ func (entity *Session) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistenc return nil, errorz.NewFieldError("api session not found", "ApiSessionId", entity.ApiSessionId) } - boltEntity := &persistence.Session{ + boltEntity := &db.Session{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Token: entity.Token, ApiSessionId: entity.ApiSessionId, @@ -57,8 +57,8 @@ func (entity *Session) toBoltEntityForCreate(tx *bbolt.Tx, env Env) (*persistenc return boltEntity, nil } -func (entity *Session) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.Session, error) { - return &persistence.Session{ +func (entity *Session) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.Session, error) { + return &db.Session{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Token: entity.Token, ApiSessionId: entity.ApiSessionId, @@ -69,7 +69,7 @@ func (entity *Session) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) }, nil } -func (entity *Session) fillFrom(_ Env, _ *bbolt.Tx, boltSession *persistence.Session) error { +func (entity *Session) fillFrom(_ Env, _ *bbolt.Tx, boltSession *db.Session) error { entity.FillCommon(boltSession) entity.Token = boltSession.Token entity.ApiSessionId = boltSession.ApiSessionId diff --git a/controller/model/testing.go b/controller/model/testing.go index 72d57f976..d8f77c007 100644 --- a/controller/model/testing.go +++ b/controller/model/testing.go @@ -21,15 +21,19 @@ import ( "crypto/x509" "github.com/golang-jwt/jwt/v5" "github.com/google/uuid" + "github.com/openziti/foundation/v2/versions" + "github.com/openziti/identity" + "github.com/openziti/metrics" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/change" + "github.com/openziti/ziti/controller/command" "github.com/openziti/ziti/controller/config" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/event" "github.com/openziti/ziti/controller/jwtsigner" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/network" - "github.com/openziti/identity" - "github.com/openziti/metrics" "testing" "time" ) @@ -40,7 +44,7 @@ var _ HostController = &testHostController{} type testHostController struct { closeNotify chan struct{} - ctx *persistence.TestContext + ctx *TestContext } func (self *testHostController) GetPeerSigners() []*x509.Certificate { @@ -52,34 +56,39 @@ func (self *testHostController) Identity() identity.Identity { } func (self *testHostController) GetNetwork() *network.Network { - return self.ctx.GetNetwork() + return self.ctx.n } -func (self testHostController) Shutdown() { +func (self *testHostController) Shutdown() { close(self.closeNotify) } -func (self testHostController) GetCloseNotifyChannel() <-chan struct{} { +func (self *testHostController) GetCloseNotifyChannel() <-chan struct{} { return self.closeNotify } -func (self testHostController) Stop() { +func (self *testHostController) Stop() { close(self.closeNotify) } -func (ctx testHostController) IsRaftEnabled() bool { +func (ctx *testHostController) IsRaftEnabled() bool { return false } type TestContext struct { - *persistence.TestContext + *db.TestContext + n *network.Network managers *Managers config *config.Config metricsRegistry metrics.Registry hostController *testHostController } -func (ctx *TestContext) JwtSignerKeyFunc(token *jwt.Token) (interface{}, error) { +func (ctx *TestContext) GetDbProvider() network.DbProvider { + return ctx.n +} + +func (ctx *TestContext) JwtSignerKeyFunc(*jwt.Token) (interface{}, error) { tlsCert, _, _ := ctx.GetServerCert() return tlsCert.Leaf.PublicKey, nil } @@ -88,7 +97,7 @@ func (ctx *TestContext) GetServerCert() (*tls.Certificate, string, jwt.SigningMe return nil, "", nil } -func (ctx *TestContext) HandleServiceUpdatedEventForIdentityId(identityId string) {} +func (ctx *TestContext) HandleServiceUpdatedEventForIdentityId(string) {} func (ctx *TestContext) Generate(string, string, jwt.Claims) (string, error) { return "I'm a very legitimate claim", nil @@ -147,19 +156,26 @@ func (ctx *TestContext) GetFingerprintGenerator() cert.FingerprintGenerator { } func NewTestContext(t *testing.T) *TestContext { - fabricTestContext := persistence.NewTestContext(t) + fabricTestContext := db.NewTestContext(t) context := &TestContext{ TestContext: fabricTestContext, metricsRegistry: metrics.NewRegistry("test", nil), - hostController: &testHostController{ - ctx: fabricTestContext, - closeNotify: make(chan struct{}), - }, } + + context.hostController = &testHostController{ + ctx: context, + closeNotify: make(chan struct{}), + } + return context } func (ctx *TestContext) Init() { ctx.TestContext.Init() + cfg := newTestConfig(ctx.TestContext) + n, err := network.NewNetwork(cfg) + ctx.NoError(err) + ctx.n = n + ctx.config = &config.Config{ Enrollment: config.Enrollment{ EdgeRouter: config.EnrollmentOption{ @@ -181,7 +197,7 @@ func (ctx *TestContext) requireNewIdentity(isAdmin bool) *Identity { newIdentity := &Identity{ Name: eid.New(), IsAdmin: isAdmin, - IdentityTypeId: persistence.DefaultIdentityType, + IdentityTypeId: db.DefaultIdentityType, } ctx.NoError(ctx.managers.Identity.Create(newIdentity, change.New())) return newIdentity @@ -231,7 +247,7 @@ func (ctx *TestContext) requireNewSession(apiSession *ApiSession, serviceId stri func (ctx *TestContext) requireNewServicePolicy(policyType string, identityRoles, serviceRoles []string) *ServicePolicy { policy := &ServicePolicy{ Name: eid.New(), - Semantic: persistence.SemanticAllOf, + Semantic: db.SemanticAllOf, IdentityRoles: identityRoles, ServiceRoles: serviceRoles, PolicyType: policyType, @@ -243,7 +259,7 @@ func (ctx *TestContext) requireNewServicePolicy(policyType string, identityRoles func (ctx *TestContext) requireNewEdgeRouterPolicy(identityRoles, edgeRouterRoles []string) *EdgeRouterPolicy { policy := &EdgeRouterPolicy{ Name: eid.New(), - Semantic: persistence.SemanticAllOf, + Semantic: db.SemanticAllOf, IdentityRoles: identityRoles, EdgeRouterRoles: edgeRouterRoles, } @@ -254,7 +270,7 @@ func (ctx *TestContext) requireNewEdgeRouterPolicy(identityRoles, edgeRouterRole func (ctx *TestContext) requireNewServiceNewEdgeRouterPolicy(serviceRoles, edgeRouterRoles []string) *ServiceEdgeRouterPolicy { policy := &ServiceEdgeRouterPolicy{ Name: eid.New(), - Semantic: persistence.SemanticAllOf, + Semantic: db.SemanticAllOf, ServiceRoles: serviceRoles, EdgeRouterRoles: edgeRouterRoles, } @@ -265,3 +281,84 @@ func (ctx *TestContext) requireNewServiceNewEdgeRouterPolicy(serviceRoles, edgeR func ss(vals ...string) []string { return vals } + +func newTestConfig(ctx *db.TestContext) *testConfig { + options := network.DefaultOptions() + options.MinRouterCost = 0 + + return &testConfig{ + closeNotify: make(chan struct{}), + ctx: ctx, + options: options, + metricsRegistry: metrics.NewRegistry("test", nil), + versionProvider: versions.NewDefaultVersionProvider(), + } +} + +type testConfig struct { + closeNotify chan struct{} + ctx *db.TestContext + options *network.Options + metricsRegistry metrics.Registry + versionProvider versions.VersionProvider +} + +func (self *testConfig) GetEventDispatcher() event.Dispatcher { + return event.DispatcherMock{} +} + +func (self *testConfig) GetId() *identity.TokenId { + return &identity.TokenId{Token: "test"} +} + +func (self *testConfig) GetMetricsRegistry() metrics.Registry { + return self.metricsRegistry +} + +func (self *testConfig) GetOptions() *network.Options { + return self.options +} + +func (self *testConfig) GetCommandDispatcher() command.Dispatcher { + return &command.LocalDispatcher{ + Limiter: command.NoOpRateLimiter{}, + } +} + +func (self *testConfig) GetDb() boltz.Db { + return self.ctx.GetDb() +} + +func (self *testConfig) GetVersionProvider() versions.VersionProvider { + return self.versionProvider +} + +func (self *testConfig) GetCloseNotify() <-chan struct{} { + return self.closeNotify +} + +// +//type testDbProvider struct { +// ctx *TestContext +//} +// +//func (p *testDbProvider) GetDb() boltz.Db { +// return p.ctx.GetDb() +//} +// +//func (p *testDbProvider) GetStores() *Stores { +// return p.ctx.n.GetStores() +//} +// +//func (p *testDbProvider) GetServiceCache() network.Cache { +// return p +//} +// +//func (p *testDbProvider) NotifyRouterRenamed(_, _ string) {} +// +//func (p *testDbProvider) RemoveFromCache(_ string) { +//} +// +//func (p *testDbProvider) GetManagers() *network.Managers { +// return p.ctx.n.Managers +//} diff --git a/controller/model/transit_router_manager.go b/controller/model/transit_router_manager.go index 46463ec5d..0934d75f0 100644 --- a/controller/model/transit_router_manager.go +++ b/controller/model/transit_router_manager.go @@ -19,18 +19,17 @@ package model import ( "fmt" "github.com/michaelquigley/pfxlog" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/common/pb/cmd_pb" "github.com/openziti/ziti/common/pb/edge_cmd_pb" "github.com/openziti/ziti/controller/apierror" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/common/pb/cmd_pb" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" @@ -38,10 +37,10 @@ import ( func NewTransitRouterManager(env Env) *TransitRouterManager { manager := &TransitRouterManager{ - baseEntityManager: newBaseEntityManager[*TransitRouter, *persistence.TransitRouter](env, env.GetStores().TransitRouter), + baseEntityManager: newBaseEntityManager[*TransitRouter, *db.TransitRouter](env, env.GetStores().TransitRouter), allowedFields: boltz.MapFieldChecker{ - persistence.FieldName: struct{}{}, - boltz.FieldTags: struct{}{}, + db.FieldName: struct{}{}, + boltz.FieldTags: struct{}{}, }, } manager.impl = manager @@ -54,7 +53,7 @@ func NewTransitRouterManager(env Env) *TransitRouterManager { } type TransitRouterManager struct { - baseEntityManager[*TransitRouter, *persistence.TransitRouter] + baseEntityManager[*TransitRouter, *db.TransitRouter] allowedFields boltz.FieldChecker } @@ -72,7 +71,7 @@ func (self *TransitRouterManager) Create(txRouter *TransitRouter, ctx *change.Co } enrollment := &Enrollment{ - BaseEntity: models.BaseEntity{}, + BaseEntity: models.BaseEntity{Id: eid.New()}, Method: MethodEnrollTransitRouterOtt, TransitRouterId: &txRouter.Id, } @@ -172,7 +171,7 @@ func (self *TransitRouterManager) collectEnrollmentsInTx(tx *bbolt.Tx, id string return err } - associationIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, persistence.FieldTransitRouterEnrollments) + associationIds := self.GetStore().GetRelatedEntitiesIdList(tx, id, db.FieldTransitRouterEnrollments) for _, enrollmentId := range associationIds { enrollment, err := self.env.GetManagers().Enrollment.readInTx(tx, enrollmentId) if err != nil { @@ -215,8 +214,8 @@ func (self *TransitRouterManager) ExtendEnrollment(router *TransitRouter, client router.Fingerprint = &fingerprint err = self.Update(router, true, &fields.UpdatedFieldsMap{ - persistence.FieldEdgeRouterCertPEM: struct{}{}, - db.FieldRouterFingerprint: struct{}{}, + db.FieldEdgeRouterCertPEM: struct{}{}, + db.FieldRouterFingerprint: struct{}{}, }, ctx) if err != nil { @@ -257,8 +256,8 @@ func (self *TransitRouterManager) ExtendEnrollmentWithVerify(router *TransitRout router.UnverifiedFingerprint = &fingerprint err = self.Update(router, true, &fields.UpdatedFieldsMap{ - persistence.FieldEdgeRouterUnverifiedCertPEM: struct{}{}, - persistence.FieldEdgeRouterUnverifiedFingerprint: struct{}{}, + db.FieldEdgeRouterUnverifiedCertPEM: struct{}{}, + db.FieldEdgeRouterUnverifiedFingerprint: struct{}{}, }, ctx) if err != nil { @@ -272,7 +271,7 @@ func (self *TransitRouterManager) ExtendEnrollmentWithVerify(router *TransitRout } func (self *TransitRouterManager) ReadOneByUnverifiedFingerprint(fingerprint string) (*TransitRouter, error) { - return self.ReadOneByQuery(fmt.Sprintf(`%s = "%v"`, persistence.FieldEdgeRouterUnverifiedFingerprint, fingerprint)) + return self.ReadOneByQuery(fmt.Sprintf(`%s = "%v"`, db.FieldEdgeRouterUnverifiedFingerprint, fingerprint)) } func (self *TransitRouterManager) ExtendEnrollmentVerify(router *TransitRouter, ctx *change.Context) error { @@ -283,9 +282,9 @@ func (self *TransitRouterManager) ExtendEnrollmentVerify(router *TransitRouter, router.UnverifiedCertPem = nil return self.Update(router, true, fields.UpdatedFieldsMap{ - db.FieldRouterFingerprint: struct{}{}, - persistence.FieldEdgeRouterUnverifiedCertPEM: struct{}{}, - persistence.FieldEdgeRouterUnverifiedFingerprint: struct{}{}, + db.FieldRouterFingerprint: struct{}{}, + db.FieldEdgeRouterUnverifiedCertPEM: struct{}{}, + db.FieldEdgeRouterUnverifiedFingerprint: struct{}{}, }, ctx) } diff --git a/controller/model/transit_router_model.go b/controller/model/transit_router_model.go index 325f79344..128f5b73f 100644 --- a/controller/model/transit_router_model.go +++ b/controller/model/transit_router_model.go @@ -17,10 +17,9 @@ package model import ( - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/storage/boltz" "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/models" - "github.com/openziti/storage/boltz" "go.etcd.io/bbolt" ) @@ -41,8 +40,8 @@ func (self *TransitRouter) GetName() string { return self.Name } -func (entity *TransitRouter) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence.TransitRouter, error) { - boltEntity := &persistence.TransitRouter{ +func (entity *TransitRouter) toBoltEntityForCreate(*bbolt.Tx, Env) (*db.TransitRouter, error) { + boltEntity := &db.TransitRouter{ Router: db.Router{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, @@ -57,8 +56,8 @@ func (entity *TransitRouter) toBoltEntityForCreate(*bbolt.Tx, Env) (*persistence return boltEntity, nil } -func (entity *TransitRouter) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*persistence.TransitRouter, error) { - ret := &persistence.TransitRouter{ +func (entity *TransitRouter) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldChecker) (*db.TransitRouter, error) { + ret := &db.TransitRouter{ Router: db.Router{ BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags), Name: entity.Name, @@ -75,7 +74,7 @@ func (entity *TransitRouter) toBoltEntityForUpdate(*bbolt.Tx, Env, boltz.FieldCh return ret, nil } -func (entity *TransitRouter) fillFrom(_ Env, _ *bbolt.Tx, boltTransitRouter *persistence.TransitRouter) error { +func (entity *TransitRouter) fillFrom(_ Env, _ *bbolt.Tx, boltTransitRouter *db.TransitRouter) error { entity.FillCommon(boltTransitRouter) entity.Name = boltTransitRouter.Name entity.IsVerified = boltTransitRouter.IsVerified diff --git a/controller/network/circuit.go b/controller/network/circuit.go index 3b3c2f19c..36a006d5f 100644 --- a/controller/network/circuit.go +++ b/controller/network/circuit.go @@ -17,10 +17,11 @@ package network import ( + "github.com/openziti/identity" + "github.com/openziti/storage/objectz" + "github.com/openziti/ziti/common/logcontext" "github.com/openziti/ziti/controller/idgen" "github.com/openziti/ziti/controller/xt" - "github.com/openziti/ziti/common/logcontext" - "github.com/openziti/identity" "github.com/orcaman/concurrent-map/v2" "sync/atomic" "time" @@ -36,6 +37,35 @@ type Circuit struct { Rerouting atomic.Bool PeerData xt.PeerData CreatedAt time.Time + UpdatedAt time.Time +} + +func (self *Circuit) GetId() string { + return self.Id +} + +func (self *Circuit) SetId(string) { + // id cannot be updated +} + +func (self *Circuit) GetCreatedAt() time.Time { + return self.CreatedAt +} + +func (self *Circuit) GetUpdatedAt() time.Time { + return self.UpdatedAt +} + +func (self *Circuit) GetTags() map[string]interface{} { + result := map[string]interface{}{} + for k, v := range self.Tags { + result[k] = v + } + return result +} + +func (self *Circuit) IsSystemEntity() bool { + return false } func (self *Circuit) cost(minRouterCost uint16) int64 { @@ -57,13 +87,37 @@ func (self *Circuit) HasRouter(routerId string) bool { type circuitController struct { circuits cmap.ConcurrentMap[string, *Circuit] idGenerator idgen.Generator + store *objectz.ObjectStore[*Circuit] } func newCircuitController() *circuitController { - return &circuitController{ + result := &circuitController{ circuits: cmap.New[*Circuit](), idGenerator: idgen.NewGenerator(), } + result.store = objectz.NewObjectStore[*Circuit](func() objectz.ObjectIterator[*Circuit] { + return IterateCMap(result.circuits) + }) + result.store.AddStringSymbol("id", func(entity *Circuit) *string { + return &entity.Id + }) + result.store.AddStringSymbol("clientId", func(entity *Circuit) *string { + return &entity.ClientId + }) + result.store.AddStringSymbol("service", func(entity *Circuit) *string { + return &entity.Service.Id + }) + result.store.AddStringSymbol("terminator", func(entity *Circuit) *string { + val := entity.Terminator.GetId() + return &val + }) + result.store.AddDatetimeSymbol("createdAt", func(entity *Circuit) *time.Time { + return &entity.CreatedAt + }) + result.store.AddDatetimeSymbol("updatedAt", func(entity *Circuit) *time.Time { + return &entity.CreatedAt + }) + return result } func (self *circuitController) nextCircuitId() (string, error) { diff --git a/controller/network/cmap_iterator.go b/controller/network/cmap_iterator.go new file mode 100644 index 000000000..19bba4bc8 --- /dev/null +++ b/controller/network/cmap_iterator.go @@ -0,0 +1,54 @@ +/* + Copyright NetFoundry Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package network + +import ( + "github.com/openziti/storage/objectz" + cmap "github.com/orcaman/concurrent-map/v2" +) + +func IterateCMap[T any](m cmap.ConcurrentMap[string, T]) objectz.ObjectIterator[T] { + iterator := &tupleChannelIterator[T]{ + c: m.IterBuffered(), + valid: true, + } + iterator.Next() + return iterator +} + +type tupleChannelIterator[T any] struct { + c <-chan cmap.Tuple[string, T] + current T + valid bool +} + +func (self *tupleChannelIterator[T]) IsValid() bool { + return self.valid +} + +func (self *tupleChannelIterator[T]) Next() { + next, ok := <-self.c + if !ok { + self.valid = false + } else { + self.current = next.Val + } +} + +func (self *tupleChannelIterator[T]) Current() T { + return self.current +} diff --git a/controller/network/db_provider.go b/controller/network/db_provider.go new file mode 100644 index 000000000..267a52b71 --- /dev/null +++ b/controller/network/db_provider.go @@ -0,0 +1,12 @@ +package network + +import ( + "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/controller/db" +) + +type DbProvider interface { + GetDb() boltz.Db + GetStores() *db.Stores + GetManagers() *Managers +} diff --git a/controller/network/link_controller.go b/controller/network/link_controller.go index 4561bb50b..c6dccc813 100644 --- a/controller/network/link_controller.go +++ b/controller/network/link_controller.go @@ -17,9 +17,10 @@ package network import ( + "github.com/openziti/foundation/v2/info" + "github.com/openziti/storage/objectz" "github.com/openziti/ziti/common/pb/ctrl_pb" "github.com/openziti/ziti/controller/idgen" - "github.com/openziti/foundation/v2/info" "github.com/orcaman/concurrent-map/v2" "math" "sync" @@ -31,6 +32,7 @@ type linkController struct { idGenerator idgen.Generator lock sync.Mutex initialLatency time.Duration + store *objectz.ObjectStore[*Link] } func newLinkController(options *Options) *linkController { @@ -38,11 +40,57 @@ func newLinkController(options *Options) *linkController { if options != nil { initialLatency = options.InitialLinkLatency } - return &linkController{ + + result := &linkController{ linkTable: newLinkTable(), idGenerator: idgen.NewGenerator(), initialLatency: initialLatency, } + + result.store = objectz.NewObjectStore[*Link](func() objectz.ObjectIterator[*Link] { + return IterateCMap[*Link](result.linkTable.links) + }) + + result.store.AddStringSymbol("id", func(entity *Link) *string { + return &entity.Id + }) + result.store.AddStringSymbol("protocol", func(entity *Link) *string { + return &entity.Protocol + }) + result.store.AddStringSymbol("dialAddress", func(entity *Link) *string { + return &entity.DialAddress + }) + result.store.AddStringSymbol("sourceRouter", func(entity *Link) *string { + return &entity.Src.Id + }) + result.store.AddStringSymbol("destRouter", func(entity *Link) *string { + return &entity.Dst.Id + }) + result.store.AddInt64Symbol("cost", func(entity *Link) *int64 { + val := entity.GetCost() + return &val + }) + result.store.AddInt64Symbol("staticCost", func(entity *Link) *int64 { + val := int64(entity.GetStaticCost()) + return &val + }) + result.store.AddInt64Symbol("destLatency", func(entity *Link) *int64 { + val := entity.GetDstLatency() + return &val + }) + result.store.AddInt64Symbol("sourceLatency", func(entity *Link) *int64 { + val := entity.GetSrcLatency() + return &val + }) + result.store.AddStringSymbol("state", func(entity *Link) *string { + if state := entity.CurrentState(); state != nil { + val := state.Mode.String() + return &val + } + return nil + }) + + return result } func (linkController *linkController) add(link *Link) { diff --git a/controller/network/managers.go b/controller/network/managers.go index c61c78a20..cc14dc1b5 100644 --- a/controller/network/managers.go +++ b/controller/network/managers.go @@ -18,6 +18,11 @@ package network import ( "github.com/michaelquigley/pfxlog" + "github.com/openziti/foundation/v2/goroutines" + "github.com/openziti/foundation/v2/versions" + "github.com/openziti/storage/ast" + "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/pb/cmd_pb" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" "github.com/openziti/ziti/controller/db" @@ -25,11 +30,6 @@ import ( "github.com/openziti/ziti/controller/idgen" "github.com/openziti/ziti/controller/ioc" "github.com/openziti/ziti/controller/models" - "github.com/openziti/ziti/common/pb/cmd_pb" - "github.com/openziti/foundation/v2/goroutines" - "github.com/openziti/foundation/v2/versions" - "github.com/openziti/storage/ast" - "github.com/openziti/storage/boltz" "go.etcd.io/bbolt" ) diff --git a/controller/network/network.go b/controller/network/network.go index 4029f07b3..9c0689250 100644 --- a/controller/network/network.go +++ b/controller/network/network.go @@ -22,6 +22,7 @@ import ( "encoding/json" "fmt" "github.com/openziti/foundation/v2/goroutines" + "github.com/openziti/storage/objectz" fabricMetrics "github.com/openziti/ziti/common/metrics" "github.com/openziti/ziti/controller/event" "os" @@ -271,6 +272,14 @@ func (network *Network) GetAllCircuits() []*Circuit { return network.circuitController.all() } +func (network *Network) GetCircuitStore() *objectz.ObjectStore[*Circuit] { + return network.circuitController.store +} + +func (network *Network) GetLinkStore() *objectz.ObjectStore[*Link] { + return network.linkController.store +} + func (network *Network) RouteResult(rs *RouteStatus) bool { return network.routeSenderController.forwardRouteResult(rs) } @@ -599,6 +608,7 @@ func (network *Network) CreateCircuit(params CreateCircuitParams) (*Circuit, err delete(peerData, uint32(ctrl_msg.TerminatorLocalAddressHeader)) delete(peerData, uint32(ctrl_msg.TerminatorRemoteAddressHeader)) + now := time.Now() // 6: Create Circuit Object circuit := &Circuit{ Id: circuitId, @@ -607,7 +617,8 @@ func (network *Network) CreateCircuit(params CreateCircuitParams) (*Circuit, err Path: path, Terminator: terminator, PeerData: peerData, - CreatedAt: time.Now(), + CreatedAt: now, + UpdatedAt: now, Tags: tags, } network.circuitController.add(circuit) @@ -1031,6 +1042,7 @@ func (network *Network) rerouteCircuit(circuit *Circuit, deadline time.Time) err if cq, err := network.UpdatePath(circuit.Path); err == nil { circuit.Path = cq + circuit.UpdatedAt = time.Now() rms := cq.CreateRouteMessages(SmartRerouteAttempt, circuit.Id, circuit.Terminator, deadline) @@ -1060,6 +1072,7 @@ func (network *Network) smartReroute(circuit *Circuit, cq *Path, deadline time.T defer circuit.Rerouting.Store(false) circuit.Path = cq + circuit.UpdatedAt = time.Now() rms := cq.CreateRouteMessages(SmartRerouteAttempt, circuit.Id, circuit.Terminator, deadline) diff --git a/controller/network/terminator.go b/controller/network/terminator.go index e42bd7087..257227b17 100644 --- a/controller/network/terminator.go +++ b/controller/network/terminator.go @@ -14,21 +14,28 @@ package network import ( + "context" + "fmt" "github.com/michaelquigley/pfxlog" + "github.com/openziti/channel/v2" + "github.com/openziti/channel/v2/protobufs" + "github.com/openziti/foundation/v2/errorz" + "github.com/openziti/storage/boltz" + "github.com/openziti/ziti/common/pb/cmd_pb" + "github.com/openziti/ziti/common/pb/ctrl_pb" + "github.com/openziti/ziti/common/pb/mgmt_pb" "github.com/openziti/ziti/controller/change" "github.com/openziti/ziti/controller/command" "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/fields" "github.com/openziti/ziti/controller/models" "github.com/openziti/ziti/controller/xt" - "github.com/openziti/ziti/common/pb/cmd_pb" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/storage/boltz" "github.com/pkg/errors" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" "reflect" "strings" + "time" ) type Terminator struct { @@ -368,6 +375,117 @@ func (self *TerminatorManager) Unmarshall(bytes []byte) (*Terminator, error) { return result, nil } +type ValidationCallback func(detail *mgmt_pb.TerminatorDetail) + +func (self *TerminatorManager) ValidateTerminators(filter string, fixInvalid bool, cb ValidationCallback) (uint64, error) { + if filter == "" { + filter = "true limit none" + } + result, err := self.BaseList(filter) + if err != nil { + return 0, err + } + + go func() { + batches := map[string][]*Terminator{} + + for _, terminator := range result.Entities { + routerId := terminator.Router + batch := append(batches[routerId], terminator) + batches[routerId] = batch + if len(batch) == 50 { + self.validateTerminatorBatch(fixInvalid, routerId, batch, cb) + delete(batches, routerId) + } + } + + for routerId, batch := range batches { + self.validateTerminatorBatch(fixInvalid, routerId, batch, cb) + } + }() + + return uint64(len(result.Entities)), nil +} + +func (self *TerminatorManager) validateTerminatorBatch(fixInvalid bool, routerId string, batch []*Terminator, cb ValidationCallback) { + router := self.Managers.Routers.getConnected(routerId) + if router == nil { + self.reportError(router, batch, cb, "router off-line") + return + } + + request := &ctrl_pb.ValidateTerminatorsV2Request{ + FixInvalid: fixInvalid, + } + for _, terminator := range batch { + request.Terminators = append(request.Terminators, &ctrl_pb.Terminator{ + Id: terminator.Id, + Binding: terminator.Binding, + Address: terminator.Address, + }) + } + + b, err := proto.Marshal(request) + if err != nil { + self.reportError(router, batch, cb, fmt.Sprintf("failed to marshal %s: %s", reflect.TypeOf(request), err.Error())) + return + } + + msg := channel.NewMessage(int32(ctrl_pb.ContentType_ValidateTerminatorsV2RequestType), b) + envelope := &ValidateTerminatorRequestSendable{ + Message: msg, + fixInvalid: fixInvalid, + cb: cb, + mgr: self, + router: router, + terminators: batch, + } + envelope.ctx, envelope.cancelF = context.WithTimeout(context.Background(), time.Minute) + + if err = router.Control.Send(envelope); err != nil { + self.reportError(router, batch, cb, fmt.Sprintf("failed to send %s: %s", reflect.TypeOf(request), err.Error())) + return + } +} + +func (self *TerminatorManager) reportError(router *Router, batch []*Terminator, cb ValidationCallback, err string) { + for _, terminator := range batch { + detail := self.newTerminatorDetail(router, terminator) + detail.State = mgmt_pb.TerminatorState_Unknown + detail.Detail = err + cb(detail) + } +} + +func (self *TerminatorManager) newTerminatorDetail(router *Router, terminator *Terminator) *mgmt_pb.TerminatorDetail { + detail := &mgmt_pb.TerminatorDetail{ + TerminatorId: terminator.Id, + ServiceId: terminator.Service, + ServiceName: "unable to retrieve", + RouterId: terminator.Router, + RouterName: "unable to retrieve", + Binding: terminator.Binding, + Address: terminator.Address, + HostId: terminator.HostId, + CreateDate: terminator.CreatedAt.Format(time.RFC3339), + } + + service, _ := self.Services.Read(terminator.Service) + if service != nil { + detail.ServiceName = service.Name + } + + if router == nil { + router, _ = self.Routers.Read(terminator.Router) + } + + if router != nil { + detail.RouterName = router.Name + } + + return detail +} + type TerminatorListResult struct { controller *TerminatorManager Entities []*Terminator @@ -420,3 +538,83 @@ func (self *DeleteTerminatorsBatchCommand) Decode(n *Network, msg *cmd_pb.Delete func (self *DeleteTerminatorsBatchCommand) GetChangeContext() *change.Context { return self.Context } + +type ValidateTerminatorRequestSendable struct { + channel.BaseSendListener + *channel.Message + fixInvalid bool + mgr *TerminatorManager + router *Router + terminators []*Terminator + cb ValidationCallback + ctx context.Context + cancelF func() +} + +func (self *ValidateTerminatorRequestSendable) AcceptReply(message *channel.Message) { + self.cancelF() + + response := &ctrl_pb.ValidateTerminatorsV2Response{} + if err := protobufs.TypedResponse(response).Unmarshall(message, nil); err != nil { + pfxlog.Logger().WithError(err).Error("unable to unmarshall validate terminators v2 response") + return + } + + var invalidIds []string + + for _, terminator := range self.terminators { + if status := response.States[terminator.Id]; status != nil && !status.Valid { + invalidIds = append(invalidIds, terminator.Id) + } + } + + fixed := false + + if self.fixInvalid && len(invalidIds) > 0 { + // todo: figure out how to inject change context from outside of websocket context + changeCtx := change.New().SetSourceType(change.SourceTypeWebSocket).SetChangeAuthorId(change.AuthorTypeUnattributed) + err := self.mgr.DeleteBatch(invalidIds, changeCtx) + if err != nil { + pfxlog.Logger().WithError(err).Error("unable to batch delete invalid terminators") + } else { + fixed = true + } + } + + for _, terminator := range self.terminators { + detail := self.mgr.newTerminatorDetail(self.router, terminator) + if status := response.States[terminator.Id]; status != nil { + if status.Valid { + detail.State = mgmt_pb.TerminatorState_Valid + } else if status.Reason == ctrl_pb.TerminatorInvalidReason_UnknownBinding { + detail.State = mgmt_pb.TerminatorState_InvalidUnknownBinding + } else if status.Reason == ctrl_pb.TerminatorInvalidReason_UnknownTerminator { + detail.State = mgmt_pb.TerminatorState_InvalidUnknownTerminator + } else if status.Reason == ctrl_pb.TerminatorInvalidReason_BadState { + detail.State = mgmt_pb.TerminatorState_InvalidBadState + } else { + detail.State = mgmt_pb.TerminatorState_Unknown + } + + if !status.Valid { + detail.Fixed = fixed + } + detail.Detail = status.Detail + } else { + detail.State = mgmt_pb.TerminatorState_Unknown + } + self.cb(detail) + } +} + +func (self *ValidateTerminatorRequestSendable) Context() context.Context { + return self.ctx +} + +func (self *ValidateTerminatorRequestSendable) SendListener() channel.SendListener { + return self +} + +func (self *ValidateTerminatorRequestSendable) ReplyReceiver() channel.ReplyReceiver { + return self +} diff --git a/controller/oidc_auth/provider.go b/controller/oidc_auth/provider.go index 71eefdd86..47dafbb3a 100644 --- a/controller/oidc_auth/provider.go +++ b/controller/oidc_auth/provider.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/gorilla/mux" "github.com/michaelquigley/pfxlog" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" "github.com/pkg/errors" "github.com/zitadel/oidc/v2/pkg/op" "golang.org/x/text/language" @@ -21,7 +21,7 @@ const ( AuthMethodPassword = model.AuthMethodPassword AuthMethodExtJwt = model.AuthMethodExtJwt - AuthMethodCert = persistence.MethodAuthenticatorCert + AuthMethodCert = db.MethodAuthenticatorCert AuthMethodSecondaryTotp = "totp" AuthMethodSecondaryExtJwt = "ejs" diff --git a/controller/persistence/base_store.go b/controller/persistence/base_store.go deleted file mode 100644 index 23f9bc1e8..000000000 --- a/controller/persistence/base_store.go +++ /dev/null @@ -1,153 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package persistence - -import ( - "github.com/openziti/ziti/controller/db" - "github.com/openziti/ziti/controller/network" - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/storage/ast" - "github.com/openziti/storage/boltz" - "go.etcd.io/bbolt" - "strings" -) - -type DbProvider interface { - GetDb() boltz.Db - GetStores() *db.Stores - GetManagers() *network.Managers -} - -type initializableStore interface { - boltz.Store - initializeLocal() - initializeLinked() - initializeIndexes(tx *bbolt.Tx, errorHolder errorz.ErrorHolder) -} - -type Store[E boltz.ExtEntity] interface { - boltz.EntityStore[E] - initializableStore - LoadOneById(tx *bbolt.Tx, id string) (E, error) -} - -type baseStore[E boltz.ExtEntity] struct { - stores *stores - *boltz.BaseStore[E] -} - -func (store *baseStore[E]) addUniqueNameField() boltz.ReadIndex { - symbolName := store.AddSymbol(FieldName, ast.NodeTypeString) - return store.AddUniqueIndex(symbolName) -} - -func (store *baseStore[E]) initializeIndexes(tx *bbolt.Tx, errorHolder errorz.ErrorHolder) { - store.InitializeIndexes(tx, errorHolder) -} - -func (store *baseStore[E]) LoadOneById(tx *bbolt.Tx, id string) (E, error) { - entity := store.NewStoreEntity() - if err := store.baseLoadOneById(tx, id, entity); err != nil { - return *new(E), err - } - return entity, nil -} - -func (store *baseStore[E]) baseLoadOneById(tx *bbolt.Tx, id string, entity E) error { - found, err := store.LoadEntity(tx, id, entity) - if err != nil { - return err - } - if !found { - return boltz.NewNotFoundError(store.GetSingularEntityType(), "id", id) - } - return nil -} - -func (store *baseStore[E]) deleteEntityReferences(tx *bbolt.Tx, entity boltz.NamedExtEntity, rolesSymbol boltz.EntitySetSymbol) error { - idRef := entityRef(entity.GetId()) - - for _, policyHolderId := range store.GetRelatedEntitiesIdList(tx, entity.GetId(), rolesSymbol.GetStore().GetEntityType()) { - err := rolesSymbol.Map(tx, []byte(policyHolderId), func(ctx *boltz.MapContext) { - if ctx.ValueS() == idRef { - ctx.Delete() - } - }) - if err != nil { - return err - } - } - return nil -} - -func (store *baseStore[E]) getParentBucket(entity boltz.Entity, childBucket *boltz.TypedBucket) *boltz.TypedBucket { - parentBucket := store.GetParentStore().GetEntityBucket(childBucket.Tx(), []byte(entity.GetId())) - parentBucket.ErrorHolderImpl = childBucket.ErrorHolderImpl - return parentBucket -} - -type NameIndexed interface { - GetNameIndex() boltz.ReadIndex -} - -func (store *baseStore[E]) GetName(tx *bbolt.Tx, id string) *string { - symbol := store.GetSymbol(FieldName) - if symbol == nil { - return nil - } - _, val := symbol.Eval(tx, []byte(id)) - if val != nil { - result := string(val) - return &result - } - return nil -} - -func (store *baseStore[E]) getRoleAttributesCursorProvider(index boltz.SetReadIndex, values []string, semantic string) (ast.SetCursorProvider, error) { - if semantic == "" { - semantic = SemanticAllOf - } - - if !isSemanticValid(semantic) { - return nil, errorz.NewFieldError("invalid semantic", FieldSemantic, semantic) - } - - roles, ids, err := splitRolesAndIds(values) - if err != nil { - return nil, err - } - - return func(tx *bbolt.Tx, forward bool) ast.SetCursor { - validIds := ast.NewTreeSet(forward) - for _, id := range ids { - if store.IsEntityPresent(tx, id) { - validIds.Add([]byte(id)) - } - } - - var rolesCursor ast.SetCursor - if strings.EqualFold(semantic, SemanticAllOf) { - rolesCursor = store.IteratorMatchingAllOf(index, roles)(tx, forward) - } else { - rolesCursor = store.IteratorMatchingAnyOf(index, roles)(tx, forward) - } - if validIds.Size() == 0 { - return rolesCursor - } - return ast.NewUnionSetCursor(rolesCursor, validIds.ToCursor(), forward) - }, nil -} diff --git a/controller/persistence/stores.go b/controller/persistence/stores.go deleted file mode 100644 index ed2779df4..000000000 --- a/controller/persistence/stores.go +++ /dev/null @@ -1,309 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package persistence - -import ( - "github.com/openziti/foundation/v2/errorz" - "github.com/openziti/storage/ast" - "github.com/openziti/storage/boltz" - "github.com/openziti/ziti/controller/change" - "github.com/openziti/ziti/controller/db" - "github.com/pkg/errors" - "go.etcd.io/bbolt" - "reflect" - "time" -) - -type Stores struct { - DbProvider DbProvider - EventualEventer EventualEventer - internal *stores - - // fabric stores - Router db.RouterStore - Service db.ServiceStore - Terminator db.TerminatorStore - - ApiSession ApiSessionStore - ApiSessionCertificate ApiSessionCertificateStore - AuthPolicy AuthPolicyStore - EventualEvent EventualEventStore - ExternalJwtSigner ExternalJwtSignerStore - Ca CaStore - Config ConfigStore - ConfigType ConfigTypeStore - EdgeRouter EdgeRouterStore - EdgeRouterPolicy EdgeRouterPolicyStore - EdgeService EdgeServiceStore - Identity IdentityStore - IdentityType IdentityTypeStore - Index boltz.Store - Session SessionStore - Revocation RevocationStore - ServiceEdgeRouterPolicy ServiceEdgeRouterPolicyStore - ServicePolicy ServicePolicyStore - TransitRouter TransitRouterStore - Enrollment EnrollmentStore - Authenticator AuthenticatorStore - PostureCheck PostureCheckStore - PostureCheckType PostureCheckTypeStore - Mfa MfaStore - storeMap map[reflect.Type]boltz.Store -} - -func (stores *Stores) addStoresToIntegrityCheck(fabricStores *db.Stores) { - val := reflect.ValueOf(stores).Elem() - for i := 0; i < val.NumField(); i++ { - f := val.Field(i) - if f.CanInterface() { - // filter by the edge Store interface, so we don't recheck fabric stores, which are already being checked - if store, ok := f.Interface().(boltz.Store); ok { - fabricStores.AddCheckable(store) - } - } - } -} - -func (stores *Stores) buildStoreMap() { - val := reflect.ValueOf(stores).Elem() - for i := 0; i < val.NumField(); i++ { - f := val.Field(i) - if f.CanInterface() { - if store, ok := f.Interface().(boltz.Store); ok && store.GetEntityType() != "indexes" { - entityType := store.GetEntityReflectType() - stores.storeMap[entityType] = store - } - } - } -} - -func (stores *Stores) GetEntityCounts(db boltz.Db) (map[string]int64, error) { - result := map[string]int64{} - for _, store := range stores.storeMap { - err := db.View(func(tx *bbolt.Tx) error { - key := store.GetEntityType() - if store.IsChildStore() { - if _, ok := store.(TransitRouterStore); ok { - // skip transit routers, since count will be == fabric routers - return nil - } else { - key = store.GetEntityType() + ".edge" - } - } - - _, count, err := store.QueryIds(tx, "true limit 1") - if err != nil { - return err - } - result[key] = count - return nil - }) - - if err != nil { - return nil, err - } - } - return result, nil -} - -func (stores *Stores) getStoresForInit() []initializableStore { - var result []initializableStore - for _, crudStore := range stores.storeMap { - if store, ok := crudStore.(initializableStore); ok { - result = append(result, store) - } - } - return result -} - -func (stores *Stores) GetStoreForEntity(entity boltz.Entity) boltz.Store { - return stores.storeMap[reflect.TypeOf(entity)] -} - -func (stores *Stores) GetStores() []boltz.Store { - var result []boltz.Store - for _, store := range stores.storeMap { - result = append(result, store) - } - return result -} - -type stores struct { - DbProvider DbProvider - EventualEventer EventualEventer - - // fabric stores - Router db.RouterStore - Service db.ServiceStore - Terminator db.TerminatorStore - - apiSession *apiSessionStoreImpl - authPolicy *AuthPolicyStoreImpl - eventualEvent *eventualEventStoreImpl - ca *caStoreImpl - config *configStoreImpl - configType *configTypeStoreImpl - edgeRouter *edgeRouterStoreImpl - edgeRouterPolicy *edgeRouterPolicyStoreImpl - edgeService *edgeServiceStoreImpl - externalJwtSigner *externalJwtSignerStoreImpl - identity *identityStoreImpl - identityType *IdentityTypeStoreImpl - revocation *revocationStoreImpl - serviceEdgeRouterPolicy *serviceEdgeRouterPolicyStoreImpl - servicePolicy *servicePolicyStoreImpl - session *sessionStoreImpl - transitRouter *transitRouterStoreImpl - enrollment *enrollmentStoreImpl - authenticator *authenticatorStoreImpl - postureCheck *postureCheckStoreImpl - postureCheckType *postureCheckTypeStoreImpl - apiSessionCertificate *ApiSessionCertificateStoreImpl - mfa *MfaStoreImpl -} - -func NewBoltStores(dbProvider DbProvider) (*Stores, error) { - errorHolder := &errorz.ErrorHolderImpl{} - - internalStores := &stores{ - DbProvider: dbProvider, - } - - internalStores.eventualEvent = newEventualEventStore(internalStores) - internalStores.EventualEventer = NewEventualEventerBbolt(dbProvider, internalStores.eventualEvent, 2*time.Second, 1000) - - internalStores.Terminator = dbProvider.GetStores().Terminator - internalStores.Router = dbProvider.GetStores().Router - internalStores.Service = dbProvider.GetStores().Service - internalStores.apiSession = newApiSessionStore(internalStores) - internalStores.apiSessionCertificate = newApiSessionCertificateStore(internalStores) - internalStores.authenticator = newAuthenticatorStore(internalStores) - internalStores.authPolicy = newAuthPolicyStore(internalStores) - internalStores.ca = newCaStore(internalStores) - internalStores.config = newConfigsStore(internalStores) - internalStores.configType = newConfigTypesStore(internalStores) - internalStores.edgeRouter = newEdgeRouterStore(internalStores) - internalStores.edgeRouterPolicy = newEdgeRouterPolicyStore(internalStores) - internalStores.edgeService = newEdgeServiceStore(internalStores) - internalStores.externalJwtSigner = newExternalJwtSignerStore(internalStores) - internalStores.transitRouter = newTransitRouterStore(internalStores) - internalStores.identity = newIdentityStore(internalStores) - internalStores.identityType = newIdentityTypeStore(internalStores) - internalStores.enrollment = newEnrollmentStore(internalStores) - internalStores.revocation = newRevocationStore(internalStores) - internalStores.serviceEdgeRouterPolicy = newServiceEdgeRouterPolicyStore(internalStores) - internalStores.servicePolicy = newServicePolicyStore(internalStores) - internalStores.session = newSessionStore(internalStores) - internalStores.postureCheck = newPostureCheckStore(internalStores) - internalStores.postureCheckType = newPostureCheckTypeStore(internalStores) - internalStores.mfa = newMfaStore(internalStores) - - externalStores := &Stores{ - DbProvider: dbProvider, - internal: internalStores, - - Terminator: dbProvider.GetStores().Terminator, - Router: dbProvider.GetStores().Router, - Service: dbProvider.GetStores().Service, - - ApiSession: internalStores.apiSession, - ApiSessionCertificate: internalStores.apiSessionCertificate, - AuthPolicy: internalStores.authPolicy, - EventualEvent: internalStores.eventualEvent, - Ca: internalStores.ca, - Config: internalStores.config, - ConfigType: internalStores.configType, - EdgeRouter: internalStores.edgeRouter, - EdgeRouterPolicy: internalStores.edgeRouterPolicy, - EdgeService: internalStores.edgeService, - ExternalJwtSigner: internalStores.externalJwtSigner, - TransitRouter: internalStores.transitRouter, - Identity: internalStores.identity, - IdentityType: internalStores.identityType, - Revocation: internalStores.revocation, - ServiceEdgeRouterPolicy: internalStores.serviceEdgeRouterPolicy, - ServicePolicy: internalStores.servicePolicy, - Session: internalStores.session, - Authenticator: internalStores.authenticator, - Enrollment: internalStores.enrollment, - PostureCheck: internalStores.postureCheck, - PostureCheckType: internalStores.postureCheckType, - Mfa: internalStores.mfa, - - storeMap: make(map[reflect.Type]boltz.Store), - } - - externalStores.EventualEventer = internalStores.EventualEventer - - // The Index store is used for querying indexes. It's a convenient store with only a single value (id), which - // is only ever queried using an index set cursor - indexStoreDef := boltz.StoreDefinition[boltz.ExtEntity]{ - EntityType: "indexes", - BasePath: []string{db.RootBucket}, - EntityNotFoundF: func(id string) error { - panic(errors.New("programming error")) - }, - } - - indexStore := boltz.NewBaseStore(indexStoreDef) - indexStore.AddIdSymbol("id", ast.NodeTypeString) - - externalStores.Index = indexStore - - externalStores.buildStoreMap() - storeList := externalStores.getStoresForInit() - - mutateCtx := change.New().SetSourceType("system.initialization").SetChangeAuthorType(change.AuthorTypeController).NewMutateContext() - err := dbProvider.GetDb().Update(mutateCtx, func(ctx boltz.MutateContext) error { - for _, store := range storeList { - store.initializeLocal() - } - for _, store := range storeList { - store.initializeLinked() - } - for _, store := range storeList { - store.initializeIndexes(ctx.Tx(), errorHolder) - } - return nil - }) - - externalStores.addStoresToIntegrityCheck(dbProvider.GetStores()) - - errorHolder.SetError(err) - if errorHolder.HasError() { - return nil, errorHolder.GetError() - } - return externalStores, nil -} - -func newBaseStore[E boltz.ExtEntity](stores *stores, strategy boltz.EntityStrategy[E]) *baseStore[E] { - return &baseStore[E]{ - stores: stores, - BaseStore: boltz.NewBaseStore(db.NewStoreDefinition[E](strategy)), - } -} - -func newChildBaseStore[E boltz.ExtEntity](stores *stores, parentMapper func(entity boltz.Entity) boltz.Entity, strategy boltz.EntityStrategy[E], parent boltz.Store, path string) *baseStore[E] { - def := db.NewStoreDefinition[E](strategy) - def.BasePath = []string{path} - def.Parent = parent - def.ParentMapper = parentMapper - return &baseStore[E]{ - stores: stores, - BaseStore: boltz.NewBaseStore[E](def), - } -} diff --git a/controller/persistence/testing.go b/controller/persistence/testing.go deleted file mode 100644 index 3bd772bb1..000000000 --- a/controller/persistence/testing.go +++ /dev/null @@ -1,276 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package persistence - -import ( - "github.com/michaelquigley/pfxlog" - "github.com/openziti/foundation/v2/versions" - "github.com/openziti/identity" - "github.com/openziti/metrics" - "github.com/openziti/storage/boltz" - "github.com/openziti/storage/boltztest" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/change" - "github.com/openziti/ziti/controller/command" - "github.com/openziti/ziti/controller/db" - "github.com/openziti/ziti/controller/event" - "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/controller/xt" - "github.com/openziti/ziti/controller/xt_smartrouting" - "github.com/pkg/errors" - "go.etcd.io/bbolt" - "testing" -) - -func newTestConfig(ctx *TestContext) *testConfig { - options := network.DefaultOptions() - options.MinRouterCost = 0 - - return &testConfig{ - ctx: ctx, - options: options, - metricsRegistry: metrics.NewRegistry("test", nil), - versionProvider: versions.NewDefaultVersionProvider(), - } -} - -type testConfig struct { - ctx *TestContext - options *network.Options - metricsRegistry metrics.Registry - versionProvider versions.VersionProvider -} - -func (self *testConfig) GetEventDispatcher() event.Dispatcher { - return event.DispatcherMock{} -} - -func (self *testConfig) GetId() *identity.TokenId { - return &identity.TokenId{Token: "test"} -} - -func (self *testConfig) GetMetricsRegistry() metrics.Registry { - return self.metricsRegistry -} - -func (self *testConfig) GetOptions() *network.Options { - return self.options -} - -func (self *testConfig) GetCommandDispatcher() command.Dispatcher { - return &command.LocalDispatcher{ - Limiter: command.NoOpRateLimiter{}, - } -} - -func (self *testConfig) GetDb() boltz.Db { - return self.ctx.GetDb() -} - -func (self *testConfig) GetVersionProvider() versions.VersionProvider { - return self.versionProvider -} - -func (self *testConfig) GetCloseNotify() <-chan struct{} { - return self.ctx.closeNotify -} - -type testDbProvider struct { - ctx *TestContext -} - -func (p *testDbProvider) GetDb() boltz.Db { - return p.ctx.GetDb() -} - -func (p *testDbProvider) GetStores() *db.Stores { - return p.ctx.n.GetStores() -} - -func (p *testDbProvider) GetServiceCache() network.Cache { - return p -} - -func (p *testDbProvider) NotifyRouterRenamed(_, _ string) {} - -func (p *testDbProvider) RemoveFromCache(_ string) { -} - -func (p *testDbProvider) GetManagers() *network.Managers { - return p.ctx.n.Managers -} - -type TestContext struct { - boltztest.BaseTestContext - n *network.Network - stores *Stores - closeNotify chan struct{} -} - -func NewTestContext(t *testing.T) *TestContext { - xt.GlobalRegistry().RegisterFactory(xt_smartrouting.NewFactory()) - - result := &TestContext{ - closeNotify: make(chan struct{}, 1), - } - result.BaseTestContext = *boltztest.NewTestContext(t, result.GetStoreForEntity) - return result -} - -func (ctx *TestContext) newViewTestCtx(tx *bbolt.Tx) boltz.MutateContext { - return boltz.NewTxMutateContext(change.New().SetChangeAuthorType("test").GetContext(), tx) -} - -func (ctx *TestContext) GetNetwork() *network.Network { - return ctx.n -} - -func (ctx *TestContext) Cleanup() { - close(ctx.closeNotify) - ctx.BaseTestContext.Cleanup() -} - -func (ctx *TestContext) GetStores() *Stores { - return ctx.stores -} - -func (ctx *TestContext) GetDb() boltz.Db { - return ctx.BaseTestContext.GetDb() -} - -func (ctx *TestContext) GetStoreForEntity(entity boltz.Entity) boltz.Store { - if _, ok := entity.(*db.Service); ok { - return ctx.n.GetStores().Service - } - return ctx.stores.GetStoreForEntity(entity) -} - -func (ctx *TestContext) GetDbProvider() DbProvider { - return &testDbProvider{ctx: ctx} -} - -func (ctx *TestContext) Init() { - ctx.BaseTestContext.InitDb(db.Open) - - dbProvider := ctx.GetDbProvider() - - config := newTestConfig(ctx) - var err error - ctx.n, err = network.NewNetwork(config) - ctx.NoError(err) - - // TODO: setup up single node raft cluster or mock? - ctx.stores, err = NewBoltStores(dbProvider) - ctx.NoError(err) - - ctx.NoError(RunMigrations(ctx.GetDb(), ctx.stores)) - - ctx.NoError(ctx.stores.EventualEventer.Start(ctx.closeNotify)) - -} - -func (ctx *TestContext) requireNewServicePolicy(policyType PolicyType, identityRoles []string, serviceRoles []string) *ServicePolicy { - entity := &ServicePolicy{ - BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, - Name: eid.New(), - PolicyType: policyType, - Semantic: SemanticAnyOf, - IdentityRoles: identityRoles, - ServiceRoles: serviceRoles, - } - boltztest.RequireCreate(ctx, entity) - return entity -} - -func (ctx *TestContext) RequireNewIdentity(name string, isAdmin bool) *Identity { - identityEntity := &Identity{ - BaseExtEntity: *boltz.NewExtEntity(eid.New(), nil), - Name: name, - IsAdmin: isAdmin, - } - boltztest.RequireCreate(ctx, identityEntity) - return identityEntity -} - -func (ctx *TestContext) RequireNewService(name string) *EdgeService { - edgeService := &EdgeService{ - Service: db.Service{ - BaseExtEntity: boltz.BaseExtEntity{Id: eid.New()}, - Name: name, - }, - } - boltztest.RequireCreate(ctx, edgeService) - return edgeService -} - -func (ctx *TestContext) getRelatedIds(entity boltz.Entity, field string) []string { - var result []string - err := ctx.GetDb().View(func(tx *bbolt.Tx) error { - store := ctx.stores.GetStoreForEntity(entity) - if store == nil { - return errors.Errorf("no store for entity of type '%v'", entity.GetEntityType()) - } - result = store.GetRelatedEntitiesIdList(tx, entity.GetId(), field) - return nil - }) - ctx.NoError(err) - return result -} - -func (ctx *TestContext) CleanupAll() { - stores := []boltz.Store{ - ctx.stores.Session, - ctx.stores.ApiSession, - ctx.stores.Service, - ctx.stores.EdgeService, - ctx.stores.Identity, - ctx.stores.EdgeRouter, - ctx.stores.Config, - ctx.stores.Identity, - ctx.stores.EdgeRouterPolicy, - ctx.stores.ServicePolicy, - ctx.stores.ServiceEdgeRouterPolicy, - } - - _ = ctx.GetDb().Update(change.New().NewMutateContext(), func(mutateCtx boltz.MutateContext) error { - for _, store := range stores { - if err := store.DeleteWhere(mutateCtx, `true limit none`); err != nil { - pfxlog.Logger().WithError(err).Errorf("failure while cleaning up %v", store.GetEntityType()) - return err - } - } - return nil - }) -} - -func (ctx *TestContext) getIdentityTypeId() string { - var result string - err := ctx.GetDb().View(func(tx *bbolt.Tx) error { - ids, _, err := ctx.stores.IdentityType.QueryIds(tx, "true") - if err != nil { - return err - } - result = ids[0] - return nil - }) - ctx.NoError(err) - return result -} - -func ss(vals ...string) []string { - return vals -} diff --git a/controller/raft/member.go b/controller/raft/member.go index 9f623482f..0fc44a42d 100644 --- a/controller/raft/member.go +++ b/controller/raft/member.go @@ -51,36 +51,41 @@ func (self *Controller) ListMembers() ([]*Member, error) { for _, srv := range configFuture.Configuration().Servers { memberSet[string(srv.Address)] = true + + version := "" + connected := false + if string(srv.ID) == self.env.GetId().Token { + version = self.env.GetVersionProvider().Version() + connected = true + } else if peer, exists := peers[string(srv.Address)]; exists { + version = peer.Version.Version + connected = true + } + result = append(result, &Member{ - Id: string(srv.ID), - Addr: string(srv.Address), - Voter: srv.Suffrage == raft.Voter, - Leader: srv.Address == leaderAddr, - Version: func() string { - if srv.Address == leaderAddr { - return self.env.GetVersionProvider().Version() - } - if peer, exists := peers[string(srv.Address)]; exists { - return peer.Version.Version - } - return "N/A" - }(), - Connected: true, + Id: string(srv.ID), + Addr: string(srv.Address), + Voter: srv.Suffrage == raft.Voter, + Leader: srv.Address == leaderAddr, + Version: version, + Connected: connected, }) } - for addr, peer := range peers { - if _, exists := memberSet[addr]; exists { - continue + if len(result) == 0 { + for addr, peer := range peers { + if _, exists := memberSet[addr]; exists { + continue + } + result = append(result, &Member{ + Id: string(peer.Id), + Addr: peer.Address, + Voter: false, + Leader: peer.Address == string(leaderAddr), + Version: peer.Version.Version, + Connected: true, + }) } - result = append(result, &Member{ - Id: string(peer.Id), - Addr: peer.Address, - Voter: false, - Leader: peer.Address == string(leaderAddr), - Version: peer.Version.Version, - Connected: true, - }) } return result, nil diff --git a/controller/raft/raft.go b/controller/raft/raft.go index f1b30c92c..6eb939584 100644 --- a/controller/raft/raft.go +++ b/controller/raft/raft.go @@ -486,7 +486,9 @@ func (self *Controller) ApplyWithTimeout(log []byte, timeout time.Duration) (int return err } - returnValue.Store(f.Response()) + if response := f.Response(); response != nil { + returnValue.Store(response) + } index.Store(f.Index()) return nil }) @@ -681,6 +683,7 @@ func (self *Controller) addConfiguredBootstrapMembers() error { if id, addr, err := self.Mesh.GetPeerInfo(bootstrapMember, time.Second*5); err != nil { pfxlog.Logger().WithError(err).Errorf("unable to get id for bootstrap member [%v]", bootstrapMember) + go self.retryBootstrapMember(bootstrapMember) } else { self.addBootstrapServer(raft.Server{ Suffrage: raft.Voter, @@ -692,6 +695,34 @@ func (self *Controller) addConfiguredBootstrapMembers() error { return nil } +func (self *Controller) retryBootstrapMember(bootstrapMember string) { + ticker := time.NewTicker(6 * time.Second) + defer ticker.Stop() + + for { + <-ticker.C + + // If we've bootstrapped, exit out + if self.bootstrapped.Load() { + return + } + + if id, addr, err := self.Mesh.GetPeerInfo(bootstrapMember, time.Second*5); err != nil { + pfxlog.Logger().WithError(err).Errorf("unable to get id for bootstrap member [%v]", bootstrapMember) + } else { + req := &cmd_pb.AddPeerRequest{ + Addr: string(addr), + Id: string(id), + IsVoter: true, + } + + if err = self.Join(req); err == nil { + return + } + } + } +} + // Join adds the given node to the raft cluster func (self *Controller) Join(req *cmd_pb.AddPeerRequest) error { self.clusterLock.Lock() diff --git a/controller/rest_client/circuit/list_circuits_parameters.go b/controller/rest_client/circuit/list_circuits_parameters.go index 8119b9bcc..fdfb4a19d 100644 --- a/controller/rest_client/circuit/list_circuits_parameters.go +++ b/controller/rest_client/circuit/list_circuits_parameters.go @@ -38,6 +38,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewListCircuitsParams creates a new ListCircuitsParams object, @@ -82,6 +83,16 @@ func NewListCircuitsParamsWithHTTPClient(client *http.Client) *ListCircuitsParam Typically these are written to a http.Request. */ type ListCircuitsParams struct { + + // Filter. + Filter *string + + // Limit. + Limit *int64 + + // Offset. + Offset *int64 + timeout time.Duration Context context.Context HTTPClient *http.Client @@ -135,6 +146,39 @@ func (o *ListCircuitsParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithFilter adds the filter to the list circuits params +func (o *ListCircuitsParams) WithFilter(filter *string) *ListCircuitsParams { + o.SetFilter(filter) + return o +} + +// SetFilter adds the filter to the list circuits params +func (o *ListCircuitsParams) SetFilter(filter *string) { + o.Filter = filter +} + +// WithLimit adds the limit to the list circuits params +func (o *ListCircuitsParams) WithLimit(limit *int64) *ListCircuitsParams { + o.SetLimit(limit) + return o +} + +// SetLimit adds the limit to the list circuits params +func (o *ListCircuitsParams) SetLimit(limit *int64) { + o.Limit = limit +} + +// WithOffset adds the offset to the list circuits params +func (o *ListCircuitsParams) WithOffset(offset *int64) *ListCircuitsParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list circuits params +func (o *ListCircuitsParams) SetOffset(offset *int64) { + o.Offset = offset +} + // WriteToRequest writes these params to a swagger request func (o *ListCircuitsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -143,6 +187,57 @@ func (o *ListCircuitsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt. } var res []error + if o.Filter != nil { + + // query param filter + var qrFilter string + + if o.Filter != nil { + qrFilter = *o.Filter + } + qFilter := qrFilter + if qFilter != "" { + + if err := r.SetQueryParam("filter", qFilter); err != nil { + return err + } + } + } + + if o.Limit != nil { + + // query param limit + var qrLimit int64 + + if o.Limit != nil { + qrLimit = *o.Limit + } + qLimit := swag.FormatInt64(qrLimit) + if qLimit != "" { + + if err := r.SetQueryParam("limit", qLimit); err != nil { + return err + } + } + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/controller/rest_client/link/list_links_parameters.go b/controller/rest_client/link/list_links_parameters.go index f80058307..b719fbebb 100644 --- a/controller/rest_client/link/list_links_parameters.go +++ b/controller/rest_client/link/list_links_parameters.go @@ -38,6 +38,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewListLinksParams creates a new ListLinksParams object, @@ -82,6 +83,16 @@ func NewListLinksParamsWithHTTPClient(client *http.Client) *ListLinksParams { Typically these are written to a http.Request. */ type ListLinksParams struct { + + // Filter. + Filter *string + + // Limit. + Limit *int64 + + // Offset. + Offset *int64 + timeout time.Duration Context context.Context HTTPClient *http.Client @@ -135,6 +146,39 @@ func (o *ListLinksParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithFilter adds the filter to the list links params +func (o *ListLinksParams) WithFilter(filter *string) *ListLinksParams { + o.SetFilter(filter) + return o +} + +// SetFilter adds the filter to the list links params +func (o *ListLinksParams) SetFilter(filter *string) { + o.Filter = filter +} + +// WithLimit adds the limit to the list links params +func (o *ListLinksParams) WithLimit(limit *int64) *ListLinksParams { + o.SetLimit(limit) + return o +} + +// SetLimit adds the limit to the list links params +func (o *ListLinksParams) SetLimit(limit *int64) { + o.Limit = limit +} + +// WithOffset adds the offset to the list links params +func (o *ListLinksParams) WithOffset(offset *int64) *ListLinksParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list links params +func (o *ListLinksParams) SetOffset(offset *int64) { + o.Offset = offset +} + // WriteToRequest writes these params to a swagger request func (o *ListLinksParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -143,6 +187,57 @@ func (o *ListLinksParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg } var res []error + if o.Filter != nil { + + // query param filter + var qrFilter string + + if o.Filter != nil { + qrFilter = *o.Filter + } + qFilter := qrFilter + if qFilter != "" { + + if err := r.SetQueryParam("filter", qFilter); err != nil { + return err + } + } + } + + if o.Limit != nil { + + // query param limit + var qrLimit int64 + + if o.Limit != nil { + qrLimit = *o.Limit + } + qLimit := swag.FormatInt64(qrLimit) + if qLimit != "" { + + if err := r.SetQueryParam("limit", qLimit); err != nil { + return err + } + } + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/controller/rest_model/circuit_detail.go b/controller/rest_model/circuit_detail.go index 226ce561a..d79b91f13 100644 --- a/controller/rest_model/circuit_detail.go +++ b/controller/rest_model/circuit_detail.go @@ -31,7 +31,6 @@ package rest_model import ( "context" - "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" @@ -43,22 +42,14 @@ import ( // // swagger:model circuitDetail type CircuitDetail struct { + BaseEntity // client Id ClientID string `json:"clientId,omitempty"` - // created at - // Required: true - // Format: date-time - CreatedAt *strfmt.DateTime `json:"createdAt"` - - // id - // Required: true - ID *string `json:"id"` - // path // Required: true - Path *CircuitDetailPath `json:"path"` + Path *Path `json:"path"` // service // Required: true @@ -69,15 +60,81 @@ type CircuitDetail struct { Terminator *EntityRef `json:"terminator"` } +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *CircuitDetail) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 BaseEntity + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.BaseEntity = aO0 + + // AO1 + var dataAO1 struct { + ClientID string `json:"clientId,omitempty"` + + Path *Path `json:"path"` + + Service *EntityRef `json:"service"` + + Terminator *EntityRef `json:"terminator"` + } + if err := swag.ReadJSON(raw, &dataAO1); err != nil { + return err + } + + m.ClientID = dataAO1.ClientID + + m.Path = dataAO1.Path + + m.Service = dataAO1.Service + + m.Terminator = dataAO1.Terminator + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m CircuitDetail) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 2) + + aO0, err := swag.WriteJSON(m.BaseEntity) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + var dataAO1 struct { + ClientID string `json:"clientId,omitempty"` + + Path *Path `json:"path"` + + Service *EntityRef `json:"service"` + + Terminator *EntityRef `json:"terminator"` + } + + dataAO1.ClientID = m.ClientID + + dataAO1.Path = m.Path + + dataAO1.Service = m.Service + + dataAO1.Terminator = m.Terminator + + jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + if errAO1 != nil { + return nil, errAO1 + } + _parts = append(_parts, jsonDataAO1) + return swag.ConcatJSON(_parts...), nil +} + // Validate validates this circuit detail func (m *CircuitDetail) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateCreatedAt(formats); err != nil { - res = append(res, err) - } - - if err := m.validateID(formats); err != nil { + // validation for a type composition with BaseEntity + if err := m.BaseEntity.Validate(formats); err != nil { res = append(res, err) } @@ -99,28 +156,6 @@ func (m *CircuitDetail) Validate(formats strfmt.Registry) error { return nil } -func (m *CircuitDetail) validateCreatedAt(formats strfmt.Registry) error { - - if err := validate.Required("createdAt", "body", m.CreatedAt); err != nil { - return err - } - - if err := validate.FormatOf("createdAt", "body", "date-time", m.CreatedAt.String(), formats); err != nil { - return err - } - - return nil -} - -func (m *CircuitDetail) validateID(formats strfmt.Registry) error { - - if err := validate.Required("id", "body", m.ID); err != nil { - return err - } - - return nil -} - func (m *CircuitDetail) validatePath(formats strfmt.Registry) error { if err := validate.Required("path", "body", m.Path); err != nil { @@ -185,6 +220,11 @@ func (m *CircuitDetail) validateTerminator(formats strfmt.Registry) error { func (m *CircuitDetail) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error + // validation for a type composition with BaseEntity + if err := m.BaseEntity.ContextValidate(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidatePath(ctx, formats); err != nil { res = append(res, err) } @@ -268,161 +308,3 @@ func (m *CircuitDetail) UnmarshalBinary(b []byte) error { *m = res return nil } - -// CircuitDetailPath circuit detail path -// -// swagger:model CircuitDetailPath -type CircuitDetailPath struct { - - // links - Links []*EntityRef `json:"links"` - - // nodes - Nodes []*EntityRef `json:"nodes"` -} - -// Validate validates this circuit detail path -func (m *CircuitDetailPath) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateLinks(formats); err != nil { - res = append(res, err) - } - - if err := m.validateNodes(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *CircuitDetailPath) validateLinks(formats strfmt.Registry) error { - if swag.IsZero(m.Links) { // not required - return nil - } - - for i := 0; i < len(m.Links); i++ { - if swag.IsZero(m.Links[i]) { // not required - continue - } - - if m.Links[i] != nil { - if err := m.Links[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("path" + "." + "links" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("path" + "." + "links" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -func (m *CircuitDetailPath) validateNodes(formats strfmt.Registry) error { - if swag.IsZero(m.Nodes) { // not required - return nil - } - - for i := 0; i < len(m.Nodes); i++ { - if swag.IsZero(m.Nodes[i]) { // not required - continue - } - - if m.Nodes[i] != nil { - if err := m.Nodes[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("path" + "." + "nodes" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("path" + "." + "nodes" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this circuit detail path based on the context it is used -func (m *CircuitDetailPath) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateLinks(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateNodes(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *CircuitDetailPath) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Links); i++ { - - if m.Links[i] != nil { - if err := m.Links[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("path" + "." + "links" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("path" + "." + "links" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -func (m *CircuitDetailPath) contextValidateNodes(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Nodes); i++ { - - if m.Nodes[i] != nil { - if err := m.Nodes[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("path" + "." + "nodes" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("path" + "." + "nodes" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *CircuitDetailPath) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *CircuitDetailPath) UnmarshalBinary(b []byte) error { - var res CircuitDetailPath - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/controller/rest_model/path.go b/controller/rest_model/path.go new file mode 100644 index 000000000..916d1f69a --- /dev/null +++ b/controller/rest_model/path.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// +// Copyright NetFoundry Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// __ __ _ +// \ \ / / (_) +// \ \ /\ / /_ _ _ __ _ __ _ _ __ __ _ +// \ \/ \/ / _` | '__| '_ \| | '_ \ / _` | +// \ /\ / (_| | | | | | | | | | | (_| | : This file is generated, do not edit it. +// \/ \/ \__,_|_| |_| |_|_|_| |_|\__, | +// __/ | +// |___/ + +package rest_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Path path +// +// swagger:model path +type Path struct { + + // links + Links []*EntityRef `json:"links"` + + // nodes + Nodes []*EntityRef `json:"nodes"` +} + +// Validate validates this path +func (m *Path) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLinks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNodes(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Path) validateLinks(formats strfmt.Registry) error { + if swag.IsZero(m.Links) { // not required + return nil + } + + for i := 0; i < len(m.Links); i++ { + if swag.IsZero(m.Links[i]) { // not required + continue + } + + if m.Links[i] != nil { + if err := m.Links[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("links" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("links" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Path) validateNodes(formats strfmt.Registry) error { + if swag.IsZero(m.Nodes) { // not required + return nil + } + + for i := 0; i < len(m.Nodes); i++ { + if swag.IsZero(m.Nodes[i]) { // not required + continue + } + + if m.Nodes[i] != nil { + if err := m.Nodes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("nodes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("nodes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this path based on the context it is used +func (m *Path) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLinks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNodes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Path) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Links); i++ { + + if m.Links[i] != nil { + if err := m.Links[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("links" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("links" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Path) contextValidateNodes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Nodes); i++ { + + if m.Nodes[i] != nil { + if err := m.Nodes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("nodes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("nodes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Path) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Path) UnmarshalBinary(b []byte) error { + var res Path + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/controller/rest_server/embedded_spec.go b/controller/rest_server/embedded_spec.go index 9872057f5..722c503ba 100644 --- a/controller/rest_server/embedded_spec.go +++ b/controller/rest_server/embedded_spec.go @@ -77,6 +77,17 @@ func init() { ], "summary": "List circuits", "operationId": "listCircuits", + "parameters": [ + { + "$ref": "#/parameters/limit" + }, + { + "$ref": "#/parameters/offset" + }, + { + "$ref": "#/parameters/filter" + } + ], "responses": { "200": { "$ref": "#/responses/listCircuits" @@ -330,6 +341,17 @@ func init() { ], "summary": "List links", "operationId": "listLinks", + "parameters": [ + { + "$ref": "#/parameters/limit" + }, + { + "$ref": "#/parameters/offset" + }, + { + "$ref": "#/parameters/filter" + } + ], "responses": { "200": { "$ref": "#/responses/listLinks" @@ -1225,49 +1247,33 @@ func init() { } }, "circuitDetail": { - "type": "object", - "required": [ - "id", - "service", - "terminator", - "path", - "createdAt" - ], - "properties": { - "clientId": { - "type": "string" - }, - "createdAt": { - "type": "string", - "format": "date-time" - }, - "id": { - "type": "string" + "allOf": [ + { + "$ref": "#/definitions/baseEntity" }, - "path": { + { "type": "object", + "required": [ + "service", + "terminator", + "path" + ], "properties": { - "links": { - "type": "array", - "items": { - "$ref": "#/definitions/entityRef" - } + "clientId": { + "type": "string" }, - "nodes": { - "type": "array", - "items": { - "$ref": "#/definitions/entityRef" - } + "path": { + "$ref": "#/definitions/path" + }, + "service": { + "$ref": "#/definitions/entityRef" + }, + "terminator": { + "$ref": "#/definitions/entityRef" } } - }, - "service": { - "$ref": "#/definitions/entityRef" - }, - "terminator": { - "$ref": "#/definitions/entityRef" } - } + ] }, "circuitList": { "type": "array", @@ -1787,6 +1793,23 @@ func init() { } } }, + "path": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + } + } + }, "raftMemberListRequest": { "type": "object" }, @@ -2641,6 +2664,23 @@ func init() { ], "summary": "List circuits", "operationId": "listCircuits", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], "responses": { "200": { "description": "A list of circuits", @@ -3373,6 +3413,23 @@ func init() { ], "summary": "List links", "operationId": "listLinks", + "parameters": [ + { + "type": "integer", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + } + ], "responses": { "200": { "description": "A list of links", @@ -6203,23 +6260,6 @@ func init() { } }, "definitions": { - "CircuitDetailPath": { - "type": "object", - "properties": { - "links": { - "type": "array", - "items": { - "$ref": "#/definitions/entityRef" - } - }, - "nodes": { - "type": "array", - "items": { - "$ref": "#/definitions/entityRef" - } - } - } - }, "apiError": { "type": "object", "properties": { @@ -6336,49 +6376,33 @@ func init() { } }, "circuitDetail": { - "type": "object", - "required": [ - "id", - "service", - "terminator", - "path", - "createdAt" - ], - "properties": { - "clientId": { - "type": "string" - }, - "createdAt": { - "type": "string", - "format": "date-time" - }, - "id": { - "type": "string" + "allOf": [ + { + "$ref": "#/definitions/baseEntity" }, - "path": { + { "type": "object", + "required": [ + "service", + "terminator", + "path" + ], "properties": { - "links": { - "type": "array", - "items": { - "$ref": "#/definitions/entityRef" - } + "clientId": { + "type": "string" }, - "nodes": { - "type": "array", - "items": { - "$ref": "#/definitions/entityRef" - } + "path": { + "$ref": "#/definitions/path" + }, + "service": { + "$ref": "#/definitions/entityRef" + }, + "terminator": { + "$ref": "#/definitions/entityRef" } } - }, - "service": { - "$ref": "#/definitions/entityRef" - }, - "terminator": { - "$ref": "#/definitions/entityRef" } - } + ] }, "circuitList": { "type": "array", @@ -6898,6 +6922,23 @@ func init() { } } }, + "path": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + }, + "nodes": { + "type": "array", + "items": { + "$ref": "#/definitions/entityRef" + } + } + } + }, "raftMemberListRequest": { "type": "object" }, diff --git a/controller/rest_server/operations/circuit/list_circuits_parameters.go b/controller/rest_server/operations/circuit/list_circuits_parameters.go index b7e885721..762af4c5d 100644 --- a/controller/rest_server/operations/circuit/list_circuits_parameters.go +++ b/controller/rest_server/operations/circuit/list_circuits_parameters.go @@ -33,7 +33,10 @@ import ( "net/http" "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewListCircuitsParams creates a new ListCircuitsParams object @@ -52,6 +55,19 @@ type ListCircuitsParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + + /* + In: query + */ + Filter *string + /* + In: query + */ + Limit *int64 + /* + In: query + */ + Offset *int64 } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -63,8 +79,88 @@ func (o *ListCircuitsParams) BindRequest(r *http.Request, route *middleware.Matc o.HTTPRequest = r + qs := runtime.Values(r.URL.Query()) + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + qLimit, qhkLimit, _ := qs.GetOK("limit") + if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } + +// bindFilter binds and validates parameter Filter from query. +func (o *ListCircuitsParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindLimit binds and validates parameter Limit from query. +func (o *ListCircuitsParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("limit", "query", "int64", raw) + } + o.Limit = &value + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *ListCircuitsParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} diff --git a/controller/rest_server/operations/circuit/list_circuits_urlbuilder.go b/controller/rest_server/operations/circuit/list_circuits_urlbuilder.go index 5b2ae84c2..42272ebe6 100644 --- a/controller/rest_server/operations/circuit/list_circuits_urlbuilder.go +++ b/controller/rest_server/operations/circuit/list_circuits_urlbuilder.go @@ -33,11 +33,19 @@ import ( "errors" "net/url" golangswaggerpaths "path" + + "github.com/go-openapi/swag" ) // ListCircuitsURL generates an URL for the list circuits operation type ListCircuitsURL struct { + Filter *string + Limit *int64 + Offset *int64 + _basePath string + // avoid unkeyed usage + _ struct{} } // WithBasePath sets the base path for this url builder, only required when it's different from the @@ -67,6 +75,34 @@ func (o *ListCircuitsURL) Build() (*url.URL, error) { } _result.Path = golangswaggerpaths.Join(_basePath, _path) + qs := make(url.Values) + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var limitQ string + if o.Limit != nil { + limitQ = swag.FormatInt64(*o.Limit) + } + if limitQ != "" { + qs.Set("limit", limitQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + return &_result, nil } diff --git a/controller/rest_server/operations/link/list_links_parameters.go b/controller/rest_server/operations/link/list_links_parameters.go index a37a8a8fd..32a147200 100644 --- a/controller/rest_server/operations/link/list_links_parameters.go +++ b/controller/rest_server/operations/link/list_links_parameters.go @@ -33,7 +33,10 @@ import ( "net/http" "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewListLinksParams creates a new ListLinksParams object @@ -52,6 +55,19 @@ type ListLinksParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + + /* + In: query + */ + Filter *string + /* + In: query + */ + Limit *int64 + /* + In: query + */ + Offset *int64 } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -63,8 +79,88 @@ func (o *ListLinksParams) BindRequest(r *http.Request, route *middleware.Matched o.HTTPRequest = r + qs := runtime.Values(r.URL.Query()) + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + qLimit, qhkLimit, _ := qs.GetOK("limit") + if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } + +// bindFilter binds and validates parameter Filter from query. +func (o *ListLinksParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindLimit binds and validates parameter Limit from query. +func (o *ListLinksParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("limit", "query", "int64", raw) + } + o.Limit = &value + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *ListLinksParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} diff --git a/controller/rest_server/operations/link/list_links_urlbuilder.go b/controller/rest_server/operations/link/list_links_urlbuilder.go index 54009ded7..b6566cd4d 100644 --- a/controller/rest_server/operations/link/list_links_urlbuilder.go +++ b/controller/rest_server/operations/link/list_links_urlbuilder.go @@ -33,11 +33,19 @@ import ( "errors" "net/url" golangswaggerpaths "path" + + "github.com/go-openapi/swag" ) // ListLinksURL generates an URL for the list links operation type ListLinksURL struct { + Filter *string + Limit *int64 + Offset *int64 + _basePath string + // avoid unkeyed usage + _ struct{} } // WithBasePath sets the base path for this url builder, only required when it's different from the @@ -67,6 +75,34 @@ func (o *ListLinksURL) Build() (*url.URL, error) { } _result.Path = golangswaggerpaths.Join(_basePath, _path) + qs := make(url.Values) + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var limitQ string + if o.Limit != nil { + limitQ = swag.FormatInt64(*o.Limit) + } + if limitQ != "" { + qs.Set("limit", limitQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + return &_result, nil } diff --git a/controller/specs/swagger.yml b/controller/specs/swagger.yml index 1cdd6a64e..ef67482d9 100644 --- a/controller/specs/swagger.yml +++ b/controller/specs/swagger.yml @@ -486,6 +486,10 @@ paths: tags: - Link operationId: listLinks + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/filter' responses: '200': $ref: '#/responses/listLinks' @@ -565,6 +569,10 @@ paths: tags: - Circuit operationId: listCircuits + parameters: + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/filter' responses: '200': $ref: '#/responses/listCircuits' @@ -1755,42 +1763,40 @@ definitions: items: $ref: '#/definitions/circuitDetail' circuitDetail: - type: object - required: - - id - - service - - terminator - - path - - createdAt - properties: - id: - type: string - clientId: - type: string - service: - $ref: '#/definitions/entityRef' - terminator: - $ref: '#/definitions/entityRef' - createdAt: - type: string - format: date-time - path: - type: object + allOf: + - $ref: '#/definitions/baseEntity' + - type: object + required: + - service + - terminator + - path properties: - nodes: - type: array - items: - $ref: '#/definitions/entityRef' - links: - type: array - items: - $ref: '#/definitions/entityRef' + clientId: + type: string + service: + $ref: '#/definitions/entityRef' + terminator: + $ref: '#/definitions/entityRef' + path: + $ref: '#/definitions/path' circuitDelete: type: object properties: immediate: type: boolean + path: + type: object + properties: + nodes: + type: array + items: + $ref: '#/definitions/entityRef' + links: + type: array + items: + $ref: '#/definitions/entityRef' + ################################################################### # Inspections ################################################################## diff --git a/controller/sync_strats/sync_instant.go b/controller/sync_strats/sync_instant.go index 8d800abc4..f05815dd4 100644 --- a/controller/sync_strats/sync_instant.go +++ b/controller/sync_strats/sync_instant.go @@ -27,12 +27,12 @@ import ( "github.com/openziti/storage/ast" "github.com/openziti/ziti/common/build" "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/env" "github.com/openziti/ziti/controller/event" "github.com/openziti/ziti/controller/handler_edge_ctrl" "github.com/openziti/ziti/controller/model" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/controller/persistence" cmap "github.com/orcaman/concurrent-map/v2" "go.etcd.io/bbolt" "google.golang.org/protobuf/proto" @@ -246,7 +246,7 @@ func (strategy *InstantStrategy) PeerAdded(peers []*event.ClusterPeer) { logger.WithField("addrs", addrs).Info("done sending new signing certificates") } -func (strategy *InstantStrategy) ApiSessionAdded(apiSession *persistence.ApiSession) { +func (strategy *InstantStrategy) ApiSessionAdded(apiSession *db.ApiSession) { logger := pfxlog.Logger().WithField("strategy", strategy.Type()) apiSessionProto, err := apiSessionToProto(strategy.ae, apiSession.Token, apiSession.IdentityId, apiSession.Id) @@ -270,7 +270,7 @@ func (strategy *InstantStrategy) ApiSessionAdded(apiSession *persistence.ApiSess }) } -func (strategy *InstantStrategy) ApiSessionUpdated(apiSession *persistence.ApiSession, _ *persistence.ApiSessionCertificate) { +func (strategy *InstantStrategy) ApiSessionUpdated(apiSession *db.ApiSession, _ *db.ApiSessionCertificate) { logger := pfxlog.Logger().WithField("strategy", strategy.Type()) apiSessionProto, err := apiSessionToProto(strategy.ae, apiSession.Token, apiSession.IdentityId, apiSession.Id) @@ -296,7 +296,7 @@ func (strategy *InstantStrategy) ApiSessionUpdated(apiSession *persistence.ApiSe }) } -func (strategy *InstantStrategy) ApiSessionDeleted(apiSession *persistence.ApiSession) { +func (strategy *InstantStrategy) ApiSessionDeleted(apiSession *db.ApiSession) { sessionRemoved := &edge_ctrl_pb.ApiSessionRemoved{ Tokens: []string{apiSession.Token}, } @@ -308,7 +308,7 @@ func (strategy *InstantStrategy) ApiSessionDeleted(apiSession *persistence.ApiSe }) } -func (strategy *InstantStrategy) SessionDeleted(session *persistence.Session) { +func (strategy *InstantStrategy) SessionDeleted(session *db.Session) { sessionRemoved := &edge_ctrl_pb.SessionRemoved{ Tokens: []string{session.Token}, } diff --git a/dist/cloudfront/get.openziti.io/routes.yml b/dist/cloudfront/get.openziti.io/routes.yml index 7c80f09f7..f9ae6bf08 100644 --- a/dist/cloudfront/get.openziti.io/routes.yml +++ b/dist/cloudfront/get.openziti.io/routes.yml @@ -7,6 +7,11 @@ - get: /miniziti.bash raw: /openziti/ziti/{{GITHUB_SHA}}/quickstart/kubernetes/ + # Linux package install script for ziti, zrok CLI, and metapackages that are in the main release repo for generic, + # portable Linux packages, not ziti-edge-tunnel +- get: /install.bash + raw: /openziti/ziti/{{GITHUB_SHA}}/dist/dist-packages/linux/ + # these are directory shortcuts, so you must supply a test file - get: /quick/ raw: /openziti/ziti/{{GITHUB_SHA}}/quickstart/docker/image/ @@ -30,5 +35,5 @@ file: package-repos.gpg - get: /zdew/ - raw: /openziti/desktop-edge-win/release-next/ - file: version-check.json + raw: /openziti/desktop-edge-win/main/release-streams/ + file: latest.json diff --git a/dist/dist-packages/linux/install.bash b/dist/dist-packages/linux/install.bash new file mode 100644 index 000000000..d32a0f2d5 --- /dev/null +++ b/dist/dist-packages/linux/install.bash @@ -0,0 +1,143 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +checkSum() { + for CMD in sha256sum md5sum; do + if command -v $CMD &>/dev/null; then + local SUMCMD=$CMD + break + fi + done + if [ -z "${SUMCMD:-}" ]; then + echo "ERROR: No checksum command found. Tried 'sha256sum', 'md5sum'." >&2 + exit 1 + fi + $SUMCMD | awk '{print $1}' +} + +installRedHat(){ + + for CMD in dnf yum; do + if command -v $CMD &>/dev/null; then + local PACKAGER=$CMD + break + fi + done + if [ -z "${PACKAGER:-}" ]; then + echo "ERROR: No package manager found. Tried 'dnf', 'yum'." >&2 + exit 1 + fi + + local REPOSRC="[OpenZitiRelease] +name=OpenZiti Release +baseurl=https://packages.openziti.org/${ZITIPAX_RPM:-zitipax-openziti-rpm-stable}/redhat/\$basearch +enabled=1 +gpgcheck=0 +gpgkey=https://packages.openziti.org/${ZITIPAX_RPM:-zitipax-openziti-rpm-stable}/redhat/\$basearch/repodata/repomd.xml.key +repo_gpgcheck=1" + + local REPOFILE="/etc/yum.repos.d/openziti-release.repo" + if [ -s $REPOFILE ]; then + local EXISTINGSUM + local REPOSUM + EXISTINGSUM=$(checkSum < $REPOFILE) + REPOSUM=$(checkSum <<< "$REPOSRC") + if [ "$EXISTINGSUM" != "$REPOSUM" ]; then + mv -v $REPOFILE{,".$(date -Iseconds)"} + echo "$REPOSRC" > $REPOFILE + + fi + else + echo "$REPOSRC" >| $REPOFILE + + fi + + $PACKAGER install --assumeyes "$@" + for PKG in "$@"; do + $PACKAGER info "$PKG" + done +} + +installDebian(){ + + for CMD in gpg gpg2; do + if command -v $CMD &>/dev/null; then + local GNUPGCMD=$CMD + break + fi + done + if [ -z "${GNUPGCMD:-}" ]; then + echo "ERROR: No GnuPG CLI found. Tried commands 'gpg', gpg2. Try installing 'gnupg'." >&2 + exit 1 + fi + for CMD in wget curl; do + if command -v $CMD &>/dev/null; then + local GETTER=$CMD + break + fi + done + if [ -z "${GETTER:-}" ]; then + echo "ERROR: No http client found. Tried 'wget', 'curl'." >&2 + exit 1 + else + case $GETTER in + wget) + GETTERCMD="wget -qO-" + ;; + curl) + GETTERCMD="curl -fsSL" + ;; + esac + fi + + # always update the pubkey + $GETTERCMD https://get.openziti.io/tun/package-repos.gpg \ + | $GNUPGCMD --batch --yes --dearmor --output /usr/share/keyrings/openziti.gpg + chmod a+r /usr/share/keyrings/openziti.gpg + + local REPOSRC="deb [signed-by=/usr/share/keyrings/openziti.gpg] https://packages.openziti.org/${ZITIPAX_DEB:-zitipax-openziti-deb-stable} debian main" + + local REPOFILE="/etc/apt/sources.list.d/openziti-release.list" + if [ -s $REPOFILE ]; then + local EXISTINGSUM + local REPOSUM + EXISTINGSUM=$(checkSum < $REPOFILE) + REPOSUM=$(checkSum <<< "$REPOSRC") + if [ "$EXISTINGSUM" != "$REPOSUM" ]; then + mv -v $REPOFILE{,".$(date -Iseconds)"} + echo "$REPOSRC" > $REPOFILE + + fi + else + echo "$REPOSRC" >| $REPOFILE + + fi + + apt-get update + apt-get install --yes "$@" + for PKG in "$@"; do + apt-cache show "$PKG=$(dpkg-query -W -f='${Version}' $PKG)" + done +} + +main(){ + if ! (( $# )); then + echo "ERROR: No arguments provided. Please provide a space-separated list of packages to install from the OpenZiti repo." >&2 + exit 1 + fi + # Detect the system's distribution family + if [ -f /etc/redhat-release ]; then + installRedHat "$@" + elif [ -f /etc/debian_version ]; then + installDebian "$@" + else + echo "ERROR: Unsupported Linux distribution family. The zrok-share package is availabe as a Debian or Red Hat package." >&2 + exit 1 + fi +} + +# ensure the script is not executed before it is fully downloaded if curl'd to bash +main "$@" diff --git a/doc/ha/ctrl1.yml b/doc/ha/ctrl1.yml index 039a7913e..23bec8d45 100644 --- a/doc/ha/ctrl1.yml +++ b/doc/ha/ctrl1.yml @@ -7,9 +7,9 @@ raft: - tls:127.0.0.1:6464 identity: - cert: ./pki/ctrl1/certs/server.cert + cert: ./pki/ctrl1/certs/server.chain.pem key: ./pki/ctrl1/keys/server.key - ca: ./pki/ctrl1/certs/server.chain.pem + ca: ./pki/ctrl1/certs/ctrl1.chain.pem ctrl: listener: tls:127.0.0.1:6262 diff --git a/doc/ha/ctrl2.yml b/doc/ha/ctrl2.yml index 5c6f6aaa2..b5fe79b96 100644 --- a/doc/ha/ctrl2.yml +++ b/doc/ha/ctrl2.yml @@ -5,9 +5,9 @@ raft: dataDir: ./data/ctrl2 identity: - cert: ./pki/ctrl2/certs/server.cert + cert: ./pki/ctrl2/certs/server.chain.pem key: ./pki/ctrl2/keys/server.key - ca: ./pki/ctrl2/certs/server.chain.pem + ca: ./pki/ctrl2/certs/ctrl2.chain.pem ctrl: listener: tls:127.0.0.1:6363 diff --git a/doc/ha/ctrl3.yml b/doc/ha/ctrl3.yml index 48f65d717..60bed20fb 100644 --- a/doc/ha/ctrl3.yml +++ b/doc/ha/ctrl3.yml @@ -5,9 +5,9 @@ raft: dataDir: ./data/ctrl3 identity: - cert: ./pki/ctrl3/certs/server.cert + cert: ./pki/ctrl3/certs/server.chain.pem key: ./pki/ctrl3/keys/server.key - ca: ./pki/ctrl3/certs/server.chain.pem + ca: ./pki/ctrl3/certs/ctrl3.chain.pem ctrl: listener: tls:127.0.0.1:6464 diff --git a/doc/ha/dev-setup-ha-pki.md b/doc/ha/dev-setup-ha-pki.md new file mode 100644 index 000000000..307d63230 --- /dev/null +++ b/doc/ha/dev-setup-ha-pki.md @@ -0,0 +1,69 @@ +# Overview + +This guide walks you through creating the certificates necessary to run a three node HA cluster. + +**NOTE**: This folder contains a script `create-pki.sh` which will perform the steps outlined in +this guide for you. + +## Create a CA + +Create a self-signed certificate authority (CA) for the trust-root of your cluster + +``` +ziti pki create ca --trust-domain ha.test --pki-root ./pki --ca-file ca --ca-name 'HA Example Trust Root' +``` + +## Create Controller Certs + +We are going to create an intermediate CA for each controller. We'll use this intermediate CA for +the following purposes: + +1. To create a cert which will represent the controller. It will be used + 1. On the client side when dialing other controllers in the cluster + 2. On the server side when receiving connections from other controllers + 3. On the server side when receiving connections from routers + 4. On the server when handling REST API requests +2. To create identity certs as part of the identity enrollment process +3. To create router certs as part of the router enrollment process + +### Notes + +#### Client vs Server Certs + +You may use separate certs and keys for client and server connections, but it's not necessary. When +you use a server cert on the client side it exposes information about what IPs and DNS entries the +cert is valid for, but since we're only connecting to other controllers, this should not be a +concern. However, the option to use separate certs is available, should you wish to use it. + +#### REST Endpoint Certs + +You may also use a different set of certs for the REST endpoint. + +#### Sharing Signing Certs + +You could use the same signing cert for all controllers in a cluster. However, if a signing cert is +ever compromised, all certs signed by the signing cert would need to be revoked. By using a separate +cert for each controller we limit the fallout from an individual controller or cert being +compromised. + +### Create the Controller 1 signing and server certs + +```shell +# Create the controller 1 intermediate/signing cert +ziti pki create intermediate --pki-root ./pki --ca-name ca --intermediate-file ctrl1 --intermediate-name 'Controller One Signing Cert' + +# Create the controller 1 server cert +ziti pki create server --pki-root ./pki --ca-name ctrl1 --dns localhost --ip 127.0.0.1 --server-name ctrl1 --spiffe-id 'controller/ctrl1' + +# Create the controller 2 intermediate/signing cert +ziti pki create intermediate --pki-root ./pki --ca-name ca --intermediate-file ctrl2 --intermediate-name 'Controller Two Signing Cert' + +# Create the controller 2 server cert +ziti pki create server --pki-root ./pki --ca-name ctrl2 --dns localhost --ip 127.0.0.1 --server-name ctrl2 --spiffe-id 'controller/ctrl2' + +# Create the controller 3 intermediate/signing cert +ziti pki create intermediate --pki-root ./pki --ca-name ca --intermediate-file ctrl3 --intermediate-name 'Controller Three Signing Cert' + +# Create the controller 3 server cert +ziti pki create server --pki-root ./pki --ca-name ctrl3 --dns localhost --ip 127.0.0.1 --server-name ctrl3 --spiffe-id 'controller/ctrl3' +``` diff --git a/doc/ha/dev-setup.md b/doc/ha/dev-setup.md index 5030478cd..1e86a7aba 100644 --- a/doc/ha/dev-setup.md +++ b/doc/ha/dev-setup.md @@ -1,81 +1,26 @@ # HA Setup for Development -**NOTE: HA is a work in progress and not yet usable for anything other than developing HA** +**NOTE: HA is in alpha. Expect bugs. Bug reports are appreciated** To set up a local three node HA cluster, do the following. -## Create a CA +## Create The Necessary PKI -Create a self-signed certificate authority (CA) for the trust-root of your cluster - -``` -ziti pki create ca --trust-domain ha.test --pki-root ./pki --ca-file ca --ca-name 'HA Example Trust Root' -``` - -## Create Controller Certs - -We are going to create an intermediate CA for each controller. We'll use this intermediate CA -for the following purposes: - -1. To create a cert which will represent the controller. It will be used - 1. On the client side when dialing other controllers in the cluster - 2. On the server side when receiving connections from other controllers - 3. On the server side when receiving connections from routers - 4. On the server when handling REST API requests -2. To create identity certs as part of the identity enrollment process -3. To create router certs as part of the router enrollment process - -### Notes - -#### Client vs Server Certs - -You may use separate certs and keys for client and server connections, but it's not necessary. -When you use a server cert on the client side it exposes information about what IPs and DNS entries -the cert is valid for, but since we're only connecting to other controllers, this should not be -a concern. However, the option to use separate certs is available, should you wish to use it. - -#### REST Endpoint Certs - -You may also use a different set of certs for the REST endpoint. - -#### Sharing Signing Certs - -You could use the same signing cert for all controllers in a cluster. However, if a signing -cert is ever compromised, all certs signed by the signing cert would need to be revoked. By -using a separate cert for each controller we limit the fallout from an individual controller -or cert being compromised. - -### Create the Controller 1 signing and server certs - -```shell -# Create the controller 1 intermediate/signing cert -ziti pki create intermediate --pki-root ./pki --ca-name ca --intermediate-file ctrl1 --intermediate-name 'Controller One Signing Cert' - -# Create the controller 1 server cert -ziti pki create server --pki-root ./pki --ca-name ctrl1 --dns localhost --ip 127.0.0.1 --server-name ctrl1 --spiffe-id 'controller/ctrl1' - -# Create the controller 2 intermediate/signing cert -ziti pki create intermediate --pki-root ./pki --ca-name ca --intermediate-file ctrl2 --intermediate-name 'Controller Two Signing Cert' - -# Create the controller 2 server cert -ziti pki create server --pki-root ./pki --ca-name ctrl2 --dns localhost --ip 127.0.0.1 --server-name ctrl2 --spiffe-id 'controller/ctrl2' - -# Create the controller 3 intermediate/signing cert -ziti pki create intermediate --pki-root ./pki --ca-name ca --intermediate-file ctrl3 --intermediate-name 'Controller Three Signing Cert' - -# Create the controller 3 server cert -ziti pki create server --pki-root ./pki --ca-name ctrl3 --dns localhost --ip 127.0.0.1 --server-name ctrl3 --spiffe-id 'controller/ctrl3' -``` +Either run the `create-pki.sh` script found in the folder, or follow the steps in +the [HA PKI Guide](./dev-setup-ha-pki.md) ## Running the Controllers -1. The controller configuration files have relative paths, so make sure you're running things from this directory. +1. The controller configuration files have relative paths, so make sure you're running things from + this directory. 2. Start all three controllers 1. `ziti controller run ctrl1.yml` 2. `ziti controller run ctrl2.yml` 3. `ziti controller run ctrl3.yml` - 4. All three are configured with `minClusterSize` of 3, so they will wait to be joined to a raft cluster - 5. The ctrl1.yml config file has the other two controllers as bootstrap members, so when it starts the first controller will start trying form the raft cluster. + 4. All three are configured with `minClusterSize` of 3, so they will wait to be joined to a raft + cluster + 5. The ctrl1.yml config file has the other two controllers as bootstrap members, so when it + starts the first controller will start trying form the raft cluster. 3. Initialize the edge using the agent 1. `ziti agent controller init admin admin 'Default Admin'` 2. You can of course use different values if you desire @@ -89,14 +34,22 @@ You should now have a three node cluster running. You can log into each controll You could then create some model data on any controller: ``` +# This will create the client side identity and policies ziti demo setup echo client + +# This will create the server side identity and policies ziti demo setup echo single-sdk-hosted ``` Any view the results on any controller ``` +ziti edge login localhost:1280 ziti edge ls services + +ziti edge login -i ctrl2 localhost:1380 ziti edge -i ctrl2 ls services + +ziti edge login -i ctrl3 localhost:1480 ziti edge -i ctrl3 ls services ``` diff --git a/doc/ha/overview.md b/doc/ha/overview.md index 7cc7ac31d..3d7404bac 100644 --- a/doc/ha/overview.md +++ b/doc/ha/overview.md @@ -3,13 +3,15 @@ This document gives a brief overview of how OpenZiti HA works and how it differs from running OpenZiti in non-HA mode. +To set up a developer HA network see the [HA Developer Setup Guide](./dev-setup.md). + ## Operational Considerations ### System of Record -In controller that's not configured for HA, the bolt database is the system of record. In -an HA setup, the raft journal is the system of record. The raft journal is stored in two places, -a snapshot directory and a bolt database of raft journal entries. +In controller that's not configured for HA, the bolt database is the system of record. In an HA +setup, the raft journal is the system of record. The raft journal is stored in two places, a +snapshot directory and a bolt database of raft journal entries. So a non-HA setup will have: @@ -18,7 +20,8 @@ So a non-HA setup will have: An HA setup will have: * raft.db - the bolt database containing raft journal entries -* snapshots/ - a directory containing raft snapshots. Each snapshot is snapshot of the controller bolt db +* snapshots/ - a directory containing raft snapshots. Each snapshot is snapshot of the controller + bolt db * ctrl.db - the controller bolt db, with the current state of the model The location of all three is controlled by the raft/dataDir config property. @@ -28,9 +31,9 @@ raft: dataDir: /var/ziti/data/ ``` -When an HA controller starts up, it will first apply the newest snapshot, then any newer journal entries -that aren't yet contained in a snapshot. This means that an HA controller should start with a -blank DB that can be overwritten by snapshot and/or have journal entries applied to it. So an HA +When an HA controller starts up, it will first apply the newest snapshot, then any newer journal +entries that aren't yet contained in a snapshot. This means that an HA controller should start with +a blank DB that can be overwritten by snapshot and/or have journal entries applied to it. So an HA controller will delete or rename the existing controller database and start with a fresh bolt db. ### Bootstrapping @@ -39,9 +42,9 @@ controller will delete or rename the existing controller database and start with Initial cluster setup can be configured either in the config file or via agent commands. -The controller will not fully start until the raft cluster has bootstrapped. The minimum -number of cluster members is set in the config file. Recommended cluster sizes are -3, 5 or 7. A cluster size of 1 is mostly useful for testing and development. +The controller will not fully start until the raft cluster has bootstrapped. The minimum number of +cluster members is set in the config file. Recommended cluster sizes are 3, 5 or 7. A cluster size +of 1 is mostly useful for testing and development. **Config File Example** @@ -54,9 +57,9 @@ raft: - tls:192.168.1.101 ``` -Note that `bootstrapMembers` can only be used when setting the cluster up for the first time -and should only be used on a single node. It cannot be used later to add additional nodes -to an existing cluster. +Note that `bootstrapMembers` can only be used when setting the cluster up for the first time and +should only be used on a single node. It cannot be used later to add additional nodes to an existing +cluster. **Agent Comands** @@ -80,11 +83,10 @@ ziti agent cluster transfer-leadership [new leader id] #### Edge Admin Initialization -Because RAFT is now the system of record, the previous pattern for configuring the default -admin won't work. In a non-HA system you initialized the controller raft DB with an admin -user directly. If you do this with an HA system, the changes you made directly to the DB -will be lost and replaced by whatever is in raft. To initialize an HA controller cluster -use the new agent command. +Because RAFT is now the system of record, the previous pattern for configuring the default admin +won't work. In a non-HA system you initialized the controller raft DB with an admin user directly. +If you do this with an HA system, the changes you made directly to the DB will be lost and replaced +by whatever is in raft. To initialize an HA controller cluster use the new agent command. ```shell ziti agent controller init @@ -94,36 +96,36 @@ The controller will not fully start until the edge admin has been initialized. ### Snapshot Application and Restarts -If a controller receives a snapshot to apply after starting up, it will apply the snapshot and -then terminate. This assumes that there is a restart script which will bring the controller -back up after it terminates. +If a controller receives a snapshot to apply after starting up, it will apply the snapshot and then +terminate. This assumes that there is a restart script which will bring the controller back up after +it terminates. -This should only happen if a controller is connected to the cluster and then gets disconnected -for long enough that a snapshot is created while it's disconnected. Because applying a snapshot -requires replacing the underlying controller bolt DB, the easiest way to do that is restart. -That way we don't have to worry about replacing the bolt DB underneath a running system. +This should only happen if a controller is connected to the cluster and then gets disconnected for +long enough that a snapshot is created while it's disconnected. Because applying a snapshot requires +replacing the underlying controller bolt DB, the easiest way to do that is restart. That way we +don't have to worry about replacing the bolt DB underneath a running system. ### Metrics -In an HA system, routers will send metrics to all controllers to which they are connected. -There is a new `doNotPropagate` flag in the metrics message, which will be set to false -until the router has successfully delivered the metrics message to a controller. The flag -will then be set to true. So the first controller to get the metrics message is expected -to deliver the metrics message to the events system for external integrators. The other -controllers will have `doNotPropage` set to true, and will only use the metrics message -internally, to update routing data. +In an HA system, routers will send metrics to all controllers to which they are connected. There is +a new `doNotPropagate` flag in the metrics message, which will be set to false until the router has +successfully delivered the metrics message to a controller. The flag will then be set to true. So +the first controller to get the metrics message is expected to deliver the metrics message to the +events system for external integrators. The other controllers will have `doNotPropage` set to true, +and will only use the metrics message internally, to update routing data. ### Certificates There are many ways to set up certificates, so this will just cover a recommended configuration. -The primary thing to ensure is that controllers have a shared root of trust. A configuration -that works would be as follows: +The primary thing to ensure is that controllers have a shared root of trust. A configuration that +works would be as follows: 1. Create a self-signed root CA 2. Create an intermediate signing cert for each controller 3. Create a server cert using the signing cert for each controller -4. Make sure that the CA bundle for each server includes both the root CA and the intermediate CA for that server +4. Make sure that the CA bundle for each server includes both the root CA and the intermediate CA + for that server Note that controller server certs must contain a SPIFFE id of the form @@ -140,7 +142,8 @@ spiffe://example.com/controller/ctrl1 **SPIFFE ID Notes:** -* This ID must be set as the only URI in the `X509v3 Subject Alternative Name` field in the certificate. +* This ID must be set as the only URI in the `X509v3 Subject Alternative Name` field in the + certificate. * These IDs are used to allow the controllers to identify each during the mTLS negotiation. * The OpenZiti CLI supports creating SPIFFE IDs in your certs * Use the `--trust-domain` flag when creating CAs @@ -158,19 +161,18 @@ Controllers now establish connections with each other, for two purposes. Both kinds of traffic flow over the same connection. -These connections do not require any extra open ports as we are using the control -channel listener to listen to both router and controller connections. As part of -the connection process the connection type is provided and the appropriate -authentication and connection setup happens based on the connection type. If no -connection type is provided, it's assumed to be a router. +These connections do not require any extra open ports as we are using the control channel listener +to listen to both router and controller connections. As part of the connection process the +connection type is provided and the appropriate authentication and connection setup happens based on +the connection type. If no connection type is provided, it's assumed to be a router. ## Distributed Model -When looking at how to make the OpenZiti controller model distributed, we first looked at -what characteristics we needed for the model data. +When looking at how to make the OpenZiti controller model distributed, we first looked at what +characteristics we needed for the model data. -Model data is the information the controller needs to figure out what it can do. This -includes things like: +Model data is the information the controller needs to figure out what it can do. This includes +things like: * Services * Routers @@ -186,12 +188,14 @@ includes things like: * Reads happen all the time, from every client and as well as admins * Speed is very important. They affect how every client perceives the system. * Availability is very important. Without reading definitions, can’t create new connections - * Can be against stale data, if we get consistency within a reasonable timeframe (seconds to minutes) + * Can be against stale data, if we get consistency within a reasonable timeframe (seconds to + minutes) * Write characteristics * Writes only happen from administrators * Speed needs to be reasonable, but doesn't need to be blazing fast * Write availability can be interrupted, since it primarily affects management operations - * Must be consistent. Write validation can’t happen with stale data. Don’t want to have to deal with reconciling concurrent, contradictory write operations. + * Must be consistent. Write validation can’t happen with stale data. Don’t want to have to deal + with reconciling concurrent, contradictory write operations. * Generally involves controller to controller coordination Of the distribution mechanisms we looked at, RAFT had the best fit. @@ -217,23 +221,27 @@ So the OpenZiti controller uses RAFT to distribute the data model. Specifically The basic flow for model updates is as follows: 1. A client requests a model update via the REST API. -2. The controller checks if it is the raft cluster leader. If it is not, it forwards the request to the leader. -3. Once the request is on the leader, it applies the model update to the raft log. This involves getting a quorum of the controllers to accept the update. -4. One the update has been accepted, it will be executed on each node of the cluster. This will generate create one or more changes to the bolt database. -5. The results of the operation (success or failure) are returned to the controller which received the original REST request. +2. The controller checks if it is the raft cluster leader. If it is not, it forwards the request to + the leader. +3. Once the request is on the leader, it applies the model update to the raft log. This involves + getting a quorum of the controllers to accept the update. +4. One the update has been accepted, it will be executed on each node of the cluster. This will + generate create one or more changes to the bolt database. +5. The results of the operation (success or failure) are returned to the controller which received + the original REST request. 6. The controller waits until the operation has been applied locally. 7. The result is returned to the REST client. ### Reads -Reads are always done to the local bolt database for performance. The assumption is that if something -like a policy change is delayed, it may temporarily allow a circuit to be created, but as soon as -the policy update is applied, it will make changes to circuits as necessary. +Reads are always done to the local bolt database for performance. The assumption is that if +something like a policy change is delayed, it may temporarily allow a circuit to be created, but as +soon as the policy update is applied, it will make changes to circuits as necessary. ## Runtime Data -In addition to model data, the controller also manages some amount of runtime data. This data is -for running OpenZiti's core functions, i.e. managing the flow of data across the mesh, along with +In addition to model data, the controller also manages some amount of runtime data. This data is for +running OpenZiti's core functions, i.e. managing the flow of data across the mesh, along with related authentication data. So this includes things like: * Links @@ -250,37 +258,36 @@ Runtime data has different characteristics than the model data does. * Reads **and** writes must be very fast * Generally involves sdk to controller or controller to router coordination -Because writes must also be fast, RAFT is not a good candidate for storing this data. -Good performance is critical for these components, so they are each evaluated individually. +Because writes must also be fast, RAFT is not a good candidate for storing this data. Good +performance is critical for these components, so they are each evaluated individually. ### Links -Each controller currently needs to know about links so that it can make routing decisions. -However, links exist on routers. So, routers are the source of record for links. -When a router connects to a controller, the router will tell the controller about any -links that it already has. The controller will ask to fill in any missing links and -the controller will ensure that it doesn't create duplicate links if multiple -controllers request the same link be created. If there are duplicates, the router -will inform the controller of the existing link. +Each controller currently needs to know about links so that it can make routing decisions. However, +links exist on routers. So, routers are the source of record for links. When a router connects to a +controller, the router will tell the controller about any links that it already has. The controller +will ask to fill in any missing links and the controller will ensure that it doesn't create +duplicate links if multiple controllers request the same link be created. If there are duplicates, +the router will inform the controller of the existing link. -The allows the routers to properly handle link dials from multiple routers and keep -controllers up to date with the current known links. +The allows the routers to properly handle link dials from multiple routers and keep controllers up +to date with the current known links. ### Circuits Circuits were and continue to be stored in memory for both standalone and HA mode -controllers.Circuits are not distributed. Rather, each controller remains responsible -for any circuits that it created. - -When a router needs to initiate circuit creation it will pick the one with the lowest -response time and send a circuit creation request to that router. The controller -will establish a route. Route tables as well as the xgress endpoints now track -which controller is responsible for the associated circuit. This way when failures -or other notifications need to be sent, the router knows which controller to talk to. - -This gets routing working with multiple controllers without a major refactor. Future -work will likely delegate more routing control to the routers, so routing should -get more robust and distributed over time. +controllers.Circuits are not distributed. Rather, each controller remains responsible for any +circuits that it created. + +When a router needs to initiate circuit creation it will pick the one with the lowest response time +and send a circuit creation request to that router. The controller will establish a route. Route +tables as well as the xgress endpoints now track which controller is responsible for the associated +circuit. This way when failures or other notifications need to be sent, the router knows which +controller to talk to. + +This gets routing working with multiple controllers without a major refactor. Future work will +likely delegate more routing control to the routers, so routing should get more robust and +distributed over time. ### Api Sessions, Sessions, Posture Data diff --git a/go.mod b/go.mod index 45476153a..957891eff 100644 --- a/go.mod +++ b/go.mod @@ -14,13 +14,13 @@ require ( github.com/dineshappavoo/basex v0.0.0-20170425072625-481a6f6dc663 github.com/ef-ds/deque v1.0.4 github.com/emirpasic/gods v1.18.1 - github.com/fatih/color v1.15.0 + github.com/fatih/color v1.16.0 github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa github.com/go-acme/lego/v4 v4.14.2 github.com/go-openapi/errors v0.20.4 github.com/go-openapi/loads v0.21.2 github.com/go-openapi/runtime v0.26.0 - github.com/go-openapi/spec v0.20.9 + github.com/go-openapi/spec v0.20.11 github.com/go-openapi/strfmt v0.21.7 github.com/go-openapi/swag v0.22.4 github.com/go-openapi/validate v0.22.1 @@ -29,9 +29,9 @@ require ( github.com/google/go-cmp v0.6.0 github.com/google/gopacket v1.1.19 github.com/google/uuid v1.4.0 - github.com/gorilla/handlers v1.5.1 - github.com/gorilla/mux v1.8.0 - github.com/gorilla/websocket v1.5.0 + github.com/gorilla/handlers v1.5.2 + github.com/gorilla/mux v1.8.1 + github.com/gorilla/websocket v1.5.1 github.com/hashicorp/go-hclog v1.5.0 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/hashicorp/raft v1.5.0 @@ -47,17 +47,17 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/natefinch/lumberjack v2.0.0+incompatible github.com/openziti/agent v1.0.16 - github.com/openziti/channel/v2 v2.0.105 - github.com/openziti/edge-api v0.26.0 - github.com/openziti/foundation/v2 v2.0.33 - github.com/openziti/identity v1.0.66 + github.com/openziti/channel/v2 v2.0.111 + github.com/openziti/edge-api v0.26.1 + github.com/openziti/foundation/v2 v2.0.35 + github.com/openziti/identity v1.0.68 github.com/openziti/jwks v1.0.3 - github.com/openziti/metrics v1.2.37 - github.com/openziti/runzmd v1.0.33 - github.com/openziti/sdk-golang v0.20.129 - github.com/openziti/secretstream v0.1.13 - github.com/openziti/storage v0.2.23 - github.com/openziti/transport/v2 v2.0.113 + github.com/openziti/metrics v1.2.40 + github.com/openziti/runzmd v1.0.36 + github.com/openziti/sdk-golang v0.20.139 + github.com/openziti/secretstream v0.1.14 + github.com/openziti/storage v0.2.26 + github.com/openziti/transport/v2 v2.0.119 github.com/openziti/x509-claims v1.0.3 github.com/openziti/xweb/v2 v2.1.0 github.com/openziti/ziti-db-explorer v1.1.3 @@ -66,10 +66,10 @@ require ( github.com/rabbitmq/amqp091-go v1.8.1 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/russross/blackfriday v1.6.0 - github.com/shirou/gopsutil/v3 v3.23.9 + github.com/shirou/gopsutil/v3 v3.23.11 github.com/sirupsen/logrus v1.9.3 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e - github.com/spf13/cobra v1.7.0 + github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.17.0 github.com/stretchr/testify v1.8.4 @@ -77,11 +77,12 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 github.com/zitadel/oidc/v2 v2.7.0 go.etcd.io/bbolt v1.3.8 - golang.org/x/crypto v0.14.0 - golang.org/x/net v0.17.0 - golang.org/x/sync v0.4.0 - golang.org/x/sys v0.13.0 - golang.org/x/text v0.13.0 + go4.org v0.0.0-20180809161055-417644f6feb5 + golang.org/x/crypto v0.16.0 + golang.org/x/net v0.19.0 + golang.org/x/sync v0.5.0 + golang.org/x/sys v0.15.0 + golang.org/x/text v0.14.0 google.golang.org/protobuf v1.31.0 gopkg.in/AlecAivazis/survey.v1 v1.8.7 gopkg.in/resty.v1 v1.12.0 @@ -108,9 +109,9 @@ require ( github.com/dlclark/regexp2 v1.10.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/eliukblau/pixterm/pkg/ansimage v0.0.0-20191210081756-9fb6cf8c2f75 // indirect - github.com/felixge/httpsnoop v1.0.1 // indirect + github.com/felixge/httpsnoop v1.0.3 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/go-jose/go-jose/v3 v3.0.0 // indirect + github.com/go-jose/go-jose/v3 v3.0.1 // indirect github.com/go-logr/logr v1.3.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -170,18 +171,18 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect - go.mongodb.org/mongo-driver v1.12.1 // indirect + go.mongodb.org/mongo-driver v1.13.0 // indirect go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect - go.opentelemetry.io/otel v1.19.0 // indirect - go.opentelemetry.io/otel/metric v1.19.0 // indirect - go.opentelemetry.io/otel/trace v1.19.0 // indirect + go.opentelemetry.io/otel v1.20.0 // indirect + go.opentelemetry.io/otel/metric v1.20.0 // indirect + go.opentelemetry.io/otel/trace v1.20.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/image v0.13.0 // indirect golang.org/x/mod v0.13.0 // indirect golang.org/x/oauth2 v0.12.0 // indirect - golang.org/x/term v0.13.0 // indirect + golang.org/x/term v0.15.0 // indirect golang.org/x/tools v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index ae3db55fa..a24babfde 100644 --- a/go.sum +++ b/go.sum @@ -137,7 +137,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= @@ -181,10 +181,10 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= +github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= @@ -206,8 +206,8 @@ github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo= -github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= +github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= +github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -244,8 +244,8 @@ github.com/go-openapi/runtime v0.26.0 h1:HYOFtG00FM1UvqrcxbEJg/SwvDRvYLQKGhw2zaQ github.com/go-openapi/runtime v0.26.0/go.mod h1:QgRGeZwrUcSHdeh4Ka9Glvo0ug1LC5WyE+EV88plZrQ= github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= -github.com/go-openapi/spec v0.20.9 h1:xnlYNQAwKd2VQRRfwTEI0DcK+2cbuvI/0c7jx3gA8/8= -github.com/go-openapi/spec v0.20.9/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= +github.com/go-openapi/spec v0.20.11 h1:J/TzFDLTt4Rcl/l1PmyErvkqlJDncGvPTMnCI39I4gY= +github.com/go-openapi/spec v0.20.11/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg= @@ -380,17 +380,17 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -616,30 +616,30 @@ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYr github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openziti/agent v1.0.16 h1:9Saji+8hFE1NpzP2XzDhsVJbCrDlhixoLHfOpFt5Z+U= github.com/openziti/agent v1.0.16/go.mod h1:zfm53+PVWoGFzjGGgQdKby5749G6VRYHe+eQJmoVKy4= -github.com/openziti/channel/v2 v2.0.105 h1:WT2zFF7krZkYUfuXA+4tQxhYiiVWlldD3mKX3qJU9Ww= -github.com/openziti/channel/v2 v2.0.105/go.mod h1:++bV6FFgGUNxaBu7iOkkCa6rSiueU34Kd6f2LSCrEtU= +github.com/openziti/channel/v2 v2.0.111 h1:ZZDyUUFcyshitXjUqAMjdAKbaDMpgV7oX1Jp1I35Rc4= +github.com/openziti/channel/v2 v2.0.111/go.mod h1:abw0qwT0MzWvh1eI2P6D6CD17PRHL8EEo1d3DHCyCdM= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= -github.com/openziti/edge-api v0.26.0 h1:082hXjj8rnyMBZHYiB6jb4n7mCXtdMXpF2iCqZOv4IM= -github.com/openziti/edge-api v0.26.0/go.mod h1:/e1pK92L471fvOAwE/hLX5sqBuuo+NwI8vmL04dUHsM= -github.com/openziti/foundation/v2 v2.0.33 h1:8CP+fi4KsmzA4jDi54jibwFWWxKpd0rSiplzN9Z0Isw= -github.com/openziti/foundation/v2 v2.0.33/go.mod h1:dWR0g3NOka3uKz9MgUHq6dmuRLmSvunkyeuOXEW/5qU= -github.com/openziti/identity v1.0.66 h1:wCIVNCoiHmeicC9yM15FC0xe6jSic879ztN63fSD6hM= -github.com/openziti/identity v1.0.66/go.mod h1:grReHVqBwhECrnrAZCxNw4ZpA2I1ox66tYfPkfGuKJY= +github.com/openziti/edge-api v0.26.1 h1:osj2irTMMvoP5jLQwJOIKFEellK6AFyT6wB0NzDdalY= +github.com/openziti/edge-api v0.26.1/go.mod h1:bHEkOF9UTjGgjHhmsjnxxNybdijJ91jpdG1WFc9morU= +github.com/openziti/foundation/v2 v2.0.35 h1:4VaMwZ2kAy6jwBYeQIBN2m8rcGroTDX4A2Jp7NAKb6M= +github.com/openziti/foundation/v2 v2.0.35/go.mod h1:Xnb3IxP1e1UcgLggqSunEpCjH3iHozkPi9Bd9GESbwo= +github.com/openziti/identity v1.0.68 h1:SaFr7BeFQBoWQDiT28vUb8D9w7v6lIAK6/9RkwmV0OU= +github.com/openziti/identity v1.0.68/go.mod h1:HbOu3TQ032v8xE6xZWjO51azF4fUxRLjO/l/oGqJwUI= github.com/openziti/jwks v1.0.3 h1:hf8wkb+Cg4nH/HM0KROFd7u+C3DkRVcFZJ7tDV+4icc= github.com/openziti/jwks v1.0.3/go.mod h1:t4xxq8vlXGsPn29kiQVnZBBDDnEoOFqtJoHibkJunQQ= -github.com/openziti/metrics v1.2.37 h1:5yWvMwQT6X43LDlNVcUtqAPJQXfKtbWSYoCIiOfXztg= -github.com/openziti/metrics v1.2.37/go.mod h1:jIL9iilxby8tR98C18uZaSe6bRG15ItR8XF2hmMt8vs= -github.com/openziti/runzmd v1.0.33 h1:tOyjRoUuVXIo1z1pNU32jALWkMmhzsSaDrhLtuOn3Ts= -github.com/openziti/runzmd v1.0.33/go.mod h1:8c/uvZR/XWXQNllTq6LuTpfKL2DTNxfI2X2wYhgRwik= -github.com/openziti/sdk-golang v0.20.129 h1:FjvXsGFxEiHq89sNyLSvNymruACFW5tbhkgZ3VCg2pE= -github.com/openziti/sdk-golang v0.20.129/go.mod h1:ZpJ7HCcIQbp8XiSno3YXkfhoDIbgjCjS2ScK2bda8eo= -github.com/openziti/secretstream v0.1.13 h1:grp53Q5gCFPXv6okwWHDVvqBBk2BhD0ikHwfV3Adhnc= -github.com/openziti/secretstream v0.1.13/go.mod h1:M4DYavDc3TVF/eemNqp5Fa+zGuYTNa0HTGSz/GkgUzA= -github.com/openziti/storage v0.2.23 h1:R5ZBGDGC/LvOz3fE/GlevwbPZ3HL7VxYEvlhKuezvNU= -github.com/openziti/storage v0.2.23/go.mod h1:NZCrN2dLtRU73McVEflK5prDgYds9J54mMNz5DmgvZE= -github.com/openziti/transport/v2 v2.0.113 h1:xFPd1W00KqkFb62rRsRXmLqfgr9d9uk0CAVZegvtGhA= -github.com/openziti/transport/v2 v2.0.113/go.mod h1:TSDHV7RTGg/FinzfOP8cg86O53BCabXedANh3eUNics= +github.com/openziti/metrics v1.2.40 h1:gySRgR8prCPqaEjmUtX0eXFs7NkI9uPAzp+z6A8+JqA= +github.com/openziti/metrics v1.2.40/go.mod h1:HXdVryf3xpZfnY4VcaOjMxiBv+qw0wJlEJNLbooB9hY= +github.com/openziti/runzmd v1.0.36 h1:HOqTZFzTTFu52qmCAQfFvKDmCSl8ZqP1PQQ0UnJIA4E= +github.com/openziti/runzmd v1.0.36/go.mod h1:jYqummjskmFh63htJFF2SrUuvxNQifqd5REUhYVaY/A= +github.com/openziti/sdk-golang v0.20.139 h1:1TaRTd5KmSrfHR6W3ASuj651o37h4NOXTRC6K53Pf3k= +github.com/openziti/sdk-golang v0.20.139/go.mod h1:z2gUWwonLa+haq40cfsNE2P23RoD+SZhxWulG7w7aI0= +github.com/openziti/secretstream v0.1.14 h1:Ta+nB5Prcct+L5LIKUA1nE56QhWS6lMPQYTlpxUltU0= +github.com/openziti/secretstream v0.1.14/go.mod h1:/hhuLfu+GIv0+cnapfsu/VOnXEvmTt3GKtCu+lQ0RIw= +github.com/openziti/storage v0.2.26 h1:15EbOC6A//dsdLSs/RYJP6Qn3Rj6Od4btXEWGezatxc= +github.com/openziti/storage v0.2.26/go.mod h1:pDCkPIN7h9L+FyJP+hcfOwk+GofzrrNoYsAThOjNza0= +github.com/openziti/transport/v2 v2.0.119 h1:KOgHU+9EZUVPvv8ncifqHmNEcFUHbJHigo3jyPvWnOc= +github.com/openziti/transport/v2 v2.0.119/go.mod h1:H2IIBP6ed9isE/eJHGXtAZL0d73ApYOpLG9sSvutNNI= github.com/openziti/x509-claims v1.0.3 h1:HNdQ8Nf1agB3lBs1gahcO6zfkeS4S5xoQ2/PkY4HRX0= github.com/openziti/x509-claims v1.0.3/go.mod h1:Z0WIpBm6c4ecrpRKrou6Gk2wrLWxJO/+tuUwKh8VewE= github.com/openziti/xweb/v2 v2.1.0 h1:Xhh3C2pZkq/Prr65V+SfFSibLDYteoc4f62KQCcTZF4= @@ -728,8 +728,8 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shirou/gopsutil/v3 v3.23.9 h1:ZI5bWVeu2ep4/DIxB4U9okeYJ7zp/QLTO4auRb/ty/E= -github.com/shirou/gopsutil/v3 v3.23.9/go.mod h1:x/NWSb71eMcjFIO0vhyGW5nZ7oSIgVjrCnADckb85GA= +github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ= +github.com/shirou/gopsutil/v3 v3.23.11/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -788,8 +788,8 @@ github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -875,8 +875,8 @@ go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsX go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= -go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= -go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= +go.mongodb.org/mongo-driver v1.13.0 h1:67DgFFjYOCMWdtTEmKFpV3ffWlFnh+CYZ8ZS/tXWUfY= +go.mongodb.org/mongo-driver v1.13.0/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 h1:CCriYyAfq1Br1aIYettdHZTy8mBTIPo7We18TuO/bak= go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= @@ -887,13 +887,13 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= -go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= -go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= -go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= +go.opentelemetry.io/otel v1.20.0 h1:vsb/ggIY+hUjD/zCAQHpzTmndPqv/ml2ArbsbfBYTAc= +go.opentelemetry.io/otel v1.20.0/go.mod h1:oUIGj3D77RwJdM6PPZImDpSZGDvkD9fhesHny69JFrs= +go.opentelemetry.io/otel/metric v1.20.0 h1:ZlrO8Hu9+GAhnepmRGhSU7/VkpjrNowxRN9GyKR4wzA= +go.opentelemetry.io/otel/metric v1.20.0/go.mod h1:90DRw3nfK4D7Sm/75yQ00gTJxtkBxX+wu6YaNymbpVM= go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY= -go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= -go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +go.opentelemetry.io/otel/trace v1.20.0 h1:+yxVAPZPbQhbC3OfAkeIVTky6iTFpcr4SiY9om7mXSQ= +go.opentelemetry.io/otel/trace v1.20.0/go.mod h1:HJSK7F/hA5RlzpZ0zKDCHCDHm556LCDtKaAo6JmBFUU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -906,6 +906,7 @@ go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go4.org v0.0.0-20180809161055-417644f6feb5 h1:+hE86LblG4AyDgwMCLTE6FOlM9+qjHSYS+rKqxUVdsM= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= @@ -933,8 +934,9 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1035,8 +1037,9 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1068,8 +1071,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180606202747-9527bec2660b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1155,16 +1158,17 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1178,8 +1182,9 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/router/env/env.go b/router/env/env.go index b40368524..2dc39f18b 100644 --- a/router/env/env.go +++ b/router/env/env.go @@ -18,11 +18,12 @@ package env import ( "github.com/openziti/channel/v2" - "github.com/openziti/ziti/router/xgress" - "github.com/openziti/ziti/router/xlink" "github.com/openziti/foundation/v2/goroutines" + "github.com/openziti/foundation/v2/versions" "github.com/openziti/identity" "github.com/openziti/metrics" + "github.com/openziti/ziti/router/xgress" + "github.com/openziti/ziti/router/xlink" ) type RouterEnv interface { @@ -38,4 +39,5 @@ type RouterEnv interface { RenderJsonConfig() (string, error) GetHeartbeatOptions() HeartbeatOptions GetRateLimiterPool() goroutines.Pool + GetVersionInfo() versions.VersionProvider } diff --git a/router/handler_ctrl/bind.go b/router/handler_ctrl/bind.go index 866548cc7..1a2c1de74 100644 --- a/router/handler_ctrl/bind.go +++ b/router/handler_ctrl/bind.go @@ -22,11 +22,11 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" + "github.com/openziti/foundation/v2/goroutines" "github.com/openziti/ziti/common/metrics" + "github.com/openziti/ziti/common/trace" "github.com/openziti/ziti/router/env" "github.com/openziti/ziti/router/forwarder" - "github.com/openziti/ziti/common/trace" - "github.com/openziti/foundation/v2/goroutines" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -70,6 +70,7 @@ func (self *bindHandler) BindChannel(binding channel.Binding) error { binding.AddTypedReceiveHandler(newDialHandler(self.env)) binding.AddTypedReceiveHandler(newRouteHandler(binding.GetChannel(), self.env, self.forwarder, self.xgDialerPool)) binding.AddTypedReceiveHandler(newValidateTerminatorsHandler(self.env)) + binding.AddTypedReceiveHandler(newValidateTerminatorsV2Handler(self.env)) binding.AddTypedReceiveHandler(newUnrouteHandler(self.forwarder)) binding.AddTypedReceiveHandler(newTraceHandler(self.env.GetRouterId(), self.forwarder.TraceController(), binding.GetChannel())) binding.AddTypedReceiveHandler(newInspectHandler(self.env, self.forwarder)) diff --git a/router/handler_ctrl/validate_terminators_v2.go b/router/handler_ctrl/validate_terminators_v2.go new file mode 100644 index 000000000..0a06666d2 --- /dev/null +++ b/router/handler_ctrl/validate_terminators_v2.go @@ -0,0 +1,111 @@ +/* + Copyright NetFoundry Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package handler_ctrl + +import ( + "github.com/michaelquigley/pfxlog" + "github.com/openziti/channel/v2" + "github.com/openziti/channel/v2/protobufs" + "github.com/openziti/ziti/common/pb/ctrl_pb" + "github.com/openziti/ziti/router/env" + "github.com/openziti/ziti/router/xgress" + "google.golang.org/protobuf/proto" +) + +type validateTerminatorsV2Handler struct { + env env.RouterEnv +} + +func newValidateTerminatorsV2Handler(env env.RouterEnv) *validateTerminatorsV2Handler { + return &validateTerminatorsV2Handler{ + env: env, + } +} + +func (handler *validateTerminatorsV2Handler) ContentType() int32 { + return int32(ctrl_pb.ContentType_ValidateTerminatorsV2RequestType) +} + +func (handler *validateTerminatorsV2Handler) HandleReceive(msg *channel.Message, ch channel.Channel) { + log := pfxlog.ContextLogger(ch.Label()) + + req := &ctrl_pb.ValidateTerminatorsV2Request{} + if err := proto.Unmarshal(msg.Body, req); err != nil { + log.Errorf("error unmarshaling validate terminators V2 msg (%v)", err) + return + } + + // because this sends AND receives messages, must be done async, otherwise message responses will never + // be received, as this handler will block processing + go handler.validateTerminators(msg, ch, req) +} + +func (handler *validateTerminatorsV2Handler) validateTerminators(msg *channel.Message, ch channel.Channel, req *ctrl_pb.ValidateTerminatorsV2Request) { + log := pfxlog.ContextLogger(ch.Label()) + + log.Debugf("validate terminators route request received: %v terminators", len(req.Terminators)) + dialers := map[string]xgress.Dialer{} + + response := &ctrl_pb.ValidateTerminatorsV2Response{ + States: map[string]*ctrl_pb.RouterTerminatorState{}, + } + + for _, terminator := range req.Terminators { + binding := terminator.Binding + dialer := dialers[binding] + if dialer == nil { + if factory, err := xgress.GlobalRegistry().Factory(binding); err == nil { + if dialer, err = factory.CreateDialer(handler.env.GetDialerCfg()[binding]); err == nil { + dialers[binding] = dialer + } + } + } + + if dialer == nil { + response.States[terminator.Id] = &ctrl_pb.RouterTerminatorState{ + Valid: false, + Reason: ctrl_pb.TerminatorInvalidReason_UnknownBinding, + } + } else if inspectable, ok := dialer.(xgress.InspectableDialer); ok { + valid, state := inspectable.InspectTerminator(terminator.Id, terminator.Address, req.FixInvalid) + response.States[terminator.Id] = &ctrl_pb.RouterTerminatorState{ + Valid: valid, + Detail: state, + Reason: ctrl_pb.TerminatorInvalidReason_UnknownTerminator, + } + } else if !dialer.IsTerminatorValid(terminator.Id, terminator.Address) { + response.States[terminator.Id] = &ctrl_pb.RouterTerminatorState{ + Valid: false, + Reason: ctrl_pb.TerminatorInvalidReason_UnknownTerminator, + } + } else { + response.States[terminator.Id] = &ctrl_pb.RouterTerminatorState{ + Valid: true, + Detail: "valid", + } + } + } + + err := protobufs.MarshalTyped(response). + ReplyTo(msg). + WithTimeout(handler.env.GetNetworkControllers().DefaultRequestTimeout()). + SendAndWaitForWire(ch) + + if err != nil { + log.WithError(err).Error("failed to send validate terminators v2 response") + } +} diff --git a/router/handler_link/ack.go b/router/handler_link/ack.go index e6957443f..82ccc1437 100644 --- a/router/handler_link/ack.go +++ b/router/handler_link/ack.go @@ -17,43 +17,23 @@ package handler_link import ( - "github.com/ef-ds/deque" "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" "github.com/openziti/ziti/router/forwarder" "github.com/openziti/ziti/router/xgress" "github.com/openziti/ziti/router/xlink" - "sync/atomic" ) type ackHandler struct { - link xlink.Xlink - forwarder *forwarder.Forwarder - acks *deque.Deque - ackIngest chan *xgress.Acknowledgement - ackForward chan *xgress.Acknowledgement - acksQueueSize int64 - closeNotify <-chan struct{} + link xlink.Xlink + forwarder *forwarder.Forwarder } -func newAckHandler(link xlink.Xlink, forwarder *forwarder.Forwarder, closeNotify <-chan struct{}) *ackHandler { - result := &ackHandler{ - link: link, - forwarder: forwarder, - acks: deque.New(), - ackIngest: make(chan *xgress.Acknowledgement, 16), - ackForward: make(chan *xgress.Acknowledgement, 1), - closeNotify: closeNotify, +func newAckHandler(link xlink.Xlink, forwarder *forwarder.Forwarder) *ackHandler { + return &ackHandler{ + link: link, + forwarder: forwarder, } - - go result.ackIngester() - go result.ackForwarder() - - forwarder.MetricsRegistry().FuncGauge("xgress.acks.queue_size", func() int64 { - return atomic.LoadInt64(&result.acksQueueSize) - }) - - return result } func (self *ackHandler) ContentType() int32 { @@ -61,63 +41,19 @@ func (self *ackHandler) ContentType() int32 { } func (self *ackHandler) HandleReceive(msg *channel.Message, ch channel.Channel) { - if ack, err := xgress.UnmarshallAcknowledgement(msg); err == nil { - select { - case self.ackIngest <- ack: - case <-self.closeNotify: - } - } else { + ack, err := xgress.UnmarshallAcknowledgement(msg) + if err != nil { pfxlog.ContextLogger(ch.Label()). WithField("linkId", self.link.Id()). WithField("routerId", self.link.DestinationId()). - WithError(err). - Error("error unmarshalling ack") + WithError(err).Error("error unmarshalling ack") + return } -} - -func (self *ackHandler) ackIngester() { - var next *xgress.Acknowledgement - for { - if next == nil { - if val, _ := self.acks.PopFront(); val != nil { - next = val.(*xgress.Acknowledgement) - } - } - if next == nil { - select { - case ack := <-self.ackIngest: - self.acks.PushBack(ack) - case <-self.closeNotify: - return - } - } else { - select { - case ack := <-self.ackIngest: - self.acks.PushBack(ack) - case self.ackForward <- next: - next = nil - case <-self.closeNotify: - return - } - } - atomic.StoreInt64(&self.acksQueueSize, int64(self.acks.Len())) - } -} - -func (self *ackHandler) ackForwarder() { - logger := pfxlog.Logger() - for { - select { - case ack := <-self.ackForward: - if err := self.forwarder.ForwardAcknowledgement(xgress.Address(self.link.Id()), ack); err != nil { - logger.WithField("linkId", self.link.Id()). - WithField("routerId", self.link.DestinationId()). - WithError(err). - Debug("unable to forward acknowledgement") - } - case <-self.closeNotify: - return - } + if err = self.forwarder.ForwardAcknowledgement(xgress.Address(self.link.Id()), ack); err != nil { + pfxlog.ContextLogger(ch.Label()). + WithField("linkId", self.link.Id()). + WithField("routerId", self.link.DestinationId()). + WithError(err).Debug("unable to forward acknowledgement") } } diff --git a/router/handler_link/ack_test.go b/router/handler_link/ack_test.go deleted file mode 100644 index cb6fe58ee..000000000 --- a/router/handler_link/ack_test.go +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package handler_link - -import ( - "sync/atomic" - "testing" -) - -// A simple test to check for failure of alignment on atomic operations for 64 bit variables in a struct -func Test64BitAlignment(t *testing.T) { - defer func() { - if r := recover(); r != nil { - t.Errorf("One of the variables that was tested is not properly 64-bit aligned.") - } - }() - - ah := ackHandler{} - - atomic.LoadInt64(&ah.acksQueueSize) -} diff --git a/router/handler_link/bind.go b/router/handler_link/bind.go index c3dd7563d..236a5dfa0 100644 --- a/router/handler_link/bind.go +++ b/router/handler_link/bind.go @@ -5,15 +5,15 @@ import ( "github.com/openziti/channel/v2" "github.com/openziti/channel/v2/latency" "github.com/openziti/channel/v2/protobufs" + "github.com/openziti/foundation/v2/concurrenz" + nfpem "github.com/openziti/foundation/v2/pem" + "github.com/openziti/metrics" "github.com/openziti/ziti/common/pb/ctrl_pb" "github.com/openziti/ziti/common/trace" "github.com/openziti/ziti/router/env" "github.com/openziti/ziti/router/forwarder" metrics2 "github.com/openziti/ziti/router/metrics" "github.com/openziti/ziti/router/xlink" - "github.com/openziti/foundation/v2/concurrenz" - nfpem "github.com/openziti/foundation/v2/pem" - "github.com/openziti/metrics" "github.com/pkg/errors" "github.com/sirupsen/logrus" "time" @@ -74,7 +74,7 @@ func (self *bindHandler) BindChannel(binding channel.Binding) error { binding.AddCloseHandler(newCloseHandler(self.xlink, self.ctrl, self.forwarder, closeNotify, self.xlinkRegistry)) binding.AddErrorHandler(newErrorHandler(self.xlink, self.ctrl)) binding.AddTypedReceiveHandler(newPayloadHandler(self.xlink, self.forwarder)) - binding.AddTypedReceiveHandler(newAckHandler(self.xlink, self.forwarder, closeNotify)) + binding.AddTypedReceiveHandler(newAckHandler(self.xlink, self.forwarder)) binding.AddTypedReceiveHandler(&latency.LatencyHandler{}) binding.AddTypedReceiveHandler(newControlHandler(self.xlink, self.forwarder)) binding.AddPeekHandler(metrics2.NewChannelPeekHandler(self.xlink.Id(), self.forwarder.MetricsRegistry())) diff --git a/router/xgress/link_send_buffer.go b/router/xgress/link_send_buffer.go index 75052bfb3..9f7c751ab 100644 --- a/router/xgress/link_send_buffer.go +++ b/router/xgress/link_send_buffer.go @@ -18,8 +18,8 @@ package xgress import ( "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/common/inspect" "github.com/openziti/foundation/v2/info" + "github.com/openziti/ziti/common/inspect" "github.com/pkg/errors" "github.com/sirupsen/logrus" "math" @@ -105,7 +105,7 @@ func NewLinkSendBuffer(x *Xgress) *LinkSendBuffer { x: x, buffer: make(map[int32]*txPayload), newlyBuffered: make(chan *txPayload, x.Options.TxQueueSize), - newlyReceivedAcks: make(chan *Acknowledgement), + newlyReceivedAcks: make(chan *Acknowledgement, 2), closeNotify: make(chan struct{}), windowsSize: x.Options.TxPortalStartSize, retxThreshold: x.Options.RetxStartMs, diff --git a/router/xgress/xgress.go b/router/xgress/xgress.go index d9f2a132b..b6ae4b170 100644 --- a/router/xgress/xgress.go +++ b/router/xgress/xgress.go @@ -30,13 +30,13 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" - "github.com/openziti/ziti/controller/xt" - "github.com/openziti/ziti/common/inspect" - "github.com/openziti/ziti/common/logcontext" "github.com/openziti/foundation/v2/concurrenz" "github.com/openziti/foundation/v2/debugz" "github.com/openziti/foundation/v2/info" "github.com/openziti/identity" + "github.com/openziti/ziti/common/inspect" + "github.com/openziti/ziti/common/logcontext" + "github.com/openziti/ziti/controller/xt" "github.com/sirupsen/logrus" ) @@ -72,6 +72,11 @@ type Dialer interface { IsTerminatorValid(id string, destination string) bool } +type InspectableDialer interface { + Dialer + InspectTerminator(id string, destination string, fixInvalid bool) (bool, string) +} + type Factory interface { CreateListener(optionsData OptionsData) (Listener, error) CreateDialer(optionsData OptionsData) (Dialer, error) diff --git a/router/xgress_edge/accept.go b/router/xgress_edge/accept.go index a13d22994..dc10b7f6a 100644 --- a/router/xgress_edge/accept.go +++ b/router/xgress_edge/accept.go @@ -21,8 +21,8 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" "github.com/openziti/channel/v2/latency" - "github.com/openziti/ziti/common/cert" "github.com/openziti/sdk-golang/ziti/edge" + "github.com/openziti/ziti/common/cert" "math" ) diff --git a/router/xgress_edge/dialer.go b/router/xgress_edge/dialer.go index b5197d9c8..4967ac050 100644 --- a/router/xgress_edge/dialer.go +++ b/router/xgress_edge/dialer.go @@ -23,10 +23,10 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" + "github.com/openziti/sdk-golang/ziti/edge" "github.com/openziti/ziti/common/logcontext" "github.com/openziti/ziti/controller/xt" "github.com/openziti/ziti/router/xgress" - "github.com/openziti/sdk-golang/ziti/edge" "github.com/pkg/errors" ) @@ -36,10 +36,30 @@ type dialer struct { } func (dialer *dialer) IsTerminatorValid(id string, destination string) bool { + valid, _ := dialer.InspectTerminator(id, destination, true) + return valid +} + +func (dialer *dialer) InspectTerminator(id string, destination string, fixInvalid bool) (bool, string) { terminatorAddress := strings.TrimPrefix(destination, "hosted:") pfxlog.Logger().Debug("looking up hosted service conn") terminator, found := dialer.factory.hostedServices.Get(terminatorAddress) - return found && terminator.terminatorId.Load() == id + if found && terminator.terminatorId.Load() == id { + updated := terminator.state.CompareAndSwap(TerminatorStateEstablishing, TerminatorStateEstablished) || + terminator.state.CompareAndSwap(TerminatorStatePendingEstablishment, TerminatorStateEstablished) + + if updated { + dialer.factory.hostedServices.notifyTerminatorCreated(id) + } + + result, err := terminator.inspect(fixInvalid) + if err != nil { + return true, err.Error() + } + return result.Type == edge.ConnTypeBind, result.Detail + } + + return false, "terminator not found" } func newDialer(factory *Factory, options *Options) xgress.Dialer { diff --git a/router/xgress_edge/fabric.go b/router/xgress_edge/fabric.go index c8a3640dc..229adf774 100644 --- a/router/xgress_edge/fabric.go +++ b/router/xgress_edge/fabric.go @@ -19,14 +19,16 @@ package xgress_edge import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" - "github.com/openziti/ziti/router/xgress_common" - "github.com/openziti/ziti/router/xgress" "github.com/openziti/foundation/v2/concurrenz" "github.com/openziti/sdk-golang/ziti/edge" + "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/router/xgress" + "github.com/openziti/ziti/router/xgress_common" "github.com/pkg/errors" "io" "math" "sync/atomic" + "time" ) // headers to pass through fabric to the other side @@ -38,15 +40,60 @@ var headersFromFabric = map[uint8]int32{ xgress_common.PayloadFlagsHeader: edge.FlagsHeader, } +type terminatorState int + +const ( + TerminatorStatePendingEstablishment terminatorState = 0 + TerminatorStateEstablishing terminatorState = 1 + TerminatorStateEstablished terminatorState = 2 + TerminatorStateDeleting terminatorState = 3 +) + +func (self terminatorState) String() string { + switch self { + case TerminatorStatePendingEstablishment: + return "pending-establishment" + case TerminatorStateEstablishing: + return "establishing" + case TerminatorStateEstablished: + return "established" + case TerminatorStateDeleting: + return "deleting" + default: + return "unknown" + } +} + type edgeTerminator struct { edge.MsgChannel edgeClientConn *edgeClientConn + terminatorId concurrenz.AtomicValue[string] + listenerId string token string instance string - terminatorId concurrenz.AtomicValue[string] + instanceSecret []byte + cost uint16 + precedence edge_ctrl_pb.TerminatorPrecedence + hostData map[uint32][]byte assignIds bool onClose func() v2 bool + state concurrenz.AtomicValue[terminatorState] + postValidate bool +} + +func (self *edgeTerminator) inspect(fixInvalidTerminators bool) (*edge.InspectResult, error) { + msg := channel.NewMessage(edge.ContentTypeConnInspectRequest, nil) + msg.PutUint32Header(edge.ConnIdHeader, self.Id()) + resp, err := msg.WithTimeout(10 * time.Second).SendForReply(self.Channel) + if err != nil { + return nil, errors.New("unable to check status with sdk client") + } + result, err := edge.UnmarshalInspectResult(resp) + if result != nil && result.Type != edge.ConnTypeBind && fixInvalidTerminators { + self.close(true, "terminator invalid") + } + return result, err } func (self *edgeTerminator) nextDialConnId() uint32 { @@ -61,7 +108,8 @@ func (self *edgeTerminator) nextDialConnId() uint32 { func (self *edgeTerminator) close(notify bool, reason string) { logger := pfxlog.Logger(). WithField("terminatorId", self.terminatorId.Load()). - WithField("token", self.token) + WithField("token", self.token). + WithField("reason", reason) if notify && !self.IsClosed() { // Notify edge client of close @@ -75,6 +123,10 @@ func (self *edgeTerminator) close(notify bool, reason string) { if self.v2 { if terminatorId := self.terminatorId.Load(); terminatorId != "" { if self.terminatorId.CompareAndSwap(terminatorId, "") { + logger.Debug("removing terminator on router") + self.edgeClientConn.listener.factory.hostedServices.Delete(terminatorId) + + self.state.Store(TerminatorStateDeleting) logger.Info("removing terminator on controller") ctrlCh := self.edgeClientConn.listener.factory.ctrls.AnyCtrlChannel() if ctrlCh == nil { @@ -82,14 +134,11 @@ func (self *edgeTerminator) close(notify bool, reason string) { } else if err := self.edgeClientConn.removeTerminator(ctrlCh, self.token, terminatorId); err != nil { logger.WithError(err).Error("failed to remove terminator") } else { - logger.Info("Successfully removed terminator on channel close") + logger.Info("Successfully removed terminator") } } else { logger.Warn("edge terminator closing, but no terminator id set, so can't remove on controller") } - - logger.Debug("removing terminator on router") - self.edgeClientConn.listener.factory.hostedServices.Delete(self.token) } } else { if terminatorId := self.terminatorId.Load(); terminatorId != "" { @@ -100,7 +149,7 @@ func (self *edgeTerminator) close(notify bool, reason string) { } else if err := self.edgeClientConn.removeTerminator(ctrlCh, self.token, terminatorId); err != nil { logger.WithError(err).Error("failed to remove terminator") } else { - logger.Info("Successfully removed terminator on channel close") + logger.Info("successfully removed terminator") } } else { logger.Warn("edge terminator closing, but no terminator id set, so can't remove on controller") diff --git a/router/xgress_edge/factory.go b/router/xgress_edge/factory.go index ea25f7dc7..2ad1b8666 100644 --- a/router/xgress_edge/factory.go +++ b/router/xgress_edge/factory.go @@ -20,24 +20,23 @@ import ( "fmt" "github.com/michaelquigley/pfxlog" "github.com/openziti/channel/v2" + "github.com/openziti/foundation/v2/versions" + "github.com/openziti/metrics" + "github.com/openziti/transport/v2" + "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + "github.com/openziti/ziti/router" + "github.com/openziti/ziti/router/env" "github.com/openziti/ziti/router/fabric" "github.com/openziti/ziti/router/handler_edge_ctrl" "github.com/openziti/ziti/router/internal/apiproxy" "github.com/openziti/ziti/router/internal/edgerouter" - "github.com/openziti/ziti/router" - "github.com/openziti/ziti/router/env" "github.com/openziti/ziti/router/xgress" - "github.com/openziti/foundation/v2/versions" - "github.com/openziti/identity" - "github.com/openziti/metrics" - "github.com/openziti/transport/v2" "github.com/pkg/errors" "strings" "time" ) type Factory struct { - id *identity.TokenId ctrls env.NetworkControllers enabled bool routerConfig *router.Config @@ -47,6 +46,7 @@ type Factory struct { versionProvider versions.VersionProvider certChecker *CertExpirationChecker metricsRegistry metrics.Registry + env env.RouterEnv } func (factory *Factory) GetNetworkControllers() env.NetworkControllers { @@ -57,10 +57,6 @@ func (factory *Factory) Enabled() bool { return factory.enabled } -const ( - WsType = "ws" -) - func (factory *Factory) BindChannel(binding channel.Binding) error { binding.AddTypedReceiveHandler(handler_edge_ctrl.NewHelloHandler(factory.stateManager, factory.edgeRouterConfig.EdgeListeners)) @@ -70,14 +66,18 @@ func (factory *Factory) BindChannel(binding channel.Binding) error { binding.AddTypedReceiveHandler(handler_edge_ctrl.NewApiSessionRemovedHandler(factory.stateManager)) binding.AddTypedReceiveHandler(handler_edge_ctrl.NewApiSessionUpdatedHandler(factory.stateManager)) binding.AddTypedReceiveHandler(handler_edge_ctrl.NewSigningCertAddedHandler(factory.stateManager)) - binding.AddTypedReceiveHandler(handler_edge_ctrl.NewExtendEnrollmentCertsHandler(factory.routerConfig.Id, func() { + binding.AddTypedReceiveHandler(handler_edge_ctrl.NewExtendEnrollmentCertsHandler(factory.env.GetRouterId(), func() { factory.certChecker.CertsUpdated() })) + binding.AddReceiveHandlerF(int32(edge_ctrl_pb.ContentType_CreateTerminatorV2ResponseType), factory.hostedServices.HandleCreateTerminatorResponse) return nil } func (factory *Factory) NotifyOfReconnect(ch channel.Channel) { + pfxlog.Logger().Info("control channel reconnected, re-establishing hosted services") + factory.hostedServices.HandleReconnect() + go factory.stateManager.ValidateSessions(ch, factory.edgeRouterConfig.SessionValidateChunkSize, factory.edgeRouterConfig.SessionValidateMinInterval, factory.edgeRouterConfig.SessionValidateMaxInterval) } @@ -86,11 +86,8 @@ func (factory *Factory) GetTraceDecoders() []channel.TraceMessageDecoder { } func (factory *Factory) Run(env env.RouterEnv) error { - factory.ctrls = env.GetNetworkControllers() - factory.stateManager.StartHeartbeat(env, factory.edgeRouterConfig.HeartbeatIntervalSeconds, env.GetCloseNotify()) - - factory.certChecker = NewCertExpirationChecker(factory.routerConfig.Id, factory.edgeRouterConfig, env.GetNetworkControllers(), env.GetCloseNotify()) + factory.certChecker = NewCertExpirationChecker(factory.env.GetRouterId(), factory.edgeRouterConfig, env.GetNetworkControllers(), env.GetCloseNotify()) go func() { if err := factory.certChecker.Run(); err != nil { @@ -118,8 +115,6 @@ func (factory *Factory) LoadConfig(configMap map[interface{}]interface{}) error } config.Tcfg["protocol"] = append(config.Tcfg.Protocols(), "ziti-edge", "") - factory.id = config.RouterConfig.Id - factory.edgeRouterConfig = config go apiproxy.Start(config) @@ -127,13 +122,15 @@ func (factory *Factory) LoadConfig(configMap map[interface{}]interface{}) error } // NewFactory constructs a new Edge Xgress Factory instance -func NewFactory(routerConfig *router.Config, versionProvider versions.VersionProvider, stateManager fabric.StateManager, metricsRegistry metrics.Registry) *Factory { +func NewFactory(routerConfig *router.Config, env env.RouterEnv, stateManager fabric.StateManager) *Factory { factory := &Factory{ - hostedServices: NewHostedServicesRegistry(), + ctrls: env.GetNetworkControllers(), + hostedServices: newHostedServicesRegistry(env), stateManager: stateManager, - versionProvider: versionProvider, + versionProvider: env.GetVersionInfo(), routerConfig: routerConfig, - metricsRegistry: metricsRegistry, + metricsRegistry: env.GetMetricsRegistry(), + env: env, } return factory } @@ -162,7 +159,7 @@ func (factory *Factory) CreateListener(optionsData xgress.OptionsData) (xgress.L channel.HelloVersionHeader: versionHeader, } - return newListener(factory.id, factory, options, headers), nil + return newListener(factory.env.GetRouterId(), factory, options, headers), nil } // CreateDialer creates a new Edge Xgress dialer diff --git a/router/xgress_edge/hosted.go b/router/xgress_edge/hosted.go index b7a6f0161..cd2b40d26 100644 --- a/router/xgress_edge/hosted.go +++ b/router/xgress_edge/hosted.go @@ -17,29 +17,118 @@ package xgress_edge import ( + "fmt" + "github.com/cenkalti/backoff/v4" "github.com/michaelquigley/pfxlog" + "github.com/openziti/channel/v2" + "github.com/openziti/channel/v2/protobufs" + "github.com/openziti/sdk-golang/ziti/edge" + "github.com/openziti/ziti/common/pb/edge_ctrl_pb" + routerEnv "github.com/openziti/ziti/router/env" cmap "github.com/orcaman/concurrent-map/v2" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "google.golang.org/protobuf/proto" "sync" + "time" ) -func NewHostedServicesRegistry() *hostedServiceRegistry { - return &hostedServiceRegistry{ - services: sync.Map{}, - ids: cmap.New[string](), +func newHostedServicesRegistry(env routerEnv.RouterEnv) *hostedServiceRegistry { + result := &hostedServiceRegistry{ + services: sync.Map{}, + events: make(chan terminatorEvent), + env: env, + retriesPending: false, + waits: cmap.New[chan struct{}](), } + go result.run() + return result } type hostedServiceRegistry struct { - services sync.Map - ids cmap.ConcurrentMap[string, string] + services sync.Map + events chan terminatorEvent + env routerEnv.RouterEnv + retriesPending bool + waits cmap.ConcurrentMap[string, chan struct{}] +} + +type terminatorEvent interface { + handle(registry *hostedServiceRegistry) +} + +func (self *hostedServiceRegistry) run() { + retryTicker := time.NewTicker(50 * time.Millisecond) + defer retryTicker.Stop() + + for { + var retryChan <-chan time.Time + if self.retriesPending { + retryChan = retryTicker.C + } + + select { + case <-self.env.GetCloseNotify(): + return + case event := <-self.events: + event.handle(self) + case <-retryChan: + self.scanForRetries() + } + } +} + +type establishTerminatorEvent struct { + terminator *edgeTerminator +} + +func (self *establishTerminatorEvent) handle(registry *hostedServiceRegistry) { + registry.tryEstablish(self.terminator) +} + +func (self *hostedServiceRegistry) EstablishTerminator(terminator *edgeTerminator) { + event := &establishTerminatorEvent{ + terminator: terminator, + } + + self.Put(terminator.terminatorId.Load(), terminator) + + select { + case <-self.env.GetCloseNotify(): + pfxlog.Logger().WithField("terminatorId", terminator.terminatorId.Load()). + Error("unable to establish terminator, hosted service registry has been shutdown") + case self.events <- event: + } +} + +func (self *hostedServiceRegistry) scanForRetries() { + self.services.Range(func(key, value any) bool { + terminator := value.(*edgeTerminator) + if terminator.state.Load() == TerminatorStatePendingEstablishment { + self.tryEstablish(terminator) + } + return true + }) +} + +func (self *hostedServiceRegistry) tryEstablish(terminator *edgeTerminator) { + terminator.state.Store(TerminatorStateEstablishing) + err := self.env.GetRateLimiterPool().QueueOrError(func() { + self.establishTerminatorWithRetry(terminator) + }) + if err != nil { + terminator.state.Store(TerminatorStatePendingEstablishment) + pfxlog.Logger().WithField("terminatorId", terminator.Id()).Info("rate limited: unable to queue to establish") + self.retriesPending = true + } } -func (registry *hostedServiceRegistry) Put(hostId string, conn *edgeTerminator) { - registry.services.Store(hostId, conn) +func (self *hostedServiceRegistry) Put(hostId string, conn *edgeTerminator) { + self.services.Store(hostId, conn) } -func (registry *hostedServiceRegistry) Get(hostId string) (*edgeTerminator, bool) { - val, ok := registry.services.Load(hostId) +func (self *hostedServiceRegistry) Get(hostId string) (*edgeTerminator, bool) { + val, ok := self.services.Load(hostId) if !ok { return nil, false } @@ -47,27 +136,40 @@ func (registry *hostedServiceRegistry) Get(hostId string) (*edgeTerminator, bool return ch, ok } -func (registry *hostedServiceRegistry) Delete(hostId string) { - registry.services.Delete(hostId) +func (self *hostedServiceRegistry) GetTerminatorForListener(listenerId string) *edgeTerminator { + var result *edgeTerminator + self.services.Range(func(key, value interface{}) bool { + terminator := value.(*edgeTerminator) + if terminator.listenerId == listenerId { + result = terminator + return false + } + return true + }) + return result } -func (registry *hostedServiceRegistry) cleanupServices(proxy *edgeClientConn) { - registry.services.Range(func(key, value interface{}) bool { +func (self *hostedServiceRegistry) Delete(hostId string) { + self.services.Delete(hostId) +} + +func (self *hostedServiceRegistry) cleanupServices(proxy *edgeClientConn) { + self.services.Range(func(key, value interface{}) bool { terminator := value.(*edgeTerminator) if terminator.edgeClientConn == proxy { terminator.close(false, "") // don't notify, channel is already closed, we can't send messages - registry.services.Delete(key) + self.services.Delete(key) } return true }) } -func (registry *hostedServiceRegistry) cleanupDuplicates(newest *edgeTerminator) { - registry.services.Range(func(key, value interface{}) bool { +func (self *hostedServiceRegistry) cleanupDuplicates(newest *edgeTerminator) { + self.services.Range(func(key, value interface{}) bool { terminator := value.(*edgeTerminator) if terminator != newest && newest.token == terminator.token && newest.instance == terminator.instance { terminator.close(false, "duplicate terminator") // don't notify, channel is already closed, we can't send messages - registry.services.Delete(key) + self.services.Delete(key) pfxlog.Logger().WithField("routerId", terminator.edgeClientConn.listener.id.Token). WithField("sessionToken", terminator.token). WithField("instance", terminator.instance). @@ -79,13 +181,13 @@ func (registry *hostedServiceRegistry) cleanupDuplicates(newest *edgeTerminator) }) } -func (registry *hostedServiceRegistry) unbindSession(sessionToken string, proxy *edgeClientConn) bool { +func (self *hostedServiceRegistry) unbindSession(connId uint32, sessionToken string, proxy *edgeClientConn) bool { atLeastOneRemoved := false - registry.services.Range(func(key, value interface{}) bool { + self.services.Range(func(key, value interface{}) bool { terminator := value.(*edgeTerminator) - if terminator.token == sessionToken && terminator.edgeClientConn == proxy { - terminator.close(true, "unbind successful") // don't notify, sdk asked us to unbind - registry.services.Delete(key) + if terminator.MsgChannel.Id() == connId && terminator.token == sessionToken && terminator.edgeClientConn == proxy { + terminator.close(false, "unbind successful") // don't notify, sdk asked us to unbind + self.services.Delete(key) pfxlog.Logger().WithField("routerId", terminator.edgeClientConn.listener.id.Token). WithField("sessionToken", sessionToken). WithField("terminatorId", terminator.terminatorId.Load()). @@ -97,9 +199,9 @@ func (registry *hostedServiceRegistry) unbindSession(sessionToken string, proxy return atLeastOneRemoved } -func (registry *hostedServiceRegistry) getRelatedTerminators(sessionToken string, proxy *edgeClientConn) []*edgeTerminator { +func (self *hostedServiceRegistry) getRelatedTerminators(sessionToken string, proxy *edgeClientConn) []*edgeTerminator { var result []*edgeTerminator - registry.services.Range(func(key, value interface{}) bool { + self.services.Range(func(key, value interface{}) bool { terminator := value.(*edgeTerminator) if terminator.token == sessionToken && terminator.edgeClientConn == proxy { result = append(result, terminator) @@ -108,3 +210,153 @@ func (registry *hostedServiceRegistry) getRelatedTerminators(sessionToken string }) return result } + +func (self *hostedServiceRegistry) establishTerminatorWithRetry(terminator *edgeTerminator) { + log := logrus.WithField("terminatorId", terminator.terminatorId.Load()) + + if state := terminator.state.Load(); state != TerminatorStateEstablishing { + log.WithField("state", state.String()).Info("not attempting to establish terminator, not in establishing state") + return + } + + operation := func() error { + if terminator.edgeClientConn.ch.IsClosed() { + return backoff.Permanent(fmt.Errorf("edge link is closed, stopping terminator creation for terminator %s", + terminator.terminatorId.Load())) + } + if state := terminator.state.Load(); state != TerminatorStateEstablishing { + return backoff.Permanent(fmt.Errorf("terminator state is %v, stopping terminator creation for terminator %s", + state.String(), terminator.terminatorId.Load())) + } + + var err error + log.Info("attempting to establish terminator") + err = self.establishTerminator(terminator) + if err != nil && terminator.state.Load() != TerminatorStateEstablishing { + return backoff.Permanent(err) + } + return err + } + + expBackoff := backoff.NewExponentialBackOff() + expBackoff.InitialInterval = 5 * time.Second + expBackoff.MaxInterval = 5 * time.Minute + + if err := backoff.Retry(operation, expBackoff); err != nil { + log.WithError(err).Error("stopping attempts to establish terminator, see error") + } else if terminator.postValidate { + if result, err := terminator.inspect(true); err != nil { + log.WithError(err).Error("error validating terminator after create") + } else if result.Type != edge.ConnTypeBind { + log.WithError(err).Error("terminator invalid in sdk after create, closed") + } else { + log.Info("terminator validated successfully") + } + } +} + +func (self *hostedServiceRegistry) establishTerminator(terminator *edgeTerminator) error { + factory := terminator.edgeClientConn.listener.factory + + log := pfxlog.Logger(). + WithField("routerId", factory.env.GetRouterId().Token). + WithField("terminatorId", terminator.terminatorId.Load()) + + request := &edge_ctrl_pb.CreateTerminatorV2Request{ + Address: terminator.terminatorId.Load(), + SessionToken: terminator.token, + Fingerprints: terminator.edgeClientConn.fingerprints.Prints(), + PeerData: terminator.hostData, + Cost: uint32(terminator.cost), + Precedence: terminator.precedence, + InstanceId: terminator.instance, + InstanceSecret: terminator.instanceSecret, + } + + timeout := factory.ctrls.DefaultRequestTimeout() + ctrlCh := factory.ctrls.AnyCtrlChannel() + if ctrlCh == nil { + errStr := "no controller available, cannot create terminator" + log.Error(errStr) + return errors.New(errStr) + } + + err := protobufs.MarshalTyped(request).WithTimeout(timeout).SendAndWaitForWire(ctrlCh) + if err != nil { + return err + } + + if self.waitForTerminatorCreated(terminator.terminatorId.Load(), 10*time.Second) { + return nil + } + + // return an error to indicate that we need to check if a response has come back after the next interval, + // and if not, re-send + return errors.Errorf("timeout waiting for response to create terminator request for terminator %v", terminator.terminatorId.Load()) +} + +func (self *hostedServiceRegistry) HandleCreateTerminatorResponse(msg *channel.Message, ctrlCh channel.Channel) { + log := pfxlog.Logger().WithField("routerId", self.env.GetRouterId().Token) + + response := &edge_ctrl_pb.CreateTerminatorV2Response{} + + if err := proto.Unmarshal(msg.Body, response); err != nil { + log.WithError(err).Error("error unmarshalling create terminator v2 response") + return + } + + log = log.WithField("terminatorId", response.TerminatorId) + + terminator, found := self.Get(response.TerminatorId) + if !found { + log.Error("no terminator found for id") + return + } + + if terminator.state.CompareAndSwap(TerminatorStateEstablishing, TerminatorStateEstablished) { + self.notifyTerminatorCreated(response.TerminatorId) + log.Info("received terminator created notification") + } else { + log.Info("received additional terminator created notification") + } +} + +func (self *hostedServiceRegistry) waitForTerminatorCreated(id string, timeout time.Duration) bool { + notifyC := make(chan struct{}) + defer self.waits.Remove(id) + + self.waits.Set(id, notifyC) + select { + case <-notifyC: + return true + case <-time.After(timeout): + return false + } +} + +func (self *hostedServiceRegistry) notifyTerminatorCreated(id string) { + notifyC, _ := self.waits.Get(id) + if notifyC != nil { + close(notifyC) + } +} + +func (self *hostedServiceRegistry) HandleReconnect() { + var restablishList []*edgeTerminator + self.services.Range(func(key, value interface{}) bool { + terminator := value.(*edgeTerminator) + if terminator.state.CompareAndSwap(TerminatorStateEstablished, TerminatorStatePendingEstablishment) { + restablishList = append(restablishList, terminator) + } + return true + }) + + // wait for verify terminator events to come in + time.Sleep(10 * time.Second) + + for _, terminator := range restablishList { + if terminator.state.Load() == TerminatorStatePendingEstablishment { + self.EstablishTerminator(terminator) + } + } +} diff --git a/router/xgress_edge/listener.go b/router/xgress_edge/listener.go index fde76c182..7236a5457 100644 --- a/router/xgress_edge/listener.go +++ b/router/xgress_edge/listener.go @@ -208,7 +208,7 @@ func (self *edgeClientConn) processBind(req *channel.Message, ch channel.Channel } if supportsCreateTerminatorV2 { - self.processBindV2(req, ch, ctrlCh) + self.processBindV2(req, ch) } else { self.processBindV1(req, ch, ctrlCh) } @@ -312,7 +312,7 @@ func (self *edgeClientConn) processBindV1(req *channel.Message, ch channel.Chann log.Info("created terminator") } -func (self *edgeClientConn) processBindV2(req *channel.Message, ch channel.Channel, ctrlCh channel.Channel) { +func (self *edgeClientConn) processBindV2(req *channel.Message, ch channel.Channel) { token := string(req.Body) log := pfxlog.ContextLogger(ch.Label()). @@ -326,33 +326,41 @@ func (self *edgeClientConn) processBindV2(req *channel.Message, ch channel.Chann return } - terminatorInstance, _ := req.GetStringHeader(edge.TerminatorIdentityHeader) + var terminatorId string - assignIds, _ := req.GetBoolHeader(edge.RouterProvidedConnId) - log.Debugf("client requested router provided connection ids: %v", assignIds) + listenerId, _ := req.GetStringHeader(edge.ListenerId) + if listenerId != "" { + log = log.WithField("listenerId", listenerId) + if terminator := self.listener.factory.hostedServices.GetTerminatorForListener(listenerId); terminator != nil { + terminatorId = terminator.terminatorId.Load() + log = log.WithField("terminatorId", terminatorId) - terminatorId := idgen.NewUUIDString() + // everything is the same, we can re-use the terminator + if terminator.edgeClientConn == self && terminator.token == token { + log.Info("duplicate create terminator request") + self.sendStateConnectedReply(req, nil) + return + } - terminator := &edgeTerminator{ - MsgChannel: *edge.NewEdgeMsgChannel(self.ch, connId), - edgeClientConn: self, - token: token, - instance: terminatorInstance, - assignIds: assignIds, - v2: true, + if terminator.terminatorId.CompareAndSwap(terminatorId, "") { + log.Info("replacing existing terminator") + self.listener.factory.hostedServices.Delete(terminatorId) + } else { + terminatorId = idgen.NewUUIDString() + log.Infof("unable to replace existing terminator, as it's being shut down, creating new one with id %s", terminatorId) + } + } } - log = log.WithField("bindConnId", terminator.MsgChannel.Id()) - terminator.terminatorId.Store(terminatorId) + if terminatorId == "" { + terminatorId = idgen.NewUUIDString() + } - log = log.WithField("terminatorId", terminatorId) - log.Debug("binding service") + log = log.WithField("bindConnId", connId).WithField("terminatorId", terminatorId) + terminatorInstance, _ := req.GetStringHeader(edge.TerminatorIdentityHeader) - hostData := make(map[uint32][]byte) - pubKey, hasKey := req.Headers[edge.PublicKeyHeader] - if hasKey { - hostData[edge.PublicKeyHeader] = pubKey - } + assignIds, _ := req.GetBoolHeader(edge.RouterProvidedConnId) + log.Debugf("client requested router provided connection ids: %v", assignIds) cost := uint16(0) if costBytes, hasCost := req.Headers[edge.CostHeader]; hasCost { @@ -369,67 +377,62 @@ func (self *edgeClientConn) processBindV2(req *channel.Message, ch channel.Chann } } - log.Debug("establishing listener") - - // need to remove session remove listener on close - terminator.onClose = self.listener.factory.stateManager.AddEdgeSessionRemovedListener(token, func(token string) { - terminator.close(true, "session ended") - }) - - self.listener.factory.hostedServices.Put(terminatorId, terminator) - var terminatorInstanceSecret []byte if terminatorInstance != "" { terminatorInstanceSecret = req.Headers[edge.TerminatorIdentitySecretHeader] } - request := &edge_ctrl_pb.CreateTerminatorV2Request{ - Address: terminatorId, - SessionToken: token, - Fingerprints: self.fingerprints.Prints(), - PeerData: hostData, - Cost: uint32(cost), - Precedence: precedence, - InstanceId: terminatorInstance, - InstanceSecret: terminatorInstanceSecret, + hostData := make(map[uint32][]byte) + if pubKey, hasKey := req.Headers[edge.PublicKeyHeader]; hasKey { + hostData[edge.PublicKeyHeader] = pubKey } - timeout := self.listener.factory.ctrls.DefaultRequestTimeout() - responseMsg, err := protobufs.MarshalTyped(request).WithTimeout(timeout).SendForReply(ctrlCh) - resp := &edge_ctrl_pb.CreateTerminatorV2Response{} - err = protobufs.TypedResponse(resp).Unmarshall(responseMsg, err) - if err == nil && resp.Result != edge_ctrl_pb.CreateTerminatorResult_Success { - err = errors.Errorf("terminator create failed: %s", resp.Msg) + postValidate := false + if supportsInspect, _ := req.GetBoolHeader(edge.SupportsInspectHeader); supportsInspect { + postValidate = true } - if err != nil { - log.WithError(err).Warn("error creating terminator") - terminator.close(false, "") // don't notify here, as we're notifying next line with a response - self.sendStateClosedReply(err.Error(), req) - return + terminator := &edgeTerminator{ + MsgChannel: *edge.NewEdgeMsgChannel(self.ch, connId), + edgeClientConn: self, + token: token, + cost: cost, + precedence: precedence, + instance: terminatorInstance, + instanceSecret: terminatorInstanceSecret, + hostData: hostData, + assignIds: assignIds, + v2: true, + postValidate: postValidate, } + terminator.terminatorId.Store(terminatorId) - if terminator.MsgChannel.IsClosed() { - log.Warn("edge channel closed while setting up terminator. cleaning up terminator now") - terminator.close(false, "edge channel closed") - return - } + log.Info("establishing terminator") - log.Debug("registered listener for terminator") - log.Debug("returning connection state CONNECTED to client") - self.sendStateConnectedReply(req, nil) + // need to remove session remove listener on close + terminator.onClose = self.listener.factory.stateManager.AddEdgeSessionRemovedListener(token, func(token string) { + terminator.close(true, "session ended") + }) - self.listener.factory.hostedServices.cleanupDuplicates(terminator) + self.sendStateConnectedReply(req, nil) - log.Info("created terminator") + self.listener.factory.hostedServices.EstablishTerminator(terminator) + if listenerId == "" { + // only removed dupes with a scan if we don't have an sdk provided key + self.listener.factory.hostedServices.cleanupDuplicates(terminator) + } } func (self *edgeClientConn) processUnbind(req *channel.Message, _ channel.Channel) { + connId, _ := req.GetUint32Header(edge.ConnIdHeader) token := string(req.Body) - atLeastOneTerminatorRemoved := self.listener.factory.hostedServices.unbindSession(token, self) + atLeastOneTerminatorRemoved := self.listener.factory.hostedServices.unbindSession(connId, token, self) if !atLeastOneTerminatorRemoved { - self.sendStateClosedReply(fmt.Sprintf("no terminator found for token '%s'", token), req) + pfxlog.Logger(). + WithField("connId", connId). + WithField("sessionToken", token). + Info("no terminator found to unbind for token") } } diff --git a/router/xgress_edge_tunnel/tunneler.go b/router/xgress_edge_tunnel/tunneler.go index 2216f6b1e..cf1161141 100644 --- a/router/xgress_edge_tunnel/tunneler.go +++ b/router/xgress_edge_tunnel/tunneler.go @@ -19,12 +19,12 @@ package xgress_edge_tunnel import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/ziti/router/fabric" + "github.com/openziti/ziti/router/xgress" "github.com/openziti/ziti/tunnel/dns" "github.com/openziti/ziti/tunnel/intercept" "github.com/openziti/ziti/tunnel/intercept/host" "github.com/openziti/ziti/tunnel/intercept/proxy" "github.com/openziti/ziti/tunnel/intercept/tproxy" - "github.com/openziti/ziti/router/xgress" cmap "github.com/orcaman/concurrent-map/v2" "github.com/pkg/errors" "math" @@ -96,7 +96,11 @@ func (self *tunneler) Start(notifyClose <-chan struct{}) error { return errors.Errorf("unsupported tunnel mode '%v'", self.listenOptions.mode) } - resolver := dns.NewResolver(self.listenOptions.resolver) + resolver, err := dns.NewResolver(self.listenOptions.resolver) + if err != nil { + pfxlog.Logger().WithError(err).Error("failed to start DNS resolver") + } + if err = intercept.SetDnsInterceptIpRange(self.listenOptions.dnsSvcIpRange); err != nil { pfxlog.Logger().Errorf("invalid dns service IP range %s: %v", self.listenOptions.dnsSvcIpRange, err) return err @@ -172,6 +176,8 @@ func (self *tunneler) ReestablishTerminators() { log := pfxlog.Logger() terminators := self.terminators.Items() + time.Sleep(10 * time.Second) // wait for validate terminator messages to come in first + if len(terminators) > 0 { pfxlog.Logger().Debugf("reestablishing %v terminators", len(terminators)) } diff --git a/tests/addressable_terminators_test.go b/tests/addressable_terminators_test.go index c524ee0f3..7adf848ff 100644 --- a/tests/addressable_terminators_test.go +++ b/tests/addressable_terminators_test.go @@ -39,6 +39,9 @@ func Test_AddressableTerminators(t *testing.T) { ctx.CreateEnrollAndStartEdgeRouter() + watcher := ctx.AdminManagementSession.newTerminatorWatcher() + defer watcher.Close() + type host struct { id *identity context ziti.Context @@ -59,7 +62,7 @@ func Test_AddressableTerminators(t *testing.T) { BindUsingEdgeIdentity: true, }) ctx.Req.NoError(err) - ctx.requireNListener(1, host.listener, 5*time.Second) + watcher.waitForTerminators(service.Id, 1, 5*time.Second) } type client struct { diff --git a/tests/auth_policy_test.go b/tests/auth_policy_test.go index 617fe95a8..4418b8d0b 100644 --- a/tests/auth_policy_test.go +++ b/tests/auth_policy_test.go @@ -23,8 +23,8 @@ import ( "github.com/golang-jwt/jwt/v5" "github.com/google/uuid" "github.com/openziti/edge-api/rest_model" - "github.com/openziti/ziti/controller/persistence" nfpem "github.com/openziti/foundation/v2/pem" + "github.com/openziti/ziti/controller/db" "net/http" "testing" "time" @@ -781,7 +781,7 @@ func Test_AuthPolicies(t *testing.T) { ctx.testContextChanged(t) identityPatch := &rest_model.IdentityPatch{ - AuthPolicyID: S(persistence.DefaultAuthPolicyId), + AuthPolicyID: S(db.DefaultAuthPolicyId), } resp, err = ctx.AdminManagementSession.newAuthenticatedRequest().SetBody(identityPatch).Patch("/identities/" + identityCreated.Data.ID) ctx.Req.NoError(err) @@ -798,7 +798,7 @@ func Test_AuthPolicies(t *testing.T) { t.Run("cannot delete the default auth policy", func(t *testing.T) { ctx.testContextChanged(t) - resp, err := ctx.AdminManagementSession.newAuthenticatedRequest().Delete("/auth-policies/" + persistence.DefaultAuthPolicyId) + resp, err := ctx.AdminManagementSession.newAuthenticatedRequest().Delete("/auth-policies/" + db.DefaultAuthPolicyId) ctx.Req.NoError(err) ctx.Req.Equal(http.StatusConflict, resp.StatusCode(), "expected 409 for DELETE: %s", resp.Body()) }) @@ -862,7 +862,7 @@ func Test_AuthPolicies(t *testing.T) { }, } - resp, err = ctx.AdminManagementSession.newAuthenticatedRequest().SetBody(authPolicyUpdate).Put("/auth-policies/" + persistence.DefaultAuthPolicyId) + resp, err = ctx.AdminManagementSession.newAuthenticatedRequest().SetBody(authPolicyUpdate).Put("/auth-policies/" + db.DefaultAuthPolicyId) ctx.Req.NoError(err) ctx.Req.Equal(http.StatusOK, resp.StatusCode(), "expected 200 for PUT %T: %s", extJwtSigner, resp.Body()) @@ -871,7 +871,7 @@ func Test_AuthPolicies(t *testing.T) { authPolicyUpdatedEnvelope := &rest_model.DetailAuthPolicyEnvelope{} - resp, err = ctx.AdminManagementSession.newAuthenticatedRequest().SetResult(authPolicyUpdatedEnvelope).Get("/auth-policies/" + persistence.DefaultAuthPolicyId) + resp, err = ctx.AdminManagementSession.newAuthenticatedRequest().SetResult(authPolicyUpdatedEnvelope).Get("/auth-policies/" + db.DefaultAuthPolicyId) ctx.Req.NoError(err) ctx.Req.Equal(http.StatusOK, resp.StatusCode(), "expected 200 for GET %s: %s", resp.Request.URL, resp.Body()) authPolicyUpdatedDetail := authPolicyUpdatedEnvelope.Data @@ -906,7 +906,7 @@ func Test_AuthPolicies(t *testing.T) { Name: S("PatchedName On Default"), } - resp, err := ctx.AdminManagementSession.newAuthenticatedRequest().SetBody(authPolicyPatch).Patch("/auth-policies/" + persistence.DefaultAuthPolicyId) + resp, err := ctx.AdminManagementSession.newAuthenticatedRequest().SetBody(authPolicyPatch).Patch("/auth-policies/" + db.DefaultAuthPolicyId) ctx.Req.NoError(err) ctx.Req.Equal(http.StatusOK, resp.StatusCode(), "expected 200 for PATCH %T: %s", "default auth policy", resp.Body()) @@ -915,7 +915,7 @@ func Test_AuthPolicies(t *testing.T) { authPolicyPatchEnvelope := &rest_model.DetailAuthPolicyEnvelope{} - resp, err = ctx.AdminManagementSession.newAuthenticatedRequest().SetResult(authPolicyPatchEnvelope).Get("/auth-policies/" + persistence.DefaultAuthPolicyId) + resp, err = ctx.AdminManagementSession.newAuthenticatedRequest().SetResult(authPolicyPatchEnvelope).Get("/auth-policies/" + db.DefaultAuthPolicyId) ctx.Req.NoError(err) ctx.Req.Equal(http.StatusOK, resp.StatusCode(), "expected 200 for GET %s: %s", resp.Request.URL, resp.Body()) authPolicyPatchedDetail := authPolicyPatchEnvelope.Data @@ -1007,9 +1007,9 @@ func Test_AuthPolicies(t *testing.T) { ctx.Req.Equal(*authPolicy.Primary.ExtJWT.Allowed, *authPolicyDetail.Primary.ExtJWT.Allowed) ctx.Req.Equal(*authPolicy.Primary.Updb.Allowed, *authPolicyDetail.Primary.Updb.Allowed) - ctx.Req.Equal(persistence.UpdbUnlimitedAttemptsLimit, *authPolicyDetail.Primary.Updb.MaxAttempts) - ctx.Req.Equal(persistence.DefaultUpdbMinPasswordLength, *authPolicyDetail.Primary.Updb.MinPasswordLength) - ctx.Req.Equal(persistence.UpdbIndefiniteLockout, *authPolicyDetail.Primary.Updb.LockoutDurationMinutes) + ctx.Req.Equal(db.UpdbUnlimitedAttemptsLimit, *authPolicyDetail.Primary.Updb.MaxAttempts) + ctx.Req.Equal(db.DefaultUpdbMinPasswordLength, *authPolicyDetail.Primary.Updb.MinPasswordLength) + ctx.Req.Equal(db.UpdbIndefiniteLockout, *authPolicyDetail.Primary.Updb.LockoutDurationMinutes) ctx.Req.Equal(*authPolicy.Primary.Updb.RequireMixedCase, *authPolicyDetail.Primary.Updb.RequireMixedCase) ctx.Req.Equal(*authPolicy.Primary.Updb.RequireNumberChar, *authPolicyDetail.Primary.Updb.RequireNumberChar) ctx.Req.Equal(*authPolicy.Primary.Updb.RequireSpecialChar, *authPolicyDetail.Primary.Updb.RequireSpecialChar) diff --git a/tests/authenticate.go b/tests/authenticate.go index 6f08b655a..3ca38fb34 100644 --- a/tests/authenticate.go +++ b/tests/authenticate.go @@ -28,18 +28,22 @@ import ( "fmt" "github.com/Jeffail/gabs" "github.com/michaelquigley/pfxlog" + "github.com/openziti/channel/v2" "github.com/openziti/edge-api/rest_model" + "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/sdk-golang/ziti" "github.com/openziti/ziti/common/cert" "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/common/pb/mgmt_pb" "github.com/openziti/ziti/controller/env" - "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/sdk-golang/ziti" + "github.com/openziti/ziti/controller/event" "github.com/pkg/errors" "gopkg.in/resty.v1" "math/big" "net/http" "net/url" "sort" + "sync" "time" ) @@ -1064,6 +1068,140 @@ func (request *authenticatedRequests) getIdentityJwt(identityId string) string { return data.Data().(string) } +func (request *authenticatedRequests) streamEvents(req *subscriptionRequest) (func(), error) { + streamEventsRequest := map[string]interface{}{} + streamEventsRequest["format"] = "json" + streamEventsRequest["subscriptions"] = req.Subscriptions + + bindHandler := func(binding channel.Binding) error { + binding.AddReceiveHandlerF(int32(mgmt_pb.ContentType_StreamEventsEventType), req.Callback) + return nil + } + + ch, err := request.testContext.NewWsMgmtChannel(channel.BindHandlerF(bindHandler)) + if err != nil { + return nil, err + } + + closeF := func() { + if err := ch.Close(); err != nil { + pfxlog.Logger().WithError(err).Error("failure closing event channel") + } + } + + msgBytes, err := json.Marshal(streamEventsRequest) + if err != nil { + closeF() + return nil, err + } + + if req.Timeout == 0 { + req.Timeout = time.Second + } + + requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_StreamEventsRequestType), msgBytes) + responseMsg, err := requestMsg.WithTimeout(req.Timeout).SendForReply(ch) + if err != nil { + closeF() + return nil, err + } + + if responseMsg.ContentType != channel.ContentTypeResultType { + closeF() + return nil, errors.Errorf("unexpected response type %v", responseMsg.ContentType) + } + + result := channel.UnmarshalResult(responseMsg) + if !result.Success { + closeF() + return nil, fmt.Errorf("error starting event streaming [%s]\n", result.Message) + } + + return closeF, nil +} + +func (request *authenticatedRequests) newTerminatorWatcher() *terminatorWatcher { + watcher := &terminatorWatcher{ + testContext: request.testContext, + counts: map[string]int{}, + notifyAll: make(chan struct{}, 1), + } + + req := &subscriptionRequest{ + Subscriptions: []*event.Subscription{ + {Type: event.TerminatorEventsNs}, + }, + Callback: watcher.HandleMessage, + } + + closer, err := request.streamEvents(req) + request.testContext.NoError(err) + + watcher.closer = closer + return watcher +} + +type subscriptionRequest struct { + Timeout time.Duration + Subscriptions []*event.Subscription + Callback func(msg *channel.Message, ch channel.Channel) +} + +type terminatorWatcher struct { + testContext *TestContext + lock sync.Mutex + counts map[string]int + notifyAll chan struct{} + closer func() +} + +func (self *terminatorWatcher) Close() { + self.closer() +} + +func (self *terminatorWatcher) HandleMessage(msg *channel.Message, _ channel.Channel) { + eventType, _ := msg.GetStringHeader(int32(mgmt_pb.Header_EventTypeHeader)) + if eventType != "terminator" { + return + } + evt := &event.TerminatorEvent{} + if err := json.Unmarshal(msg.Body, &evt); err != nil { + pfxlog.Logger().WithError(err).Error("unable to unmarshal terminator event") + } + + self.lock.Lock() + self.counts[evt.ServiceId] = evt.TotalTerminators + self.lock.Unlock() + + for { + select { + case self.notifyAll <- struct{}{}: + default: + return + } + } +} + +func (self *terminatorWatcher) waitForTerminators(service string, count int, timeout time.Duration) { + start := time.Now() + for { + self.lock.Lock() + current := self.counts[service] + self.lock.Unlock() + + if current >= count { + return + } + + self.testContext.False(time.Since(start) > timeout, "timed out waiting for terminator creation") + + select { + case <-self.notifyAll: + case <-time.After(100 * time.Millisecond): + } + } +} + func newSelfSignedCert(commonName string) (*x509.Certificate, crypto.PrivateKey) { priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { diff --git a/tests/context.go b/tests/context.go index 08ff74df6..11394d7ce 100644 --- a/tests/context.go +++ b/tests/context.go @@ -28,22 +28,26 @@ import ( "fmt" "github.com/go-openapi/strfmt" "github.com/google/uuid" + "github.com/gorilla/websocket" + "github.com/openziti/channel/v2" + "github.com/openziti/channel/v2/websockets" "github.com/openziti/edge-api/rest_model" - "github.com/openziti/ziti/common" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/router/enroll" - "github.com/openziti/ziti/router/fabric" - "github.com/openziti/ziti/router/xgress_edge" - "github.com/openziti/ziti/router/xgress_edge_tunnel" - "github.com/openziti/ziti/controller/xt_smartrouting" - "github.com/openziti/ziti/router" - "github.com/openziti/ziti/router/xgress" nfPem "github.com/openziti/foundation/v2/pem" "github.com/openziti/foundation/v2/versions" "github.com/openziti/identity/certtools" "github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti/edge" sdkEnroll "github.com/openziti/sdk-golang/ziti/enroll" + "github.com/openziti/ziti/common" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/env" + "github.com/openziti/ziti/controller/xt_smartrouting" + "github.com/openziti/ziti/router" + "github.com/openziti/ziti/router/enroll" + "github.com/openziti/ziti/router/fabric" + "github.com/openziti/ziti/router/xgress" + "github.com/openziti/ziti/router/xgress_edge" + "github.com/openziti/ziti/router/xgress_edge_tunnel" "github.com/pkg/errors" "io" "net" @@ -62,12 +66,12 @@ import ( "github.com/Jeffail/gabs" "github.com/michaelquigley/pfxlog" - "github.com/openziti/ziti/controller/server" - "github.com/openziti/ziti/controller" idlib "github.com/openziti/identity" "github.com/openziti/transport/v2" "github.com/openziti/transport/v2/tcp" "github.com/openziti/transport/v2/tls" + "github.com/openziti/ziti/controller" + "github.com/openziti/ziti/controller/server" "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" ) @@ -283,6 +287,42 @@ func (ctx *TestContext) NewClientComponents(apiPath string) (*resty.Client, *htt return client, httpClient, clientTransport } +func (ctx *TestContext) NewWsMgmtChannel(bindHandler channel.BindHandler) (channel.Channel, error) { + log := pfxlog.Logger() + + wsUrl := "wss://" + ctx.ApiHost + "/fabric/v1/ws-api" + + dialer := &websocket.Dialer{ + Proxy: http.ProxyFromEnvironment, + TLSClientConfig: ctx.DefaultClientApiClient().GetClient().Transport.(*http.Transport).TLSClientConfig, + HandshakeTimeout: 5 * time.Second, + } + + authHeader := http.Header{} + authHeader.Set(env.ZitiSession, *ctx.AdminManagementSession.AuthResponse.Token) + + conn, resp, err := dialer.Dial(wsUrl, authHeader) + if err != nil { + if resp != nil { + if body, rerr := io.ReadAll(resp.Body); rerr == nil { + log.WithError(err).Errorf("response body [%v]", string(body)) + } + } else { + log.WithError(err).Error("no response from websocket dial") + } + return nil, err + } + + id := &idlib.TokenId{Token: "mgmt"} + underlayFactory := websockets.NewUnderlayFactory(id, conn, nil) + + ch, err := channel.NewChannel("mgmt", underlayFactory, bindHandler, nil) + if err != nil { + return nil, err + } + return ch, nil +} + func (ctx *TestContext) NewClientComponentsWithClientCert(cert *x509.Certificate, privateKey crypto.PrivateKey) (*resty.Client, *http.Client, *http.Transport) { clientTransport := ctx.NewTransportWithClientCert(cert, privateKey) httpClient := ctx.NewHttpClient(clientTransport) @@ -457,7 +497,7 @@ func (ctx *TestContext) startEdgeRouter() { ctx.router = router.Create(config, NewVersionProviderTest()) stateManager := fabric.NewStateManager() - xgressEdgeFactory := xgress_edge.NewFactory(config, NewVersionProviderTest(), stateManager, ctx.router.GetMetricsRegistry()) + xgressEdgeFactory := xgress_edge.NewFactory(config, ctx.router, stateManager) xgress.GlobalRegistry().Register(common.EdgeBinding, xgressEdgeFactory) xgressEdgeTunnelFactory := xgress_edge_tunnel.NewFactory(ctx.router, config, stateManager) @@ -818,32 +858,6 @@ func (ctx *TestContext) requireEntityEnrolled(name string, entity *gabs.Containe ctx.Req.Nil(expiresAt, "expected "+name+" with isVerified=true to have an nil enrollment expires at date") } -func (ctx *TestContext) requireNListener(count int, l edge.Listener, timeout time.Duration) { - sl, ok := l.(edge.SessionListener) - ctx.Req.True(ok, "must be session listener") - - c := make(chan []edge.Listener, 5) - sl.SetConnectionChangeHandler(func(conn []edge.Listener) { - select { - case c <- conn: - default: - } - }) - - t := time.After(timeout) - - for { - select { - case state := <-c: - if len(state) >= count { - return - } - case <-t: - ctx.Req.Failf("timeout", "listener did not have %v connections within %v", count, timeout) - } - } -} - func (ctx *TestContext) WrapNetConn(conn edge.Conn, err error) *TestConn { ctx.Req.NoError(err) return &TestConn{ diff --git a/tests/data_flow_hs_test.go b/tests/data_flow_hs_test.go index 83d43ff5a..8809e7052 100644 --- a/tests/data_flow_hs_test.go +++ b/tests/data_flow_hs_test.go @@ -38,21 +38,24 @@ func Test_HSDataflow(t *testing.T) { ctx.CreateEnrollAndStartEdgeRouter() + watcher := ctx.AdminManagementSession.newTerminatorWatcher() + defer watcher.Close() + _, hostContext1 := ctx.AdminManagementSession.RequireCreateSdkContext() defer hostContext1.Close() listener1, err := hostContext1.Listen(service.Name) ctx.Req.NoError(err) - ctx.requireNListener(1, listener1, 2*time.Second) _, hostContext2 := ctx.AdminManagementSession.RequireCreateSdkContext() defer hostContext2.Close() listener2, err := hostContext2.Listen(service.Name) ctx.Req.NoError(err) - ctx.requireNListener(1, listener2, 2*time.Second) defer listener2.Close() + watcher.waitForTerminators(service.Id, 2, 2*time.Second) + serverHandler := func(conn *testServerConn) error { for { name, eof := conn.ReadString(1024, time.Minute) diff --git a/tests/external_jwt_signer_test.go b/tests/external_jwt_signer_test.go index 0f39df32a..8e5c75940 100644 --- a/tests/external_jwt_signer_test.go +++ b/tests/external_jwt_signer_test.go @@ -22,8 +22,8 @@ package tests import ( "github.com/google/uuid" "github.com/openziti/edge-api/rest_model" - "github.com/openziti/ziti/controller/persistence" nfpem "github.com/openziti/foundation/v2/pem" + "github.com/openziti/ziti/controller/db" "net/http" "testing" "time" @@ -199,7 +199,7 @@ func Test_ExternalJWTSigner(t *testing.T) { ctx.Req.Equal(jwtSignerCert.NotAfter, time.Time(*jwtSignerDetail.NotAfter)) ctx.Req.Equal(fingerprint, *jwtSignerDetail.Fingerprint) ctx.Req.False(*jwtSignerDetail.UseExternalID) - ctx.Req.Equal(persistence.DefaultClaimsProperty, *jwtSignerDetail.ClaimsProperty) + ctx.Req.Equal(db.DefaultClaimsProperty, *jwtSignerDetail.ClaimsProperty) ctx.Req.Nil(jwtSignerDetail.ExternalAuthURL) ctx.Req.Equal(*jwtSigner.Issuer, *jwtSignerDetail.Issuer) ctx.Req.Equal(*jwtSigner.Audience, *jwtSignerDetail.Audience) diff --git a/tests/identity_test.go b/tests/identity_test.go index 9aaeeb642..ca429e970 100644 --- a/tests/identity_test.go +++ b/tests/identity_test.go @@ -24,10 +24,10 @@ import ( "github.com/golang-jwt/jwt/v5" "github.com/google/uuid" "github.com/openziti/edge-api/rest_model" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/persistence" nfpem "github.com/openziti/foundation/v2/pem" "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/db" "net/http" "net/url" "sort" @@ -127,7 +127,7 @@ func Test_Identity(t *testing.T) { resp, err = ctx.AdminManagementSession.newAuthenticatedRequest().SetResult(getResponse).Get("/identities/" + createResponse.Data.ID) ctx.Req.NoError(err) ctx.Req.Equal(http.StatusOK, resp.StatusCode()) - ctx.Req.Equal(persistence.DefaultAuthPolicyId, *getResponse.Data.AuthPolicyID) + ctx.Req.Equal(db.DefaultAuthPolicyId, *getResponse.Data.AuthPolicyID) }) diff --git a/tests/list_services_perf_test.go b/tests/list_services_perf_test.go index 3d29e2106..9926f3755 100644 --- a/tests/list_services_perf_test.go +++ b/tests/list_services_perf_test.go @@ -5,10 +5,10 @@ package tests import ( "encoding/json" "fmt" - "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/foundation/v2/concurrenz" "github.com/openziti/metrics" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/model" "go.etcd.io/bbolt" "net/url" "os" @@ -70,8 +70,8 @@ func Test_ExportIdentityServicePostureChecks(t *testing.T) { managers := ctx.EdgeController.AppEnv.Managers identityManager := managers.Identity - bindServices := stores.Identity.GetRefCountedLinkCollection(persistence.FieldIdentityBindServices) - dialServices := stores.Identity.GetRefCountedLinkCollection(persistence.FieldIdentityDialServices) + bindServices := stores.Identity.GetRefCountedLinkCollection(db.FieldIdentityBindServices) + dialServices := stores.Identity.GetRefCountedLinkCollection(db.FieldIdentityDialServices) type identityServicePostureChecks struct { Id string diff --git a/tests/model_sdk_performance_test.go b/tests/model_sdk_performance_test.go index 77b7b63e4..a7e969ac5 100644 --- a/tests/model_sdk_performance_test.go +++ b/tests/model_sdk_performance_test.go @@ -10,14 +10,14 @@ import ( service2 "github.com/openziti/edge-api/rest_client_api_client/service" apiClientSession "github.com/openziti/edge-api/rest_client_api_client/session" "github.com/openziti/edge-api/rest_model" - "github.com/openziti/ziti/common/eid" - "github.com/openziti/ziti/controller/model" - "github.com/openziti/ziti/controller/persistence" - "github.com/openziti/ziti/controller/models" "github.com/openziti/foundation/v2/errorz" idloader "github.com/openziti/identity" edge_apis "github.com/openziti/sdk-golang/edge-apis" "github.com/openziti/sdk-golang/ziti" + "github.com/openziti/ziti/common/eid" + "github.com/openziti/ziti/controller/db" + "github.com/openziti/ziti/controller/model" + "github.com/openziti/ziti/controller/models" "github.com/rcrowley/go-metrics" "io" "net/url" @@ -274,7 +274,7 @@ func (ctx *modelPerf) createIdentities(spec *perfScenarioSpec) { enrollments := []*model.Enrollment{ { BaseEntity: models.BaseEntity{}, - Method: persistence.MethodEnrollOtt, + Method: db.MethodEnrollOtt, Token: uuid.New().String(), }, } @@ -358,7 +358,7 @@ func (ctx *modelPerf) createServicePolicy(policyType string, identityRoles, serv PolicyType: policyType, IdentityRoles: identityRoles, ServiceRoles: serviceRoles, - Semantic: persistence.SemanticAnyOf, + Semantic: db.SemanticAnyOf, } ctx.Req.NoError(policyHandler.Create(policy)) } @@ -371,7 +371,7 @@ func (ctx *modelPerf) createEdgeRouterPolicy(identityRoles, edgeRouterRoles []st Name: id, IdentityRoles: identityRoles, EdgeRouterRoles: edgeRouterRoles, - Semantic: persistence.SemanticAnyOf, + Semantic: db.SemanticAnyOf, } ctx.NoError(policyHandler.Create(policy)) } @@ -384,7 +384,7 @@ func (ctx *modelPerf) createServiceEdgeRouterPolicy(edgeRouterRoles, serviceRole Name: id, EdgeRouterRoles: edgeRouterRoles, ServiceRoles: serviceRoles, - Semantic: persistence.SemanticAnyOf, + Semantic: db.SemanticAnyOf, } ctx.NoError(policyHandler.Create(policy)) } diff --git a/tests/terminator_update_test.go b/tests/terminator_update_test.go index 58d7cc1d2..a1f26a941 100644 --- a/tests/terminator_update_test.go +++ b/tests/terminator_update_test.go @@ -37,9 +37,12 @@ func Test_UpdateTerminators(t *testing.T) { _, context := ctx.AdminManagementSession.RequireCreateSdkContext() defer context.Close() + watcher := ctx.AdminManagementSession.newTerminatorWatcher() + defer watcher.Close() + listener, err := context.Listen(service.Name) ctx.Req.NoError(err) - ctx.requireNListener(1, listener, time.Second) + watcher.waitForTerminators(service.Id, 1, 2*time.Second) defer func() { _ = listener.Close() }() terminators := ctx.AdminManagementSession.listTerminators(`binding="edge"`) diff --git a/tunnel/dns/server.go b/tunnel/dns/server.go index 2cadc2ee6..9235f0eeb 100644 --- a/tunnel/dns/server.go +++ b/tunnel/dns/server.go @@ -60,29 +60,32 @@ func flushDnsCaches() { } } -func NewResolver(config string) Resolver { +func NewResolver(config string) (Resolver, error) { flushDnsCaches() if config == "" { - return nil + return nil, nil } resolverURL, err := url.Parse(config) if err != nil { - log.Fatalf("failed to parse resolver configuration '%s': %s", config, err) + return nil, fmt.Errorf("failed to parse resolver configuration '%s': %w", config, err) } switch resolverURL.Scheme { case "", "file": - return NewRefCountingResolver(NewHostFile(resolverURL.Path)) + return NewRefCountingResolver(NewHostFile(resolverURL.Path)), nil case "udp": - return NewRefCountingResolver(NewDnsServer(resolverURL.Host)) + dnsResolver, err := NewDnsServer(resolverURL.Host) + if err != nil { + return nil, err + } + return NewRefCountingResolver(dnsResolver), nil } - log.Fatalf("invalid resolver configuration '%s'. must be 'file://' or 'udp://' URL", config) - return nil + return nil, fmt.Errorf("invalid resolver configuration '%s'. must be 'file://' or 'udp://' URL", config) } -func NewDnsServer(addr string) Resolver { +func NewDnsServer(addr string) (Resolver, error) { log.Infof("starting dns server...") s := &dns.Server{ Addr: addr, @@ -108,9 +111,9 @@ func NewDnsServer(addr string) Resolver { select { case err := <-errChan: if err != nil { - log.Fatalf("dns server failed to start: %s", err) + return nil, fmt.Errorf("dns server failed to start: %w", err) } else { - log.Fatal("dns server stopped prematurely") + return nil, fmt.Errorf("dns server stopped prematurely") } case <-time.After(2 * time.Second): log.Infof("dns server running at %s", s.Addr) @@ -125,10 +128,10 @@ func NewDnsServer(addr string) Resolver { err := r.testSystemResolver() if err != nil { _ = r.Cleanup() - log.Fatalf("system resolver test failed: %s\n\n"+resolverConfigHelp, err, addr) + return nil, fmt.Errorf("system resolver test failed: %s\n\n"+resolverConfigHelp, err, addr) } - return r + return r, nil } func (r *resolver) testSystemResolver() error { diff --git a/tunnel/intercept/proxy/proxy.go b/tunnel/intercept/proxy/proxy.go index f0dd1b48e..8dee0254f 100644 --- a/tunnel/intercept/proxy/proxy.go +++ b/tunnel/intercept/proxy/proxy.go @@ -17,15 +17,14 @@ package proxy import ( - "fmt" "github.com/michaelquigley/pfxlog" + "github.com/openziti/foundation/v2/info" + "github.com/openziti/foundation/v2/mempool" "github.com/openziti/ziti/tunnel" "github.com/openziti/ziti/tunnel/dns" "github.com/openziti/ziti/tunnel/entities" "github.com/openziti/ziti/tunnel/intercept" "github.com/openziti/ziti/tunnel/udp_vconn" - "github.com/openziti/foundation/v2/info" - "github.com/openziti/foundation/v2/mempool" "github.com/pkg/errors" "io" "net" @@ -61,7 +60,6 @@ func (self *Service) Stop() error { type interceptor struct { interceptIP net.IP services map[string]*Service - closeCh chan interface{} } func New(ip net.IP, serviceList []string) (intercept.Interceptor, error) { @@ -98,7 +96,6 @@ func New(ip net.IP, serviceList []string) (intercept.Interceptor, error) { p := interceptor{ interceptIP: ip, services: services, - closeCh: make(chan interface{}), } return &p, nil } @@ -117,27 +114,23 @@ func (p *interceptor) Intercept(service *entities.Service, _ dns.Resolver, _ int // pre-fetch network session todo move this to service poller? service.FabricProvider.PrepForUse(*service.ID) - go p.runServiceListener(proxiedService) - return nil + return p.runServiceListener(proxiedService) } -func (p *interceptor) runServiceListener(service *Service) { +func (p *interceptor) runServiceListener(service *Service) error { if service.Protocol == intercept.TCP { - p.handleTCP(service) - } else { - p.handleUDP(service) + return p.handleTCP(service) } + return p.handleUDP(service) } -func (p *interceptor) handleTCP(service *Service) { +func (p *interceptor) handleTCP(service *Service) error { log := pfxlog.Logger().WithField("service", service.Name) listenAddr := net.TCPAddr{IP: p.interceptIP, Port: service.Port} server, err := net.Listen("tcp4", listenAddr.String()) if err != nil { - log.Fatalln(err) - p.closeCh <- err - return + return err } service.setCloser(server) @@ -145,33 +138,31 @@ func (p *interceptor) handleTCP(service *Service) { log.Info("service is listening") defer log.Info("service stopped") - defer func() { - p.closeCh <- fmt.Sprintf("service listener %s exited", service.Name) - }() - for { - conn, err := server.Accept() - if err != nil { - log.WithError(err).Error("accept failed") - p.closeCh <- err - return + go func() { + for { + conn, err := server.Accept() + if err != nil { + log.WithError(err).Error("accept failed") + return + } + sourceAddr := service.TunnelService.GetSourceAddr(conn.RemoteAddr(), conn.LocalAddr()) + appInfo := tunnel.GetAppInfo("tcp", "", p.interceptIP.String(), strconv.Itoa(service.Port), sourceAddr) + identity := service.TunnelService.GetDialIdentity(conn.RemoteAddr(), conn.LocalAddr()) + go tunnel.DialAndRun(service.TunnelService, identity, conn, appInfo, true) } - sourceAddr := service.TunnelService.GetSourceAddr(conn.RemoteAddr(), conn.LocalAddr()) - appInfo := tunnel.GetAppInfo("tcp", "", p.interceptIP.String(), strconv.Itoa(service.Port), sourceAddr) - identity := service.TunnelService.GetDialIdentity(conn.RemoteAddr(), conn.LocalAddr()) - go tunnel.DialAndRun(service.TunnelService, identity, conn, appInfo, true) - } + }() + + return nil } -func (p *interceptor) handleUDP(service *Service) { +func (p *interceptor) handleUDP(service *Service) error { log := pfxlog.Logger().WithField("service", service.Name) listenAddr := &net.UDPAddr{IP: p.interceptIP, Port: service.Port} udpPacketConn, err := net.ListenUDP("udp", listenAddr) if err != nil { - log.Fatalln(err) - p.closeCh <- err - return + return err } service.setCloser(udpPacketConn) @@ -185,6 +176,7 @@ func (p *interceptor) handleUDP(service *Service) { } vconnManager := udp_vconn.NewManager(service.TunnelService.FabricProvider, udp_vconn.NewUnlimitedConnectionPolicy(), udp_vconn.NewDefaultExpirationPolicy()) go reader.generateReadEvents(vconnManager) + return nil } func (p *interceptor) Stop() { diff --git a/tunnel/intercept/svcpoll.go b/tunnel/intercept/svcpoll.go index ca3f439f0..256fecfa8 100644 --- a/tunnel/intercept/svcpoll.go +++ b/tunnel/intercept/svcpoll.go @@ -20,12 +20,12 @@ import ( "fmt" "github.com/michaelquigley/pfxlog" "github.com/openziti/edge-api/rest_model" + "github.com/openziti/foundation/v2/stringz" + "github.com/openziti/sdk-golang/ziti" "github.com/openziti/ziti/tunnel" "github.com/openziti/ziti/tunnel/dns" "github.com/openziti/ziti/tunnel/entities" "github.com/openziti/ziti/tunnel/health" - "github.com/openziti/foundation/v2/stringz" - "github.com/openziti/sdk-golang/ziti" "github.com/pkg/errors" logrus "github.com/sirupsen/logrus" "net" @@ -84,9 +84,6 @@ func (self *ServiceListenerGroup) WaitForShutdown() { break } - self.Lock() - defer self.Unlock() - for _, listener := range self.listener { listener.stop() } diff --git a/ziti/cmd/database/add_debug_admin.go b/ziti/cmd/database/add_debug_admin.go index 09009df2c..c8b40b30b 100644 --- a/ziti/cmd/database/add_debug_admin.go +++ b/ziti/cmd/database/add_debug_admin.go @@ -26,7 +26,6 @@ import ( "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/model" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/controller/persistence" "github.com/spf13/cobra" ) @@ -84,7 +83,7 @@ func (action *addDebugAdminAction) run(dbFile, username, password string) { managers: controllers, } - stores, err := persistence.NewBoltStores(dbProvider) + stores, err := db.InitStores(boltDb) action.noError(err) id := "debug-admin" @@ -100,10 +99,10 @@ func (action *addDebugAdminAction) run(dbFile, username, password string) { fmt.Printf("removing existing identity with id '%v'\n", id) } - identity = &persistence.Identity{ + identity = &db.Identity{ BaseExtEntity: boltz.BaseExtEntity{Id: id}, Name: name, - IdentityTypeId: persistence.DefaultIdentityType, + IdentityTypeId: db.DefaultIdentityType, IsDefaultAdmin: false, IsAdmin: true, } @@ -113,8 +112,8 @@ func (action *addDebugAdminAction) run(dbFile, username, password string) { authHandler := model.AuthenticatorManager{} result := authHandler.HashPassword(password) - authenticator := &persistence.AuthenticatorUpdb{ - Authenticator: persistence.Authenticator{ + authenticator := &db.AuthenticatorUpdb{ + Authenticator: db.Authenticator{ BaseExtEntity: boltz.BaseExtEntity{ Id: eid.New(), }, diff --git a/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md b/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md index 8796bb93c..e77f097da 100644 --- a/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md +++ b/ziti/cmd/demo/setup-scripts/multi-sdk-hosted.md @@ -1,12 +1,12 @@ # Purpose -This script sets up an echo service which is hosted by two SDK applications and -is accessed by another sdk application. +This script sets up an echo service which is hosted by two SDK applications and is accessed by +another sdk application. # Prerequisites -You need at least one controller and an edge router running. for this to work. -You can use the quick-start script found [here](https://github.com/openziti/ziti/tree/release-next/quickstart). +You need at least one controller and an edge router running. for this to work. You can use the +quick-start script found [here](https://github.com/openziti/ziti/tree/release-next/quickstart). # Setup @@ -40,10 +40,10 @@ ziti edge create service echo -a echo ## Create and enroll the hosting identities ```action:ziti -ziti edge create identity service echo-host-1 -a echo,echo-host -o echo-host-1.jwt +ziti edge create identity echo-host-1 -a echo,echo-host -o echo-host-1.jwt ziti edge enroll --rm echo-host-1.jwt -ziti edge create identity service echo-host-2 -a echo,echo-host -o echo-host-2.jwt +ziti edge create identity echo-host-2 -a echo,echo-host -o echo-host-2.jwt ziti edge enroll --rm echo-host-2.jwt ``` @@ -62,8 +62,7 @@ ziti demo echo-server -i echo-host-1.json ziti demo echo-server -i echo-host-2.json ``` -and -the zcat client using +and the zcat client using ``` ziti demo zcat -i zcat.json ziti:echo diff --git a/ziti/cmd/demo/setup-scripts/sdk-client.md b/ziti/cmd/demo/setup-scripts/sdk-client.md index 09506a053..43bf07f62 100644 --- a/ziti/cmd/demo/setup-scripts/sdk-client.md +++ b/ziti/cmd/demo/setup-scripts/sdk-client.md @@ -4,8 +4,8 @@ This script sets up the SDK client side for an echo service # Prerequisites -You need at least one controller and an edge router running. for this to work. -You can use the quick-start script found [here](https://github.com/openziti/ziti/tree/release-next/quickstart). +You need at least one controller and an edge router running. for this to work. You can use the +quick-start script found [here](https://github.com/openziti/ziti/tree/release-next/quickstart). # Setup @@ -27,7 +27,7 @@ ziti edge delete service-policies echo-dial ## Create and enroll the client app identity ```action:ziti -ziti edge create identity service zcat -a echo,echo-client -o zcat.jwt +ziti edge create identity zcat -a echo,echo-client -o zcat.jwt ziti edge enroll --rm zcat.jwt ``` diff --git a/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md b/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md index fa846f42b..3a2890ef9 100644 --- a/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md +++ b/ziti/cmd/demo/setup-scripts/single-sdk-hosted.md @@ -4,8 +4,8 @@ This script sets up an echo service which is hosted by an SDK application. # Prerequisites -You need at least one controller and an edge router running. for this to work. -You can use the quick-start script found [here](https://github.com/openziti/ziti/tree/release-next/quickstart). +You need at least one controller and an edge router running. for this to work. You can use the +quick-start script found [here](https://github.com/openziti/ziti/tree/release-next/quickstart). # Setup @@ -39,7 +39,7 @@ ziti edge create service echo -a echo ## Create and enroll the hosting identity ```action:ziti -ziti edge create identity service echo-host-1 -a echo,echo-host -o echo-host-1.jwt +ziti edge create identity echo-host-1 -a echo,echo-host -o echo-host-1.jwt ziti edge enroll --rm echo-host-1.jwt ``` @@ -57,8 +57,7 @@ You should now be to run the echo server with ziti demo echo-server -i echo-host-1.json ``` -and -the zcat client using +and the zcat client using ``` ziti demo zcat -i zcat.json ziti:echo diff --git a/ziti/cmd/edge/create_identity.go b/ziti/cmd/edge/create_identity.go index 00a2e0977..fa110f62c 100644 --- a/ziti/cmd/edge/create_identity.go +++ b/ziti/cmd/edge/create_identity.go @@ -18,7 +18,7 @@ package edge import ( "fmt" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/ziti/cmd/api" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/pkg/errors" @@ -110,9 +110,9 @@ func runCreateIdentity(o *createIdentityOptions) error { o.username = strings.TrimSpace(o.username) if o.username != "" { - api.SetJSONValue(entityData, o.username, "enrollment", persistence.MethodEnrollUpdb) + api.SetJSONValue(entityData, o.username, "enrollment", db.MethodEnrollUpdb) } else { - api.SetJSONValue(entityData, true, "enrollment", persistence.MethodEnrollOtt) + api.SetJSONValue(entityData, true, "enrollment", db.MethodEnrollOtt) } api.SetJSONValue(entityData, o.isAdmin, "isAdmin") api.SetJSONValue(entityData, o.roleAttributes, "roleAttributes") @@ -184,9 +184,9 @@ func runCreateIdentity(o *createIdentityOptions) error { if o.jwtOutputFile != "" { id := result.S("data", "id").Data().(string) - enrollmentType := persistence.MethodEnrollOtt + enrollmentType := db.MethodEnrollOtt if o.username != "" { - enrollmentType = persistence.MethodEnrollUpdb + enrollmentType = db.MethodEnrollUpdb } if err = getIdentityJwt(&o.Options, id, o.jwtOutputFile, enrollmentType, o.Options.Timeout, o.Options.Verbose); err != nil { return err @@ -206,9 +206,9 @@ func getIdentityJwt(o *api.Options, id string, outputFile string, enrollmentType } var dataContainer *gabs.Container - if enrollmentType == persistence.MethodEnrollUpdb { + if enrollmentType == db.MethodEnrollUpdb { dataContainer = newIdentity.Path("enrollment.updb.jwt") - } else if enrollmentType == persistence.MethodEnrollOtt { + } else if enrollmentType == db.MethodEnrollOtt { dataContainer = newIdentity.Path("enrollment.ott.jwt") } else { return errors.Errorf("unsupported enrollment type '%s'", enrollmentType) diff --git a/ziti/cmd/edge/quickstart.go b/ziti/cmd/edge/quickstart.go index 5ea1ec649..b77b3bb91 100644 --- a/ziti/cmd/edge/quickstart.go +++ b/ziti/cmd/edge/quickstart.go @@ -146,13 +146,13 @@ func (o *QuickstartOpts) run(ctx context.Context) { o.createMinimalPki() - ctrl := create.NewCmdCreateConfigController() - ctrl.SetArgs([]string{ - fmt.Sprintf("--output=%s", ctrlYaml), - }) - _ = ctrl.Execute() - if !o.AlreadyInitialized { + ctrl := create.NewCmdCreateConfigController() + ctrl.SetArgs([]string{ + fmt.Sprintf("--output=%s", ctrlYaml), + }) + _ = ctrl.Execute() + initCmd := edgeSubCmd.NewEdgeInitializeCmd(version.GetCmdBuildInfo()) initCmd.SetArgs([]string{ fmt.Sprintf("--username=%s", o.Username), @@ -335,12 +335,18 @@ func (o *QuickstartOpts) createMinimalPki() { //ziti pki create server --pki-root="${ZITI_HOME}/pki" --ca-name "intermediate-ca" --server-name "server" --server-file "server" --dns "localhost,${ZITI_HOSTNAME}" svr := pki.NewCmdPKICreateServer(o.out, o.errOut) + var ips = "127.0.0.1,::1" + ip_override := os.Getenv("ZITI_CTRL_EDGE_IP_OVERRIDE") + if ip_override != "" { + ips = ips + "," + ip_override + } svr.SetArgs([]string{ fmt.Sprintf("--pki-root=%s", where), fmt.Sprintf("--ca-name=%s", "intermediate-ca"), fmt.Sprintf("--server-name=%s", "server"), fmt.Sprintf("--server-file=%s", "server"), fmt.Sprintf("--dns=%s,%s", "localhost", helpers.GetCtrlAdvertisedAddress()), + fmt.Sprintf("--ip=%s", ips), }) svrErr := svr.Execute() if svrErr != nil { diff --git a/ziti/cmd/fabric/list.go b/ziti/cmd/fabric/list.go index 10339a422..e0034f17b 100644 --- a/ziti/cmd/fabric/list.go +++ b/ziti/cmd/fabric/list.go @@ -18,6 +18,7 @@ package fabric import ( "fmt" + "github.com/openziti/foundation/v2/stringz" fabric_rest_client "github.com/openziti/ziti/controller/rest_client" "github.com/openziti/ziti/controller/rest_client/circuit" "github.com/openziti/ziti/controller/rest_client/link" @@ -25,11 +26,11 @@ import ( "github.com/openziti/ziti/controller/rest_client/service" "github.com/openziti/ziti/controller/rest_client/terminator" "github.com/openziti/ziti/controller/rest_model" - "github.com/openziti/foundation/v2/stringz" "github.com/openziti/ziti/ziti/cmd/api" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "strings" + "time" "github.com/jedib0t/go-pretty/v6/table" "github.com/jedib0t/go-pretty/v6/text" @@ -92,7 +93,7 @@ func runListCircuits(o *api.Options) error { ctx, cancelF := o.GetContext() defer cancelF() result, err := client.Circuit.ListCircuits(&circuit.ListCircuitsParams{ - //Filter: o.GetFilter(), + Filter: o.GetFilter(), Context: ctx, }) return outputResult(result, err, o, outputCircuits) @@ -102,7 +103,7 @@ func runListCircuits(o *api.Options) error { func outputCircuits(o *api.Options, results *circuit.ListCircuitsOK) error { t := table.NewWriter() t.SetStyle(table.StyleRounded) - t.AppendHeader(table.Row{"ID", "Client", "Service", "Terminator", "Path"}) + t.AppendHeader(table.Row{"ID", "Client", "Service", "Terminator", "CreatedAt", "Path"}) for _, entity := range results.Payload.Data { pathLabel := strings.Builder{} @@ -126,6 +127,7 @@ func outputCircuits(o *api.Options, results *circuit.ListCircuitsOK) error { entity.ClientID, entity.Service.Name, entity.Terminator.ID, + time.Time(*entity.CreatedAt).UTC().Format(time.DateTime), pathLabel.String(), }) } @@ -140,7 +142,7 @@ func runListLinks(o *api.Options) error { ctx, cancelF := o.GetContext() defer cancelF() result, err := client.Link.ListLinks(&link.ListLinksParams{ - //Filter: o.GetFilter(), + Filter: o.GetFilter(), Context: ctx, }) return outputResult(result, err, o, outputLinks) diff --git a/ziti/cmd/fabric/root.go b/ziti/cmd/fabric/root.go index 447d61b0e..51da34c6f 100644 --- a/ziti/cmd/fabric/root.go +++ b/ziti/cmd/fabric/root.go @@ -37,6 +37,7 @@ func NewFabricCmd(p common.OptionsProvider) *cobra.Command { fabricCmd.AddCommand(newDbCmd(p)) fabricCmd.AddCommand(newStreamCommand(p)) fabricCmd.AddCommand(newRaftCmd(p)) + fabricCmd.AddCommand(newValidateCommand(p)) return fabricCmd } @@ -99,6 +100,19 @@ func newStreamCommand(p common.OptionsProvider) *cobra.Command { return streamCmd } +func newValidateCommand(p common.OptionsProvider) *cobra.Command { + validateCmd := &cobra.Command{ + Use: "validate", + Short: "validate model data", + Run: func(cmd *cobra.Command, args []string) { + cmdhelper.CheckErr(cmd.Help()) + }, + } + + validateCmd.AddCommand(NewValidateTerminatorsCmd(p)) + return validateCmd +} + // createEntityOfType create an entity of the given type on the Ziti Controller func createEntityOfType(entityType string, body string, options *api.Options) (*gabs.Container, error) { return util.ControllerCreate("fabric", entityType, body, options.Out, options.OutputJSONRequest, options.OutputJSONResponse, options.Timeout, options.Verbose) diff --git a/ziti/cmd/fabric/validate_terminators.go b/ziti/cmd/fabric/validate_terminators.go new file mode 100644 index 000000000..a40b1677d --- /dev/null +++ b/ziti/cmd/fabric/validate_terminators.go @@ -0,0 +1,124 @@ +/* + Copyright NetFoundry Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package fabric + +import ( + "fmt" + "github.com/michaelquigley/pfxlog" + "github.com/openziti/channel/v2" + "github.com/openziti/channel/v2/protobufs" + "github.com/openziti/ziti/common/pb/mgmt_pb" + "github.com/openziti/ziti/ziti/cmd/api" + "github.com/openziti/ziti/ziti/cmd/common" + "github.com/spf13/cobra" + "google.golang.org/protobuf/proto" + "time" +) + +type validateTerminatorsAction struct { + api.Options + filter string + fixInvalid bool + showOnlyInvalid bool + + eventNotify chan *mgmt_pb.TerminatorDetail +} + +func NewValidateTerminatorsCmd(p common.OptionsProvider) *cobra.Command { + action := validateTerminatorsAction{ + Options: api.Options{ + CommonOptions: p(), + }, + } + + validateTerminatorsCmd := &cobra.Command{ + Use: "terminators", + Short: "Validate terminators", + Example: "ziti fabric validate terminators --circuits --metrics --metrics-filter '.*'", + Args: cobra.ExactArgs(0), + RunE: action.validateTerminators, + } + + action.AddCommonFlags(validateTerminatorsCmd) + validateTerminatorsCmd.Flags().BoolVar(&action.fixInvalid, "fix-invalid", false, "Fix invalid terminators. Usually this means deleting them.") + validateTerminatorsCmd.Flags().BoolVar(&action.showOnlyInvalid, "show-only-invalid", false, "Hide results for valid terminators") + validateTerminatorsCmd.Flags().StringVar(&action.filter, "filter", "", "Specify which terminators to validate") + return validateTerminatorsCmd +} + +func (self *validateTerminatorsAction) validateTerminators(cmd *cobra.Command, _ []string) error { + closeNotify := make(chan struct{}) + self.eventNotify = make(chan *mgmt_pb.TerminatorDetail, 1) + + bindHandler := func(binding channel.Binding) error { + binding.AddReceiveHandler(int32(mgmt_pb.ContentType_ValidateTerminatorResultType), self) + binding.AddCloseHandler(channel.CloseHandlerF(func(ch channel.Channel) { + close(closeNotify) + })) + return nil + } + + ch, err := api.NewWsMgmtChannel(channel.BindHandlerF(bindHandler)) + if err != nil { + return err + } + + request := &mgmt_pb.ValidateTerminatorsRequest{ + Filter: self.filter, + FixInvalid: self.fixInvalid, + } + + responseMsg, err := protobufs.MarshalTyped(request).WithTimeout(time.Duration(self.Timeout) * time.Second).SendForReply(ch) + + response := &mgmt_pb.ValidateTerminatorsResponse{} + if err = protobufs.TypedResponse(response).Unmarshall(responseMsg, err); err != nil { + return err + } + + if !response.Success { + return fmt.Errorf("failed to start terminator validation: %s", response.Message) + } + + fmt.Printf("started validation of %v terminators\n", response.TerminatorCount) + + expected := response.TerminatorCount + + for expected > 0 { + select { + case <-closeNotify: + fmt.Printf("channel closed, exiting") + return nil + case detail := <-self.eventNotify: + if !self.showOnlyInvalid || detail.State != mgmt_pb.TerminatorState_Valid { + fmt.Printf("id: %s, binding: %s, hostId: %s, routerId: %s, state: %s, fixed: %v, detail: %s\n", + detail.TerminatorId, detail.Binding, detail.HostId, detail.RouterId, detail.State.String(), detail.Fixed, detail.Detail) + } + expected-- + } + } + return nil +} + +func (self *validateTerminatorsAction) HandleReceive(msg *channel.Message, _ channel.Channel) { + detail := &mgmt_pb.TerminatorDetail{} + if err := proto.Unmarshal(msg.Body, detail); err != nil { + pfxlog.Logger().WithError(err).Error("unable to unmarshal terminator detail") + return + } + + self.eventNotify <- detail +} diff --git a/ziti/router/run.go b/ziti/router/run.go index 638413f47..4edbc1b87 100644 --- a/ziti/router/run.go +++ b/ziti/router/run.go @@ -20,16 +20,16 @@ import ( "fmt" "github.com/michaelquigley/pfxlog" "github.com/openziti/agent" + "github.com/openziti/foundation/v2/debugz" "github.com/openziti/ziti/common" + "github.com/openziti/ziti/common/version" + "github.com/openziti/ziti/router" "github.com/openziti/ziti/router/debugops" "github.com/openziti/ziti/router/fabric" + "github.com/openziti/ziti/router/xgress" "github.com/openziti/ziti/router/xgress_edge" "github.com/openziti/ziti/router/xgress_edge_transport" "github.com/openziti/ziti/router/xgress_edge_tunnel" - "github.com/openziti/ziti/router" - "github.com/openziti/ziti/router/xgress" - "github.com/openziti/foundation/v2/debugz" - "github.com/openziti/ziti/common/version" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -75,7 +75,7 @@ func run(cmd *cobra.Command, args []string) { stateManager := fabric.NewStateManager() - xgressEdgeFactory := xgress_edge.NewFactory(config, version.GetCmdBuildInfo(), stateManager, r.GetMetricsRegistry()) + xgressEdgeFactory := xgress_edge.NewFactory(config, r, stateManager) xgress.GlobalRegistry().Register(common.EdgeBinding, xgressEdgeFactory) if err := r.RegisterXrctrl(xgressEdgeFactory); err != nil { logrus.WithError(err).Panic("error registering edge in framework") diff --git a/ziti/tunnel/root.go b/ziti/tunnel/root.go index 6248aa426..8a21abf32 100644 --- a/ziti/tunnel/root.go +++ b/ziti/tunnel/root.go @@ -28,13 +28,13 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/agent" + "github.com/openziti/sdk-golang/ziti" + "github.com/openziti/ziti/common/enrollment" + "github.com/openziti/ziti/common/version" "github.com/openziti/ziti/tunnel" "github.com/openziti/ziti/tunnel/dns" "github.com/openziti/ziti/tunnel/entities" "github.com/openziti/ziti/tunnel/intercept" - "github.com/openziti/sdk-golang/ziti" - "github.com/openziti/ziti/common/enrollment" - "github.com/openziti/ziti/common/version" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -136,7 +136,10 @@ func rootPostRun(cmd *cobra.Command, _ []string) { sdkinfo.SetApplication("ziti-tunnel", version.GetVersion()) resolverConfig := cmd.Flag(resolverCfgFlag).Value.String() - resolver := dns.NewResolver(resolverConfig) + resolver, err := dns.NewResolver(resolverConfig) + if err != nil { + log.WithError(err).Fatal("failed to start DNS resolver") + } serviceListenerGroup := intercept.NewServiceListenerGroup(interceptor, resolver) diff --git a/zititest/go.mod b/zititest/go.mod index b16ad44e8..bc1baa0fc 100644 --- a/zititest/go.mod +++ b/zititest/go.mod @@ -11,21 +11,21 @@ require ( github.com/google/uuid v1.4.0 github.com/michaelquigley/pfxlog v0.6.10 github.com/openziti/agent v1.0.16 - github.com/openziti/channel/v2 v2.0.105 - github.com/openziti/fablab v0.5.25 - github.com/openziti/foundation/v2 v2.0.33 - github.com/openziti/identity v1.0.66 - github.com/openziti/sdk-golang v0.20.129 - github.com/openziti/storage v0.2.23 - github.com/openziti/transport/v2 v2.0.113 + github.com/openziti/channel/v2 v2.0.111 + github.com/openziti/fablab v0.5.32 + github.com/openziti/foundation/v2 v2.0.35 + github.com/openziti/identity v1.0.68 + github.com/openziti/sdk-golang v0.20.139 + github.com/openziti/storage v0.2.26 + github.com/openziti/transport/v2 v2.0.119 github.com/openziti/ziti v0.28.3 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/sirupsen/logrus v1.9.3 - github.com/spf13/cobra v1.7.0 + github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.8.4 go.etcd.io/bbolt v1.3.8 - golang.org/x/net v0.17.0 + golang.org/x/net v0.19.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -40,7 +40,7 @@ require ( github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect - github.com/aws/aws-sdk-go v1.47.0 // indirect + github.com/aws/aws-sdk-go v1.47.10 // indirect github.com/biogo/store v0.0.0-20200525035639-8c94ae1e7c9c // indirect github.com/blang/semver v3.5.1+incompatible // indirect github.com/boltdb/bolt v1.3.1 // indirect @@ -56,12 +56,12 @@ require ( github.com/ef-ds/deque v1.0.4 // indirect github.com/eliukblau/pixterm/pkg/ansimage v0.0.0-20191210081756-9fb6cf8c2f75 // indirect github.com/emirpasic/gods v1.18.1 // indirect - github.com/fatih/color v1.15.0 // indirect - github.com/felixge/httpsnoop v1.0.1 // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/felixge/httpsnoop v1.0.3 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa // indirect github.com/go-acme/lego/v4 v4.14.2 // indirect - github.com/go-jose/go-jose/v3 v3.0.0 // indirect + github.com/go-jose/go-jose/v3 v3.0.1 // indirect github.com/go-logr/logr v1.3.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -71,7 +71,7 @@ require ( github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/loads v0.21.2 // indirect github.com/go-openapi/runtime v0.26.0 // indirect - github.com/go-openapi/spec v0.20.9 // indirect + github.com/go-openapi/spec v0.20.11 // indirect github.com/go-openapi/strfmt v0.21.7 // indirect github.com/go-openapi/swag v0.22.4 // indirect github.com/go-openapi/validate v0.22.1 // indirect @@ -79,11 +79,11 @@ require ( github.com/golang-jwt/jwt/v5 v5.0.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/gomarkdown/markdown v0.0.0-20230922112808-5421fefb8386 // indirect - github.com/gorilla/handlers v1.5.1 // indirect - github.com/gorilla/mux v1.8.0 // indirect + github.com/gorilla/handlers v1.5.2 // indirect + github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/gorilla/websocket v1.5.1 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-msgpack v0.5.5 // indirect @@ -128,11 +128,11 @@ require ( github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/openziti/dilithium v0.3.3 // indirect - github.com/openziti/edge-api v0.26.0 // indirect + github.com/openziti/edge-api v0.26.1 // indirect github.com/openziti/jwks v1.0.3 // indirect - github.com/openziti/metrics v1.2.37 // indirect - github.com/openziti/runzmd v1.0.33 // indirect - github.com/openziti/secretstream v0.1.13 // indirect + github.com/openziti/metrics v1.2.40 // indirect + github.com/openziti/runzmd v1.0.36 // indirect + github.com/openziti/secretstream v0.1.14 // indirect github.com/openziti/x509-claims v1.0.3 // indirect github.com/openziti/xweb/v2 v2.1.0 // indirect github.com/openziti/ziti-db-explorer v1.1.3 // indirect @@ -150,7 +150,7 @@ require ( github.com/russross/blackfriday v1.6.0 // indirect github.com/sagikazarmark/locafero v0.3.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/shirou/gopsutil/v3 v3.23.9 // indirect + github.com/shirou/gopsutil/v3 v3.23.11 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect github.com/sourcegraph/conc v0.3.0 // indirect @@ -170,22 +170,23 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect github.com/zitadel/oidc/v2 v2.7.0 // indirect - go.mongodb.org/mongo-driver v1.12.1 // indirect + go.mongodb.org/mongo-driver v1.13.0 // indirect go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect - go.opentelemetry.io/otel v1.19.0 // indirect - go.opentelemetry.io/otel/metric v1.19.0 // indirect - go.opentelemetry.io/otel/trace v1.19.0 // indirect + go.opentelemetry.io/otel v1.20.0 // indirect + go.opentelemetry.io/otel/metric v1.20.0 // indirect + go.opentelemetry.io/otel/trace v1.20.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.14.0 // indirect + go4.org v0.0.0-20180809161055-417644f6feb5 // indirect + golang.org/x/crypto v0.16.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/image v0.13.0 // indirect golang.org/x/mod v0.13.0 // indirect golang.org/x/oauth2 v0.12.0 // indirect - golang.org/x/sync v0.4.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sync v0.5.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect gopkg.in/AlecAivazis/survey.v1 v1.8.7 // indirect diff --git a/zititest/go.sum b/zititest/go.sum index bd8d036db..49ab4fa70 100644 --- a/zititest/go.sum +++ b/zititest/go.sum @@ -96,8 +96,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/aws/aws-sdk-go v1.47.0 h1:/JUg9V1+xh+qBn8A6ec/l15ETPaMaBqxkjz+gg63dNk= -github.com/aws/aws-sdk-go v1.47.0/go.mod h1:DlEaEbWKZmsITVbqlSVvekPARM1HzeV9PMYg15ymSDA= +github.com/aws/aws-sdk-go v1.47.10 h1:cvufN7WkD1nlOgpRopsmxKQlFp5X1MfyAw4r7BBORQc= +github.com/aws/aws-sdk-go v1.47.10/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= @@ -139,7 +139,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= @@ -181,10 +181,10 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= +github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= @@ -206,8 +206,8 @@ github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo= -github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= +github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= +github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -244,8 +244,8 @@ github.com/go-openapi/runtime v0.26.0 h1:HYOFtG00FM1UvqrcxbEJg/SwvDRvYLQKGhw2zaQ github.com/go-openapi/runtime v0.26.0/go.mod h1:QgRGeZwrUcSHdeh4Ka9Glvo0ug1LC5WyE+EV88plZrQ= github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= -github.com/go-openapi/spec v0.20.9 h1:xnlYNQAwKd2VQRRfwTEI0DcK+2cbuvI/0c7jx3gA8/8= -github.com/go-openapi/spec v0.20.9/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= +github.com/go-openapi/spec v0.20.11 h1:J/TzFDLTt4Rcl/l1PmyErvkqlJDncGvPTMnCI39I4gY= +github.com/go-openapi/spec v0.20.11/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg= @@ -378,17 +378,17 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -626,32 +626,32 @@ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYr github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openziti/agent v1.0.16 h1:9Saji+8hFE1NpzP2XzDhsVJbCrDlhixoLHfOpFt5Z+U= github.com/openziti/agent v1.0.16/go.mod h1:zfm53+PVWoGFzjGGgQdKby5749G6VRYHe+eQJmoVKy4= -github.com/openziti/channel/v2 v2.0.105 h1:WT2zFF7krZkYUfuXA+4tQxhYiiVWlldD3mKX3qJU9Ww= -github.com/openziti/channel/v2 v2.0.105/go.mod h1:++bV6FFgGUNxaBu7iOkkCa6rSiueU34Kd6f2LSCrEtU= +github.com/openziti/channel/v2 v2.0.111 h1:ZZDyUUFcyshitXjUqAMjdAKbaDMpgV7oX1Jp1I35Rc4= +github.com/openziti/channel/v2 v2.0.111/go.mod h1:abw0qwT0MzWvh1eI2P6D6CD17PRHL8EEo1d3DHCyCdM= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= -github.com/openziti/edge-api v0.26.0 h1:082hXjj8rnyMBZHYiB6jb4n7mCXtdMXpF2iCqZOv4IM= -github.com/openziti/edge-api v0.26.0/go.mod h1:/e1pK92L471fvOAwE/hLX5sqBuuo+NwI8vmL04dUHsM= -github.com/openziti/fablab v0.5.25 h1:KxbhNFeX40TlB1Ot+KnEZos0LYtTs77dNekIMRDLvEg= -github.com/openziti/fablab v0.5.25/go.mod h1:uUY3gr4IcGL6vsxBX7gA/b/StF0mHsICkW8HZBvkx9o= -github.com/openziti/foundation/v2 v2.0.33 h1:8CP+fi4KsmzA4jDi54jibwFWWxKpd0rSiplzN9Z0Isw= -github.com/openziti/foundation/v2 v2.0.33/go.mod h1:dWR0g3NOka3uKz9MgUHq6dmuRLmSvunkyeuOXEW/5qU= -github.com/openziti/identity v1.0.66 h1:wCIVNCoiHmeicC9yM15FC0xe6jSic879ztN63fSD6hM= -github.com/openziti/identity v1.0.66/go.mod h1:grReHVqBwhECrnrAZCxNw4ZpA2I1ox66tYfPkfGuKJY= +github.com/openziti/edge-api v0.26.1 h1:osj2irTMMvoP5jLQwJOIKFEellK6AFyT6wB0NzDdalY= +github.com/openziti/edge-api v0.26.1/go.mod h1:bHEkOF9UTjGgjHhmsjnxxNybdijJ91jpdG1WFc9morU= +github.com/openziti/fablab v0.5.32 h1:F2n3m+EZ9ulXUnnox2x6SjsuYQkuNnSao62FaLhLSUA= +github.com/openziti/fablab v0.5.32/go.mod h1:qgW8yiZ7lXuE0FZ85pL4t4ohD5JAnNU1r4EdGLs2TM4= +github.com/openziti/foundation/v2 v2.0.35 h1:4VaMwZ2kAy6jwBYeQIBN2m8rcGroTDX4A2Jp7NAKb6M= +github.com/openziti/foundation/v2 v2.0.35/go.mod h1:Xnb3IxP1e1UcgLggqSunEpCjH3iHozkPi9Bd9GESbwo= +github.com/openziti/identity v1.0.68 h1:SaFr7BeFQBoWQDiT28vUb8D9w7v6lIAK6/9RkwmV0OU= +github.com/openziti/identity v1.0.68/go.mod h1:HbOu3TQ032v8xE6xZWjO51azF4fUxRLjO/l/oGqJwUI= github.com/openziti/jwks v1.0.3 h1:hf8wkb+Cg4nH/HM0KROFd7u+C3DkRVcFZJ7tDV+4icc= github.com/openziti/jwks v1.0.3/go.mod h1:t4xxq8vlXGsPn29kiQVnZBBDDnEoOFqtJoHibkJunQQ= -github.com/openziti/metrics v1.2.37 h1:5yWvMwQT6X43LDlNVcUtqAPJQXfKtbWSYoCIiOfXztg= -github.com/openziti/metrics v1.2.37/go.mod h1:jIL9iilxby8tR98C18uZaSe6bRG15ItR8XF2hmMt8vs= -github.com/openziti/runzmd v1.0.33 h1:tOyjRoUuVXIo1z1pNU32jALWkMmhzsSaDrhLtuOn3Ts= -github.com/openziti/runzmd v1.0.33/go.mod h1:8c/uvZR/XWXQNllTq6LuTpfKL2DTNxfI2X2wYhgRwik= -github.com/openziti/sdk-golang v0.20.129 h1:FjvXsGFxEiHq89sNyLSvNymruACFW5tbhkgZ3VCg2pE= -github.com/openziti/sdk-golang v0.20.129/go.mod h1:ZpJ7HCcIQbp8XiSno3YXkfhoDIbgjCjS2ScK2bda8eo= -github.com/openziti/secretstream v0.1.13 h1:grp53Q5gCFPXv6okwWHDVvqBBk2BhD0ikHwfV3Adhnc= -github.com/openziti/secretstream v0.1.13/go.mod h1:M4DYavDc3TVF/eemNqp5Fa+zGuYTNa0HTGSz/GkgUzA= -github.com/openziti/storage v0.2.23 h1:R5ZBGDGC/LvOz3fE/GlevwbPZ3HL7VxYEvlhKuezvNU= -github.com/openziti/storage v0.2.23/go.mod h1:NZCrN2dLtRU73McVEflK5prDgYds9J54mMNz5DmgvZE= -github.com/openziti/transport/v2 v2.0.113 h1:xFPd1W00KqkFb62rRsRXmLqfgr9d9uk0CAVZegvtGhA= -github.com/openziti/transport/v2 v2.0.113/go.mod h1:TSDHV7RTGg/FinzfOP8cg86O53BCabXedANh3eUNics= +github.com/openziti/metrics v1.2.40 h1:gySRgR8prCPqaEjmUtX0eXFs7NkI9uPAzp+z6A8+JqA= +github.com/openziti/metrics v1.2.40/go.mod h1:HXdVryf3xpZfnY4VcaOjMxiBv+qw0wJlEJNLbooB9hY= +github.com/openziti/runzmd v1.0.36 h1:HOqTZFzTTFu52qmCAQfFvKDmCSl8ZqP1PQQ0UnJIA4E= +github.com/openziti/runzmd v1.0.36/go.mod h1:jYqummjskmFh63htJFF2SrUuvxNQifqd5REUhYVaY/A= +github.com/openziti/sdk-golang v0.20.139 h1:1TaRTd5KmSrfHR6W3ASuj651o37h4NOXTRC6K53Pf3k= +github.com/openziti/sdk-golang v0.20.139/go.mod h1:z2gUWwonLa+haq40cfsNE2P23RoD+SZhxWulG7w7aI0= +github.com/openziti/secretstream v0.1.14 h1:Ta+nB5Prcct+L5LIKUA1nE56QhWS6lMPQYTlpxUltU0= +github.com/openziti/secretstream v0.1.14/go.mod h1:/hhuLfu+GIv0+cnapfsu/VOnXEvmTt3GKtCu+lQ0RIw= +github.com/openziti/storage v0.2.26 h1:15EbOC6A//dsdLSs/RYJP6Qn3Rj6Od4btXEWGezatxc= +github.com/openziti/storage v0.2.26/go.mod h1:pDCkPIN7h9L+FyJP+hcfOwk+GofzrrNoYsAThOjNza0= +github.com/openziti/transport/v2 v2.0.119 h1:KOgHU+9EZUVPvv8ncifqHmNEcFUHbJHigo3jyPvWnOc= +github.com/openziti/transport/v2 v2.0.119/go.mod h1:H2IIBP6ed9isE/eJHGXtAZL0d73ApYOpLG9sSvutNNI= github.com/openziti/x509-claims v1.0.3 h1:HNdQ8Nf1agB3lBs1gahcO6zfkeS4S5xoQ2/PkY4HRX0= github.com/openziti/x509-claims v1.0.3/go.mod h1:Z0WIpBm6c4ecrpRKrou6Gk2wrLWxJO/+tuUwKh8VewE= github.com/openziti/xweb/v2 v2.1.0 h1:Xhh3C2pZkq/Prr65V+SfFSibLDYteoc4f62KQCcTZF4= @@ -742,8 +742,8 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shirou/gopsutil/v3 v3.23.9 h1:ZI5bWVeu2ep4/DIxB4U9okeYJ7zp/QLTO4auRb/ty/E= -github.com/shirou/gopsutil/v3 v3.23.9/go.mod h1:x/NWSb71eMcjFIO0vhyGW5nZ7oSIgVjrCnADckb85GA= +github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ= +github.com/shirou/gopsutil/v3 v3.23.11/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -802,8 +802,8 @@ github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -889,8 +889,8 @@ go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsX go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= -go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= -go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= +go.mongodb.org/mongo-driver v1.13.0 h1:67DgFFjYOCMWdtTEmKFpV3ffWlFnh+CYZ8ZS/tXWUfY= +go.mongodb.org/mongo-driver v1.13.0/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 h1:CCriYyAfq1Br1aIYettdHZTy8mBTIPo7We18TuO/bak= go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= @@ -901,13 +901,13 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= -go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= -go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= -go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= +go.opentelemetry.io/otel v1.20.0 h1:vsb/ggIY+hUjD/zCAQHpzTmndPqv/ml2ArbsbfBYTAc= +go.opentelemetry.io/otel v1.20.0/go.mod h1:oUIGj3D77RwJdM6PPZImDpSZGDvkD9fhesHny69JFrs= +go.opentelemetry.io/otel/metric v1.20.0 h1:ZlrO8Hu9+GAhnepmRGhSU7/VkpjrNowxRN9GyKR4wzA= +go.opentelemetry.io/otel/metric v1.20.0/go.mod h1:90DRw3nfK4D7Sm/75yQ00gTJxtkBxX+wu6YaNymbpVM= go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY= -go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= -go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +go.opentelemetry.io/otel/trace v1.20.0 h1:+yxVAPZPbQhbC3OfAkeIVTky6iTFpcr4SiY9om7mXSQ= +go.opentelemetry.io/otel/trace v1.20.0/go.mod h1:HJSK7F/hA5RlzpZ0zKDCHCDHm556LCDtKaAo6JmBFUU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -920,6 +920,7 @@ go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go4.org v0.0.0-20180809161055-417644f6feb5 h1:+hE86LblG4AyDgwMCLTE6FOlM9+qjHSYS+rKqxUVdsM= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= @@ -947,8 +948,9 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1049,8 +1051,9 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1082,8 +1085,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180606202747-9527bec2660b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1169,16 +1172,17 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1192,8 +1196,9 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/zititest/models/router-test/main.go b/zititest/models/router-test/main.go index 370e264d2..d7f01a097 100644 --- a/zititest/models/router-test/main.go +++ b/zititest/models/router-test/main.go @@ -19,7 +19,7 @@ import ( "github.com/openziti/fablab/kernel/lib/runlevel/6_disposal/terraform" "github.com/openziti/fablab/kernel/model" "github.com/openziti/fablab/resources" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/zititest/models/test_resources" "github.com/openziti/ziti/zititest/zitilab" "github.com/openziti/ziti/zititest/zitilab/actions/edge" @@ -65,7 +65,7 @@ func (d dbStrategy) GetDbFile(*model.Model) string { return getDbFile() } -func (d dbStrategy) GetSite(router *persistence.EdgeRouter) (string, bool) { +func (d dbStrategy) GetSite(router *db.EdgeRouter) (string, bool) { for _, attr := range router.RoleAttributes { if strings.Contains(attr, "Hosted") { return "us-west-2b", true @@ -74,7 +74,7 @@ func (d dbStrategy) GetSite(router *persistence.EdgeRouter) (string, bool) { return "us-west-1c", true } -func (d dbStrategy) PostProcess(router *persistence.EdgeRouter, c *model.Component) { +func (d dbStrategy) PostProcess(router *db.EdgeRouter, c *model.Component) { if router.IsTunnelerEnabled { c.Scope.Tags = append(c.Scope.Tags, "tunneler") } diff --git a/zititest/models/sdk-hosting-test/configs/ctrl.yml.tmpl b/zititest/models/sdk-hosting-test/configs/ctrl.yml.tmpl index f54e8478b..5a134a115 100644 --- a/zititest/models/sdk-hosting-test/configs/ctrl.yml.tmpl +++ b/zititest/models/sdk-hosting-test/configs/ctrl.yml.tmpl @@ -5,7 +5,7 @@ raft: minClusterSize: 3 dataDir: /home/{{ .Model.MustVariable "credentials.ssh.username" }}/fablab/ctrldata {{else}} -db: /home/{{ .Model.MustVariable "credentials.ssh.username" }}/fablab/ctrl.db +db: /home/{{ .Model.MustVariable "credentials.ssh.username" }}/ctrl.db {{end}} identity: @@ -36,30 +36,31 @@ ctrl: # connections. The value of newListener must be resolvable both via DNS and validate via certificates #newListener: tls:localhost:6262 -#events: -# jsonLogger: -# subscriptions: -# - type: fabric.routers -# - type: fabric.terminators +events: + jsonLogger: + subscriptions: + - type: entityChange + - type: edge.apiSessions + - type: edge.entityCounts + interval: 15s + - type: edge.sessions + - type: fabric.routers + - type: fabric.terminators # - type: metrics # sourceFilter: .* # metricFilter: .*egress.*m1_rate* # - type: fabric.circuits # include: # - created -# - type: edge.sessions # include: # - created -# - type: edge.apiSessions # - type: fabric.usage # - type: services # - type: fabric.usage -# - type: edge.entityCounts -# interval: 5s -# handler: -# type: file -# format: json -# path: /tmp/ziti-events.log + handler: + type: file + format: json + path: /home/{{ .Model.MustVariable "credentials.ssh.username" }}/logs/event.log healthChecks: boltCheck: diff --git a/zititest/models/sdk-hosting-test/configs/router.yml.tmpl b/zititest/models/sdk-hosting-test/configs/router.yml.tmpl index 0f5bd0e01..72999dd24 100644 --- a/zititest/models/sdk-hosting-test/configs/router.yml.tmpl +++ b/zititest/models/sdk-hosting-test/configs/router.yml.tmpl @@ -41,7 +41,7 @@ listeners: {{if .Component.HasTag "tunneler"}} - binding: tunnel options: - mode: tproxy + mode: host {{end}} - binding: edge address: tls:0.0.0.0:6262 diff --git a/zititest/models/sdk-hosting-test/main.go b/zititest/models/sdk-hosting-test/main.go index c4e462857..175660e99 100644 --- a/zititest/models/sdk-hosting-test/main.go +++ b/zititest/models/sdk-hosting-test/main.go @@ -3,6 +3,7 @@ package main import ( "embed" _ "embed" + "errors" "fmt" "github.com/openziti/fablab" "github.com/openziti/fablab/kernel/lib/actions" @@ -19,35 +20,30 @@ import ( "github.com/openziti/fablab/kernel/lib/runlevel/6_disposal/terraform" "github.com/openziti/fablab/kernel/model" "github.com/openziti/fablab/resources" - "github.com/openziti/ziti/controller/persistence" + "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/zititest/models/test_resources" "github.com/openziti/ziti/zititest/zitilab" "github.com/openziti/ziti/zititest/zitilab/actions/edge" "github.com/openziti/ziti/zititest/zitilab/models" "go.etcd.io/bbolt" "os" + "os/exec" "path" "strings" "time" ) -const TargetZitiVersion = "v0.30.5" +// const TargetZitiVersion = "v0.31.0" -//go:embed configs -var configResource embed.FS +const TargetZitiVersion = "" +const TargetZitiEdgeTunnelVersion = "" -type scaleStrategy struct{} +//const TargetZitiEdgeTunnelVersion = "0.22.12" -func (self scaleStrategy) IsScaled(entity model.Entity) bool { - return entity.GetType() == model.EntityTypeHost && entity.GetScope().HasTag("scaled") -} +var TunnelType = "!zet" -func (self scaleStrategy) GetEntityCount(entity model.Entity) uint32 { - if entity.GetType() == model.EntityTypeHost && entity.GetScope().HasTag("scaled") { - return 4 - } - return 1 -} +//go:embed configs +var configResource embed.FS type dbStrategy struct{} @@ -55,7 +51,7 @@ func (d dbStrategy) GetDbFile(m *model.Model) string { return m.MustStringVariable("db_file") } -func (d dbStrategy) GetSite(router *persistence.EdgeRouter) (string, bool) { +func (d dbStrategy) GetSite(router *db.EdgeRouter) (string, bool) { if strings.Contains(strings.ToLower(router.Name), "london") { return "eu-west-2a", true // london region } @@ -69,13 +65,13 @@ func (d dbStrategy) GetSite(router *persistence.EdgeRouter) (string, bool) { return "us-east-1a", true } -func (d dbStrategy) PostProcess(router *persistence.EdgeRouter, c *model.Component) { +func (d dbStrategy) PostProcess(router *db.EdgeRouter, c *model.Component) { if router.IsTunnelerEnabled { c.Scope.Tags = append(c.Scope.Tags, "tunneler") } c.Scope.Tags = append(c.Scope.Tags, "edge-router") c.Scope.Tags = append(c.Scope.Tags, "pre-created") - c.Host.InstanceType = "c5.large" + c.Host.InstanceType = "c5.xlarge" c.Type.(*zitilab.RouterType).Version = TargetZitiVersion } @@ -87,8 +83,8 @@ func (d dbStrategy) ProcessDbModel(tx *bbolt.Tx, m *model.Model, builder *models } func (d dbStrategy) CreateIdentityHosts(tx *bbolt.Tx, m *model.Model, builder *models.ZitiDbBuilder) error { - edgeStores := builder.GetEdgeStores() - ids, _, err := edgeStores.Identity.QueryIds(tx, "true limit none") + stores := builder.GetStores() + ids, _, err := stores.Identity.QueryIds(tx, "true limit none") if err != nil { return err } @@ -97,12 +93,12 @@ func (d dbStrategy) CreateIdentityHosts(tx *bbolt.Tx, m *model.Model, builder *m hostingIdentities := map[string]int{} for _, identityId := range ids { - cursorProvider := edgeStores.Identity.GetIdentityServicesCursorProvider(identityId) + cursorProvider := stores.Identity.GetIdentityServicesCursorProvider(identityId) cursor := cursorProvider(tx, true) identityServiceCount := 0 for cursor.IsValid() { serviceId := string(cursor.Current()) - if edgeStores.EdgeService.IsBindableByIdentity(tx, serviceId, identityId) { + if stores.EdgeService.IsBindableByIdentity(tx, serviceId, identityId) { identityServiceCount++ } cursor.Next() @@ -113,6 +109,8 @@ func (d dbStrategy) CreateIdentityHosts(tx *bbolt.Tx, m *model.Model, builder *m } } + fmt.Printf("service count: %v\n", servicesCount) + regionCount := len(m.Regions) perRegion := servicesCount / regionCount @@ -151,7 +149,7 @@ func (d dbStrategy) CreateIdentityHosts(tx *bbolt.Tx, m *model.Model, builder *m Scope: model.Scope{Tags: model.Tags{}}, Region: region, Components: model.Components{}, - InstanceType: "t3.medium", + InstanceType: "t3.xlarge", } hostId := fmt.Sprintf("%s_svc_hosts_%v", regionId, i) region.Hosts[hostId] = tunnelsHost @@ -165,13 +163,30 @@ func (d dbStrategy) CreateIdentityHosts(tx *bbolt.Tx, m *model.Model, builder *m svcCount := hostingIdentities[identityId] + getConfigPath := func(c *model.Component) string { + user := c.GetHost().GetSshUser() + return fmt.Sprintf("/home/%s/etc/%s.json", user, c.Id) + } + + var tunnelType model.ComponentType + if TunnelType == "zet" { + tunnelType = &zitilab.ZitiEdgeTunnelType{ + Version: TargetZitiEdgeTunnelVersion, + LogConfig: "'2;bind.c=6'", + ConfigPathF: getConfigPath, + } + } else { + tunnelType = &zitilab.ZitiTunnelType{ + Mode: zitilab.ZitiTunnelModeHost, + Version: TargetZitiVersion, + ConfigPathF: getConfigPath, + } + } + tunnelComponent := &model.Component{ Scope: model.Scope{Tags: model.Tags{"sdk-tunneler", "pre-created", fmt.Sprintf("serviceCount=%v", svcCount)}}, - Type: &zitilab.ZitiTunnelType{ - Mode: zitilab.ZitiTunnelModeHost, - Version: TargetZitiVersion, - }, - Host: tunnelHost, + Type: tunnelType, + Host: tunnelHost, } tunnelHost.Components[identityId] = tunnelComponent } @@ -183,7 +198,7 @@ func (d dbStrategy) CreateIdentityHosts(tx *bbolt.Tx, m *model.Model, builder *m var dbStrategyInstance = dbStrategy{} var m = &model.Model{ - Id: "router-test", + Id: "sdk-hosting-test", Scope: model.Scope{ Defaults: model.Variables{ "environment": "sdk-hosting-test", @@ -208,7 +223,6 @@ var m = &model.Model{ }, }, StructureFactories: []model.Factory{ - model.NewScaleFactoryWithDefaultEntityFactory(scaleStrategy{}), &models.ZitiDbBuilder{Strategy: dbStrategyInstance}, }, Resources: model.Resources{ @@ -222,7 +236,7 @@ var m = &model.Model{ Site: "us-east-1a", Hosts: model.Hosts{ "ctrl": { - InstanceType: "c5.large", + InstanceType: "c5.xlarge", Components: model.Components{ "ctrl": { Scope: model.Scope{Tags: model.Tags{"ctrl"}}, @@ -240,16 +254,15 @@ var m = &model.Model{ "bootstrap": model.ActionBinder(func(m *model.Model) model.Action { workflow := actions.Workflow() - //workflow.AddAction(component.Stop("*")) - //workflow.AddAction(host.GroupExec("*", 25, "rm -f logs/*")) - workflow.AddAction(component.Start("#ctrl")) workflow.AddAction(semaphore.Sleep(2 * time.Second)) workflow.AddAction(edge.Login("#ctrl")) workflow.AddAction(edge.ReEnrollEdgeRouters(".edge-router .pre-created", 2)) - workflow.AddAction(edge.ReEnrollIdentities(".sdk-tunneler .pre-created", 10)) + if quickRun, _ := m.GetBoolVariable("quick_run"); !quickRun { + workflow.AddAction(edge.ReEnrollIdentities(".sdk-tunneler .pre-created", 10)) + } return workflow }), "stop": model.Bind(component.StopInParallelHostExclusive("*", 15)), @@ -258,6 +271,44 @@ var m = &model.Model{ host.GroupExec("*", 25, "rm -f logs/*"), )), "login": model.Bind(edge.Login("#ctrl")), + "refreshCtrlZiti": model.ActionBinder(func(m *model.Model) model.Action { + return model.ActionFunc(func(run model.Run) error { + zitiPath, err := exec.LookPath("ziti") + if err != nil { + return err + } + + deferred := rsync.NewRsyncHost("ctrl", zitiPath, "/home/ubuntu/fablab/bin/ziti") + return deferred.Execute(run) + }) + }), + "refreshRouterZiti": model.ActionBinder(func(m *model.Model) model.Action { + return model.ActionFunc(func(run model.Run) error { + zitiPath, err := exec.LookPath("ziti") + if err != nil { + return err + } + + deferred := rsync.NewRsyncHost("component.edge-router", zitiPath, "/home/ubuntu/fablab/bin/ziti") + return deferred.Execute(run) + }) + }), + "refreshZiti": model.ActionBinder(func(m *model.Model) model.Action { + return model.ActionFunc(func(run model.Run) error { + zitiPath, err := exec.LookPath("ziti") + if err != nil { + return err + } + + hosts := os.Getenv("HOSTS") + if hosts == "" { + return errors.New("expected hosts to refresh in HOSTS env") + } + + deferred := rsync.NewRsyncHost(hosts, zitiPath, "/home/ubuntu/fablab/bin/ziti") + return deferred.Execute(run) + }) + }), }, Infrastructure: model.Stages{ @@ -272,12 +323,14 @@ var m = &model.Model{ Distribution: model.Stages{ distribution.DistributeSshKey("*"), - distribution.Locations("*", "logs"), rsync.RsyncStaged(), model.StageActionF(func(run model.Run) error { - dbFile := dbStrategyInstance.GetDbFile(run.GetModel()) - deferred := rsync.NewRsyncHost("#ctrl", dbFile, "/home/ubuntu/fablab/ctrl.db") - return deferred.Execute(run) + if quickRun, _ := run.GetModel().GetBoolVariable("quick_run"); !quickRun { + dbFile := dbStrategyInstance.GetDbFile(run.GetModel()) + deferred := rsync.NewRsyncHost("#ctrl", dbFile, "/home/ubuntu/ctrl.db") + return deferred.Execute(run) + } + return nil }), }, diff --git a/zititest/zitilab/component_common.go b/zititest/zitilab/component_common.go index 7d4df7474..fde736691 100644 --- a/zititest/zitilab/component_common.go +++ b/zititest/zitilab/component_common.go @@ -35,14 +35,9 @@ func getZitiProcessFilter(c *model.Component, zitiType string) func(string) bool } func startZitiComponent(c *model.Component, zitiType string, version string, configName string) error { - binaryName := "ziti" - if version != "" { - binaryName += "-" + version - } - user := c.GetHost().GetSshUser() - binaryPath := fmt.Sprintf("/home/%s/fablab/bin/%s", user, binaryName) + binaryPath := getZitiBinaryPath(c, version) configPath := fmt.Sprintf("/home/%s/fablab/cfg/%s", user, configName) logsPath := fmt.Sprintf("/home/%s/logs/%s.log", user, c.Id) @@ -53,7 +48,7 @@ func startZitiComponent(c *model.Component, zitiType string, version string, con serviceCmd := fmt.Sprintf("nohup %s %s %s run --log-formatter pfxlog %s --cli-agent-alias %s > %s 2>&1 &", useSudo, binaryPath, zitiType, configPath, c.Id, logsPath) - + logrus.Info(serviceCmd) value, err := c.GetHost().ExecLogged(serviceCmd) if err != nil { return err @@ -66,14 +61,26 @@ func startZitiComponent(c *model.Component, zitiType string, version string, con return nil } -func getPrefixVersion(version string) string { - if version == "" || strings.HasPrefix(version, "v") { - return version +func canonicalizeZitiVersion(version *string) { + if version != nil { + if *version != "" && *version != "latest" && !strings.HasPrefix(*version, "v") { + *version = "v" + *version + } } - return "v" + version } -func reEnrollIdentity(run model.Run, c *model.Component, binaryName string, configName string) error { +func getZitiBinaryPath(c *model.Component, version string) string { + binaryName := "ziti" + if version != "" { + binaryName += "-" + version + } + + user := c.GetHost().GetSshUser() + + return fmt.Sprintf("/home/%s/fablab/bin/%s", user, binaryName) +} + +func reEnrollIdentity(run model.Run, c *model.Component, zitiBinaryPath string, configPath string) error { if err := zitilib_actions.EdgeExec(run.GetModel(), "delete", "authenticator", "where", fmt.Sprintf("identity=\"%v\"", c.Id)); err != nil { return err } @@ -90,13 +97,14 @@ func reEnrollIdentity(run model.Run, c *model.Component, binaryName string, conf return err } - remoteJwt := "/home/ubuntu/fablab/cfg/" + c.Id + ".jwt" + configDir := filepath.Dir(configPath) + remoteJwt := configDir + c.Id + ".jwt" if err := c.GetHost().SendFile(jwtFileName, remoteJwt); err != nil { return err } - tmpl := "set -o pipefail; /home/ubuntu/fablab/bin/%s edge enroll %s 2>&1 | tee /home/ubuntu/logs/%s.identity.enroll.log " - cmd := fmt.Sprintf(tmpl, binaryName, remoteJwt, c.Id) + tmpl := "set -o pipefail; mkdir -p %s; %s edge enroll %s -o %s 2>&1 | tee /home/ubuntu/logs/%s.identity.enroll.log " + cmd := fmt.Sprintf(tmpl, configDir, zitiBinaryPath, remoteJwt, configPath, c.Id) return c.GetHost().ExecLogOnlyOnError(cmd) } diff --git a/zititest/zitilab/component_controller.go b/zititest/zitilab/component_controller.go index 65e6382c7..976e74f90 100644 --- a/zititest/zitilab/component_controller.go +++ b/zititest/zitilab/component_controller.go @@ -25,7 +25,6 @@ import ( "github.com/openziti/ziti/zititest/zitilab/stageziti" "github.com/pkg/errors" "io/fs" - "strings" ) var _ model.ComponentType = (*ControllerType)(nil) @@ -47,9 +46,7 @@ type ControllerType struct { } func (self *ControllerType) InitType(*model.Component) { - if self.Version != "" && self.Version != "latest" && !strings.HasPrefix(self.Version, "v") { - self.Version = "v" + self.Version - } + canonicalizeZitiVersion(&self.Version) } func (self *ControllerType) GetActions() map[string]model.ComponentAction { @@ -134,9 +131,10 @@ func (self *ControllerType) InitStandalone(run model.Run, c *model.Component) er binaryName += "-" + self.Version } + binaryPath := getZitiBinaryPath(c, self.Version) configPath := fmt.Sprintf("/home/%s/fablab/cfg/%s", factory.User(), self.getConfigName(c)) - tmpl := "rm -f /home/%v/fablab/ctrl.db && set -o pipefail; /home/%s/fablab/bin/%s controller --log-formatter pfxlog edge init %s -u %s -p %s 2>&1 | tee logs/controller.edge.init.log" - cmd := fmt.Sprintf(tmpl, factory.User(), factory.User(), binaryName, configPath, username, password) + tmpl := "rm -f /home/%v/fablab/ctrl.db && set -o pipefail; %s controller --log-formatter pfxlog edge init %s -u %s -p %s 2>&1 | tee logs/controller.edge.init.log" + cmd := fmt.Sprintf(tmpl, factory.User(), binaryPath, configPath, username, password) return host.Exec(c.GetHost(), cmd).Execute(run) } diff --git a/zititest/zitilab/component_echo_server.go b/zititest/zitilab/component_echo_server.go index b0425c42d..1a2472e13 100644 --- a/zititest/zitilab/component_echo_server.go +++ b/zititest/zitilab/component_echo_server.go @@ -18,9 +18,7 @@ type EchoServerType struct { } func (self *EchoServerType) InitType(*model.Component) { - if self.Version != "" && self.Version != "latest" && !strings.HasPrefix(self.Version, "v") { - self.Version = "v" + self.Version - } + canonicalizeZitiVersion(&self.Version) } func (self *EchoServerType) Dump() any { @@ -48,14 +46,9 @@ func (self *EchoServerType) IsRunning(_ model.Run, c *model.Component) (bool, er } func (self *EchoServerType) Start(_ model.Run, c *model.Component) error { - binaryName := "ziti" - if self.Version != "" { - binaryName += "-" + self.Version - } - user := c.GetHost().GetSshUser() - binaryPath := fmt.Sprintf("/home/%s/fablab/bin/%s", user, binaryName) + binaryPath := getZitiBinaryPath(c, self.Version) configPath := fmt.Sprintf("/home/%s/fablab/cfg/%s.json", user, c.Id) logsPath := fmt.Sprintf("/home/%s/logs/%s.log", user, c.Id) diff --git a/zititest/zitilab/component_router.go b/zititest/zitilab/component_router.go index 73d1f1f3f..6b4cafd81 100644 --- a/zititest/zitilab/component_router.go +++ b/zititest/zitilab/component_router.go @@ -45,9 +45,7 @@ type RouterType struct { } func (self *RouterType) InitType(*model.Component) { - if self.Version != "" && self.Version != "latest" && !strings.HasPrefix(self.Version, "v") { - self.Version = "v" + self.Version - } + canonicalizeZitiVersion(&self.Version) } func (self *RouterType) GetActions() map[string]model.ComponentAction { @@ -106,15 +104,6 @@ func (self *RouterType) getConfigName(c *model.Component) string { return configName } -func (self *RouterType) getBinaryName() string { - binaryName := "ziti" - version := self.Version - if version != "" { - binaryName += "-" + version - } - return binaryName -} - func (self *RouterType) getProcessFilter(c *model.Component) func(string) bool { return getZitiProcessFilter(c, "router") } @@ -173,8 +162,8 @@ func (self *RouterType) CreateAndEnroll(run model.Run, c *model.Component) error return err } - tmpl := "set -o pipefail; /home/ubuntu/fablab/bin/%v router enroll /home/ubuntu/fablab/cfg/%s -j %s 2>&1 | tee /home/ubuntu/logs/%s.router.enroll.log " - cmd := fmt.Sprintf(tmpl, self.getBinaryName(), self.getConfigName(c), remoteJwt, c.Id) + tmpl := "set -o pipefail; %s router enroll /home/ubuntu/fablab/cfg/%s -j %s 2>&1 | tee /home/ubuntu/logs/%s.router.enroll.log " + cmd := fmt.Sprintf(tmpl, getZitiBinaryPath(c, self.Version), self.getConfigName(c), remoteJwt, c.Id) return c.GetHost().ExecLogOnlyOnError(cmd) } @@ -193,8 +182,8 @@ func (self *RouterType) ReEnroll(_ model.Run, c *model.Component) error { return err } - tmpl := "set -o pipefail; /home/ubuntu/fablab/bin/%s router enroll /home/ubuntu/fablab/cfg/%s -j %s 2>&1 | tee /home/ubuntu/logs/%s.router.enroll.log " - cmd := fmt.Sprintf(tmpl, self.getBinaryName(), self.getConfigName(c), remoteJwt, c.Id) + tmpl := "set -o pipefail; %s router enroll /home/ubuntu/fablab/cfg/%s -j %s 2>&1 | tee /home/ubuntu/logs/%s.router.enroll.log " + cmd := fmt.Sprintf(tmpl, getZitiBinaryPath(c, self.Version), self.getConfigName(c), remoteJwt, c.Id) return c.GetHost().ExecLogOnlyOnError(cmd) } diff --git a/zititest/zitilab/component_zcat.go b/zititest/zitilab/component_zcat.go index d7e5f3645..e5b589de3 100644 --- a/zititest/zitilab/component_zcat.go +++ b/zititest/zitilab/component_zcat.go @@ -16,9 +16,7 @@ type ZCatType struct { } func (self *ZCatType) InitType(*model.Component) { - if self.Version != "" && self.Version != "latest" && !strings.HasPrefix(self.Version, "v") { - self.Version = "v" + self.Version - } + canonicalizeZitiVersion(&self.Version) } func (self *ZCatType) Dump() any { diff --git a/zititest/zitilab/component_ziti_edge_tunnel.go b/zititest/zitilab/component_ziti_edge_tunnel.go index b0948b52d..0d41052a3 100644 --- a/zititest/zitilab/component_ziti_edge_tunnel.go +++ b/zititest/zitilab/component_ziti_edge_tunnel.go @@ -27,8 +27,17 @@ import ( var _ model.ComponentType = (*ZitiEdgeTunnelType)(nil) type ZitiEdgeTunnelType struct { - Version string - LocalPath string + Version string + ZitiVersion string + LocalPath string + LogConfig string + ConfigPathF func(c *model.Component) string +} + +func (self *ZitiEdgeTunnelType) GetActions() map[string]model.ComponentAction { + return map[string]model.ComponentAction{ + ZitiTunnelActionsReEnroll: model.ComponentActionF(self.ReEnroll), + } } func (self *ZitiEdgeTunnelType) Dump() any { @@ -43,6 +52,7 @@ func (self *ZitiEdgeTunnelType) InitType(*model.Component) { if strings.HasPrefix(self.Version, "v") { self.Version = self.Version[1:] } + canonicalizeZitiVersion(&self.ZitiVersion) } func (self *ZitiEdgeTunnelType) getBinaryName() string { @@ -55,7 +65,10 @@ func (self *ZitiEdgeTunnelType) getBinaryName() string { } func (self *ZitiEdgeTunnelType) StageFiles(r model.Run, c *model.Component) error { - return stageziti.StageZitiEdgeTunnelOnce(r, c, self.Version, self.LocalPath) + if err := stageziti.StageZitiEdgeTunnelOnce(r, c, self.Version, self.LocalPath); err != nil { + return err + } + return stageziti.StageZitiOnce(r, c, self.ZitiVersion, self.LocalPath) } func (self *ZitiEdgeTunnelType) getProcessFilter(c *model.Component) func(string) bool { @@ -74,15 +87,27 @@ func (self *ZitiEdgeTunnelType) IsRunning(_ model.Run, c *model.Component) (bool return len(pids) > 0, nil } +func (self *ZitiEdgeTunnelType) GetConfigPath(c *model.Component) string { + if self.ConfigPathF != nil { + return self.ConfigPathF(c) + } + return fmt.Sprintf("/home/%s/fablab/cfg/%s.json", c.GetHost().GetSshUser(), c.Id) +} + func (self *ZitiEdgeTunnelType) Start(_ model.Run, c *model.Component) error { user := c.GetHost().GetSshUser() binaryPath := fmt.Sprintf("/home/%s/fablab/bin/%s", user, self.getBinaryName()) - configPath := fmt.Sprintf("/home/%s/fablab/cfg/%s.json", user, c.Id) + configPath := self.GetConfigPath(c) logsPath := fmt.Sprintf("/home/%s/logs/%s.log", user, c.Id) - serviceCmd := fmt.Sprintf("sudo %s run -i %s > %s 2>&1 &", binaryPath, configPath, logsPath) + logging := "" + if self.LogConfig != "" { + logging = "ZITI_LOG=" + self.LogConfig + " " + } + serviceCmd := fmt.Sprintf("%ssudo %s run -i %s > %s 2>&1 &", logging, binaryPath, configPath, logsPath) + logrus.Infof("starting: %s", serviceCmd) value, err := c.GetHost().ExecLogged(serviceCmd) if err != nil { return err @@ -98,3 +123,7 @@ func (self *ZitiEdgeTunnelType) Start(_ model.Run, c *model.Component) error { func (self *ZitiEdgeTunnelType) Stop(_ model.Run, c *model.Component) error { return c.GetHost().KillProcesses("-TERM", self.getProcessFilter(c)) } + +func (self *ZitiEdgeTunnelType) ReEnroll(run model.Run, c *model.Component) error { + return reEnrollIdentity(run, c, getZitiBinaryPath(c, self.ZitiVersion), self.GetConfigPath(c)) +} diff --git a/zititest/zitilab/component_ziti_tunnel.go b/zititest/zitilab/component_ziti_tunnel.go index b76151db0..8cc0b428f 100644 --- a/zititest/zitilab/component_ziti_tunnel.go +++ b/zititest/zitilab/component_ziti_tunnel.go @@ -50,9 +50,10 @@ func (self ZitiTunnelMode) String() string { } type ZitiTunnelType struct { - Mode ZitiTunnelMode - Version string - LocalPath string + Mode ZitiTunnelMode + Version string + LocalPath string + ConfigPathF func(c *model.Component) string } func (self *ZitiTunnelType) GetActions() map[string]model.ComponentAction { @@ -62,9 +63,7 @@ func (self *ZitiTunnelType) GetActions() map[string]model.ComponentAction { } func (self *ZitiTunnelType) InitType(*model.Component) { - if self.Version != "" && self.Version != "latest" && !strings.HasPrefix(self.Version, "v") { - self.Version = "v" + self.Version - } + canonicalizeZitiVersion(&self.Version) } func (self *ZitiTunnelType) Dump() any { @@ -102,16 +101,11 @@ func (self *ZitiTunnelType) IsRunning(_ model.Run, c *model.Component) (bool, er return len(pids) > 0, nil } -func (self *ZitiTunnelType) GetBinaryName() string { - binaryName := "ziti" - if self.Version != "" { - binaryName += "-" + self.Version +func (self *ZitiTunnelType) GetConfigPath(c *model.Component) string { + if self.ConfigPathF != nil { + return self.ConfigPathF(c) } - return binaryName -} - -func (self *ZitiTunnelType) GetConfigName(c *model.Component) string { - return fmt.Sprintf("%s.json", c.Id) + return fmt.Sprintf("/home/%s/fablab/cfg/%s.json", c.GetHost().GetSshUser(), c.Id) } func (self *ZitiTunnelType) Start(_ model.Run, c *model.Component) error { @@ -119,8 +113,8 @@ func (self *ZitiTunnelType) Start(_ model.Run, c *model.Component) error { user := c.GetHost().GetSshUser() - binaryPath := fmt.Sprintf("/home/%s/fablab/bin/%s", user, self.GetBinaryName()) - configPath := fmt.Sprintf("/home/%s/fablab/cfg/%s", user, self.GetConfigName(c)) + binaryPath := getZitiBinaryPath(c, self.Version) + configPath := self.GetConfigPath(c) logsPath := fmt.Sprintf("/home/%s/logs/%s.log", user, c.Id) useSudo := "" @@ -128,7 +122,7 @@ func (self *ZitiTunnelType) Start(_ model.Run, c *model.Component) error { useSudo = "sudo" } - serviceCmd := fmt.Sprintf("%s %s tunnel %s --log-formatter pfxlog -i %s --cli-agent-alias %s > %s 2>&1 &", + serviceCmd := fmt.Sprintf("%s %s tunnel %s -v --log-formatter pfxlog -i %s --cli-agent-alias %s > %s 2>&1 &", useSudo, binaryPath, mode.String(), configPath, c.Id, logsPath) value, err := c.Host.ExecLogged( @@ -150,5 +144,5 @@ func (self *ZitiTunnelType) Stop(_ model.Run, c *model.Component) error { } func (self *ZitiTunnelType) ReEnroll(run model.Run, c *model.Component) error { - return reEnrollIdentity(run, c, self.GetBinaryName(), self.GetConfigName(c)) + return reEnrollIdentity(run, c, getZitiBinaryPath(c, self.Version), self.GetConfigPath(c)) } diff --git a/zititest/zitilab/models/db_builder.go b/zititest/zitilab/models/db_builder.go index e78375707..e05c15aff 100644 --- a/zititest/zitilab/models/db_builder.go +++ b/zititest/zitilab/models/db_builder.go @@ -6,7 +6,6 @@ import ( "github.com/openziti/storage/boltz" "github.com/openziti/ziti/controller/db" "github.com/openziti/ziti/controller/network" - "github.com/openziti/ziti/controller/persistence" "github.com/openziti/ziti/zititest/zitilab" "github.com/pkg/errors" "go.etcd.io/bbolt" @@ -15,16 +14,15 @@ import ( type ZitiDbBuilderStrategy interface { GetDbFile(m *model.Model) string - GetSite(router *persistence.EdgeRouter) (string, bool) - PostProcess(router *persistence.EdgeRouter, c *model.Component) + GetSite(router *db.EdgeRouter) (string, bool) + PostProcess(router *db.EdgeRouter, c *model.Component) ProcessDbModel(tx *bbolt.Tx, m *model.Model, builder *ZitiDbBuilder) error } type ZitiDbBuilder struct { - Strategy ZitiDbBuilderStrategy - zitiDb boltz.Db - stores *db.Stores - edgeStores *persistence.Stores + Strategy ZitiDbBuilderStrategy + zitiDb boltz.Db + stores *db.Stores } func (self *ZitiDbBuilder) GetDb() boltz.Db { @@ -35,10 +33,6 @@ func (self *ZitiDbBuilder) GetStores() *db.Stores { return self.stores } -func (self *ZitiDbBuilder) GetEdgeStores() *persistence.Stores { - return self.edgeStores -} - func (self *ZitiDbBuilder) GetManagers() *network.Managers { panic("should not be needed") } @@ -63,24 +57,19 @@ func (self *ZitiDbBuilder) Build(m *model.Model) error { return errors.Wrapf(err, "unable to init fabric stores using db [%v]", dbFile) } - self.edgeStores, err = persistence.NewBoltStores(self) - if err != nil { - return errors.Wrapf(err, "unable to init edge stores using db [%v]", dbFile) - } - return self.zitiDb.View(func(tx *bbolt.Tx) error { return self.Strategy.ProcessDbModel(tx, m, self) }) } func (self *ZitiDbBuilder) CreateEdgeRouterHosts(tx *bbolt.Tx, m *model.Model) error { - ids, _, err := self.edgeStores.EdgeRouter.QueryIds(tx, "true limit none") + ids, _, err := self.stores.EdgeRouter.QueryIds(tx, "true limit none") if err != nil { return err } for _, id := range ids { - er, err := self.edgeStores.EdgeRouter.LoadOneById(tx, id) + er, err := self.stores.EdgeRouter.LoadOneById(tx, id) if err != nil { return err } @@ -130,7 +119,7 @@ func (self *ZitiDbBuilder) CreateEdgeRouterHosts(tx *bbolt.Tx, m *model.Model) e return nil } -func (self *ZitiDbBuilder) DefaultGetSite(er *persistence.EdgeRouter) (string, bool) { +func (self *ZitiDbBuilder) DefaultGetSite(er *db.EdgeRouter) (string, bool) { if val, found := er.Tags["fablab.site"]; found { return fmt.Sprintf("%v", val), true }