ProcessUserMessage
This commit is contained in:
parent
b50098d04e
commit
39dab226fb
@ -78,3 +78,15 @@ func ProcessServerResponse(srv *InternalServer, msg []byte) (*meowlib.FromServer
|
||||
}
|
||||
return fsmsg, nil
|
||||
}
|
||||
|
||||
func ProcessUserMessage(peer Peer, message []byte, signature []byte) (*meowlib.UserMessage, error) {
|
||||
dec, err := peer.AsymDecryptMessage(message, signature)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
msg, err := peer.DeserializeUserMessage(dec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return msg, nil
|
||||
}
|
||||
|
@ -142,6 +142,15 @@ func (p *Peer) SerializeUserMessage(msg *meowlib.UserMessage) ([]byte, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (p *Peer) DeserializeUserMessage(data []byte) (*meowlib.UserMessage, error) {
|
||||
var msg meowlib.UserMessage
|
||||
err := proto.Unmarshal(data, &msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &msg, nil
|
||||
}
|
||||
|
||||
// AsymEncryptMessage prepares a message to send to a specific peer contact
|
||||
func (p *Peer) AsymEncryptMessage(Message []byte) (EncryptedMessage []byte, Signature []byte, Servers []*meowlib.Server, err error) {
|
||||
EncryptedMessage, Signature, err = meowlib.AsymEncryptAndSign(p.Contact.EncryptionPublicKey, p.MyIdentity.Private, Message)
|
||||
|
Loading…
Reference in New Issue
Block a user