Contact struct removed from peer
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		@@ -98,7 +98,14 @@ func (id *Identity) AnswerInvitation(MyName string, ContactName string, MessageS
 | 
				
			|||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		peer.Name = ReceivedContact.Name
 | 
							peer.Name = ReceivedContact.Name
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	peer.Contact = *ReceivedContact
 | 
						peer.ContactEncryption = ReceivedContact.EncryptionPublicKey
 | 
				
			||||||
 | 
						peer.ContactLookupKey = ReceivedContact.LookupPublicKey
 | 
				
			||||||
 | 
						peer.ContactPublicKey = ReceivedContact.ContactPublicKey
 | 
				
			||||||
 | 
						peer.InvitationId = ReceivedContact.InvitationId
 | 
				
			||||||
 | 
						peer.InvitationMessage = ReceivedContact.InvitationMessage
 | 
				
			||||||
 | 
						for srv := range ReceivedContact.PullServers {
 | 
				
			||||||
 | 
							peer.ContactPullServers = append(peer.ContactPullServers, ReceivedContact.PullServers[srv].GetUid())
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	/*	for _, i := range MessageServerIdxs {
 | 
						/*	for _, i := range MessageServerIdxs {
 | 
				
			||||||
		srv := id.MessageServers.Servers[i].GetServerCard()
 | 
							srv := id.MessageServers.Servers[i].GetServerCard()
 | 
				
			||||||
		peer.MyContact.PullServers = append(peer.MyContact.PullServers, srv)
 | 
							peer.MyContact.PullServers = append(peer.MyContact.PullServers, srv)
 | 
				
			||||||
@@ -119,7 +126,14 @@ func (id *Identity) AnswerInvitation(MyName string, ContactName string, MessageS
 | 
				
			|||||||
func (id *Identity) FinalizeInvitation(ReceivedContact *meowlib.ContactCard) error {
 | 
					func (id *Identity) FinalizeInvitation(ReceivedContact *meowlib.ContactCard) error {
 | 
				
			||||||
	for i, p := range id.Peers {
 | 
						for i, p := range id.Peers {
 | 
				
			||||||
		if p.InvitationId == ReceivedContact.InvitationId {
 | 
							if p.InvitationId == ReceivedContact.InvitationId {
 | 
				
			||||||
			id.Peers[i].Contact = *ReceivedContact
 | 
								//id.Peers[i].Name = ReceivedContact.Name
 | 
				
			||||||
 | 
								id.Peers[i].ContactEncryption = ReceivedContact.EncryptionPublicKey
 | 
				
			||||||
 | 
								id.Peers[i].ContactLookupKey = ReceivedContact.LookupPublicKey
 | 
				
			||||||
 | 
								id.Peers[i].ContactPublicKey = ReceivedContact.ContactPublicKey
 | 
				
			||||||
 | 
								for srv := range ReceivedContact.PullServers {
 | 
				
			||||||
 | 
									id.Peers[i].ContactPullServers = append(id.Peers[i].ContactPullServers, ReceivedContact.PullServers[srv].GetUid())
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return nil
 | 
								return nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -206,11 +220,11 @@ func (id *Identity) generateRandomHiddenStuff() {
 | 
				
			|||||||
		p.MyEncryptionKp = meowlib.NewKeyPair()
 | 
							p.MyEncryptionKp = meowlib.NewKeyPair()
 | 
				
			||||||
		p.MyIdentity = meowlib.NewKeyPair()
 | 
							p.MyIdentity = meowlib.NewKeyPair()
 | 
				
			||||||
		p.MyLookupKp = meowlib.NewKeyPair()
 | 
							p.MyLookupKp = meowlib.NewKeyPair()
 | 
				
			||||||
		p.Contact.Name = randomLenString(4, 20)
 | 
							p.Name = randomLenString(4, 20)
 | 
				
			||||||
		p.Contact.ContactPublicKey = p.MyLookupKp.Public
 | 
							p.ContactPublicKey = p.MyLookupKp.Public
 | 
				
			||||||
		p.Contact.EncryptionPublicKey = p.MyIdentity.Public
 | 
							p.ContactEncryption = p.MyIdentity.Public
 | 
				
			||||||
		p.Contact.LookupPublicKey = p.MyEncryptionKp.Public
 | 
							p.ContactLookupKey = p.MyEncryptionKp.Public
 | 
				
			||||||
		p.Contact.AddUrls([]string{randomLenString(14, 60), randomLenString(14, 60)})
 | 
							//	p.Contact.AddUrls([]string{randomLenString(14, 60), randomLenString(14, 60)}) // todo add servers
 | 
				
			||||||
		id.Peers = append(id.Peers, p)
 | 
							id.Peers = append(id.Peers, p)
 | 
				
			||||||
		id.HidePeer(0, randomLenString(8, 14))
 | 
							id.HidePeer(0, randomLenString(8, 14))
 | 
				
			||||||
		// TODO Add random conversations
 | 
							// TODO Add random conversations
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,11 +33,11 @@ func createId() *Identity {
 | 
				
			|||||||
	p.MyEncryptionKp = meowlib.NewKeyPair()
 | 
						p.MyEncryptionKp = meowlib.NewKeyPair()
 | 
				
			||||||
	p.MyIdentity = meowlib.NewKeyPair()
 | 
						p.MyIdentity = meowlib.NewKeyPair()
 | 
				
			||||||
	p.MyLookupKp = meowlib.NewKeyPair()
 | 
						p.MyLookupKp = meowlib.NewKeyPair()
 | 
				
			||||||
	p.Contact.Name = "foo"
 | 
						p.Name = "foo"
 | 
				
			||||||
	p.Contact.ContactPublicKey = p.MyLookupKp.Public
 | 
						p.ContactPublicKey = p.MyLookupKp.Public
 | 
				
			||||||
	p.Contact.EncryptionPublicKey = p.MyIdentity.Public
 | 
						p.ContactEncryption = p.MyIdentity.Public
 | 
				
			||||||
	p.Contact.LookupPublicKey = p.MyEncryptionKp.Public
 | 
						p.ContactLookupKey = p.MyEncryptionKp.Public
 | 
				
			||||||
	p.Contact.AddUrls([]string{"http:/127.0.0.1/meow", "tcp://localhost:1234"})
 | 
						//p.Contact.AddUrls([]string{"http:/127.0.0.1/meow", "tcp://localhost:1234"}) //todo add servers
 | 
				
			||||||
	id.Peers = append(id.Peers, p)
 | 
						id.Peers = append(id.Peers, p)
 | 
				
			||||||
	return id
 | 
						return id
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,15 +26,15 @@ type Peer struct {
 | 
				
			|||||||
	MyLookupKp     meowlib.KeyPair `json:"my_lookup_kp,omitempty"`
 | 
						MyLookupKp     meowlib.KeyPair `json:"my_lookup_kp,omitempty"`
 | 
				
			||||||
	MyPullServers  []string        `json:"my_pull_servers,omitempty"`
 | 
						MyPullServers  []string        `json:"my_pull_servers,omitempty"`
 | 
				
			||||||
	// Peer keys and infos
 | 
						// Peer keys and infos
 | 
				
			||||||
	Contact            meowlib.ContactCard `json:"contact,omitempty"` // todo : remove
 | 
						//Contact            meowlib.ContactCard `json:"contact,omitempty"` // todo : remove
 | 
				
			||||||
	ContactPublicKey   string              `json:"contact_public_key,omitempty"`
 | 
						ContactPublicKey   string    `json:"contact_public_key,omitempty"`
 | 
				
			||||||
	ContactLookupKey   string              `json:"contact_lookup_key,omitempty"`
 | 
						ContactLookupKey   string    `json:"contact_lookup_key,omitempty"`
 | 
				
			||||||
	ContactEncryption  string              `json:"contact_encryption,omitempty"`
 | 
						ContactEncryption  string    `json:"contact_encryption,omitempty"`
 | 
				
			||||||
	ContactPullServers []string            `json:"contact_pull_servers,omitempty"`
 | 
						ContactPullServers []string  `json:"contact_pull_servers,omitempty"`
 | 
				
			||||||
	InvitationId       string              `json:"invitation_id,omitempty"`
 | 
						InvitationId       string    `json:"invitation_id,omitempty"`
 | 
				
			||||||
	InvitationUrl      string              `json:"invitation_url,omitempty"`
 | 
						InvitationUrl      string    `json:"invitation_url,omitempty"`
 | 
				
			||||||
	InvitationMessage  string              `json:"invitation_message,omitempty"`
 | 
						InvitationMessage  string    `json:"invitation_message,omitempty"`
 | 
				
			||||||
	InvitationExpiry   time.Time           `json:"invitation_expiry,omitempty"`
 | 
						InvitationExpiry   time.Time `json:"invitation_expiry,omitempty"`
 | 
				
			||||||
	// Internal management attributes
 | 
						// Internal management attributes
 | 
				
			||||||
	Visible             bool      `json:"visible,omitempty"`
 | 
						Visible             bool      `json:"visible,omitempty"`
 | 
				
			||||||
	VisiblePassword     string    `json:"visible_password,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) {
 | 
					func (p *Peer) BuildSimpleUserMessage(message []byte) (*meowlib.UserMessage, error) {
 | 
				
			||||||
	var msg meowlib.UserMessage
 | 
						var msg meowlib.UserMessage
 | 
				
			||||||
	msg.Destination = p.Contact.LookupPublicKey
 | 
						msg.Destination = p.ContactLookupKey
 | 
				
			||||||
	msg.From = p.MyIdentity.Public
 | 
						msg.From = p.MyIdentity.Public
 | 
				
			||||||
	msg.Data = message
 | 
						msg.Data = message
 | 
				
			||||||
	msg.Type = "1"
 | 
						msg.Type = "1"
 | 
				
			||||||
@@ -122,7 +122,7 @@ func (p *Peer) BuildSingleFileMessage(filename string, message []byte) ([]meowli
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		var msg meowlib.UserMessage
 | 
							var msg meowlib.UserMessage
 | 
				
			||||||
		var file meowlib.File
 | 
							var file meowlib.File
 | 
				
			||||||
		msg.Destination = p.Contact.LookupPublicKey
 | 
							msg.Destination = p.ContactLookupKey
 | 
				
			||||||
		msg.From = p.MyIdentity.Public
 | 
							msg.From = p.MyIdentity.Public
 | 
				
			||||||
		file.Filename = fi.Name()
 | 
							file.Filename = fi.Name()
 | 
				
			||||||
		file.Chunk = uint32(chunk)
 | 
							file.Chunk = uint32(chunk)
 | 
				
			||||||
@@ -151,7 +151,7 @@ func (p *Peer) BuildInvitationAnswerMessage(myContactCard *meowlib.ContactCard)
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	invitation.Payload = out
 | 
						invitation.Payload = out
 | 
				
			||||||
	msg.Destination = p.Contact.LookupPublicKey
 | 
						msg.Destination = p.ContactLookupKey
 | 
				
			||||||
	msg.From = p.MyIdentity.Public
 | 
						msg.From = p.MyIdentity.Public
 | 
				
			||||||
	msg.Type = "1"
 | 
						msg.Type = "1"
 | 
				
			||||||
	return &msg, nil
 | 
						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
 | 
					// AsymEncryptMessage prepares a message to send to a specific peer contact
 | 
				
			||||||
func (p *Peer) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, error) {
 | 
					func (p *Peer) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, error) {
 | 
				
			||||||
	var enc *meowlib.EncryptedMessage
 | 
						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 {
 | 
						if err != nil {
 | 
				
			||||||
		fmt.Println(err.Error())
 | 
							fmt.Println(err.Error())
 | 
				
			||||||
		return enc, err
 | 
							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
 | 
					// AsymDecryptMessage reads a message from a specific peer contact
 | 
				
			||||||
func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMessage []byte, err error) {
 | 
					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 {
 | 
						if err != nil {
 | 
				
			||||||
		fmt.Println(err.Error())
 | 
							fmt.Println(err.Error())
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -202,7 +202,7 @@ func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMe
 | 
				
			|||||||
// PackUserMessage will package the previously encrypted message
 | 
					// PackUserMessage will package the previously encrypted message
 | 
				
			||||||
func (p *Peer) PackUserMessage(message []byte, signature []byte) *meowlib.PackedUserMessage {
 | 
					func (p *Peer) PackUserMessage(message []byte, signature []byte) *meowlib.PackedUserMessage {
 | 
				
			||||||
	var msg meowlib.PackedUserMessage
 | 
						var msg meowlib.PackedUserMessage
 | 
				
			||||||
	msg.Destination = p.Contact.LookupPublicKey
 | 
						msg.Destination = p.ContactLookupKey
 | 
				
			||||||
	msg.Payload = message
 | 
						msg.Payload = message
 | 
				
			||||||
	msg.Signature = signature
 | 
						msg.Signature = signature
 | 
				
			||||||
	return &msg
 | 
						return &msg
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ func TestGetFromPublicKey(t *testing.T) {
 | 
				
			|||||||
	for i := 1; i < 10; i++ {
 | 
						for i := 1; i < 10; i++ {
 | 
				
			||||||
		var p Peer
 | 
							var p Peer
 | 
				
			||||||
		p.Name = "test" + strconv.Itoa(i)
 | 
							p.Name = "test" + strconv.Itoa(i)
 | 
				
			||||||
		p.Contact.ContactPublicKey = "stringToFind" + strconv.Itoa(i)
 | 
							p.ContactPublicKey = "stringToFind" + strconv.Itoa(i)
 | 
				
			||||||
		id.Peers = append(id.Peers, p)
 | 
							id.Peers = append(id.Peers, p)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p5 := id.Peers.GetFromPublicKey("stringToFind5")
 | 
						p5 := id.Peers.GetFromPublicKey("stringToFind5")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@ type PeerList []Peer
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (pl *PeerList) GetFromPublicKey(publickey string) *Peer {
 | 
					func (pl *PeerList) GetFromPublicKey(publickey string) *Peer {
 | 
				
			||||||
	for _, peer := range *pl {
 | 
						for _, peer := range *pl {
 | 
				
			||||||
		if peer.Contact.ContactPublicKey == publickey {
 | 
							if peer.ContactPublicKey == publickey {
 | 
				
			||||||
			return &peer
 | 
								return &peer
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -26,7 +26,7 @@ func (pl *PeerList) GetFromMyLookupKey(publickey string) *Peer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (pl *PeerList) GetFromName(name string) *Peer {
 | 
					func (pl *PeerList) GetFromName(name string) *Peer {
 | 
				
			||||||
	for _, peer := range *pl {
 | 
						for _, peer := range *pl {
 | 
				
			||||||
		if peer.Contact.Name == name {
 | 
							if peer.Name == name {
 | 
				
			||||||
			return &peer
 | 
								return &peer
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user