locks + message helper rename
This commit is contained in:
parent
a5cf1ec7ac
commit
023a3c701a
@ -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")
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
BIN
qrcode.png
BIN
qrcode.png
Binary file not shown.
Before Width: | Height: | Size: 9.2 KiB |
Loading…
Reference in New Issue
Block a user