1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2025-03-31 01:24:31 +00:00

renaming of key related functions, updated doc

This commit is contained in:
postmannen 2024-12-19 06:39:57 +01:00
parent ca1ce3c534
commit fb51f3947b
7 changed files with 18 additions and 20 deletions

View file

@ -1,3 +1,7 @@
# TODO # TODO
## Key and ACL updates to use jetstream ## Key and ACL updates to use jetstream
## tailfile
Replace the hpcloud/tail with <https://github.com/tenebris-tech/tail>

View file

@ -294,7 +294,7 @@ func (c *centralAuth) updateHash(proc process, message Message) {
b, err := cbor.Marshal(sortedNodesAndKeys) b, err := cbor.Marshal(sortedNodesAndKeys)
if err != nil { if err != nil {
er := fmt.Errorf("error: methodKeysAllow, failed to marshal slice, and will not update hash for public keys: %v", err) er := fmt.Errorf("error: updateHash, failed to marshal slice, and will not update hash for public keys: %v", err)
c.pki.errorKernel.errSend(proc, message, er, logError) c.pki.errorKernel.errSend(proc, message, er, logError)
return return

View file

@ -12,13 +12,13 @@
# Core ctrl # Core ctrl
- [Messaging](./core_messaging_overview.md) - [Messaging](./core_messaging_overview.md)
- [Message fields](./core_messaging_message_fields.md) - [Message fields](./core_messaging_message_fields.md)
- [Message jetstream/broadcast](./core_messaging_jetstream.md) - [Message jetstream/broadcast](./core_messaging_jetstream.md)
- [Request Methods](./core_request_methods.md) - [Request Methods](./core_request_methods.md)
- [{{CTRL_DATA}} variable](./core_messaging_CTRL_DATA.md)
- [{{CTRL_FILE}} variable](./core_messaging_CTRL_FILE.md)
- [Nats timeouts](./core_nats_timeouts.md) - [Nats timeouts](./core_nats_timeouts.md)
- [Startup folder](./core_startup_folder.md) - [Startup folder](./core_startup_folder.md)
- [{{CTRL_DATA}} variable](./core_messaging_CTRL_DATA.md)
- [{{CTRL_FILE}} variable](./core_messaging_CTRL_FILE.md)
- [Errors](./core_errors.md) - [Errors](./core_errors.md)
- [central](./core_central.md) - [central](./core_central.md)
- [hello messages](./core_hello_messages.md) - [hello messages](./core_hello_messages.md)

View file

@ -112,7 +112,7 @@ func (p *processes) Start(proc process) {
if proc.configuration.StartProcesses.StartSubHello { if proc.configuration.StartProcesses.StartSubHello {
proc.startup.startProcess(proc, Hello, procFuncHello) proc.startup.startProcess(proc, Hello, procFuncHelloSubscriber)
} }
if proc.configuration.StartProcesses.IsCentralErrorLogger { if proc.configuration.StartProcesses.IsCentralErrorLogger {

View file

@ -198,7 +198,7 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
TailFile: HandlerFunc(methodTailFile), TailFile: HandlerFunc(methodTailFile),
PublicKey: HandlerFunc(methodPublicKey), PublicKey: HandlerFunc(methodPublicKey),
KeysRequestUpdate: HandlerFunc(methodKeysRequestUpdate), KeysRequestUpdate: HandlerFunc(methodKeysRequestUpdate),
KeysDeliverUpdate: HandlerFunc(methodKeysDeliverUpdate), KeysDeliverUpdate: HandlerFunc(methodKeysReceiveUpdate),
KeysAllow: HandlerFunc(methodKeysAllow), KeysAllow: HandlerFunc(methodKeysAllow),
KeysDelete: HandlerFunc(methodKeysDelete), KeysDelete: HandlerFunc(methodKeysDelete),

View file

@ -163,7 +163,7 @@ func procFuncKeysRequestUpdate(ctx context.Context, proc process, procFuncCh cha
// ---- // ----
// Handler to receive the public keys from a central server. // Handler to receive the public keys from a central server.
func methodKeysDeliverUpdate(proc process, message Message, node string) ([]byte, error) { func methodKeysReceiveUpdate(proc process, message Message, node string) ([]byte, error) {
// Get a context with the timeout specified in message.MethodTimeout. // Get a context with the timeout specified in message.MethodTimeout.
ctx, _ := getContextForMethodTimeout(proc.ctx, message) ctx, _ := getContextForMethodTimeout(proc.ctx, message)
@ -195,11 +195,11 @@ func methodKeysDeliverUpdate(proc process, message Message, node string) ([]byte
err := json.Unmarshal(message.Data, &keysAndHash) err := json.Unmarshal(message.Data, &keysAndHash)
if err != nil { if err != nil {
er := fmt.Errorf("error: REQKeysDeliverUpdate : json unmarshal failed: %v, message: %v", err, message) er := fmt.Errorf("error: methodKeysReceiveUpdate : json unmarshal failed: %v, message: %v", err, message)
proc.errorKernel.errSend(proc, message, er, logWarning) proc.errorKernel.errSend(proc, message, er, logWarning)
} }
er := fmt.Errorf("<---- REQKeysDeliverUpdate: after unmarshal, nodeAuth keysAndhash contains: %+v", keysAndHash) er := fmt.Errorf("<---- methodKeysReceiveUpdate: after unmarshal, nodeAuth keysAndhash contains: %+v", keysAndHash)
proc.errorKernel.logDebug(er) proc.errorKernel.logDebug(er)
// If the received map was empty we also want to delete all the locally stored keys, // If the received map was empty we also want to delete all the locally stored keys,
@ -213,7 +213,7 @@ func methodKeysDeliverUpdate(proc process, message Message, node string) ([]byte
proc.nodeAuth.publicKeys.mu.Unlock() proc.nodeAuth.publicKeys.mu.Unlock()
if err != nil { if err != nil {
er := fmt.Errorf("error: REQKeysDeliverUpdate : json unmarshal failed: %v, message: %v", err, message) er := fmt.Errorf("error: methodKeysReceiveUpdate : json unmarshal failed: %v, message: %v", err, message)
proc.errorKernel.errSend(proc, message, er, logWarning) proc.errorKernel.errSend(proc, message, er, logWarning)
} }
@ -222,18 +222,12 @@ func methodKeysDeliverUpdate(proc process, message Message, node string) ([]byte
err = proc.nodeAuth.publicKeys.saveToFile() err = proc.nodeAuth.publicKeys.saveToFile()
if err != nil { if err != nil {
er := fmt.Errorf("error: REQKeysDeliverUpdate : save to file failed: %v, message: %v", err, message) er := fmt.Errorf("error: methodKeysReceiveUpdate : save to file failed: %v, message: %v", err, message)
proc.errorKernel.errSend(proc, message, er, logWarning) proc.errorKernel.errSend(proc, message, er, logWarning)
} }
// Prepare and queue for sending a new message with the output
// of the action executed.
// newReplyMessage(proc, message, out)
} }
}() }()
// Send back an ACK message.
// ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
return nil, nil return nil, nil
} }

View file

@ -63,7 +63,7 @@ func methodHello(proc process, message Message, node string) ([]byte, error) {
// received, the handler will deliver the message to the procFunc on the // received, the handler will deliver the message to the procFunc on the
// proc.procFuncCh, and we can then read that message from the procFuncCh in // proc.procFuncCh, and we can then read that message from the procFuncCh in
// the procFunc running. // the procFunc running.
func procFuncHello(ctx context.Context, proc process, procFuncCh chan Message) error { func procFuncHelloSubscriber(ctx context.Context, proc process, procFuncCh chan Message) error {
// sayHelloNodes := make(map[Node]struct{}) // sayHelloNodes := make(map[Node]struct{})
for { for {