Server processing initiated
This commit is contained in:
parent
adb058492f
commit
6293e979b7
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"forge.redroom.link/yves/meowlib"
|
||||
"forge.redroom.link/yves/meowlib/client"
|
||||
"forge.redroom.link/yves/meowlib/server"
|
||||
)
|
||||
|
||||
func TestEndToEnd(t *testing.T) {
|
||||
@ -112,17 +113,40 @@ func TestEndToEnd(t *testing.T) {
|
||||
///////////////////////////////////////
|
||||
// Simulating server side processing //
|
||||
///////////////////////////////////////
|
||||
var server1 server.Identity
|
||||
server1.ServerName = intS1.ServerData.Name
|
||||
server1.ServerKp = FriendServer1KP
|
||||
server1.ServerDesc = intS1.ServerData.Description
|
||||
// Unpack
|
||||
srv_from, srv_encmsg, srv_signature, err := server1.UnpackReceived(protoPackedServerMsg)
|
||||
// Decrypt
|
||||
srv_clear, err := server1.AsymDecryptMessage(srv_from, srv_encmsg, srv_signature)
|
||||
// Decode msg
|
||||
srv_msg, err := server1.DecodeToServerMessage(srv_clear)
|
||||
// Response : Ack received message
|
||||
srv_fromServerMessage, err := server1.BuildSimpleAckResponseMessage(srv_msg.Uuid)
|
||||
srv_resp, srv_respsig, err := server1.AsymEncryptMessage(srv_from, srv_fromServerMessage)
|
||||
resp, err := server1.PackResponseMessage(srv_resp, srv_respsig)
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Back to client, decoding server response //
|
||||
//////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// server unpack
|
||||
|
||||
// server decrypt
|
||||
|
||||
// server decode protobuf
|
||||
|
||||
// user unpack
|
||||
|
||||
// user decrypt
|
||||
decMess, err2 := MyFirstFriend.AsymDecryptMessage([]byte(EncMsg), EncMsgSignature)
|
||||
if err2 != nil {
|
||||
fmt.Println(err2.Error())
|
||||
}
|
||||
fmt.Println(decMess)
|
||||
// user decode protobuf
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ message PackedServerMessage {
|
||||
|
||||
// structure defining a message for a server, that will be encrypted, then sent in a "packedmessage" payload
|
||||
message ToServerMessage {
|
||||
string type = 1; // Type
|
||||
string type = 1; // Type 1 : final destination / 2 : forward
|
||||
string from = 2 ; // My pub key for the server to send me an encrypter answer
|
||||
bytes payload = 3 ; // optional payload for server
|
||||
|
||||
@ -28,6 +28,7 @@ message ToServerMessage {
|
||||
repeated PackedUserMessage messages = 5;
|
||||
|
||||
repeated Server knownServers = 6;
|
||||
|
||||
string uuid = 7;
|
||||
|
||||
}
|
||||
@ -83,16 +84,16 @@ message PackedUserMessage {
|
||||
|
||||
// structure defining information that might be exchanged between two peers.
|
||||
message UserMessage {
|
||||
string Destination = 1;
|
||||
string From = 2;
|
||||
string Type = 3;
|
||||
bytes Data = 4;
|
||||
string destination = 1;
|
||||
string from = 2;
|
||||
string type = 3;
|
||||
bytes data = 4;
|
||||
message ConversationStatus {
|
||||
string LocalUuid = 1;
|
||||
uint64 LocalSequence = 2 ;
|
||||
uint64 Sent = 3 ;
|
||||
uint64 Received = 4;
|
||||
uint64 Processed = 5;
|
||||
string localUuid = 1;
|
||||
uint64 localSequence = 2 ;
|
||||
uint64 sent = 3 ;
|
||||
uint64 received = 4;
|
||||
uint64 processed = 5;
|
||||
ContactCard myNextIdentity = 6;
|
||||
int32 peerNextIdentityAck = 7; // version of the new peed accepted id
|
||||
}
|
||||
|
@ -88,11 +88,15 @@ func (id *Identity) DecodeToServerMessage(toServerMessage []byte) (*meowlib.ToSe
|
||||
// Outbound processing chain
|
||||
//
|
||||
|
||||
func (id *Identity) BuildSimpleAckResponseMessage(uuidToAck string) (fromServerMessage *meowlib.FromServerMessage, err error) {
|
||||
func (id *Identity) BuildSimpleAckResponseMessage(uuidToAck string) (fromServerMessage []byte, err error) {
|
||||
var msg meowlib.FromServerMessage
|
||||
msg.ServerPublicKey = id.ServerKp.Public
|
||||
msg.UuidAck = uuidToAck
|
||||
return &msg, nil
|
||||
out, err := proto.Marshal(&msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AsymEncryptMessage prepares a message to send to a specific client contact
|
||||
|
Loading…
Reference in New Issue
Block a user