Cleanup + proto update + Peers functions
This commit is contained in:
@ -24,6 +24,8 @@ type Peer struct {
|
||||
MessageNotification string `json:"message_notification,omitempty"`
|
||||
OnionMode bool `json:"onion_mode,omitempty"`
|
||||
LastMessage time.Time `json:"last_message,omitempty"`
|
||||
MessageDb string `json:"message_db,omitempty"` // sql url for messages storage
|
||||
DbPassword string `json:"db_password,omitempty"`
|
||||
}
|
||||
|
||||
type PeerList []Peer
|
||||
@ -52,14 +54,14 @@ func (pl *PeerList) GetFromName(name string) *Peer {
|
||||
}
|
||||
|
||||
// AsymEncryptMessage prepares a message to send to a specific peer contact
|
||||
func (p *Peer) AsymEncryptMessage(Message []byte) (LookupPublicKey string, EncryptedMessage []byte, Signature []byte, Servers []*meowlib.Server, err error) {
|
||||
func (p *Peer) AsymEncryptMessage(Message []byte) (EncryptedMessage []byte, Signature []byte, Servers []*meowlib.Server, err error) {
|
||||
EncryptedMessage, Signature, err = meowlib.EncryptAndSign(p.Contact.EncryptionPublicKey, p.Me.Private, Message)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return "", nil, nil, nil, err
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
return p.LookupKp.Public, EncryptedMessage, Signature, p.Contact.PullServers, err
|
||||
return EncryptedMessage, Signature, p.Contact.PullServers, err
|
||||
}
|
||||
|
||||
// AsymDecryptMessage reads a message from a specific peer contact
|
||||
@ -71,3 +73,34 @@ func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMe
|
||||
}
|
||||
return DecryptedMessage, err
|
||||
}
|
||||
|
||||
// Pack will package the previously encrypted message for sending it to the peer in protobuff format
|
||||
func (p *Peer) Pack(message []byte, signature []byte) meowlib.PackedUserMessage {
|
||||
var msg meowlib.PackedUserMessage
|
||||
msg.Destination = p.Contact.LookupPublicKey
|
||||
msg.From = p.Me.Public
|
||||
msg.Payload = message
|
||||
msg.Signature = signature
|
||||
return msg
|
||||
}
|
||||
|
||||
func (p *Peer) GetConversationRequest() meowlib.ToServerMessage_ConversationRequest {
|
||||
var cr meowlib.ToServerMessage_ConversationRequest
|
||||
return cr
|
||||
}
|
||||
|
||||
func (p *Peer) StoreMessage(msg []byte) {
|
||||
|
||||
}
|
||||
|
||||
func (p *Peer) LoadMessage(uid string) {
|
||||
|
||||
}
|
||||
|
||||
func (p *Peer) LoadLastMessages(qty int) {
|
||||
|
||||
}
|
||||
|
||||
func (p *Peer) GetLastMessageUid(msg []byte) {
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user