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

renamed request types and methods for keys

This commit is contained in:
postmannen 2025-01-06 06:10:55 +01:00
parent e7a061b69f
commit e8cab7f124
5 changed files with 17 additions and 22 deletions

View file

@ -147,7 +147,7 @@ func (c *centralAuth) addPublicKey(proc process, msg Message) {
er := fmt.Errorf("info: new public key for node: %v. Key needs to be authorized by operator to be allowed into the system by using the keysAllow method", msg.FromNode) er := fmt.Errorf("info: new public key for node: %v. Key needs to be authorized by operator to be allowed into the system by using the keysAllow method", msg.FromNode)
c.pki.errorKernel.infoSend(proc, msg, er) c.pki.errorKernel.infoSend(proc, msg, er)
c.pki.errorKernel.logDebug(er) c.pki.errorKernel.logInfo(er)
} }
// deletePublicKeys to the db if the node do not exist, or if it is a new value. // deletePublicKeys to the db if the node do not exist, or if it is a new value.

View file

@ -2,7 +2,6 @@ package ctrl
import ( import (
"bytes" "bytes"
"encoding/json"
"fmt" "fmt"
"io" "io"
"log" "log"
@ -106,11 +105,7 @@ func (s *server) readStartupFolder() {
} }
j, err := json.MarshalIndent(messages, "", " ") er = fmt.Errorf("read from startup folder: %v", messages)
if err != nil {
log.Printf("test error: %v\n", err)
}
er = fmt.Errorf("%v", string(j))
s.errorKernel.errSend(s.processInitial, Message{}, er, logInfo) s.errorKernel.errSend(s.processInitial, Message{}, er, logInfo)
s.messageDeliverLocalCh <- messages s.messageDeliverLocalCh <- messages

View file

@ -134,7 +134,7 @@ func (p *processes) Start(proc process) {
if proc.configuration.StartProcesses.EnableKeyUpdates { if proc.configuration.StartProcesses.EnableKeyUpdates {
// The key update on the client is only a proc func that publish requests. // The key update on the client is only a proc func that publish requests.
proc.startup.startProcess(proc, None, procFuncKeysRequestUpdate) proc.startup.startProcess(proc, None, procFuncKeysRequestUpdate)
proc.startup.startProcess(proc, KeysDeliverUpdate, nil) proc.startup.startProcess(proc, KeysUpdateReceive, nil)
} }
if proc.configuration.StartProcesses.EnableAclUpdates { if proc.configuration.StartProcesses.EnableAclUpdates {
@ -144,13 +144,13 @@ func (p *processes) Start(proc process) {
} }
if proc.configuration.StartProcesses.IsCentralKey { if proc.configuration.StartProcesses.IsCentralKey {
proc.startup.startProcess(proc, KeysRequestUpdate, nil) proc.startup.startProcess(proc, KeysUpdateRequest, nil)
proc.startup.startProcess(proc, KeysAllow, nil) proc.startup.startProcess(proc, KeysAllow, nil)
proc.startup.startProcess(proc, KeysDelete, nil) proc.startup.startProcess(proc, KeysDelete, nil)
} }
if proc.configuration.StartProcesses.IsCentralAcl { if proc.configuration.StartProcesses.IsCentralAcl {
proc.startup.startProcess(proc, KeysRequestUpdate, nil) proc.startup.startProcess(proc, KeysUpdateRequest, nil)
proc.startup.startProcess(proc, KeysAllow, nil) proc.startup.startProcess(proc, KeysAllow, nil)
proc.startup.startProcess(proc, KeysDelete, nil) proc.startup.startProcess(proc, KeysDelete, nil)
proc.startup.startProcess(proc, AclRequestUpdate, nil) proc.startup.startProcess(proc, AclRequestUpdate, nil)

View file

@ -124,11 +124,11 @@ const (
// REQPublicKey will get the public ed25519 key from a node. // REQPublicKey will get the public ed25519 key from a node.
PublicKey Method = "publicKey" PublicKey Method = "publicKey"
// REQKeysRequestUpdate will receive all the messages of the current hash of all public keys // KeysUpdateRequest will receive all the messages of the current hash of all public keys
// a node have stored, and send out an update if needed.. // a node have stored, and send out an update if needed..
KeysRequestUpdate Method = "keysRequestUpdate" KeysUpdateRequest Method = "keysUpdateRequest"
// REQKeysDeliverUpdate will deliver the public from central to a node. // KeysUpdateReceive,deliver the public key from central to a node.
KeysDeliverUpdate Method = "keysDeliverUpdate" KeysUpdateReceive Method = "keysUpdateReceive"
// REQKeysAllow // REQKeysAllow
KeysAllow Method = "keysAllow" KeysAllow Method = "keysAllow"
// REQKeysDelete // REQKeysDelete
@ -199,8 +199,8 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
TailFile: Handler(methodTailFile), TailFile: Handler(methodTailFile),
PublicKey: Handler(methodPublicKey), PublicKey: Handler(methodPublicKey),
KeysRequestUpdate: Handler(methodKeysRequestUpdate), KeysUpdateRequest: Handler(methodKeysUpdateRequest),
KeysDeliverUpdate: Handler(methodKeysDeliverUpdate), KeysUpdateReceive: Handler(methodKeysUpdateReceive),
KeysAllow: Handler(methodKeysAllow), KeysAllow: Handler(methodKeysAllow),
KeysDelete: Handler(methodKeysDelete), KeysDelete: Handler(methodKeysDelete),

View file

@ -50,7 +50,7 @@ func methodPublicKey(proc process, message Message, node string) ([]byte, error)
// The nodes publish messages with the hash of all the public keys it currently // The nodes publish messages with the hash of all the public keys it currently
// have stored. If the hash is different than the one we currently have on central // have stored. If the hash is different than the one we currently have on central
// we send out an update with all the current keys to the node. // we send out an update with all the current keys to the node.
func methodKeysRequestUpdate(proc process, message Message, node string) ([]byte, error) { func methodKeysUpdateRequest(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.
// TODO: // TODO:
@ -144,8 +144,8 @@ func procFuncKeysRequestUpdate(ctx context.Context, proc process, procFuncCh cha
ToNode: Node(proc.configuration.CentralNodeName), ToNode: Node(proc.configuration.CentralNodeName),
FromNode: Node(proc.node), FromNode: Node(proc.node),
Data: []byte(proc.nodeAuth.publicKeys.keysAndHash.Hash[:]), Data: []byte(proc.nodeAuth.publicKeys.keysAndHash.Hash[:]),
Method: KeysRequestUpdate, Method: KeysUpdateRequest,
ReplyMethod: KeysDeliverUpdate, ReplyMethod: KeysUpdateReceive,
ACKTimeout: proc.configuration.DefaultMessageTimeout, ACKTimeout: proc.configuration.DefaultMessageTimeout,
Retries: 1, Retries: 1,
} }
@ -167,7 +167,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 methodKeysUpdateReceive(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)
@ -357,7 +357,7 @@ func pushKeys(proc process, message Message, nodes []Node) error {
proc.errorKernel.logDebug(er) proc.errorKernel.logDebug(er)
msg := Message{ msg := Message{
ToNode: n, ToNode: n,
Method: KeysDeliverUpdate, Method: KeysUpdateReceive,
ReplyMethod: None, ReplyMethod: None,
ACKTimeout: 0, ACKTimeout: 0,
} }
@ -396,7 +396,7 @@ func pushKeys(proc process, message Message, nodes []Node) error {
proc.errorKernel.logDebug(er) proc.errorKernel.logDebug(er)
msg := Message{ msg := Message{
ToNode: n, ToNode: n,
Method: KeysDeliverUpdate, Method: KeysUpdateReceive,
Data: b, Data: b,
ReplyMethod: None, ReplyMethod: None,
ACKTimeout: 0, ACKTimeout: 0,