From 102cfd43c97f1ada5f0626487e817b3fe72ac5ed Mon Sep 17 00:00:00 2001 From: postmannen Date: Wed, 20 Apr 2022 06:26:01 +0200 Subject: [PATCH] Renamed REQPublicKeysPut to REQPublicKeysToNode --- central_auth.go | 6 ++++-- configuration_flags.go | 14 +++++++------- processes.go | 14 +++++++------- requests.go | 12 ++++++------ 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/central_auth.go b/central_auth.go index 88e4a3a..a187a28 100644 --- a/central_auth.go +++ b/central_auth.go @@ -13,6 +13,8 @@ import ( type signatureBase32 string type argsString string + +// centralAuth holds the logic related to handling public keys and auth maps. type centralAuth struct { // schema map[Node]map[argsString]signatureBase32 nodePublicKeys *nodePublicKeys @@ -22,6 +24,7 @@ type centralAuth struct { errorKernel *errorKernel } +// newCentralAuth will return a prepared *centralAuth with input values set. func newCentralAuth(configuration *Configuration, errorKernel *errorKernel) *centralAuth { c := centralAuth{ // schema: make(map[Node]map[argsString]signatureBase32), @@ -60,7 +63,6 @@ func newCentralAuth(configuration *Configuration, errorKernel *errorKernel) *cen } // addPublicKey to the db if the node do not exist, or if it is a new value. -// We should return an error if the key have changed. func (c *centralAuth) addPublicKey(proc process, msg Message) { c.nodePublicKeys.mu.Lock() @@ -94,7 +96,7 @@ func (c *centralAuth) addPublicKey(proc process, msg Message) { //c.dbDump(c.bucketPublicKeys) } -// dbView will look up and return a specific value if it exists for a key in a bucket in a DB. +// dbGetPublicKey will look up and return a specific value if it exists for a key in a bucket in a DB. func (c *centralAuth) dbGetPublicKey(node string) ([]byte, error) { var value []byte // View is a help function to get values out of the database. diff --git a/configuration_flags.go b/configuration_flags.go index 1404397..ec2d0bd 100644 --- a/configuration_flags.go +++ b/configuration_flags.go @@ -92,7 +92,7 @@ type Configuration struct { // Publisher for asking central for public keys StartPubREQPublicKeysGet bool // Subscriber for receiving updates of public keys from central - StartSubREQPublicKeysPut bool + StartSubREQPublicKeysToNode bool // Start the central error logger. StartSubREQErrorLog bool // Subscriber for hello messages @@ -168,7 +168,7 @@ type ConfigurationFromFile struct { StartPubREQHello *int StartPubREQPublicKeysGet *bool - StartSubREQPublicKeysPut *bool + StartSubREQPublicKeysToNode *bool StartSubREQErrorLog *bool StartSubREQHello *bool StartSubREQToFileAppend *bool @@ -232,7 +232,7 @@ func newConfigurationDefaults() Configuration { StartPubREQHello: 30, StartPubREQPublicKeysGet: true, - StartSubREQPublicKeysPut: true, + StartSubREQPublicKeysToNode: true, StartSubREQErrorLog: false, StartSubREQHello: true, StartSubREQToFileAppend: true, @@ -437,10 +437,10 @@ func checkConfigValues(cf ConfigurationFromFile) Configuration { } else { conf.StartPubREQPublicKeysGet = *cf.StartPubREQPublicKeysGet } - if cf.StartSubREQPublicKeysPut == nil { - conf.StartSubREQPublicKeysPut = cd.StartSubREQPublicKeysPut + if cf.StartSubREQPublicKeysToNode == nil { + conf.StartSubREQPublicKeysToNode = cd.StartSubREQPublicKeysToNode } else { - conf.StartSubREQPublicKeysPut = *cf.StartSubREQPublicKeysPut + conf.StartSubREQPublicKeysToNode = *cf.StartSubREQPublicKeysToNode } if cf.StartSubREQErrorLog == nil { conf.StartSubREQErrorLog = cd.StartSubREQErrorLog @@ -591,7 +591,7 @@ func (c *Configuration) CheckFlags() error { flag.IntVar(&c.StartPubREQHello, "startPubREQHello", fc.StartPubREQHello, "Make the current node send hello messages to central at given interval in seconds") flag.BoolVar(&c.StartPubREQPublicKeysGet, "startPubREQPublicKeysGet", fc.StartPubREQPublicKeysGet, "true/false") - flag.BoolVar(&c.StartSubREQPublicKeysPut, "startSubREQPublicKeysPut", fc.StartSubREQPublicKeysPut, "true/false") + flag.BoolVar(&c.StartSubREQPublicKeysToNode, "startSubREQPublicKeysToNode", fc.StartSubREQPublicKeysToNode, "true/false") flag.BoolVar(&c.StartSubREQErrorLog, "startSubREQErrorLog", fc.StartSubREQErrorLog, "true/false") flag.BoolVar(&c.StartSubREQHello, "startSubREQHello", fc.StartSubREQHello, "true/false") flag.BoolVar(&c.StartSubREQToFileAppend, "startSubREQToFileAppend", fc.StartSubREQToFileAppend, "true/false") diff --git a/processes.go b/processes.go index 81c410d..ac2e610 100644 --- a/processes.go +++ b/processes.go @@ -174,8 +174,8 @@ func (p *processes) Start(proc process) { proc.startup.subREQPublicKeysGet(proc) } - if proc.configuration.StartSubREQPublicKeysPut { - proc.startup.subREQPublicKeysPut(proc) + if proc.configuration.StartSubREQPublicKeysToNode { + proc.startup.subREQPublicKeysToNode(proc) } if proc.configuration.StartSubREQHttpGet { @@ -302,7 +302,7 @@ func (s startup) pubREQHello(p process) { // pubREQPublicKeysGet defines the startup of a publisher that will send REQPublicKeysGet // to central server and ask for publics keys, and to get them deliver back with a request -// of type pubREQPublicKeysPut. +// of type pubREQPublicKeysToNode. func (s startup) pubREQPublicKeysGet(p process) { log.Printf("Starting PublicKeysGet Publisher: %#v\n", p.node) @@ -322,7 +322,7 @@ func (s startup) pubREQPublicKeysGet(p process) { FromNode: Node(p.node), // Data: []byte(d), Method: REQPublicKeysGet, - ReplyMethod: REQPublicKeysPut, + ReplyMethod: REQPublicKeysToNode, ACKTimeout: proc.configuration.DefaultMessageTimeout, Retries: 1, } @@ -355,9 +355,9 @@ func (s startup) subREQPublicKeysGet(p process) { go proc.spawnWorker() } -func (s startup) subREQPublicKeysPut(p process) { - log.Printf("Starting Public keys put subscriber: %#v\n", p.node) - sub := newSubject(REQPublicKeysPut, string(p.node)) +func (s startup) subREQPublicKeysToNode(p process) { + log.Printf("Starting Public keys to Node subscriber: %#v\n", p.node) + sub := newSubject(REQPublicKeysToNode, string(p.node)) proc := newProcess(p.ctx, s.server, sub, processKindSubscriber, nil) go proc.spawnWorker() } diff --git a/requests.go b/requests.go index 23e9773..61eb915 100644 --- a/requests.go +++ b/requests.go @@ -138,8 +138,8 @@ const ( REQPublicKey Method = "REQPublicKey" // REQPublicKeysGet will get all the public keys from central. REQPublicKeysGet Method = "REQPublicKeysGet" - // REQPublicKeysPut will put all the public received from central. - REQPublicKeysPut Method = "REQPublicKeysPut" + // REQPublicKeysToNode will put all the public received from central. + REQPublicKeysToNode Method = "REQPublicKeysToNode" ) // The mapping of all the method constants specified, what type @@ -227,7 +227,7 @@ func (m Method) GetMethodsAvailable() MethodsAvailable { REQPublicKeysGet: methodREQPublicKeysGet{ event: EventNACK, }, - REQPublicKeysPut: methodREQPublicKeysPut{ + REQPublicKeysToNode: methodREQPublicKeysToNode{ event: EventNACK, }, }, @@ -2091,18 +2091,18 @@ func (m methodREQPublicKeysGet) handler(proc process, message Message, node stri // ---- -type methodREQPublicKeysPut struct { +type methodREQPublicKeysToNode struct { event Event } -func (m methodREQPublicKeysPut) getKind() Event { +func (m methodREQPublicKeysToNode) getKind() Event { return m.event } // TODO: Rename to :REQPublicKeysToNode // // Handler to put the public key replies received from a central server. -func (m methodREQPublicKeysPut) handler(proc process, message Message, node string) ([]byte, error) { +func (m methodREQPublicKeysToNode) handler(proc process, message Message, node string) ([]byte, error) { // Get a context with the timeout specified in message.MethodTimeout. // TODO: