diff --git a/asymcrypt_test.go b/asymcrypt_test.go index c0391b7..034b9cc 100644 --- a/asymcrypt_test.go +++ b/asymcrypt_test.go @@ -3,8 +3,8 @@ package meowlib import ( "encoding/base64" "fmt" - "io/ioutil" "log" + "os" "testing" "github.com/stretchr/testify/assert" @@ -123,19 +123,19 @@ func TestFlutterCompat(t *testing.T) { } func TestFlutterDecode(t *testing.T) { - pub, err := ioutil.ReadFile("/home/yves/Documents/code/flutter/meowlib/pub.key") + pub, err := os.ReadFile("/home/yves/Documents/code/flutter/meowlib/pub.key") if err != nil { fmt.Println("Err") } - priv, err := ioutil.ReadFile("/home/yves/Documents/code/flutter/meowlib/priv.key") + priv, err := os.ReadFile("/home/yves/Documents/code/flutter/meowlib/priv.key") if err != nil { fmt.Println("Err") } - msg, err := ioutil.ReadFile("/home/yves/Documents/code/flutter/meowlib/msg.enc") + msg, err := os.ReadFile("/home/yves/Documents/code/flutter/meowlib/msg.enc") if err != nil { fmt.Println("Err") } - sign, err := ioutil.ReadFile("/home/yves/Documents/code/flutter/meowlib/msg.sign") + sign, err := os.ReadFile("/home/yves/Documents/code/flutter/meowlib/msg.sign") if err != nil { fmt.Println("Err") } @@ -154,11 +154,11 @@ func TestFlutterDecode(t *testing.T) { } func TestFlutterEncode(t *testing.T) { - pub, err := ioutil.ReadFile("/home/yves/Documents/code/flutter/meowlib/pub.key") + pub, err := os.ReadFile("/home/yves/Documents/code/flutter/meowlib/pub.key") if err != nil { fmt.Println("Err") } - priv, err := ioutil.ReadFile("/home/yves/Documents/code/flutter/meowlib/priv.key") + priv, err := os.ReadFile("/home/yves/Documents/code/flutter/meowlib/priv.key") if err != nil { fmt.Println("Err") } @@ -168,11 +168,11 @@ func TestFlutterEncode(t *testing.T) { log.Println(err.Error()) } - err = ioutil.WriteFile("/home/yves/Documents/code/flutter/meowlib/gomsg.enc", encMess, 0644) + err = os.WriteFile("/home/yves/Documents/code/flutter/meowlib/gomsg.enc", encMess, 0644) if err != nil { fmt.Println("Err") } - err = ioutil.WriteFile("/home/yves/Documents/code/flutter/meowlib/gomsg.sign", sign2, 0644) + err = os.WriteFile("/home/yves/Documents/code/flutter/meowlib/gomsg.sign", sign2, 0644) if err != nil { fmt.Println("Err") } diff --git a/client/identity.go b/client/identity.go index 762a9e0..222a9d1 100644 --- a/client/identity.go +++ b/client/identity.go @@ -48,8 +48,8 @@ func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerI } } for _, i := range MessageServerIdxs { - srv := id.MessageServers.Servers[i].ServerData - myContactCard.PullServers = append(myContactCard.PullServers, &srv) + srv := &id.MessageServers.Servers[i].ServerData + myContactCard.PullServers = append(myContactCard.PullServers, srv) } myContactCard.Name = MyName myContactCard.ContactPublicKey = peer.MyIdentity.Public diff --git a/client/message.go b/client/message.go index 1821e30..7030107 100644 --- a/client/message.go +++ b/client/message.go @@ -2,7 +2,7 @@ package client import "fmt" -func MakeText(peer *Peer, text string, srv *InternalServer) ([]byte, error) { +func ProcessOutboundTextMessage(peer *Peer, text string, srv *InternalServer) ([]byte, error) { // Creating User message usermessage, err := peer.BuildSimpleUserMessage([]byte(text)) if err != nil { @@ -22,7 +22,7 @@ func MakeText(peer *Peer, text string, srv *InternalServer) ([]byte, error) { packedMsg := peer.PackUserMessage(EncMsg, EncMsgSignature) // Creating Server message for transporting the user message - toServerMessage, err := srv.BuildMessageSendingMessage(&packedMsg) + toServerMessage, err := srv.BuildMessageSendingMessage(packedMsg) if err != nil { return nil, err } diff --git a/client/peer.go b/client/peer.go index 6a46d69..6bbd644 100644 --- a/client/peer.go +++ b/client/peer.go @@ -143,12 +143,12 @@ func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMe } // PackUserMessage will package the previously encrypted message for sending it to the peer in protobuff format -func (p *Peer) PackUserMessage(message []byte, signature []byte) meowlib.PackedUserMessage { +func (p *Peer) PackUserMessage(message []byte, signature []byte) *meowlib.PackedUserMessage { var msg meowlib.PackedUserMessage msg.Destination = p.Contact.LookupPublicKey msg.Payload = message msg.Signature = signature - return msg + return &msg } func (ints *InternalServer) UnPackUserMessage(protoPackedMessage []byte) (payload []byte, signature []byte, err error) { diff --git a/contactcard.go b/contactcard.go index 92e3cf5..1bd6578 100644 --- a/contactcard.go +++ b/contactcard.go @@ -159,10 +159,10 @@ func (Contact *ContactCard) WriteQr(filename string) error { return nil } -func ReadQr(Filename string) ContactCard { +func ReadQr(filename string) *ContactCard { var contact ContactCard // open and decode image file - file, _ := os.Open("qrcode.jpg") + file, _ := os.Open(filename) img, _, _ := image.Decode(file) // prepare BinaryBitmap @@ -173,5 +173,5 @@ func ReadQr(Filename string) ContactCard { result, _ := qrReader.Decode(bmp, nil) fmt.Println(result) - return contact + return &contact } diff --git a/endtoend_test.go b/endtoend_test.go index a23b1b7..845e694 100644 --- a/endtoend_test.go +++ b/endtoend_test.go @@ -103,7 +103,7 @@ func TestEndToEnd(t *testing.T) { intS1 := client.InternalServerFromServer(srv) // Creating Server message for transporting the user message - toServerMessage, err := intS1.BuildMessageSendingMessage(&packedMsg) + toServerMessage, err := intS1.BuildMessageSendingMessage(packedMsg) if err != nil { fmt.Println(err.Error()) } diff --git a/qrcode.png b/qrcode.png deleted file mode 100644 index a0a1658..0000000 Binary files a/qrcode.png and /dev/null differ