Contact struct removed from peer
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc
2024-02-10 22:36:25 +01:00
parent 24183ff581
commit 0fd7548ba4
5 changed files with 44 additions and 30 deletions

View File

@ -26,15 +26,15 @@ type Peer struct {
MyLookupKp meowlib.KeyPair `json:"my_lookup_kp,omitempty"`
MyPullServers []string `json:"my_pull_servers,omitempty"`
// Peer keys and infos
Contact meowlib.ContactCard `json:"contact,omitempty"` // todo : remove
ContactPublicKey string `json:"contact_public_key,omitempty"`
ContactLookupKey string `json:"contact_lookup_key,omitempty"`
ContactEncryption string `json:"contact_encryption,omitempty"`
ContactPullServers []string `json:"contact_pull_servers,omitempty"`
InvitationId string `json:"invitation_id,omitempty"`
InvitationUrl string `json:"invitation_url,omitempty"`
InvitationMessage string `json:"invitation_message,omitempty"`
InvitationExpiry time.Time `json:"invitation_expiry,omitempty"`
//Contact meowlib.ContactCard `json:"contact,omitempty"` // todo : remove
ContactPublicKey string `json:"contact_public_key,omitempty"`
ContactLookupKey string `json:"contact_lookup_key,omitempty"`
ContactEncryption string `json:"contact_encryption,omitempty"`
ContactPullServers []string `json:"contact_pull_servers,omitempty"`
InvitationId string `json:"invitation_id,omitempty"`
InvitationUrl string `json:"invitation_url,omitempty"`
InvitationMessage string `json:"invitation_message,omitempty"`
InvitationExpiry time.Time `json:"invitation_expiry,omitempty"`
// Internal management attributes
Visible bool `json:"visible,omitempty"`
VisiblePassword string `json:"visible_password,omitempty"`
@ -86,7 +86,7 @@ func (p *Peer) GetContact() *meowlib.ContactCard {
func (p *Peer) BuildSimpleUserMessage(message []byte) (*meowlib.UserMessage, error) {
var msg meowlib.UserMessage
msg.Destination = p.Contact.LookupPublicKey
msg.Destination = p.ContactLookupKey
msg.From = p.MyIdentity.Public
msg.Data = message
msg.Type = "1"
@ -122,7 +122,7 @@ func (p *Peer) BuildSingleFileMessage(filename string, message []byte) ([]meowli
}
var msg meowlib.UserMessage
var file meowlib.File
msg.Destination = p.Contact.LookupPublicKey
msg.Destination = p.ContactLookupKey
msg.From = p.MyIdentity.Public
file.Filename = fi.Name()
file.Chunk = uint32(chunk)
@ -151,7 +151,7 @@ func (p *Peer) BuildInvitationAnswerMessage(myContactCard *meowlib.ContactCard)
return nil, err
}
invitation.Payload = out
msg.Destination = p.Contact.LookupPublicKey
msg.Destination = p.ContactLookupKey
msg.From = p.MyIdentity.Public
msg.Type = "1"
return &msg, nil
@ -181,7 +181,7 @@ func (p *Peer) DeserializeUserMessage(data []byte) (*meowlib.UserMessage, error)
// AsymEncryptMessage prepares a message to send to a specific peer contact
func (p *Peer) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, error) {
var enc *meowlib.EncryptedMessage
enc, err := meowlib.AsymEncryptAndSign(p.Contact.EncryptionPublicKey, p.MyIdentity.Private, Message)
enc, err := meowlib.AsymEncryptAndSign(p.ContactEncryption, p.MyIdentity.Private, Message)
if err != nil {
fmt.Println(err.Error())
return enc, err
@ -191,7 +191,7 @@ func (p *Peer) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, er
// AsymDecryptMessage reads a message from a specific peer contact
func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMessage []byte, err error) {
DecryptedMessage, err = meowlib.AsymDecryptAndCheck(p.MyEncryptionKp.Private, p.Contact.ContactPublicKey, Message, Signature)
DecryptedMessage, err = meowlib.AsymDecryptAndCheck(p.MyEncryptionKp.Private, p.ContactPublicKey, Message, Signature)
if err != nil {
fmt.Println(err.Error())
return nil, err
@ -202,7 +202,7 @@ func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMe
// PackUserMessage will package the previously encrypted message
func (p *Peer) PackUserMessage(message []byte, signature []byte) *meowlib.PackedUserMessage {
var msg meowlib.PackedUserMessage
msg.Destination = p.Contact.LookupPublicKey
msg.Destination = p.ContactLookupKey
msg.Payload = message
msg.Signature = signature
return &msg