ca.pb.go 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116
  1. // Code generated by protoc-gen-gogo.
  2. // source: ca.proto
  3. // DO NOT EDIT!
  4. package api
  5. import proto "github.com/gogo/protobuf/proto"
  6. import fmt "fmt"
  7. import math "math"
  8. import _ "github.com/gogo/protobuf/gogoproto"
  9. import _ "github.com/docker/swarmkit/protobuf/plugin"
  10. import github_com_docker_swarmkit_api_deepcopy "github.com/docker/swarmkit/api/deepcopy"
  11. import (
  12. context "golang.org/x/net/context"
  13. grpc "google.golang.org/grpc"
  14. )
  15. import raftselector "github.com/docker/swarmkit/manager/raftselector"
  16. import codes "google.golang.org/grpc/codes"
  17. import metadata "google.golang.org/grpc/metadata"
  18. import transport "google.golang.org/grpc/transport"
  19. import rafttime "time"
  20. import strings "strings"
  21. import reflect "reflect"
  22. import io "io"
  23. // Reference imports to suppress errors if they are not otherwise used.
  24. var _ = proto.Marshal
  25. var _ = fmt.Errorf
  26. var _ = math.Inf
  27. type NodeCertificateStatusRequest struct {
  28. NodeID string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
  29. }
  30. func (m *NodeCertificateStatusRequest) Reset() { *m = NodeCertificateStatusRequest{} }
  31. func (*NodeCertificateStatusRequest) ProtoMessage() {}
  32. func (*NodeCertificateStatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorCa, []int{0} }
  33. type NodeCertificateStatusResponse struct {
  34. Status *IssuanceStatus `protobuf:"bytes,1,opt,name=status" json:"status,omitempty"`
  35. Certificate *Certificate `protobuf:"bytes,2,opt,name=certificate" json:"certificate,omitempty"`
  36. }
  37. func (m *NodeCertificateStatusResponse) Reset() { *m = NodeCertificateStatusResponse{} }
  38. func (*NodeCertificateStatusResponse) ProtoMessage() {}
  39. func (*NodeCertificateStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorCa, []int{1} }
  40. type IssueNodeCertificateRequest struct {
  41. // DEPRECATED: Role is now selected based on which secret is matched.
  42. Role NodeRole `protobuf:"varint,1,opt,name=role,proto3,enum=docker.swarmkit.v1.NodeRole" json:"role,omitempty"`
  43. // CSR is the certificate signing request.
  44. CSR []byte `protobuf:"bytes,2,opt,name=csr,proto3" json:"csr,omitempty"`
  45. // Token represents a user-provided string that is necessary for new
  46. // nodes to join the cluster
  47. Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"`
  48. // Availability allows a user to control the current scheduling status of a node
  49. Availability NodeSpec_Availability `protobuf:"varint,4,opt,name=availability,proto3,enum=docker.swarmkit.v1.NodeSpec_Availability" json:"availability,omitempty"`
  50. }
  51. func (m *IssueNodeCertificateRequest) Reset() { *m = IssueNodeCertificateRequest{} }
  52. func (*IssueNodeCertificateRequest) ProtoMessage() {}
  53. func (*IssueNodeCertificateRequest) Descriptor() ([]byte, []int) { return fileDescriptorCa, []int{2} }
  54. type IssueNodeCertificateResponse struct {
  55. NodeID string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
  56. NodeMembership NodeSpec_Membership `protobuf:"varint,2,opt,name=node_membership,json=nodeMembership,proto3,enum=docker.swarmkit.v1.NodeSpec_Membership" json:"node_membership,omitempty"`
  57. }
  58. func (m *IssueNodeCertificateResponse) Reset() { *m = IssueNodeCertificateResponse{} }
  59. func (*IssueNodeCertificateResponse) ProtoMessage() {}
  60. func (*IssueNodeCertificateResponse) Descriptor() ([]byte, []int) { return fileDescriptorCa, []int{3} }
  61. type GetRootCACertificateRequest struct {
  62. }
  63. func (m *GetRootCACertificateRequest) Reset() { *m = GetRootCACertificateRequest{} }
  64. func (*GetRootCACertificateRequest) ProtoMessage() {}
  65. func (*GetRootCACertificateRequest) Descriptor() ([]byte, []int) { return fileDescriptorCa, []int{4} }
  66. type GetRootCACertificateResponse struct {
  67. Certificate []byte `protobuf:"bytes,1,opt,name=certificate,proto3" json:"certificate,omitempty"`
  68. }
  69. func (m *GetRootCACertificateResponse) Reset() { *m = GetRootCACertificateResponse{} }
  70. func (*GetRootCACertificateResponse) ProtoMessage() {}
  71. func (*GetRootCACertificateResponse) Descriptor() ([]byte, []int) { return fileDescriptorCa, []int{5} }
  72. type GetUnlockKeyRequest struct {
  73. }
  74. func (m *GetUnlockKeyRequest) Reset() { *m = GetUnlockKeyRequest{} }
  75. func (*GetUnlockKeyRequest) ProtoMessage() {}
  76. func (*GetUnlockKeyRequest) Descriptor() ([]byte, []int) { return fileDescriptorCa, []int{6} }
  77. type GetUnlockKeyResponse struct {
  78. UnlockKey []byte `protobuf:"bytes,1,opt,name=unlock_key,json=unlockKey,proto3" json:"unlock_key,omitempty"`
  79. Version Version `protobuf:"bytes,2,opt,name=version" json:"version"`
  80. }
  81. func (m *GetUnlockKeyResponse) Reset() { *m = GetUnlockKeyResponse{} }
  82. func (*GetUnlockKeyResponse) ProtoMessage() {}
  83. func (*GetUnlockKeyResponse) Descriptor() ([]byte, []int) { return fileDescriptorCa, []int{7} }
  84. func init() {
  85. proto.RegisterType((*NodeCertificateStatusRequest)(nil), "docker.swarmkit.v1.NodeCertificateStatusRequest")
  86. proto.RegisterType((*NodeCertificateStatusResponse)(nil), "docker.swarmkit.v1.NodeCertificateStatusResponse")
  87. proto.RegisterType((*IssueNodeCertificateRequest)(nil), "docker.swarmkit.v1.IssueNodeCertificateRequest")
  88. proto.RegisterType((*IssueNodeCertificateResponse)(nil), "docker.swarmkit.v1.IssueNodeCertificateResponse")
  89. proto.RegisterType((*GetRootCACertificateRequest)(nil), "docker.swarmkit.v1.GetRootCACertificateRequest")
  90. proto.RegisterType((*GetRootCACertificateResponse)(nil), "docker.swarmkit.v1.GetRootCACertificateResponse")
  91. proto.RegisterType((*GetUnlockKeyRequest)(nil), "docker.swarmkit.v1.GetUnlockKeyRequest")
  92. proto.RegisterType((*GetUnlockKeyResponse)(nil), "docker.swarmkit.v1.GetUnlockKeyResponse")
  93. }
  94. type authenticatedWrapperCAServer struct {
  95. local CAServer
  96. authorize func(context.Context, []string) error
  97. }
  98. func NewAuthenticatedWrapperCAServer(local CAServer, authorize func(context.Context, []string) error) CAServer {
  99. return &authenticatedWrapperCAServer{
  100. local: local,
  101. authorize: authorize,
  102. }
  103. }
  104. func (p *authenticatedWrapperCAServer) GetRootCACertificate(ctx context.Context, r *GetRootCACertificateRequest) (*GetRootCACertificateResponse, error) {
  105. return p.local.GetRootCACertificate(ctx, r)
  106. }
  107. func (p *authenticatedWrapperCAServer) GetUnlockKey(ctx context.Context, r *GetUnlockKeyRequest) (*GetUnlockKeyResponse, error) {
  108. if err := p.authorize(ctx, []string{"swarm-manager"}); err != nil {
  109. return nil, err
  110. }
  111. return p.local.GetUnlockKey(ctx, r)
  112. }
  113. type authenticatedWrapperNodeCAServer struct {
  114. local NodeCAServer
  115. authorize func(context.Context, []string) error
  116. }
  117. func NewAuthenticatedWrapperNodeCAServer(local NodeCAServer, authorize func(context.Context, []string) error) NodeCAServer {
  118. return &authenticatedWrapperNodeCAServer{
  119. local: local,
  120. authorize: authorize,
  121. }
  122. }
  123. func (p *authenticatedWrapperNodeCAServer) IssueNodeCertificate(ctx context.Context, r *IssueNodeCertificateRequest) (*IssueNodeCertificateResponse, error) {
  124. return p.local.IssueNodeCertificate(ctx, r)
  125. }
  126. func (p *authenticatedWrapperNodeCAServer) NodeCertificateStatus(ctx context.Context, r *NodeCertificateStatusRequest) (*NodeCertificateStatusResponse, error) {
  127. return p.local.NodeCertificateStatus(ctx, r)
  128. }
  129. func (m *NodeCertificateStatusRequest) Copy() *NodeCertificateStatusRequest {
  130. if m == nil {
  131. return nil
  132. }
  133. o := &NodeCertificateStatusRequest{}
  134. o.CopyFrom(m)
  135. return o
  136. }
  137. func (m *NodeCertificateStatusRequest) CopyFrom(src interface{}) {
  138. o := src.(*NodeCertificateStatusRequest)
  139. *m = *o
  140. }
  141. func (m *NodeCertificateStatusResponse) Copy() *NodeCertificateStatusResponse {
  142. if m == nil {
  143. return nil
  144. }
  145. o := &NodeCertificateStatusResponse{}
  146. o.CopyFrom(m)
  147. return o
  148. }
  149. func (m *NodeCertificateStatusResponse) CopyFrom(src interface{}) {
  150. o := src.(*NodeCertificateStatusResponse)
  151. *m = *o
  152. if o.Status != nil {
  153. m.Status = &IssuanceStatus{}
  154. github_com_docker_swarmkit_api_deepcopy.Copy(m.Status, o.Status)
  155. }
  156. if o.Certificate != nil {
  157. m.Certificate = &Certificate{}
  158. github_com_docker_swarmkit_api_deepcopy.Copy(m.Certificate, o.Certificate)
  159. }
  160. }
  161. func (m *IssueNodeCertificateRequest) Copy() *IssueNodeCertificateRequest {
  162. if m == nil {
  163. return nil
  164. }
  165. o := &IssueNodeCertificateRequest{}
  166. o.CopyFrom(m)
  167. return o
  168. }
  169. func (m *IssueNodeCertificateRequest) CopyFrom(src interface{}) {
  170. o := src.(*IssueNodeCertificateRequest)
  171. *m = *o
  172. if o.CSR != nil {
  173. m.CSR = make([]byte, len(o.CSR))
  174. copy(m.CSR, o.CSR)
  175. }
  176. }
  177. func (m *IssueNodeCertificateResponse) Copy() *IssueNodeCertificateResponse {
  178. if m == nil {
  179. return nil
  180. }
  181. o := &IssueNodeCertificateResponse{}
  182. o.CopyFrom(m)
  183. return o
  184. }
  185. func (m *IssueNodeCertificateResponse) CopyFrom(src interface{}) {
  186. o := src.(*IssueNodeCertificateResponse)
  187. *m = *o
  188. }
  189. func (m *GetRootCACertificateRequest) Copy() *GetRootCACertificateRequest {
  190. if m == nil {
  191. return nil
  192. }
  193. o := &GetRootCACertificateRequest{}
  194. o.CopyFrom(m)
  195. return o
  196. }
  197. func (m *GetRootCACertificateRequest) CopyFrom(src interface{}) {}
  198. func (m *GetRootCACertificateResponse) Copy() *GetRootCACertificateResponse {
  199. if m == nil {
  200. return nil
  201. }
  202. o := &GetRootCACertificateResponse{}
  203. o.CopyFrom(m)
  204. return o
  205. }
  206. func (m *GetRootCACertificateResponse) CopyFrom(src interface{}) {
  207. o := src.(*GetRootCACertificateResponse)
  208. *m = *o
  209. if o.Certificate != nil {
  210. m.Certificate = make([]byte, len(o.Certificate))
  211. copy(m.Certificate, o.Certificate)
  212. }
  213. }
  214. func (m *GetUnlockKeyRequest) Copy() *GetUnlockKeyRequest {
  215. if m == nil {
  216. return nil
  217. }
  218. o := &GetUnlockKeyRequest{}
  219. o.CopyFrom(m)
  220. return o
  221. }
  222. func (m *GetUnlockKeyRequest) CopyFrom(src interface{}) {}
  223. func (m *GetUnlockKeyResponse) Copy() *GetUnlockKeyResponse {
  224. if m == nil {
  225. return nil
  226. }
  227. o := &GetUnlockKeyResponse{}
  228. o.CopyFrom(m)
  229. return o
  230. }
  231. func (m *GetUnlockKeyResponse) CopyFrom(src interface{}) {
  232. o := src.(*GetUnlockKeyResponse)
  233. *m = *o
  234. if o.UnlockKey != nil {
  235. m.UnlockKey = make([]byte, len(o.UnlockKey))
  236. copy(m.UnlockKey, o.UnlockKey)
  237. }
  238. github_com_docker_swarmkit_api_deepcopy.Copy(&m.Version, &o.Version)
  239. }
  240. // Reference imports to suppress errors if they are not otherwise used.
  241. var _ context.Context
  242. var _ grpc.ClientConn
  243. // This is a compile-time assertion to ensure that this generated file
  244. // is compatible with the grpc package it is being compiled against.
  245. const _ = grpc.SupportPackageIsVersion4
  246. // Client API for CA service
  247. type CAClient interface {
  248. GetRootCACertificate(ctx context.Context, in *GetRootCACertificateRequest, opts ...grpc.CallOption) (*GetRootCACertificateResponse, error)
  249. // GetUnlockKey returns the current unlock key for the cluster for the role of the client
  250. // asking.
  251. GetUnlockKey(ctx context.Context, in *GetUnlockKeyRequest, opts ...grpc.CallOption) (*GetUnlockKeyResponse, error)
  252. }
  253. type cAClient struct {
  254. cc *grpc.ClientConn
  255. }
  256. func NewCAClient(cc *grpc.ClientConn) CAClient {
  257. return &cAClient{cc}
  258. }
  259. func (c *cAClient) GetRootCACertificate(ctx context.Context, in *GetRootCACertificateRequest, opts ...grpc.CallOption) (*GetRootCACertificateResponse, error) {
  260. out := new(GetRootCACertificateResponse)
  261. err := grpc.Invoke(ctx, "/docker.swarmkit.v1.CA/GetRootCACertificate", in, out, c.cc, opts...)
  262. if err != nil {
  263. return nil, err
  264. }
  265. return out, nil
  266. }
  267. func (c *cAClient) GetUnlockKey(ctx context.Context, in *GetUnlockKeyRequest, opts ...grpc.CallOption) (*GetUnlockKeyResponse, error) {
  268. out := new(GetUnlockKeyResponse)
  269. err := grpc.Invoke(ctx, "/docker.swarmkit.v1.CA/GetUnlockKey", in, out, c.cc, opts...)
  270. if err != nil {
  271. return nil, err
  272. }
  273. return out, nil
  274. }
  275. // Server API for CA service
  276. type CAServer interface {
  277. GetRootCACertificate(context.Context, *GetRootCACertificateRequest) (*GetRootCACertificateResponse, error)
  278. // GetUnlockKey returns the current unlock key for the cluster for the role of the client
  279. // asking.
  280. GetUnlockKey(context.Context, *GetUnlockKeyRequest) (*GetUnlockKeyResponse, error)
  281. }
  282. func RegisterCAServer(s *grpc.Server, srv CAServer) {
  283. s.RegisterService(&_CA_serviceDesc, srv)
  284. }
  285. func _CA_GetRootCACertificate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
  286. in := new(GetRootCACertificateRequest)
  287. if err := dec(in); err != nil {
  288. return nil, err
  289. }
  290. if interceptor == nil {
  291. return srv.(CAServer).GetRootCACertificate(ctx, in)
  292. }
  293. info := &grpc.UnaryServerInfo{
  294. Server: srv,
  295. FullMethod: "/docker.swarmkit.v1.CA/GetRootCACertificate",
  296. }
  297. handler := func(ctx context.Context, req interface{}) (interface{}, error) {
  298. return srv.(CAServer).GetRootCACertificate(ctx, req.(*GetRootCACertificateRequest))
  299. }
  300. return interceptor(ctx, in, info, handler)
  301. }
  302. func _CA_GetUnlockKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
  303. in := new(GetUnlockKeyRequest)
  304. if err := dec(in); err != nil {
  305. return nil, err
  306. }
  307. if interceptor == nil {
  308. return srv.(CAServer).GetUnlockKey(ctx, in)
  309. }
  310. info := &grpc.UnaryServerInfo{
  311. Server: srv,
  312. FullMethod: "/docker.swarmkit.v1.CA/GetUnlockKey",
  313. }
  314. handler := func(ctx context.Context, req interface{}) (interface{}, error) {
  315. return srv.(CAServer).GetUnlockKey(ctx, req.(*GetUnlockKeyRequest))
  316. }
  317. return interceptor(ctx, in, info, handler)
  318. }
  319. var _CA_serviceDesc = grpc.ServiceDesc{
  320. ServiceName: "docker.swarmkit.v1.CA",
  321. HandlerType: (*CAServer)(nil),
  322. Methods: []grpc.MethodDesc{
  323. {
  324. MethodName: "GetRootCACertificate",
  325. Handler: _CA_GetRootCACertificate_Handler,
  326. },
  327. {
  328. MethodName: "GetUnlockKey",
  329. Handler: _CA_GetUnlockKey_Handler,
  330. },
  331. },
  332. Streams: []grpc.StreamDesc{},
  333. Metadata: "ca.proto",
  334. }
  335. // Client API for NodeCA service
  336. type NodeCAClient interface {
  337. IssueNodeCertificate(ctx context.Context, in *IssueNodeCertificateRequest, opts ...grpc.CallOption) (*IssueNodeCertificateResponse, error)
  338. NodeCertificateStatus(ctx context.Context, in *NodeCertificateStatusRequest, opts ...grpc.CallOption) (*NodeCertificateStatusResponse, error)
  339. }
  340. type nodeCAClient struct {
  341. cc *grpc.ClientConn
  342. }
  343. func NewNodeCAClient(cc *grpc.ClientConn) NodeCAClient {
  344. return &nodeCAClient{cc}
  345. }
  346. func (c *nodeCAClient) IssueNodeCertificate(ctx context.Context, in *IssueNodeCertificateRequest, opts ...grpc.CallOption) (*IssueNodeCertificateResponse, error) {
  347. out := new(IssueNodeCertificateResponse)
  348. err := grpc.Invoke(ctx, "/docker.swarmkit.v1.NodeCA/IssueNodeCertificate", in, out, c.cc, opts...)
  349. if err != nil {
  350. return nil, err
  351. }
  352. return out, nil
  353. }
  354. func (c *nodeCAClient) NodeCertificateStatus(ctx context.Context, in *NodeCertificateStatusRequest, opts ...grpc.CallOption) (*NodeCertificateStatusResponse, error) {
  355. out := new(NodeCertificateStatusResponse)
  356. err := grpc.Invoke(ctx, "/docker.swarmkit.v1.NodeCA/NodeCertificateStatus", in, out, c.cc, opts...)
  357. if err != nil {
  358. return nil, err
  359. }
  360. return out, nil
  361. }
  362. // Server API for NodeCA service
  363. type NodeCAServer interface {
  364. IssueNodeCertificate(context.Context, *IssueNodeCertificateRequest) (*IssueNodeCertificateResponse, error)
  365. NodeCertificateStatus(context.Context, *NodeCertificateStatusRequest) (*NodeCertificateStatusResponse, error)
  366. }
  367. func RegisterNodeCAServer(s *grpc.Server, srv NodeCAServer) {
  368. s.RegisterService(&_NodeCA_serviceDesc, srv)
  369. }
  370. func _NodeCA_IssueNodeCertificate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
  371. in := new(IssueNodeCertificateRequest)
  372. if err := dec(in); err != nil {
  373. return nil, err
  374. }
  375. if interceptor == nil {
  376. return srv.(NodeCAServer).IssueNodeCertificate(ctx, in)
  377. }
  378. info := &grpc.UnaryServerInfo{
  379. Server: srv,
  380. FullMethod: "/docker.swarmkit.v1.NodeCA/IssueNodeCertificate",
  381. }
  382. handler := func(ctx context.Context, req interface{}) (interface{}, error) {
  383. return srv.(NodeCAServer).IssueNodeCertificate(ctx, req.(*IssueNodeCertificateRequest))
  384. }
  385. return interceptor(ctx, in, info, handler)
  386. }
  387. func _NodeCA_NodeCertificateStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
  388. in := new(NodeCertificateStatusRequest)
  389. if err := dec(in); err != nil {
  390. return nil, err
  391. }
  392. if interceptor == nil {
  393. return srv.(NodeCAServer).NodeCertificateStatus(ctx, in)
  394. }
  395. info := &grpc.UnaryServerInfo{
  396. Server: srv,
  397. FullMethod: "/docker.swarmkit.v1.NodeCA/NodeCertificateStatus",
  398. }
  399. handler := func(ctx context.Context, req interface{}) (interface{}, error) {
  400. return srv.(NodeCAServer).NodeCertificateStatus(ctx, req.(*NodeCertificateStatusRequest))
  401. }
  402. return interceptor(ctx, in, info, handler)
  403. }
  404. var _NodeCA_serviceDesc = grpc.ServiceDesc{
  405. ServiceName: "docker.swarmkit.v1.NodeCA",
  406. HandlerType: (*NodeCAServer)(nil),
  407. Methods: []grpc.MethodDesc{
  408. {
  409. MethodName: "IssueNodeCertificate",
  410. Handler: _NodeCA_IssueNodeCertificate_Handler,
  411. },
  412. {
  413. MethodName: "NodeCertificateStatus",
  414. Handler: _NodeCA_NodeCertificateStatus_Handler,
  415. },
  416. },
  417. Streams: []grpc.StreamDesc{},
  418. Metadata: "ca.proto",
  419. }
  420. func (m *NodeCertificateStatusRequest) Marshal() (dAtA []byte, err error) {
  421. size := m.Size()
  422. dAtA = make([]byte, size)
  423. n, err := m.MarshalTo(dAtA)
  424. if err != nil {
  425. return nil, err
  426. }
  427. return dAtA[:n], nil
  428. }
  429. func (m *NodeCertificateStatusRequest) MarshalTo(dAtA []byte) (int, error) {
  430. var i int
  431. _ = i
  432. var l int
  433. _ = l
  434. if len(m.NodeID) > 0 {
  435. dAtA[i] = 0xa
  436. i++
  437. i = encodeVarintCa(dAtA, i, uint64(len(m.NodeID)))
  438. i += copy(dAtA[i:], m.NodeID)
  439. }
  440. return i, nil
  441. }
  442. func (m *NodeCertificateStatusResponse) Marshal() (dAtA []byte, err error) {
  443. size := m.Size()
  444. dAtA = make([]byte, size)
  445. n, err := m.MarshalTo(dAtA)
  446. if err != nil {
  447. return nil, err
  448. }
  449. return dAtA[:n], nil
  450. }
  451. func (m *NodeCertificateStatusResponse) MarshalTo(dAtA []byte) (int, error) {
  452. var i int
  453. _ = i
  454. var l int
  455. _ = l
  456. if m.Status != nil {
  457. dAtA[i] = 0xa
  458. i++
  459. i = encodeVarintCa(dAtA, i, uint64(m.Status.Size()))
  460. n1, err := m.Status.MarshalTo(dAtA[i:])
  461. if err != nil {
  462. return 0, err
  463. }
  464. i += n1
  465. }
  466. if m.Certificate != nil {
  467. dAtA[i] = 0x12
  468. i++
  469. i = encodeVarintCa(dAtA, i, uint64(m.Certificate.Size()))
  470. n2, err := m.Certificate.MarshalTo(dAtA[i:])
  471. if err != nil {
  472. return 0, err
  473. }
  474. i += n2
  475. }
  476. return i, nil
  477. }
  478. func (m *IssueNodeCertificateRequest) Marshal() (dAtA []byte, err error) {
  479. size := m.Size()
  480. dAtA = make([]byte, size)
  481. n, err := m.MarshalTo(dAtA)
  482. if err != nil {
  483. return nil, err
  484. }
  485. return dAtA[:n], nil
  486. }
  487. func (m *IssueNodeCertificateRequest) MarshalTo(dAtA []byte) (int, error) {
  488. var i int
  489. _ = i
  490. var l int
  491. _ = l
  492. if m.Role != 0 {
  493. dAtA[i] = 0x8
  494. i++
  495. i = encodeVarintCa(dAtA, i, uint64(m.Role))
  496. }
  497. if len(m.CSR) > 0 {
  498. dAtA[i] = 0x12
  499. i++
  500. i = encodeVarintCa(dAtA, i, uint64(len(m.CSR)))
  501. i += copy(dAtA[i:], m.CSR)
  502. }
  503. if len(m.Token) > 0 {
  504. dAtA[i] = 0x1a
  505. i++
  506. i = encodeVarintCa(dAtA, i, uint64(len(m.Token)))
  507. i += copy(dAtA[i:], m.Token)
  508. }
  509. if m.Availability != 0 {
  510. dAtA[i] = 0x20
  511. i++
  512. i = encodeVarintCa(dAtA, i, uint64(m.Availability))
  513. }
  514. return i, nil
  515. }
  516. func (m *IssueNodeCertificateResponse) Marshal() (dAtA []byte, err error) {
  517. size := m.Size()
  518. dAtA = make([]byte, size)
  519. n, err := m.MarshalTo(dAtA)
  520. if err != nil {
  521. return nil, err
  522. }
  523. return dAtA[:n], nil
  524. }
  525. func (m *IssueNodeCertificateResponse) MarshalTo(dAtA []byte) (int, error) {
  526. var i int
  527. _ = i
  528. var l int
  529. _ = l
  530. if len(m.NodeID) > 0 {
  531. dAtA[i] = 0xa
  532. i++
  533. i = encodeVarintCa(dAtA, i, uint64(len(m.NodeID)))
  534. i += copy(dAtA[i:], m.NodeID)
  535. }
  536. if m.NodeMembership != 0 {
  537. dAtA[i] = 0x10
  538. i++
  539. i = encodeVarintCa(dAtA, i, uint64(m.NodeMembership))
  540. }
  541. return i, nil
  542. }
  543. func (m *GetRootCACertificateRequest) Marshal() (dAtA []byte, err error) {
  544. size := m.Size()
  545. dAtA = make([]byte, size)
  546. n, err := m.MarshalTo(dAtA)
  547. if err != nil {
  548. return nil, err
  549. }
  550. return dAtA[:n], nil
  551. }
  552. func (m *GetRootCACertificateRequest) MarshalTo(dAtA []byte) (int, error) {
  553. var i int
  554. _ = i
  555. var l int
  556. _ = l
  557. return i, nil
  558. }
  559. func (m *GetRootCACertificateResponse) Marshal() (dAtA []byte, err error) {
  560. size := m.Size()
  561. dAtA = make([]byte, size)
  562. n, err := m.MarshalTo(dAtA)
  563. if err != nil {
  564. return nil, err
  565. }
  566. return dAtA[:n], nil
  567. }
  568. func (m *GetRootCACertificateResponse) MarshalTo(dAtA []byte) (int, error) {
  569. var i int
  570. _ = i
  571. var l int
  572. _ = l
  573. if len(m.Certificate) > 0 {
  574. dAtA[i] = 0xa
  575. i++
  576. i = encodeVarintCa(dAtA, i, uint64(len(m.Certificate)))
  577. i += copy(dAtA[i:], m.Certificate)
  578. }
  579. return i, nil
  580. }
  581. func (m *GetUnlockKeyRequest) Marshal() (dAtA []byte, err error) {
  582. size := m.Size()
  583. dAtA = make([]byte, size)
  584. n, err := m.MarshalTo(dAtA)
  585. if err != nil {
  586. return nil, err
  587. }
  588. return dAtA[:n], nil
  589. }
  590. func (m *GetUnlockKeyRequest) MarshalTo(dAtA []byte) (int, error) {
  591. var i int
  592. _ = i
  593. var l int
  594. _ = l
  595. return i, nil
  596. }
  597. func (m *GetUnlockKeyResponse) Marshal() (dAtA []byte, err error) {
  598. size := m.Size()
  599. dAtA = make([]byte, size)
  600. n, err := m.MarshalTo(dAtA)
  601. if err != nil {
  602. return nil, err
  603. }
  604. return dAtA[:n], nil
  605. }
  606. func (m *GetUnlockKeyResponse) MarshalTo(dAtA []byte) (int, error) {
  607. var i int
  608. _ = i
  609. var l int
  610. _ = l
  611. if len(m.UnlockKey) > 0 {
  612. dAtA[i] = 0xa
  613. i++
  614. i = encodeVarintCa(dAtA, i, uint64(len(m.UnlockKey)))
  615. i += copy(dAtA[i:], m.UnlockKey)
  616. }
  617. dAtA[i] = 0x12
  618. i++
  619. i = encodeVarintCa(dAtA, i, uint64(m.Version.Size()))
  620. n3, err := m.Version.MarshalTo(dAtA[i:])
  621. if err != nil {
  622. return 0, err
  623. }
  624. i += n3
  625. return i, nil
  626. }
  627. func encodeFixed64Ca(dAtA []byte, offset int, v uint64) int {
  628. dAtA[offset] = uint8(v)
  629. dAtA[offset+1] = uint8(v >> 8)
  630. dAtA[offset+2] = uint8(v >> 16)
  631. dAtA[offset+3] = uint8(v >> 24)
  632. dAtA[offset+4] = uint8(v >> 32)
  633. dAtA[offset+5] = uint8(v >> 40)
  634. dAtA[offset+6] = uint8(v >> 48)
  635. dAtA[offset+7] = uint8(v >> 56)
  636. return offset + 8
  637. }
  638. func encodeFixed32Ca(dAtA []byte, offset int, v uint32) int {
  639. dAtA[offset] = uint8(v)
  640. dAtA[offset+1] = uint8(v >> 8)
  641. dAtA[offset+2] = uint8(v >> 16)
  642. dAtA[offset+3] = uint8(v >> 24)
  643. return offset + 4
  644. }
  645. func encodeVarintCa(dAtA []byte, offset int, v uint64) int {
  646. for v >= 1<<7 {
  647. dAtA[offset] = uint8(v&0x7f | 0x80)
  648. v >>= 7
  649. offset++
  650. }
  651. dAtA[offset] = uint8(v)
  652. return offset + 1
  653. }
  654. type raftProxyCAServer struct {
  655. local CAServer
  656. connSelector raftselector.ConnProvider
  657. localCtxMods, remoteCtxMods []func(context.Context) (context.Context, error)
  658. }
  659. func NewRaftProxyCAServer(local CAServer, connSelector raftselector.ConnProvider, localCtxMod, remoteCtxMod func(context.Context) (context.Context, error)) CAServer {
  660. redirectChecker := func(ctx context.Context) (context.Context, error) {
  661. s, ok := transport.StreamFromContext(ctx)
  662. if !ok {
  663. return ctx, grpc.Errorf(codes.InvalidArgument, "remote addr is not found in context")
  664. }
  665. addr := s.ServerTransport().RemoteAddr().String()
  666. md, ok := metadata.FromContext(ctx)
  667. if ok && len(md["redirect"]) != 0 {
  668. return ctx, grpc.Errorf(codes.ResourceExhausted, "more than one redirect to leader from: %s", md["redirect"])
  669. }
  670. if !ok {
  671. md = metadata.New(map[string]string{})
  672. }
  673. md["redirect"] = append(md["redirect"], addr)
  674. return metadata.NewContext(ctx, md), nil
  675. }
  676. remoteMods := []func(context.Context) (context.Context, error){redirectChecker}
  677. remoteMods = append(remoteMods, remoteCtxMod)
  678. var localMods []func(context.Context) (context.Context, error)
  679. if localCtxMod != nil {
  680. localMods = []func(context.Context) (context.Context, error){localCtxMod}
  681. }
  682. return &raftProxyCAServer{
  683. local: local,
  684. connSelector: connSelector,
  685. localCtxMods: localMods,
  686. remoteCtxMods: remoteMods,
  687. }
  688. }
  689. func (p *raftProxyCAServer) runCtxMods(ctx context.Context, ctxMods []func(context.Context) (context.Context, error)) (context.Context, error) {
  690. var err error
  691. for _, mod := range ctxMods {
  692. ctx, err = mod(ctx)
  693. if err != nil {
  694. return ctx, err
  695. }
  696. }
  697. return ctx, nil
  698. }
  699. func (p *raftProxyCAServer) pollNewLeaderConn(ctx context.Context) (*grpc.ClientConn, error) {
  700. ticker := rafttime.NewTicker(500 * rafttime.Millisecond)
  701. defer ticker.Stop()
  702. for {
  703. select {
  704. case <-ticker.C:
  705. conn, err := p.connSelector.LeaderConn(ctx)
  706. if err != nil {
  707. return nil, err
  708. }
  709. client := NewHealthClient(conn)
  710. resp, err := client.Check(ctx, &HealthCheckRequest{Service: "Raft"})
  711. if err != nil || resp.Status != HealthCheckResponse_SERVING {
  712. continue
  713. }
  714. return conn, nil
  715. case <-ctx.Done():
  716. return nil, ctx.Err()
  717. }
  718. }
  719. }
  720. func (p *raftProxyCAServer) GetRootCACertificate(ctx context.Context, r *GetRootCACertificateRequest) (*GetRootCACertificateResponse, error) {
  721. conn, err := p.connSelector.LeaderConn(ctx)
  722. if err != nil {
  723. if err == raftselector.ErrIsLeader {
  724. ctx, err = p.runCtxMods(ctx, p.localCtxMods)
  725. if err != nil {
  726. return nil, err
  727. }
  728. return p.local.GetRootCACertificate(ctx, r)
  729. }
  730. return nil, err
  731. }
  732. modCtx, err := p.runCtxMods(ctx, p.remoteCtxMods)
  733. if err != nil {
  734. return nil, err
  735. }
  736. resp, err := NewCAClient(conn).GetRootCACertificate(modCtx, r)
  737. if err != nil {
  738. if !strings.Contains(err.Error(), "is closing") && !strings.Contains(err.Error(), "the connection is unavailable") && !strings.Contains(err.Error(), "connection error") {
  739. return resp, err
  740. }
  741. conn, err := p.pollNewLeaderConn(ctx)
  742. if err != nil {
  743. if err == raftselector.ErrIsLeader {
  744. return p.local.GetRootCACertificate(ctx, r)
  745. }
  746. return nil, err
  747. }
  748. return NewCAClient(conn).GetRootCACertificate(modCtx, r)
  749. }
  750. return resp, err
  751. }
  752. func (p *raftProxyCAServer) GetUnlockKey(ctx context.Context, r *GetUnlockKeyRequest) (*GetUnlockKeyResponse, error) {
  753. conn, err := p.connSelector.LeaderConn(ctx)
  754. if err != nil {
  755. if err == raftselector.ErrIsLeader {
  756. ctx, err = p.runCtxMods(ctx, p.localCtxMods)
  757. if err != nil {
  758. return nil, err
  759. }
  760. return p.local.GetUnlockKey(ctx, r)
  761. }
  762. return nil, err
  763. }
  764. modCtx, err := p.runCtxMods(ctx, p.remoteCtxMods)
  765. if err != nil {
  766. return nil, err
  767. }
  768. resp, err := NewCAClient(conn).GetUnlockKey(modCtx, r)
  769. if err != nil {
  770. if !strings.Contains(err.Error(), "is closing") && !strings.Contains(err.Error(), "the connection is unavailable") && !strings.Contains(err.Error(), "connection error") {
  771. return resp, err
  772. }
  773. conn, err := p.pollNewLeaderConn(ctx)
  774. if err != nil {
  775. if err == raftselector.ErrIsLeader {
  776. return p.local.GetUnlockKey(ctx, r)
  777. }
  778. return nil, err
  779. }
  780. return NewCAClient(conn).GetUnlockKey(modCtx, r)
  781. }
  782. return resp, err
  783. }
  784. type raftProxyNodeCAServer struct {
  785. local NodeCAServer
  786. connSelector raftselector.ConnProvider
  787. localCtxMods, remoteCtxMods []func(context.Context) (context.Context, error)
  788. }
  789. func NewRaftProxyNodeCAServer(local NodeCAServer, connSelector raftselector.ConnProvider, localCtxMod, remoteCtxMod func(context.Context) (context.Context, error)) NodeCAServer {
  790. redirectChecker := func(ctx context.Context) (context.Context, error) {
  791. s, ok := transport.StreamFromContext(ctx)
  792. if !ok {
  793. return ctx, grpc.Errorf(codes.InvalidArgument, "remote addr is not found in context")
  794. }
  795. addr := s.ServerTransport().RemoteAddr().String()
  796. md, ok := metadata.FromContext(ctx)
  797. if ok && len(md["redirect"]) != 0 {
  798. return ctx, grpc.Errorf(codes.ResourceExhausted, "more than one redirect to leader from: %s", md["redirect"])
  799. }
  800. if !ok {
  801. md = metadata.New(map[string]string{})
  802. }
  803. md["redirect"] = append(md["redirect"], addr)
  804. return metadata.NewContext(ctx, md), nil
  805. }
  806. remoteMods := []func(context.Context) (context.Context, error){redirectChecker}
  807. remoteMods = append(remoteMods, remoteCtxMod)
  808. var localMods []func(context.Context) (context.Context, error)
  809. if localCtxMod != nil {
  810. localMods = []func(context.Context) (context.Context, error){localCtxMod}
  811. }
  812. return &raftProxyNodeCAServer{
  813. local: local,
  814. connSelector: connSelector,
  815. localCtxMods: localMods,
  816. remoteCtxMods: remoteMods,
  817. }
  818. }
  819. func (p *raftProxyNodeCAServer) runCtxMods(ctx context.Context, ctxMods []func(context.Context) (context.Context, error)) (context.Context, error) {
  820. var err error
  821. for _, mod := range ctxMods {
  822. ctx, err = mod(ctx)
  823. if err != nil {
  824. return ctx, err
  825. }
  826. }
  827. return ctx, nil
  828. }
  829. func (p *raftProxyNodeCAServer) pollNewLeaderConn(ctx context.Context) (*grpc.ClientConn, error) {
  830. ticker := rafttime.NewTicker(500 * rafttime.Millisecond)
  831. defer ticker.Stop()
  832. for {
  833. select {
  834. case <-ticker.C:
  835. conn, err := p.connSelector.LeaderConn(ctx)
  836. if err != nil {
  837. return nil, err
  838. }
  839. client := NewHealthClient(conn)
  840. resp, err := client.Check(ctx, &HealthCheckRequest{Service: "Raft"})
  841. if err != nil || resp.Status != HealthCheckResponse_SERVING {
  842. continue
  843. }
  844. return conn, nil
  845. case <-ctx.Done():
  846. return nil, ctx.Err()
  847. }
  848. }
  849. }
  850. func (p *raftProxyNodeCAServer) IssueNodeCertificate(ctx context.Context, r *IssueNodeCertificateRequest) (*IssueNodeCertificateResponse, error) {
  851. conn, err := p.connSelector.LeaderConn(ctx)
  852. if err != nil {
  853. if err == raftselector.ErrIsLeader {
  854. ctx, err = p.runCtxMods(ctx, p.localCtxMods)
  855. if err != nil {
  856. return nil, err
  857. }
  858. return p.local.IssueNodeCertificate(ctx, r)
  859. }
  860. return nil, err
  861. }
  862. modCtx, err := p.runCtxMods(ctx, p.remoteCtxMods)
  863. if err != nil {
  864. return nil, err
  865. }
  866. resp, err := NewNodeCAClient(conn).IssueNodeCertificate(modCtx, r)
  867. if err != nil {
  868. if !strings.Contains(err.Error(), "is closing") && !strings.Contains(err.Error(), "the connection is unavailable") && !strings.Contains(err.Error(), "connection error") {
  869. return resp, err
  870. }
  871. conn, err := p.pollNewLeaderConn(ctx)
  872. if err != nil {
  873. if err == raftselector.ErrIsLeader {
  874. return p.local.IssueNodeCertificate(ctx, r)
  875. }
  876. return nil, err
  877. }
  878. return NewNodeCAClient(conn).IssueNodeCertificate(modCtx, r)
  879. }
  880. return resp, err
  881. }
  882. func (p *raftProxyNodeCAServer) NodeCertificateStatus(ctx context.Context, r *NodeCertificateStatusRequest) (*NodeCertificateStatusResponse, error) {
  883. conn, err := p.connSelector.LeaderConn(ctx)
  884. if err != nil {
  885. if err == raftselector.ErrIsLeader {
  886. ctx, err = p.runCtxMods(ctx, p.localCtxMods)
  887. if err != nil {
  888. return nil, err
  889. }
  890. return p.local.NodeCertificateStatus(ctx, r)
  891. }
  892. return nil, err
  893. }
  894. modCtx, err := p.runCtxMods(ctx, p.remoteCtxMods)
  895. if err != nil {
  896. return nil, err
  897. }
  898. resp, err := NewNodeCAClient(conn).NodeCertificateStatus(modCtx, r)
  899. if err != nil {
  900. if !strings.Contains(err.Error(), "is closing") && !strings.Contains(err.Error(), "the connection is unavailable") && !strings.Contains(err.Error(), "connection error") {
  901. return resp, err
  902. }
  903. conn, err := p.pollNewLeaderConn(ctx)
  904. if err != nil {
  905. if err == raftselector.ErrIsLeader {
  906. return p.local.NodeCertificateStatus(ctx, r)
  907. }
  908. return nil, err
  909. }
  910. return NewNodeCAClient(conn).NodeCertificateStatus(modCtx, r)
  911. }
  912. return resp, err
  913. }
  914. func (m *NodeCertificateStatusRequest) Size() (n int) {
  915. var l int
  916. _ = l
  917. l = len(m.NodeID)
  918. if l > 0 {
  919. n += 1 + l + sovCa(uint64(l))
  920. }
  921. return n
  922. }
  923. func (m *NodeCertificateStatusResponse) Size() (n int) {
  924. var l int
  925. _ = l
  926. if m.Status != nil {
  927. l = m.Status.Size()
  928. n += 1 + l + sovCa(uint64(l))
  929. }
  930. if m.Certificate != nil {
  931. l = m.Certificate.Size()
  932. n += 1 + l + sovCa(uint64(l))
  933. }
  934. return n
  935. }
  936. func (m *IssueNodeCertificateRequest) Size() (n int) {
  937. var l int
  938. _ = l
  939. if m.Role != 0 {
  940. n += 1 + sovCa(uint64(m.Role))
  941. }
  942. l = len(m.CSR)
  943. if l > 0 {
  944. n += 1 + l + sovCa(uint64(l))
  945. }
  946. l = len(m.Token)
  947. if l > 0 {
  948. n += 1 + l + sovCa(uint64(l))
  949. }
  950. if m.Availability != 0 {
  951. n += 1 + sovCa(uint64(m.Availability))
  952. }
  953. return n
  954. }
  955. func (m *IssueNodeCertificateResponse) Size() (n int) {
  956. var l int
  957. _ = l
  958. l = len(m.NodeID)
  959. if l > 0 {
  960. n += 1 + l + sovCa(uint64(l))
  961. }
  962. if m.NodeMembership != 0 {
  963. n += 1 + sovCa(uint64(m.NodeMembership))
  964. }
  965. return n
  966. }
  967. func (m *GetRootCACertificateRequest) Size() (n int) {
  968. var l int
  969. _ = l
  970. return n
  971. }
  972. func (m *GetRootCACertificateResponse) Size() (n int) {
  973. var l int
  974. _ = l
  975. l = len(m.Certificate)
  976. if l > 0 {
  977. n += 1 + l + sovCa(uint64(l))
  978. }
  979. return n
  980. }
  981. func (m *GetUnlockKeyRequest) Size() (n int) {
  982. var l int
  983. _ = l
  984. return n
  985. }
  986. func (m *GetUnlockKeyResponse) Size() (n int) {
  987. var l int
  988. _ = l
  989. l = len(m.UnlockKey)
  990. if l > 0 {
  991. n += 1 + l + sovCa(uint64(l))
  992. }
  993. l = m.Version.Size()
  994. n += 1 + l + sovCa(uint64(l))
  995. return n
  996. }
  997. func sovCa(x uint64) (n int) {
  998. for {
  999. n++
  1000. x >>= 7
  1001. if x == 0 {
  1002. break
  1003. }
  1004. }
  1005. return n
  1006. }
  1007. func sozCa(x uint64) (n int) {
  1008. return sovCa(uint64((x << 1) ^ uint64((int64(x) >> 63))))
  1009. }
  1010. func (this *NodeCertificateStatusRequest) String() string {
  1011. if this == nil {
  1012. return "nil"
  1013. }
  1014. s := strings.Join([]string{`&NodeCertificateStatusRequest{`,
  1015. `NodeID:` + fmt.Sprintf("%v", this.NodeID) + `,`,
  1016. `}`,
  1017. }, "")
  1018. return s
  1019. }
  1020. func (this *NodeCertificateStatusResponse) String() string {
  1021. if this == nil {
  1022. return "nil"
  1023. }
  1024. s := strings.Join([]string{`&NodeCertificateStatusResponse{`,
  1025. `Status:` + strings.Replace(fmt.Sprintf("%v", this.Status), "IssuanceStatus", "IssuanceStatus", 1) + `,`,
  1026. `Certificate:` + strings.Replace(fmt.Sprintf("%v", this.Certificate), "Certificate", "Certificate", 1) + `,`,
  1027. `}`,
  1028. }, "")
  1029. return s
  1030. }
  1031. func (this *IssueNodeCertificateRequest) String() string {
  1032. if this == nil {
  1033. return "nil"
  1034. }
  1035. s := strings.Join([]string{`&IssueNodeCertificateRequest{`,
  1036. `Role:` + fmt.Sprintf("%v", this.Role) + `,`,
  1037. `CSR:` + fmt.Sprintf("%v", this.CSR) + `,`,
  1038. `Token:` + fmt.Sprintf("%v", this.Token) + `,`,
  1039. `Availability:` + fmt.Sprintf("%v", this.Availability) + `,`,
  1040. `}`,
  1041. }, "")
  1042. return s
  1043. }
  1044. func (this *IssueNodeCertificateResponse) String() string {
  1045. if this == nil {
  1046. return "nil"
  1047. }
  1048. s := strings.Join([]string{`&IssueNodeCertificateResponse{`,
  1049. `NodeID:` + fmt.Sprintf("%v", this.NodeID) + `,`,
  1050. `NodeMembership:` + fmt.Sprintf("%v", this.NodeMembership) + `,`,
  1051. `}`,
  1052. }, "")
  1053. return s
  1054. }
  1055. func (this *GetRootCACertificateRequest) String() string {
  1056. if this == nil {
  1057. return "nil"
  1058. }
  1059. s := strings.Join([]string{`&GetRootCACertificateRequest{`,
  1060. `}`,
  1061. }, "")
  1062. return s
  1063. }
  1064. func (this *GetRootCACertificateResponse) String() string {
  1065. if this == nil {
  1066. return "nil"
  1067. }
  1068. s := strings.Join([]string{`&GetRootCACertificateResponse{`,
  1069. `Certificate:` + fmt.Sprintf("%v", this.Certificate) + `,`,
  1070. `}`,
  1071. }, "")
  1072. return s
  1073. }
  1074. func (this *GetUnlockKeyRequest) String() string {
  1075. if this == nil {
  1076. return "nil"
  1077. }
  1078. s := strings.Join([]string{`&GetUnlockKeyRequest{`,
  1079. `}`,
  1080. }, "")
  1081. return s
  1082. }
  1083. func (this *GetUnlockKeyResponse) String() string {
  1084. if this == nil {
  1085. return "nil"
  1086. }
  1087. s := strings.Join([]string{`&GetUnlockKeyResponse{`,
  1088. `UnlockKey:` + fmt.Sprintf("%v", this.UnlockKey) + `,`,
  1089. `Version:` + strings.Replace(strings.Replace(this.Version.String(), "Version", "Version", 1), `&`, ``, 1) + `,`,
  1090. `}`,
  1091. }, "")
  1092. return s
  1093. }
  1094. func valueToStringCa(v interface{}) string {
  1095. rv := reflect.ValueOf(v)
  1096. if rv.IsNil() {
  1097. return "nil"
  1098. }
  1099. pv := reflect.Indirect(rv).Interface()
  1100. return fmt.Sprintf("*%v", pv)
  1101. }
  1102. func (m *NodeCertificateStatusRequest) Unmarshal(dAtA []byte) error {
  1103. l := len(dAtA)
  1104. iNdEx := 0
  1105. for iNdEx < l {
  1106. preIndex := iNdEx
  1107. var wire uint64
  1108. for shift := uint(0); ; shift += 7 {
  1109. if shift >= 64 {
  1110. return ErrIntOverflowCa
  1111. }
  1112. if iNdEx >= l {
  1113. return io.ErrUnexpectedEOF
  1114. }
  1115. b := dAtA[iNdEx]
  1116. iNdEx++
  1117. wire |= (uint64(b) & 0x7F) << shift
  1118. if b < 0x80 {
  1119. break
  1120. }
  1121. }
  1122. fieldNum := int32(wire >> 3)
  1123. wireType := int(wire & 0x7)
  1124. if wireType == 4 {
  1125. return fmt.Errorf("proto: NodeCertificateStatusRequest: wiretype end group for non-group")
  1126. }
  1127. if fieldNum <= 0 {
  1128. return fmt.Errorf("proto: NodeCertificateStatusRequest: illegal tag %d (wire type %d)", fieldNum, wire)
  1129. }
  1130. switch fieldNum {
  1131. case 1:
  1132. if wireType != 2 {
  1133. return fmt.Errorf("proto: wrong wireType = %d for field NodeID", wireType)
  1134. }
  1135. var stringLen uint64
  1136. for shift := uint(0); ; shift += 7 {
  1137. if shift >= 64 {
  1138. return ErrIntOverflowCa
  1139. }
  1140. if iNdEx >= l {
  1141. return io.ErrUnexpectedEOF
  1142. }
  1143. b := dAtA[iNdEx]
  1144. iNdEx++
  1145. stringLen |= (uint64(b) & 0x7F) << shift
  1146. if b < 0x80 {
  1147. break
  1148. }
  1149. }
  1150. intStringLen := int(stringLen)
  1151. if intStringLen < 0 {
  1152. return ErrInvalidLengthCa
  1153. }
  1154. postIndex := iNdEx + intStringLen
  1155. if postIndex > l {
  1156. return io.ErrUnexpectedEOF
  1157. }
  1158. m.NodeID = string(dAtA[iNdEx:postIndex])
  1159. iNdEx = postIndex
  1160. default:
  1161. iNdEx = preIndex
  1162. skippy, err := skipCa(dAtA[iNdEx:])
  1163. if err != nil {
  1164. return err
  1165. }
  1166. if skippy < 0 {
  1167. return ErrInvalidLengthCa
  1168. }
  1169. if (iNdEx + skippy) > l {
  1170. return io.ErrUnexpectedEOF
  1171. }
  1172. iNdEx += skippy
  1173. }
  1174. }
  1175. if iNdEx > l {
  1176. return io.ErrUnexpectedEOF
  1177. }
  1178. return nil
  1179. }
  1180. func (m *NodeCertificateStatusResponse) Unmarshal(dAtA []byte) error {
  1181. l := len(dAtA)
  1182. iNdEx := 0
  1183. for iNdEx < l {
  1184. preIndex := iNdEx
  1185. var wire uint64
  1186. for shift := uint(0); ; shift += 7 {
  1187. if shift >= 64 {
  1188. return ErrIntOverflowCa
  1189. }
  1190. if iNdEx >= l {
  1191. return io.ErrUnexpectedEOF
  1192. }
  1193. b := dAtA[iNdEx]
  1194. iNdEx++
  1195. wire |= (uint64(b) & 0x7F) << shift
  1196. if b < 0x80 {
  1197. break
  1198. }
  1199. }
  1200. fieldNum := int32(wire >> 3)
  1201. wireType := int(wire & 0x7)
  1202. if wireType == 4 {
  1203. return fmt.Errorf("proto: NodeCertificateStatusResponse: wiretype end group for non-group")
  1204. }
  1205. if fieldNum <= 0 {
  1206. return fmt.Errorf("proto: NodeCertificateStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire)
  1207. }
  1208. switch fieldNum {
  1209. case 1:
  1210. if wireType != 2 {
  1211. return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType)
  1212. }
  1213. var msglen int
  1214. for shift := uint(0); ; shift += 7 {
  1215. if shift >= 64 {
  1216. return ErrIntOverflowCa
  1217. }
  1218. if iNdEx >= l {
  1219. return io.ErrUnexpectedEOF
  1220. }
  1221. b := dAtA[iNdEx]
  1222. iNdEx++
  1223. msglen |= (int(b) & 0x7F) << shift
  1224. if b < 0x80 {
  1225. break
  1226. }
  1227. }
  1228. if msglen < 0 {
  1229. return ErrInvalidLengthCa
  1230. }
  1231. postIndex := iNdEx + msglen
  1232. if postIndex > l {
  1233. return io.ErrUnexpectedEOF
  1234. }
  1235. if m.Status == nil {
  1236. m.Status = &IssuanceStatus{}
  1237. }
  1238. if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
  1239. return err
  1240. }
  1241. iNdEx = postIndex
  1242. case 2:
  1243. if wireType != 2 {
  1244. return fmt.Errorf("proto: wrong wireType = %d for field Certificate", wireType)
  1245. }
  1246. var msglen int
  1247. for shift := uint(0); ; shift += 7 {
  1248. if shift >= 64 {
  1249. return ErrIntOverflowCa
  1250. }
  1251. if iNdEx >= l {
  1252. return io.ErrUnexpectedEOF
  1253. }
  1254. b := dAtA[iNdEx]
  1255. iNdEx++
  1256. msglen |= (int(b) & 0x7F) << shift
  1257. if b < 0x80 {
  1258. break
  1259. }
  1260. }
  1261. if msglen < 0 {
  1262. return ErrInvalidLengthCa
  1263. }
  1264. postIndex := iNdEx + msglen
  1265. if postIndex > l {
  1266. return io.ErrUnexpectedEOF
  1267. }
  1268. if m.Certificate == nil {
  1269. m.Certificate = &Certificate{}
  1270. }
  1271. if err := m.Certificate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
  1272. return err
  1273. }
  1274. iNdEx = postIndex
  1275. default:
  1276. iNdEx = preIndex
  1277. skippy, err := skipCa(dAtA[iNdEx:])
  1278. if err != nil {
  1279. return err
  1280. }
  1281. if skippy < 0 {
  1282. return ErrInvalidLengthCa
  1283. }
  1284. if (iNdEx + skippy) > l {
  1285. return io.ErrUnexpectedEOF
  1286. }
  1287. iNdEx += skippy
  1288. }
  1289. }
  1290. if iNdEx > l {
  1291. return io.ErrUnexpectedEOF
  1292. }
  1293. return nil
  1294. }
  1295. func (m *IssueNodeCertificateRequest) Unmarshal(dAtA []byte) error {
  1296. l := len(dAtA)
  1297. iNdEx := 0
  1298. for iNdEx < l {
  1299. preIndex := iNdEx
  1300. var wire uint64
  1301. for shift := uint(0); ; shift += 7 {
  1302. if shift >= 64 {
  1303. return ErrIntOverflowCa
  1304. }
  1305. if iNdEx >= l {
  1306. return io.ErrUnexpectedEOF
  1307. }
  1308. b := dAtA[iNdEx]
  1309. iNdEx++
  1310. wire |= (uint64(b) & 0x7F) << shift
  1311. if b < 0x80 {
  1312. break
  1313. }
  1314. }
  1315. fieldNum := int32(wire >> 3)
  1316. wireType := int(wire & 0x7)
  1317. if wireType == 4 {
  1318. return fmt.Errorf("proto: IssueNodeCertificateRequest: wiretype end group for non-group")
  1319. }
  1320. if fieldNum <= 0 {
  1321. return fmt.Errorf("proto: IssueNodeCertificateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
  1322. }
  1323. switch fieldNum {
  1324. case 1:
  1325. if wireType != 0 {
  1326. return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
  1327. }
  1328. m.Role = 0
  1329. for shift := uint(0); ; shift += 7 {
  1330. if shift >= 64 {
  1331. return ErrIntOverflowCa
  1332. }
  1333. if iNdEx >= l {
  1334. return io.ErrUnexpectedEOF
  1335. }
  1336. b := dAtA[iNdEx]
  1337. iNdEx++
  1338. m.Role |= (NodeRole(b) & 0x7F) << shift
  1339. if b < 0x80 {
  1340. break
  1341. }
  1342. }
  1343. case 2:
  1344. if wireType != 2 {
  1345. return fmt.Errorf("proto: wrong wireType = %d for field CSR", wireType)
  1346. }
  1347. var byteLen int
  1348. for shift := uint(0); ; shift += 7 {
  1349. if shift >= 64 {
  1350. return ErrIntOverflowCa
  1351. }
  1352. if iNdEx >= l {
  1353. return io.ErrUnexpectedEOF
  1354. }
  1355. b := dAtA[iNdEx]
  1356. iNdEx++
  1357. byteLen |= (int(b) & 0x7F) << shift
  1358. if b < 0x80 {
  1359. break
  1360. }
  1361. }
  1362. if byteLen < 0 {
  1363. return ErrInvalidLengthCa
  1364. }
  1365. postIndex := iNdEx + byteLen
  1366. if postIndex > l {
  1367. return io.ErrUnexpectedEOF
  1368. }
  1369. m.CSR = append(m.CSR[:0], dAtA[iNdEx:postIndex]...)
  1370. if m.CSR == nil {
  1371. m.CSR = []byte{}
  1372. }
  1373. iNdEx = postIndex
  1374. case 3:
  1375. if wireType != 2 {
  1376. return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
  1377. }
  1378. var stringLen uint64
  1379. for shift := uint(0); ; shift += 7 {
  1380. if shift >= 64 {
  1381. return ErrIntOverflowCa
  1382. }
  1383. if iNdEx >= l {
  1384. return io.ErrUnexpectedEOF
  1385. }
  1386. b := dAtA[iNdEx]
  1387. iNdEx++
  1388. stringLen |= (uint64(b) & 0x7F) << shift
  1389. if b < 0x80 {
  1390. break
  1391. }
  1392. }
  1393. intStringLen := int(stringLen)
  1394. if intStringLen < 0 {
  1395. return ErrInvalidLengthCa
  1396. }
  1397. postIndex := iNdEx + intStringLen
  1398. if postIndex > l {
  1399. return io.ErrUnexpectedEOF
  1400. }
  1401. m.Token = string(dAtA[iNdEx:postIndex])
  1402. iNdEx = postIndex
  1403. case 4:
  1404. if wireType != 0 {
  1405. return fmt.Errorf("proto: wrong wireType = %d for field Availability", wireType)
  1406. }
  1407. m.Availability = 0
  1408. for shift := uint(0); ; shift += 7 {
  1409. if shift >= 64 {
  1410. return ErrIntOverflowCa
  1411. }
  1412. if iNdEx >= l {
  1413. return io.ErrUnexpectedEOF
  1414. }
  1415. b := dAtA[iNdEx]
  1416. iNdEx++
  1417. m.Availability |= (NodeSpec_Availability(b) & 0x7F) << shift
  1418. if b < 0x80 {
  1419. break
  1420. }
  1421. }
  1422. default:
  1423. iNdEx = preIndex
  1424. skippy, err := skipCa(dAtA[iNdEx:])
  1425. if err != nil {
  1426. return err
  1427. }
  1428. if skippy < 0 {
  1429. return ErrInvalidLengthCa
  1430. }
  1431. if (iNdEx + skippy) > l {
  1432. return io.ErrUnexpectedEOF
  1433. }
  1434. iNdEx += skippy
  1435. }
  1436. }
  1437. if iNdEx > l {
  1438. return io.ErrUnexpectedEOF
  1439. }
  1440. return nil
  1441. }
  1442. func (m *IssueNodeCertificateResponse) Unmarshal(dAtA []byte) error {
  1443. l := len(dAtA)
  1444. iNdEx := 0
  1445. for iNdEx < l {
  1446. preIndex := iNdEx
  1447. var wire uint64
  1448. for shift := uint(0); ; shift += 7 {
  1449. if shift >= 64 {
  1450. return ErrIntOverflowCa
  1451. }
  1452. if iNdEx >= l {
  1453. return io.ErrUnexpectedEOF
  1454. }
  1455. b := dAtA[iNdEx]
  1456. iNdEx++
  1457. wire |= (uint64(b) & 0x7F) << shift
  1458. if b < 0x80 {
  1459. break
  1460. }
  1461. }
  1462. fieldNum := int32(wire >> 3)
  1463. wireType := int(wire & 0x7)
  1464. if wireType == 4 {
  1465. return fmt.Errorf("proto: IssueNodeCertificateResponse: wiretype end group for non-group")
  1466. }
  1467. if fieldNum <= 0 {
  1468. return fmt.Errorf("proto: IssueNodeCertificateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
  1469. }
  1470. switch fieldNum {
  1471. case 1:
  1472. if wireType != 2 {
  1473. return fmt.Errorf("proto: wrong wireType = %d for field NodeID", wireType)
  1474. }
  1475. var stringLen uint64
  1476. for shift := uint(0); ; shift += 7 {
  1477. if shift >= 64 {
  1478. return ErrIntOverflowCa
  1479. }
  1480. if iNdEx >= l {
  1481. return io.ErrUnexpectedEOF
  1482. }
  1483. b := dAtA[iNdEx]
  1484. iNdEx++
  1485. stringLen |= (uint64(b) & 0x7F) << shift
  1486. if b < 0x80 {
  1487. break
  1488. }
  1489. }
  1490. intStringLen := int(stringLen)
  1491. if intStringLen < 0 {
  1492. return ErrInvalidLengthCa
  1493. }
  1494. postIndex := iNdEx + intStringLen
  1495. if postIndex > l {
  1496. return io.ErrUnexpectedEOF
  1497. }
  1498. m.NodeID = string(dAtA[iNdEx:postIndex])
  1499. iNdEx = postIndex
  1500. case 2:
  1501. if wireType != 0 {
  1502. return fmt.Errorf("proto: wrong wireType = %d for field NodeMembership", wireType)
  1503. }
  1504. m.NodeMembership = 0
  1505. for shift := uint(0); ; shift += 7 {
  1506. if shift >= 64 {
  1507. return ErrIntOverflowCa
  1508. }
  1509. if iNdEx >= l {
  1510. return io.ErrUnexpectedEOF
  1511. }
  1512. b := dAtA[iNdEx]
  1513. iNdEx++
  1514. m.NodeMembership |= (NodeSpec_Membership(b) & 0x7F) << shift
  1515. if b < 0x80 {
  1516. break
  1517. }
  1518. }
  1519. default:
  1520. iNdEx = preIndex
  1521. skippy, err := skipCa(dAtA[iNdEx:])
  1522. if err != nil {
  1523. return err
  1524. }
  1525. if skippy < 0 {
  1526. return ErrInvalidLengthCa
  1527. }
  1528. if (iNdEx + skippy) > l {
  1529. return io.ErrUnexpectedEOF
  1530. }
  1531. iNdEx += skippy
  1532. }
  1533. }
  1534. if iNdEx > l {
  1535. return io.ErrUnexpectedEOF
  1536. }
  1537. return nil
  1538. }
  1539. func (m *GetRootCACertificateRequest) Unmarshal(dAtA []byte) error {
  1540. l := len(dAtA)
  1541. iNdEx := 0
  1542. for iNdEx < l {
  1543. preIndex := iNdEx
  1544. var wire uint64
  1545. for shift := uint(0); ; shift += 7 {
  1546. if shift >= 64 {
  1547. return ErrIntOverflowCa
  1548. }
  1549. if iNdEx >= l {
  1550. return io.ErrUnexpectedEOF
  1551. }
  1552. b := dAtA[iNdEx]
  1553. iNdEx++
  1554. wire |= (uint64(b) & 0x7F) << shift
  1555. if b < 0x80 {
  1556. break
  1557. }
  1558. }
  1559. fieldNum := int32(wire >> 3)
  1560. wireType := int(wire & 0x7)
  1561. if wireType == 4 {
  1562. return fmt.Errorf("proto: GetRootCACertificateRequest: wiretype end group for non-group")
  1563. }
  1564. if fieldNum <= 0 {
  1565. return fmt.Errorf("proto: GetRootCACertificateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
  1566. }
  1567. switch fieldNum {
  1568. default:
  1569. iNdEx = preIndex
  1570. skippy, err := skipCa(dAtA[iNdEx:])
  1571. if err != nil {
  1572. return err
  1573. }
  1574. if skippy < 0 {
  1575. return ErrInvalidLengthCa
  1576. }
  1577. if (iNdEx + skippy) > l {
  1578. return io.ErrUnexpectedEOF
  1579. }
  1580. iNdEx += skippy
  1581. }
  1582. }
  1583. if iNdEx > l {
  1584. return io.ErrUnexpectedEOF
  1585. }
  1586. return nil
  1587. }
  1588. func (m *GetRootCACertificateResponse) Unmarshal(dAtA []byte) error {
  1589. l := len(dAtA)
  1590. iNdEx := 0
  1591. for iNdEx < l {
  1592. preIndex := iNdEx
  1593. var wire uint64
  1594. for shift := uint(0); ; shift += 7 {
  1595. if shift >= 64 {
  1596. return ErrIntOverflowCa
  1597. }
  1598. if iNdEx >= l {
  1599. return io.ErrUnexpectedEOF
  1600. }
  1601. b := dAtA[iNdEx]
  1602. iNdEx++
  1603. wire |= (uint64(b) & 0x7F) << shift
  1604. if b < 0x80 {
  1605. break
  1606. }
  1607. }
  1608. fieldNum := int32(wire >> 3)
  1609. wireType := int(wire & 0x7)
  1610. if wireType == 4 {
  1611. return fmt.Errorf("proto: GetRootCACertificateResponse: wiretype end group for non-group")
  1612. }
  1613. if fieldNum <= 0 {
  1614. return fmt.Errorf("proto: GetRootCACertificateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
  1615. }
  1616. switch fieldNum {
  1617. case 1:
  1618. if wireType != 2 {
  1619. return fmt.Errorf("proto: wrong wireType = %d for field Certificate", wireType)
  1620. }
  1621. var byteLen int
  1622. for shift := uint(0); ; shift += 7 {
  1623. if shift >= 64 {
  1624. return ErrIntOverflowCa
  1625. }
  1626. if iNdEx >= l {
  1627. return io.ErrUnexpectedEOF
  1628. }
  1629. b := dAtA[iNdEx]
  1630. iNdEx++
  1631. byteLen |= (int(b) & 0x7F) << shift
  1632. if b < 0x80 {
  1633. break
  1634. }
  1635. }
  1636. if byteLen < 0 {
  1637. return ErrInvalidLengthCa
  1638. }
  1639. postIndex := iNdEx + byteLen
  1640. if postIndex > l {
  1641. return io.ErrUnexpectedEOF
  1642. }
  1643. m.Certificate = append(m.Certificate[:0], dAtA[iNdEx:postIndex]...)
  1644. if m.Certificate == nil {
  1645. m.Certificate = []byte{}
  1646. }
  1647. iNdEx = postIndex
  1648. default:
  1649. iNdEx = preIndex
  1650. skippy, err := skipCa(dAtA[iNdEx:])
  1651. if err != nil {
  1652. return err
  1653. }
  1654. if skippy < 0 {
  1655. return ErrInvalidLengthCa
  1656. }
  1657. if (iNdEx + skippy) > l {
  1658. return io.ErrUnexpectedEOF
  1659. }
  1660. iNdEx += skippy
  1661. }
  1662. }
  1663. if iNdEx > l {
  1664. return io.ErrUnexpectedEOF
  1665. }
  1666. return nil
  1667. }
  1668. func (m *GetUnlockKeyRequest) Unmarshal(dAtA []byte) error {
  1669. l := len(dAtA)
  1670. iNdEx := 0
  1671. for iNdEx < l {
  1672. preIndex := iNdEx
  1673. var wire uint64
  1674. for shift := uint(0); ; shift += 7 {
  1675. if shift >= 64 {
  1676. return ErrIntOverflowCa
  1677. }
  1678. if iNdEx >= l {
  1679. return io.ErrUnexpectedEOF
  1680. }
  1681. b := dAtA[iNdEx]
  1682. iNdEx++
  1683. wire |= (uint64(b) & 0x7F) << shift
  1684. if b < 0x80 {
  1685. break
  1686. }
  1687. }
  1688. fieldNum := int32(wire >> 3)
  1689. wireType := int(wire & 0x7)
  1690. if wireType == 4 {
  1691. return fmt.Errorf("proto: GetUnlockKeyRequest: wiretype end group for non-group")
  1692. }
  1693. if fieldNum <= 0 {
  1694. return fmt.Errorf("proto: GetUnlockKeyRequest: illegal tag %d (wire type %d)", fieldNum, wire)
  1695. }
  1696. switch fieldNum {
  1697. default:
  1698. iNdEx = preIndex
  1699. skippy, err := skipCa(dAtA[iNdEx:])
  1700. if err != nil {
  1701. return err
  1702. }
  1703. if skippy < 0 {
  1704. return ErrInvalidLengthCa
  1705. }
  1706. if (iNdEx + skippy) > l {
  1707. return io.ErrUnexpectedEOF
  1708. }
  1709. iNdEx += skippy
  1710. }
  1711. }
  1712. if iNdEx > l {
  1713. return io.ErrUnexpectedEOF
  1714. }
  1715. return nil
  1716. }
  1717. func (m *GetUnlockKeyResponse) Unmarshal(dAtA []byte) error {
  1718. l := len(dAtA)
  1719. iNdEx := 0
  1720. for iNdEx < l {
  1721. preIndex := iNdEx
  1722. var wire uint64
  1723. for shift := uint(0); ; shift += 7 {
  1724. if shift >= 64 {
  1725. return ErrIntOverflowCa
  1726. }
  1727. if iNdEx >= l {
  1728. return io.ErrUnexpectedEOF
  1729. }
  1730. b := dAtA[iNdEx]
  1731. iNdEx++
  1732. wire |= (uint64(b) & 0x7F) << shift
  1733. if b < 0x80 {
  1734. break
  1735. }
  1736. }
  1737. fieldNum := int32(wire >> 3)
  1738. wireType := int(wire & 0x7)
  1739. if wireType == 4 {
  1740. return fmt.Errorf("proto: GetUnlockKeyResponse: wiretype end group for non-group")
  1741. }
  1742. if fieldNum <= 0 {
  1743. return fmt.Errorf("proto: GetUnlockKeyResponse: illegal tag %d (wire type %d)", fieldNum, wire)
  1744. }
  1745. switch fieldNum {
  1746. case 1:
  1747. if wireType != 2 {
  1748. return fmt.Errorf("proto: wrong wireType = %d for field UnlockKey", wireType)
  1749. }
  1750. var byteLen int
  1751. for shift := uint(0); ; shift += 7 {
  1752. if shift >= 64 {
  1753. return ErrIntOverflowCa
  1754. }
  1755. if iNdEx >= l {
  1756. return io.ErrUnexpectedEOF
  1757. }
  1758. b := dAtA[iNdEx]
  1759. iNdEx++
  1760. byteLen |= (int(b) & 0x7F) << shift
  1761. if b < 0x80 {
  1762. break
  1763. }
  1764. }
  1765. if byteLen < 0 {
  1766. return ErrInvalidLengthCa
  1767. }
  1768. postIndex := iNdEx + byteLen
  1769. if postIndex > l {
  1770. return io.ErrUnexpectedEOF
  1771. }
  1772. m.UnlockKey = append(m.UnlockKey[:0], dAtA[iNdEx:postIndex]...)
  1773. if m.UnlockKey == nil {
  1774. m.UnlockKey = []byte{}
  1775. }
  1776. iNdEx = postIndex
  1777. case 2:
  1778. if wireType != 2 {
  1779. return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
  1780. }
  1781. var msglen int
  1782. for shift := uint(0); ; shift += 7 {
  1783. if shift >= 64 {
  1784. return ErrIntOverflowCa
  1785. }
  1786. if iNdEx >= l {
  1787. return io.ErrUnexpectedEOF
  1788. }
  1789. b := dAtA[iNdEx]
  1790. iNdEx++
  1791. msglen |= (int(b) & 0x7F) << shift
  1792. if b < 0x80 {
  1793. break
  1794. }
  1795. }
  1796. if msglen < 0 {
  1797. return ErrInvalidLengthCa
  1798. }
  1799. postIndex := iNdEx + msglen
  1800. if postIndex > l {
  1801. return io.ErrUnexpectedEOF
  1802. }
  1803. if err := m.Version.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
  1804. return err
  1805. }
  1806. iNdEx = postIndex
  1807. default:
  1808. iNdEx = preIndex
  1809. skippy, err := skipCa(dAtA[iNdEx:])
  1810. if err != nil {
  1811. return err
  1812. }
  1813. if skippy < 0 {
  1814. return ErrInvalidLengthCa
  1815. }
  1816. if (iNdEx + skippy) > l {
  1817. return io.ErrUnexpectedEOF
  1818. }
  1819. iNdEx += skippy
  1820. }
  1821. }
  1822. if iNdEx > l {
  1823. return io.ErrUnexpectedEOF
  1824. }
  1825. return nil
  1826. }
  1827. func skipCa(dAtA []byte) (n int, err error) {
  1828. l := len(dAtA)
  1829. iNdEx := 0
  1830. for iNdEx < l {
  1831. var wire uint64
  1832. for shift := uint(0); ; shift += 7 {
  1833. if shift >= 64 {
  1834. return 0, ErrIntOverflowCa
  1835. }
  1836. if iNdEx >= l {
  1837. return 0, io.ErrUnexpectedEOF
  1838. }
  1839. b := dAtA[iNdEx]
  1840. iNdEx++
  1841. wire |= (uint64(b) & 0x7F) << shift
  1842. if b < 0x80 {
  1843. break
  1844. }
  1845. }
  1846. wireType := int(wire & 0x7)
  1847. switch wireType {
  1848. case 0:
  1849. for shift := uint(0); ; shift += 7 {
  1850. if shift >= 64 {
  1851. return 0, ErrIntOverflowCa
  1852. }
  1853. if iNdEx >= l {
  1854. return 0, io.ErrUnexpectedEOF
  1855. }
  1856. iNdEx++
  1857. if dAtA[iNdEx-1] < 0x80 {
  1858. break
  1859. }
  1860. }
  1861. return iNdEx, nil
  1862. case 1:
  1863. iNdEx += 8
  1864. return iNdEx, nil
  1865. case 2:
  1866. var length int
  1867. for shift := uint(0); ; shift += 7 {
  1868. if shift >= 64 {
  1869. return 0, ErrIntOverflowCa
  1870. }
  1871. if iNdEx >= l {
  1872. return 0, io.ErrUnexpectedEOF
  1873. }
  1874. b := dAtA[iNdEx]
  1875. iNdEx++
  1876. length |= (int(b) & 0x7F) << shift
  1877. if b < 0x80 {
  1878. break
  1879. }
  1880. }
  1881. iNdEx += length
  1882. if length < 0 {
  1883. return 0, ErrInvalidLengthCa
  1884. }
  1885. return iNdEx, nil
  1886. case 3:
  1887. for {
  1888. var innerWire uint64
  1889. var start int = iNdEx
  1890. for shift := uint(0); ; shift += 7 {
  1891. if shift >= 64 {
  1892. return 0, ErrIntOverflowCa
  1893. }
  1894. if iNdEx >= l {
  1895. return 0, io.ErrUnexpectedEOF
  1896. }
  1897. b := dAtA[iNdEx]
  1898. iNdEx++
  1899. innerWire |= (uint64(b) & 0x7F) << shift
  1900. if b < 0x80 {
  1901. break
  1902. }
  1903. }
  1904. innerWireType := int(innerWire & 0x7)
  1905. if innerWireType == 4 {
  1906. break
  1907. }
  1908. next, err := skipCa(dAtA[start:])
  1909. if err != nil {
  1910. return 0, err
  1911. }
  1912. iNdEx = start + next
  1913. }
  1914. return iNdEx, nil
  1915. case 4:
  1916. return iNdEx, nil
  1917. case 5:
  1918. iNdEx += 4
  1919. return iNdEx, nil
  1920. default:
  1921. return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
  1922. }
  1923. }
  1924. panic("unreachable")
  1925. }
  1926. var (
  1927. ErrInvalidLengthCa = fmt.Errorf("proto: negative length found during unmarshaling")
  1928. ErrIntOverflowCa = fmt.Errorf("proto: integer overflow")
  1929. )
  1930. func init() { proto.RegisterFile("ca.proto", fileDescriptorCa) }
  1931. var fileDescriptorCa = []byte{
  1932. // 610 bytes of a gzipped FileDescriptorProto
  1933. 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x40,
  1934. 0x10, 0xee, 0xba, 0x25, 0x6d, 0x27, 0xa1, 0x45, 0xdb, 0x56, 0x32, 0x69, 0xea, 0x54, 0xe6, 0xd0,
  1935. 0x72, 0xc0, 0x6d, 0x03, 0x27, 0xb8, 0x90, 0x04, 0xa9, 0x8a, 0x50, 0x11, 0xda, 0x08, 0xae, 0x95,
  1936. 0xe3, 0x2c, 0xc1, 0x8a, 0xe3, 0x35, 0xde, 0x75, 0x20, 0x37, 0x24, 0x10, 0x6f, 0x80, 0xe0, 0xc4,
  1937. 0x23, 0xf0, 0x1c, 0x11, 0x27, 0x24, 0x2e, 0x9c, 0x22, 0xea, 0x07, 0xe0, 0x19, 0x90, 0xd7, 0x36,
  1938. 0xcd, 0x8f, 0x13, 0xca, 0xc9, 0xbb, 0xb3, 0xdf, 0xf7, 0xcd, 0xcc, 0xb7, 0xe3, 0x85, 0x35, 0xcb,
  1939. 0x34, 0x3c, 0x9f, 0x09, 0x86, 0x71, 0x9b, 0x59, 0x5d, 0xea, 0x1b, 0xfc, 0xb5, 0xe9, 0xf7, 0xba,
  1940. 0xb6, 0x30, 0xfa, 0x27, 0xc5, 0xbc, 0x18, 0x78, 0x94, 0xc7, 0x80, 0x62, 0x9e, 0x7b, 0xd4, 0x4a,
  1941. 0x37, 0xdb, 0x1d, 0xd6, 0x61, 0x72, 0x79, 0x14, 0xad, 0x92, 0xe8, 0x96, 0xe7, 0x04, 0x1d, 0xdb,
  1942. 0x3d, 0x8a, 0x3f, 0x71, 0x50, 0xaf, 0x43, 0xe9, 0x09, 0x6b, 0xd3, 0x3a, 0xf5, 0x85, 0xfd, 0xc2,
  1943. 0xb6, 0x4c, 0x41, 0x9b, 0xc2, 0x14, 0x01, 0x27, 0xf4, 0x55, 0x40, 0xb9, 0xc0, 0xb7, 0x60, 0xd5,
  1944. 0x65, 0x6d, 0x7a, 0x6e, 0xb7, 0x55, 0xb4, 0x8f, 0x0e, 0xd7, 0x6b, 0x10, 0x8e, 0xca, 0xb9, 0x88,
  1945. 0xd2, 0x78, 0x44, 0x72, 0xd1, 0x51, 0xa3, 0xad, 0x7f, 0x41, 0xb0, 0x37, 0x47, 0x85, 0x7b, 0xcc,
  1946. 0xe5, 0x14, 0xdf, 0x87, 0x1c, 0x97, 0x11, 0xa9, 0x92, 0xaf, 0xe8, 0xc6, 0x6c, 0x43, 0x46, 0x83,
  1947. 0xf3, 0xc0, 0x74, 0xad, 0x94, 0x9b, 0x30, 0x70, 0x15, 0xf2, 0xd6, 0xa5, 0xb0, 0xaa, 0x48, 0x81,
  1948. 0x72, 0x96, 0xc0, 0x58, 0x7e, 0x32, 0xce, 0xd1, 0x7f, 0x20, 0xd8, 0x8d, 0xd4, 0xe9, 0x54, 0x95,
  1949. 0x69, 0x97, 0xf7, 0x60, 0xc5, 0x67, 0x0e, 0x95, 0xc5, 0x6d, 0x54, 0x4a, 0x59, 0xda, 0x11, 0x93,
  1950. 0x30, 0x87, 0xd6, 0x14, 0x15, 0x11, 0x89, 0xc6, 0x37, 0x61, 0xd9, 0xe2, 0xbe, 0x2c, 0xa8, 0x50,
  1951. 0x5b, 0x0d, 0x47, 0xe5, 0xe5, 0x7a, 0x93, 0x90, 0x28, 0x86, 0xb7, 0xe1, 0x9a, 0x60, 0x5d, 0xea,
  1952. 0xaa, 0xcb, 0x91, 0x69, 0x24, 0xde, 0xe0, 0x33, 0x28, 0x98, 0x7d, 0xd3, 0x76, 0xcc, 0x96, 0xed,
  1953. 0xd8, 0x62, 0xa0, 0xae, 0xc8, 0x74, 0xb7, 0xe7, 0xa5, 0x6b, 0x7a, 0xd4, 0x32, 0xaa, 0x63, 0x04,
  1954. 0x32, 0x41, 0xd7, 0x3f, 0x22, 0x28, 0x65, 0x77, 0x95, 0xb8, 0x7e, 0x95, 0xcb, 0xc3, 0x4f, 0x61,
  1955. 0x53, 0x82, 0x7a, 0xb4, 0xd7, 0xa2, 0x3e, 0x7f, 0x69, 0x7b, 0xb2, 0xa3, 0x8d, 0xca, 0xc1, 0xc2,
  1956. 0xba, 0xce, 0xfe, 0xc2, 0xc9, 0x46, 0xc4, 0xbf, 0xdc, 0xeb, 0x7b, 0xb0, 0x7b, 0x4a, 0x05, 0x61,
  1957. 0x4c, 0xd4, 0xab, 0xb3, 0x66, 0xeb, 0x0f, 0xa1, 0x94, 0x7d, 0x9c, 0x54, 0xbd, 0x3f, 0x79, 0xdf,
  1958. 0x51, 0xe5, 0x85, 0xc9, 0xeb, 0xdc, 0x81, 0xad, 0x53, 0x2a, 0x9e, 0xb9, 0x0e, 0xb3, 0xba, 0x8f,
  1959. 0xe9, 0x20, 0x15, 0xf6, 0x61, 0x7b, 0x32, 0x9c, 0x08, 0xee, 0x01, 0x04, 0x32, 0x78, 0xde, 0xa5,
  1960. 0x83, 0x44, 0x6f, 0x3d, 0x48, 0x61, 0xf8, 0x01, 0xac, 0xf6, 0xa9, 0xcf, 0x6d, 0xe6, 0x26, 0xb3,
  1961. 0xb5, 0x9b, 0xd5, 0xf8, 0xf3, 0x18, 0x52, 0x5b, 0x19, 0x8e, 0xca, 0x4b, 0x24, 0x65, 0x54, 0xde,
  1962. 0x2b, 0xa0, 0xd4, 0xab, 0xf8, 0x1d, 0x92, 0xb9, 0x67, 0x9a, 0xc2, 0x47, 0x59, 0x5a, 0x0b, 0xdc,
  1963. 0x29, 0x1e, 0x5f, 0x9d, 0x10, 0xb7, 0xa7, 0xaf, 0x7d, 0xfb, 0xfa, 0xfb, 0xb3, 0xa2, 0xdc, 0x40,
  1964. 0xf8, 0x0d, 0x14, 0xc6, 0x0d, 0xc0, 0x07, 0x73, 0xb4, 0xa6, 0x9d, 0x2b, 0x1e, 0xfe, 0x1b, 0x98,
  1965. 0x24, 0xdb, 0x91, 0xc9, 0x36, 0xe1, 0xba, 0x44, 0xde, 0xe9, 0x99, 0xae, 0xd9, 0xa1, 0x7e, 0xe5,
  1966. 0x93, 0x02, 0x72, 0xae, 0x12, 0x2b, 0xb2, 0xa6, 0x32, 0xdb, 0x8a, 0x05, 0x7f, 0x65, 0xb6, 0x15,
  1967. 0x8b, 0x06, 0x7e, 0xcc, 0x8a, 0x0f, 0x08, 0x76, 0x32, 0x9f, 0x24, 0x7c, 0x3c, 0x6f, 0xac, 0xe7,
  1968. 0xbd, 0x81, 0xc5, 0x93, 0xff, 0x60, 0x4c, 0x17, 0x52, 0x53, 0x87, 0x17, 0xda, 0xd2, 0xcf, 0x0b,
  1969. 0x6d, 0xe9, 0x6d, 0xa8, 0xa1, 0x61, 0xa8, 0xa1, 0xef, 0xa1, 0x86, 0x7e, 0x85, 0x1a, 0x6a, 0xe5,
  1970. 0xe4, 0x0b, 0x7c, 0xf7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0xad, 0xed, 0x8f, 0xe6, 0x05,
  1971. 0x00, 0x00,
  1972. }