2022-05-18 09:26:06 +00:00
|
|
|
package steward
|
|
|
|
|
|
|
|
import (
|
2022-05-24 07:35:14 +00:00
|
|
|
"bytes"
|
2022-05-24 13:51:36 +00:00
|
|
|
"encoding/json"
|
2022-05-18 09:26:06 +00:00
|
|
|
"fmt"
|
2022-05-24 13:51:36 +00:00
|
|
|
|
|
|
|
"github.com/fxamacker/cbor/v2"
|
2022-05-18 09:26:06 +00:00
|
|
|
)
|
|
|
|
|
2022-05-24 07:35:14 +00:00
|
|
|
// ----
|
|
|
|
|
|
|
|
type methodREQAclRequestUpdate struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclRequestUpdate) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handler to get all acl's from a central server.
|
|
|
|
func (m methodREQAclRequestUpdate) handler(proc process, message Message, node string) ([]byte, error) {
|
2022-06-02 04:29:37 +00:00
|
|
|
inf := fmt.Errorf("<--- subscriber methodREQAclRequestUpdate received from: %v, hash data = %v", message.FromNode, message.Data)
|
2022-05-26 05:13:34 +00:00
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
2022-06-02 04:29:37 +00:00
|
|
|
// fmt.Printf("\n --- subscriber methodREQAclRequestUpdate: the message brought to handler : %+v\n", message)
|
2022-05-26 05:13:34 +00:00
|
|
|
|
2022-05-24 07:35:14 +00:00
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, _ := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
outCh := make(chan []byte)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
// Done
|
|
|
|
case outCh <- []byte{}:
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
// case out := <-outCh:
|
|
|
|
case <-outCh:
|
|
|
|
// Using a func here to set the scope of the lock, and then be able to
|
|
|
|
// defer the unlock when leaving that scope.
|
|
|
|
func() {
|
2022-05-24 10:00:38 +00:00
|
|
|
proc.centralAuth.accessLists.schemaGenerated.mu.Lock()
|
|
|
|
defer proc.centralAuth.accessLists.schemaGenerated.mu.Unlock()
|
2022-05-24 07:35:14 +00:00
|
|
|
|
2022-10-05 07:16:22 +00:00
|
|
|
er := fmt.Errorf("info: subscriber methodREQAclRequestUpdate: got acl hash from NODE=%v, HASH data =%v", message.FromNode, message.Data)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(er, proc.configuration)
|
2022-05-24 07:35:14 +00:00
|
|
|
|
|
|
|
// Check if the received hash is the same as the one currently active,
|
2022-05-24 10:00:38 +00:00
|
|
|
// If it is the same we exit the handler immediately.
|
|
|
|
hash32 := proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap[message.FromNode].Hash
|
|
|
|
hash := hash32[:]
|
2022-10-05 07:16:22 +00:00
|
|
|
er = fmt.Errorf("info: subscriber methodREQAclRequestUpdate: the central acl hash=%v", hash32)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(er, proc.configuration)
|
2022-05-24 10:00:38 +00:00
|
|
|
if bytes.Equal(hash, message.Data) {
|
2022-10-05 07:16:22 +00:00
|
|
|
er := fmt.Errorf("info: subscriber methodREQAclRequestUpdate: NODE AND CENTRAL HAVE EQUAL ACL HASH, NOTHING TO DO, EXITING HANDLER")
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(er, proc.configuration)
|
2022-05-24 07:35:14 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-10-05 07:16:22 +00:00
|
|
|
er = fmt.Errorf("info: subscriber methodREQAclRequestUpdate: NODE AND CENTRAL HAD NOT EQUAL ACL, PREPARING TO SEND NEW VERSION OF Acl")
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(er, proc.configuration)
|
2022-05-26 05:13:34 +00:00
|
|
|
|
|
|
|
// Generate JSON for Message.Data
|
2022-05-24 13:51:36 +00:00
|
|
|
|
2022-05-26 05:13:34 +00:00
|
|
|
hdh := HostACLsSerializedWithHash{}
|
|
|
|
hdh.Data = proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap[message.FromNode].Data
|
2022-05-27 10:17:15 +00:00
|
|
|
// fmt.Printf("\n * DEBUGGING: before marshalling, hdh.Data=%v\n", hdh.Data)
|
2022-05-26 05:13:34 +00:00
|
|
|
hdh.Hash = proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap[message.FromNode].Hash
|
2022-05-27 10:17:15 +00:00
|
|
|
// fmt.Printf("\n * DEBUGGING: before marshalling, hdh.Hash=%v\n\n", hdh.Hash)
|
2022-05-24 13:51:36 +00:00
|
|
|
|
2022-05-26 05:13:34 +00:00
|
|
|
js, err := json.Marshal(hdh)
|
2022-05-24 13:51:36 +00:00
|
|
|
if err != nil {
|
|
|
|
er := fmt.Errorf("error: REQAclRequestUpdate : json marshal failed: %v, message: %v", err, message)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logWarning)
|
2022-05-24 13:51:36 +00:00
|
|
|
}
|
2022-05-24 07:35:14 +00:00
|
|
|
|
2022-10-05 07:16:22 +00:00
|
|
|
er = fmt.Errorf("----> subscriber methodREQAclRequestUpdate: SENDING ACL'S TO NODE=%v, serializedAndHash=%+v", message.FromNode, hdh)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(er, proc.configuration)
|
2022-05-26 05:13:34 +00:00
|
|
|
|
2022-05-24 13:51:36 +00:00
|
|
|
newReplyMessage(proc, message, js)
|
2022-05-24 07:35:14 +00:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// NB: We're not sending an ACK message for this request type.
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2022-05-24 13:51:36 +00:00
|
|
|
// ----
|
|
|
|
|
|
|
|
type methodREQAclDeliverUpdate struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclDeliverUpdate) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handler to receive the acls from a central server.
|
|
|
|
func (m methodREQAclDeliverUpdate) handler(proc process, message Message, node string) ([]byte, error) {
|
2022-05-26 05:13:34 +00:00
|
|
|
inf := fmt.Errorf("<--- subscriber methodREQAclDeliverUpdate received from: %v, containing: %v", message.FromNode, message.Data)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
2022-05-27 10:17:15 +00:00
|
|
|
// fmt.Printf("\n --- subscriber methodREQAclRequestUpdate: the message received on handler : %+v\n\n", message)
|
2022-05-26 05:13:34 +00:00
|
|
|
|
2022-05-24 13:51:36 +00:00
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, _ := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
outCh := make(chan []byte)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
// Normally we would do some logic here, where the result is passed to outCh when done,
|
|
|
|
// so we can split up the working logic, and f.ex. sending a reply logic.
|
|
|
|
// In this case this go func and the below select is not needed, but keeping it so the
|
|
|
|
// structure is the same as the other handlers.
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
|
|
|
|
case outCh <- []byte{}:
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
|
|
|
// case proc.toRingbufferCh <- []subjectAndMessage{sam}:
|
|
|
|
case <-ctx.Done():
|
|
|
|
case <-outCh:
|
|
|
|
|
|
|
|
proc.nodeAuth.nodeAcl.mu.Lock()
|
|
|
|
|
|
|
|
hdh := HostACLsSerializedWithHash{}
|
|
|
|
|
|
|
|
err := json.Unmarshal(message.Data, &hdh)
|
|
|
|
if err != nil {
|
2022-05-26 05:13:34 +00:00
|
|
|
er := fmt.Errorf("error: subscriber REQAclDeliverUpdate : json unmarshal failed: %v, message: %v", err, message)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logWarning)
|
2022-05-24 13:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mapOfFromNodeCommands := make(map[Node]map[command]struct{})
|
2022-05-26 05:13:34 +00:00
|
|
|
|
2022-06-01 12:30:30 +00:00
|
|
|
if len(hdh.Data) != 0 {
|
|
|
|
err = cbor.Unmarshal(hdh.Data, &mapOfFromNodeCommands)
|
|
|
|
if err != nil {
|
|
|
|
er := fmt.Errorf("error: subscriber REQAclDeliverUpdate : cbor unmarshal failed: %v, message: %v", err, message)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logError)
|
2022-06-01 12:30:30 +00:00
|
|
|
}
|
2022-05-24 13:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proc.nodeAuth.nodeAcl.aclAndHash.Hash = hdh.Hash
|
|
|
|
proc.nodeAuth.nodeAcl.aclAndHash.Acl = mapOfFromNodeCommands
|
|
|
|
|
2022-05-26 05:13:34 +00:00
|
|
|
fmt.Printf("\n <---- subscriber REQAclDeliverUpdate: after unmarshal, nodeAuth aclAndhash contains: %+v\n\n", proc.nodeAuth.nodeAcl.aclAndHash)
|
2022-05-24 13:51:36 +00:00
|
|
|
|
|
|
|
proc.nodeAuth.nodeAcl.mu.Unlock()
|
|
|
|
|
|
|
|
err = proc.nodeAuth.nodeAcl.saveToFile()
|
|
|
|
if err != nil {
|
2022-05-26 05:13:34 +00:00
|
|
|
er := fmt.Errorf("error: subscriber REQAclDeliverUpdate : save to file failed: %v, message: %v", err, message)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logError)
|
2022-05-24 13:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2022-05-18 09:26:06 +00:00
|
|
|
// ---
|
|
|
|
|
2022-05-18 12:43:35 +00:00
|
|
|
type methodREQAclAddCommand struct {
|
2022-05-18 09:26:06 +00:00
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:43:35 +00:00
|
|
|
func (m methodREQAclAddCommand) getKind() Event {
|
2022-05-18 09:26:06 +00:00
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:43:35 +00:00
|
|
|
func (m methodREQAclAddCommand) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclAddCommand received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-18 12:43:35 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 3:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclAddAccessList: got <3 number methodArgs, want 3")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:43:35 +00:00
|
|
|
host := message.MethodArgs[0]
|
|
|
|
source := message.MethodArgs[1]
|
|
|
|
cmd := message.MethodArgs[2]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.aclAddCommand(Node(host), Node(source), command(cmd))
|
2022-05-18 12:43:35 +00:00
|
|
|
|
|
|
|
outString := fmt.Sprintf("acl added: host=%v, source=%v, command=%v\n", host, source, cmd)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-18 12:43:35 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-18 12:43:35 +00:00
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclAddAccessList: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-18 12:43:35 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
|
type methodREQAclDeleteCommand struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclDeleteCommand) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclDeleteCommand) handler(proc process, message Message, node string) ([]byte, error) {
|
2022-05-19 06:27:12 +00:00
|
|
|
inf := fmt.Errorf("<--- methodREQAclDeleteCommand received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
2022-05-18 09:26:06 +00:00
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-18 09:26:06 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 3:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclDeleteCommand: got <3 number methodArgs, want 3")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-18 09:26:06 +00:00
|
|
|
host := message.MethodArgs[0]
|
|
|
|
source := message.MethodArgs[1]
|
|
|
|
cmd := message.MethodArgs[2]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.aclDeleteCommand(Node(host), Node(source), command(cmd))
|
2022-05-18 09:26:06 +00:00
|
|
|
|
2022-05-19 06:27:12 +00:00
|
|
|
outString := fmt.Sprintf("acl deleted: host=%v, source=%v, command=%v\n", host, source, cmd)
|
2022-05-18 09:26:06 +00:00
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-18 09:26:06 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-18 09:26:06 +00:00
|
|
|
cancel()
|
2022-05-19 19:35:14 +00:00
|
|
|
er := fmt.Errorf("error: methodREQAclDeleteCommand: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-19 19:35:14 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
|
type methodREQAclDeleteSource struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclDeleteSource) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclDeleteSource) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclDeleteSource received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-19 19:35:14 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 2:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclDeleteSource: got <2 number methodArgs, want 2")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-19 19:35:14 +00:00
|
|
|
host := message.MethodArgs[0]
|
|
|
|
source := message.MethodArgs[1]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.aclDeleteSource(Node(host), Node(source))
|
2022-05-19 19:35:14 +00:00
|
|
|
|
|
|
|
outString := fmt.Sprintf("acl deleted: host=%v, source=%v\n", host, source)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-19 19:35:14 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-19 19:35:14 +00:00
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclDeleteSource: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-18 09:26:06 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---
|
2022-05-19 20:19:22 +00:00
|
|
|
|
|
|
|
type methodREQAclGroupNodesAddNode struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupNodesAddNode) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupNodesAddNode) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclGroupNodesAddNode received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-19 20:19:22 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 2:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclGroupNodesAddNode: got <2 number methodArgs, want 2")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-19 20:19:22 +00:00
|
|
|
ng := message.MethodArgs[0]
|
|
|
|
n := message.MethodArgs[1]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.groupNodesAddNode(nodeGroup(ng), Node(n))
|
2022-05-19 20:19:22 +00:00
|
|
|
|
|
|
|
outString := fmt.Sprintf("added node to nodeGroup: nodeGroup=%v, node=%v\n", ng, n)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-19 20:19:22 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-19 20:19:22 +00:00
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclGroupNodesAddNode: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-19 20:19:22 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
|
type methodREQAclGroupNodesDeleteNode struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupNodesDeleteNode) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupNodesDeleteNode) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclGroupNodesDeleteNode received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-19 20:19:22 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 2:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclGroupNodesDeleteNode: got <2 number methodArgs, want 2")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-19 20:19:22 +00:00
|
|
|
ng := message.MethodArgs[0]
|
|
|
|
n := message.MethodArgs[1]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.groupNodesDeleteNode(nodeGroup(ng), Node(n))
|
2022-05-19 20:19:22 +00:00
|
|
|
|
|
|
|
outString := fmt.Sprintf("deleted node from nodeGroup: nodeGroup=%v, node=%v\n", ng, n)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-19 20:19:22 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-19 20:19:22 +00:00
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclGroupNodesDeleteNode: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-19 20:19:22 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---
|
2022-05-20 03:18:26 +00:00
|
|
|
|
|
|
|
type methodREQAclGroupNodesDeleteGroup struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupNodesDeleteGroup) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupNodesDeleteGroup) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclGroupNodesDeleteGroup received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-20 03:18:26 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 1:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclGroupNodesDeleteGroup: got <1 number methodArgs, want 1")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-20 03:18:26 +00:00
|
|
|
ng := message.MethodArgs[0]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.groupNodesDeleteGroup(nodeGroup(ng))
|
2022-05-20 03:18:26 +00:00
|
|
|
|
|
|
|
outString := fmt.Sprintf("deleted nodeGroup: nodeGroup=%v\n", ng)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-20 03:18:26 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-20 03:18:26 +00:00
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclGroupNodesDeleteGroup: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-20 03:18:26 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---
|
2022-05-20 03:59:34 +00:00
|
|
|
|
|
|
|
type methodREQAclGroupCommandsAddCommand struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupCommandsAddCommand) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupCommandsAddCommand) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclGroupCommandsAddCommand received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-20 03:59:34 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 2:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclGroupCommandsAddCommand: got <2 number methodArgs, want 1")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-20 03:59:34 +00:00
|
|
|
cg := message.MethodArgs[0]
|
|
|
|
c := message.MethodArgs[1]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.groupCommandsAddCommand(commandGroup(cg), command(c))
|
2022-05-20 03:59:34 +00:00
|
|
|
|
|
|
|
outString := fmt.Sprintf("added command to commandGroup: commandGroup=%v, command=%v\n", cg, c)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-20 03:59:34 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-20 03:59:34 +00:00
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclGroupCommandsAddCommand: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-20 03:59:34 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---
|
2022-05-20 04:27:46 +00:00
|
|
|
|
|
|
|
type methodREQAclGroupCommandsDeleteCommand struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupCommandsDeleteCommand) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupCommandsDeleteCommand) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclGroupCommandsDeleteCommand received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-20 04:27:46 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 1:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclGroupCommandsDeleteCommand: got <1 number methodArgs, want 1")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-20 04:27:46 +00:00
|
|
|
cg := message.MethodArgs[0]
|
|
|
|
c := message.MethodArgs[1]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.groupCommandsDeleteCommand(commandGroup(cg), command(c))
|
2022-05-20 04:27:46 +00:00
|
|
|
|
|
|
|
outString := fmt.Sprintf("deleted command from commandGroup: commandGroup=%v, command=%v\n", cg, c)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-20 04:27:46 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-20 04:27:46 +00:00
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclGroupCommandsDeleteCommand: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-20 04:27:46 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---
|
2022-05-20 11:56:17 +00:00
|
|
|
|
|
|
|
type methodREQAclGroupCommandsDeleteGroup struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupCommandsDeleteGroup) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclGroupCommandsDeleteGroup) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclGroupCommandsDeleteGroup received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
2022-05-21 06:05:53 +00:00
|
|
|
errCh := make(chan error)
|
2022-05-20 11:56:17 +00:00
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 1:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclGroupCommandsDeleteGroup: got <1 number methodArgs, want 1")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-20 11:56:17 +00:00
|
|
|
cg := message.MethodArgs[0]
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
proc.centralAuth.groupCommandDeleteGroup(commandGroup(cg))
|
2022-05-20 11:56:17 +00:00
|
|
|
|
|
|
|
outString := fmt.Sprintf("deleted commandGroup: commandGroup=%v\n", cg)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
2022-05-21 06:05:53 +00:00
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-20 11:56:17 +00:00
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
case <-ctx.Done():
|
2022-05-20 11:56:17 +00:00
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclGroupCommandsDeleteGroup: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-20 11:56:17 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
2022-05-21 05:09:35 +00:00
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
|
type methodREQAclExport struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclExport) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclExport) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclExport received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
outCh := make(chan []byte)
|
|
|
|
errCh := make(chan error)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-06-01 13:58:17 +00:00
|
|
|
out, err := proc.centralAuth.exportACLs()
|
2022-05-21 05:09:35 +00:00
|
|
|
if err != nil {
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclExport failed: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// outString := fmt.Sprintf("Exported acls sent from: %v\n", message.FromNode)
|
|
|
|
// out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-21 05:09:35 +00:00
|
|
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclExport: method timed out: %v", message.MethodArgs)
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-21 05:09:35 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|
2022-05-21 05:26:36 +00:00
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
|
type methodREQAclImport struct {
|
|
|
|
event Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclImport) getKind() Event {
|
|
|
|
return m.event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m methodREQAclImport) handler(proc process, message Message, node string) ([]byte, error) {
|
|
|
|
inf := fmt.Errorf("<--- methodREQAclImport received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
|
|
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
|
|
|
// Get a context with the timeout specified in message.MethodTimeout.
|
|
|
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
|
|
|
|
|
|
|
outCh := make(chan []byte)
|
|
|
|
errCh := make(chan error)
|
|
|
|
|
|
|
|
proc.processes.wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer proc.processes.wg.Done()
|
|
|
|
|
2022-05-21 06:05:53 +00:00
|
|
|
switch {
|
|
|
|
case len(message.MethodArgs) < 1:
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclImport: got <1 number methodArgs, want 1")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-21 05:26:36 +00:00
|
|
|
js := []byte(message.MethodArgs[0])
|
2022-06-01 13:58:17 +00:00
|
|
|
err := proc.centralAuth.importACLs(js)
|
2022-05-21 05:26:36 +00:00
|
|
|
if err != nil {
|
|
|
|
errCh <- fmt.Errorf("error: methodREQAclImport failed: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
outString := fmt.Sprintf("Imported acl's sent from: %v\n", message.FromNode)
|
|
|
|
out := []byte(outString)
|
|
|
|
|
|
|
|
select {
|
|
|
|
case outCh <- out:
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
|
|
|
case err := <-errCh:
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, err, logError)
|
2022-05-21 05:26:36 +00:00
|
|
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
cancel()
|
|
|
|
er := fmt.Errorf("error: methodREQAclImport: method timed out")
|
2023-01-11 07:38:15 +00:00
|
|
|
proc.errorKernel.errSend(proc, message, er, logInfo)
|
2022-05-21 05:26:36 +00:00
|
|
|
|
|
|
|
case out := <-outCh:
|
|
|
|
// Prepare and queue for sending a new message with the output
|
|
|
|
// of the action executed.
|
|
|
|
newReplyMessage(proc, message, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
|
|
|
return ackMsg, nil
|
|
|
|
}
|