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:
parent
e7a061b69f
commit
e8cab7f124
5 changed files with 17 additions and 22 deletions
|
@ -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)
|
||||
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.
|
||||
|
|
|
@ -2,7 +2,6 @@ package ctrl
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
|
@ -106,11 +105,7 @@ func (s *server) readStartupFolder() {
|
|||
|
||||
}
|
||||
|
||||
j, err := json.MarshalIndent(messages, "", " ")
|
||||
if err != nil {
|
||||
log.Printf("test error: %v\n", err)
|
||||
}
|
||||
er = fmt.Errorf("%v", string(j))
|
||||
er = fmt.Errorf("read from startup folder: %v", messages)
|
||||
s.errorKernel.errSend(s.processInitial, Message{}, er, logInfo)
|
||||
|
||||
s.messageDeliverLocalCh <- messages
|
||||
|
|
|
@ -134,7 +134,7 @@ func (p *processes) Start(proc process) {
|
|||
if proc.configuration.StartProcesses.EnableKeyUpdates {
|
||||
// The key update on the client is only a proc func that publish requests.
|
||||
proc.startup.startProcess(proc, None, procFuncKeysRequestUpdate)
|
||||
proc.startup.startProcess(proc, KeysDeliverUpdate, nil)
|
||||
proc.startup.startProcess(proc, KeysUpdateReceive, nil)
|
||||
}
|
||||
|
||||
if proc.configuration.StartProcesses.EnableAclUpdates {
|
||||
|
@ -144,13 +144,13 @@ func (p *processes) Start(proc process) {
|
|||
}
|
||||
|
||||
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, KeysDelete, nil)
|
||||
}
|
||||
|
||||
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, KeysDelete, nil)
|
||||
proc.startup.startProcess(proc, AclRequestUpdate, nil)
|
||||
|
|
12
requests.go
12
requests.go
|
@ -124,11 +124,11 @@ const (
|
|||
|
||||
// REQPublicKey will get the public ed25519 key from a node.
|
||||
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..
|
||||
KeysRequestUpdate Method = "keysRequestUpdate"
|
||||
// REQKeysDeliverUpdate will deliver the public from central to a node.
|
||||
KeysDeliverUpdate Method = "keysDeliverUpdate"
|
||||
KeysUpdateRequest Method = "keysUpdateRequest"
|
||||
// KeysUpdateReceive,deliver the public key from central to a node.
|
||||
KeysUpdateReceive Method = "keysUpdateReceive"
|
||||
// REQKeysAllow
|
||||
KeysAllow Method = "keysAllow"
|
||||
// REQKeysDelete
|
||||
|
@ -199,8 +199,8 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
|
|||
TailFile: Handler(methodTailFile),
|
||||
PublicKey: Handler(methodPublicKey),
|
||||
|
||||
KeysRequestUpdate: Handler(methodKeysRequestUpdate),
|
||||
KeysDeliverUpdate: Handler(methodKeysDeliverUpdate),
|
||||
KeysUpdateRequest: Handler(methodKeysUpdateRequest),
|
||||
KeysUpdateReceive: Handler(methodKeysUpdateReceive),
|
||||
KeysAllow: Handler(methodKeysAllow),
|
||||
KeysDelete: Handler(methodKeysDelete),
|
||||
|
||||
|
|
|
@ -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
|
||||
// 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.
|
||||
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.
|
||||
|
||||
// TODO:
|
||||
|
@ -144,8 +144,8 @@ func procFuncKeysRequestUpdate(ctx context.Context, proc process, procFuncCh cha
|
|||
ToNode: Node(proc.configuration.CentralNodeName),
|
||||
FromNode: Node(proc.node),
|
||||
Data: []byte(proc.nodeAuth.publicKeys.keysAndHash.Hash[:]),
|
||||
Method: KeysRequestUpdate,
|
||||
ReplyMethod: KeysDeliverUpdate,
|
||||
Method: KeysUpdateRequest,
|
||||
ReplyMethod: KeysUpdateReceive,
|
||||
ACKTimeout: proc.configuration.DefaultMessageTimeout,
|
||||
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.
|
||||
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.
|
||||
|
||||
ctx, _ := getContextForMethodTimeout(proc.ctx, message)
|
||||
|
@ -357,7 +357,7 @@ func pushKeys(proc process, message Message, nodes []Node) error {
|
|||
proc.errorKernel.logDebug(er)
|
||||
msg := Message{
|
||||
ToNode: n,
|
||||
Method: KeysDeliverUpdate,
|
||||
Method: KeysUpdateReceive,
|
||||
ReplyMethod: None,
|
||||
ACKTimeout: 0,
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ func pushKeys(proc process, message Message, nodes []Node) error {
|
|||
proc.errorKernel.logDebug(er)
|
||||
msg := Message{
|
||||
ToNode: n,
|
||||
Method: KeysDeliverUpdate,
|
||||
Method: KeysUpdateReceive,
|
||||
Data: b,
|
||||
ReplyMethod: None,
|
||||
ACKTimeout: 0,
|
||||
|
|
Loading…
Add table
Reference in a new issue