mirror of
https://github.com/postmannen/ctrl.git
synced 2025-03-31 01:24:31 +00:00
implemented initial subscriber verify signature
This commit is contained in:
parent
6724753e62
commit
5b211b6fac
1 changed files with 22 additions and 10 deletions
32
process.go
32
process.go
|
@ -508,15 +508,17 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
|||
p.processes.errorKernel.errSend(p, message, er)
|
||||
}
|
||||
|
||||
var out []byte
|
||||
out := []byte{}
|
||||
var err error
|
||||
|
||||
// Call the method handler for the specified method.
|
||||
out, err = mh.handler(p, message, thisNode)
|
||||
if p.verifySignature(message) {
|
||||
// Call the method handler for the specified method.
|
||||
out, err = mh.handler(p, message, thisNode)
|
||||
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err)
|
||||
p.processes.errorKernel.errSend(p, message, er)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err)
|
||||
p.processes.errorKernel.errSend(p, message, er)
|
||||
}
|
||||
}
|
||||
|
||||
// Send a confirmation message back to the publisher
|
||||
|
@ -530,11 +532,14 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
|||
p.processes.errorKernel.errSend(p, message, er)
|
||||
}
|
||||
|
||||
_, err := mf.handler(p, message, thisNode)
|
||||
if p.verifySignature(message) {
|
||||
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err)
|
||||
p.processes.errorKernel.errSend(p, message, er)
|
||||
_, err := mf.handler(p, message, thisNode)
|
||||
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err)
|
||||
p.processes.errorKernel.errSend(p, message, er)
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
|
@ -544,6 +549,13 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
|||
}
|
||||
}
|
||||
|
||||
// verifySignature
|
||||
func (p process) verifySignature(m Message) bool {
|
||||
fmt.Printf(" * verifySignature, fromNode: %v, method: %v, signature: %v\n", m.FromNode, m.Method, m.ArgSignature)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// SubscribeMessage will register the Nats callback function for the specified
|
||||
// nats subject. This allows us to receive Nats messages for a given subject
|
||||
// on a node.
|
||||
|
|
Loading…
Add table
Reference in a new issue