From 023a3c701af36a427451f345c081c00b6cf47080 Mon Sep 17 00:00:00 2001 From: ycc Date: Sat, 3 Dec 2022 00:05:28 +0100 Subject: [PATCH] locks + message helper rename --- asymcrypt_test.go | 18 +++++++++--------- client/identity.go | 4 ++-- client/message.go | 4 ++-- client/peer.go | 4 ++-- contactcard.go | 6 +++--- endtoend_test.go | 2 +- qrcode.png | Bin 9421 -> 0 bytes 7 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 qrcode.png 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 a0a16589be898d98057ffd7ae6b69cde2585d51d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9421 zcmeHtX+x50+ch|0IoGzq0W{lLSfypdwZ^tro9vbc} z2dK;t6^As@RH$u=8sb2Lih_!WipZn%e0$%Y@OP03fsZRtBKB`3m^9GxY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