begin adding device to device communication
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
ycc 2024-01-18 22:43:41 +01:00
parent 44661de993
commit f8a1cb6f68
2 changed files with 26 additions and 12 deletions

View File

@ -21,6 +21,7 @@ type Identity struct {
RootKp meowlib.KeyPair `json:"id_kp,omitempty"`
Status string `json:"status,omitempty"`
Peers PeerList `json:"peers,omitempty"`
Devices PeerList `json:"devices,omitempty"`
HiddenPeers [][]byte `json:"hiddend_peers,omitempty"`
Device meowlib.KeyPair `json:"device,omitempty"`
KnownServers ServerList `json:"known_servers,omitempty"`
@ -207,9 +208,15 @@ func (id *Identity) generateRandomHiddenStuff() {
}
}
type BackgroundJob struct {
RootPublic string `json:"root_public,omitempty"`
Device meowlib.KeyPair `json:"device,omitempty"`
Jobs []*RequestsJob `json:"jobs,omitempty"`
}
type RequestsJob struct {
server Server `json:"server,omitempty"`
lookupKeys []meowlib.KeyPair `json:"lookup_keys,omitempty"`
Server Server `json:"server,omitempty"`
LookupKeys []meowlib.KeyPair `json:"lookup_keys,omitempty"`
}
func (id *Identity) GetRequestJobs() []*RequestsJob {
@ -218,19 +225,19 @@ func (id *Identity) GetRequestJobs() []*RequestsJob {
// build a server map
for _, server := range id.MessageServers.Servers {
var rj RequestsJob
rj.server = server
rj.Server = server
srvs[server.ServerData.GetUid()] = &rj
}
// add ids to the map
for _, peer := range id.Peers {
for _, server := range peer.MyPullServers {
srvs[server.GetUid()].lookupKeys = append(srvs[server.GetUid()].lookupKeys, peer.MyLookupKp)
srvs[server.GetUid()].LookupKeys = append(srvs[server.GetUid()].LookupKeys, peer.MyLookupKp)
}
}
// add hidden peers
for _, peer := range id.unlockedHiddenPeers {
for _, server := range peer.MyPullServers {
srvs[server.GetUid()].lookupKeys = append(srvs[server.GetUid()].lookupKeys, peer.MyLookupKp)
srvs[server.GetUid()].LookupKeys = append(srvs[server.GetUid()].LookupKeys, peer.MyLookupKp)
}
}
// todo add garbage
@ -244,9 +251,12 @@ func (id *Identity) GetRequestJobs() []*RequestsJob {
return list
}
func (id *Identity) SaveRequestJobs() error {
jobs := id.GetRequestJobs()
jsonjobs, err := json.Marshal(jobs)
func (id *Identity) SaveBackgroundJob() error {
var bj BackgroundJob
bj.Jobs = id.GetRequestJobs()
bj.RootPublic = id.RootKp.Public
bj.Device = id.Device
jsonjobs, err := json.Marshal(bj)
if err != nil {
return err
}

View File

@ -65,6 +65,7 @@ message ToServerMessage {
Invitation invitation = 9; // invitation for the 2 first steps of a "through server" invitation process
repeated PackedUserMessage device_messages = 10; // messages to another device belonging to the same user
}
message ConversationResponse {
@ -74,17 +75,20 @@ message ToServerMessage {
// structure defining a from server receiver message decrypted from a "packedmessage" payload
message FromServerMessage {
string type = 1; // Type
string serverPublicKey = 2 ; // Pub key from the server
string server_public_key = 2 ; // Pub key from the server
bytes payload = 3 ; //
string uuidAck = 4 ; // Ack for the last received ToServerMessage Uuid
string serverUuid = 5 ; // Provides the server uuid that replaced the client uuid
string uuid_ack = 4 ; // Ack for the last received ToServerMessage Uuid
string server_uuid = 5 ; // Provides the server uuid that replaced the client uuid
repeated PackedUserMessage chat = 6;
repeated ServerCard knownServers = 7;
repeated ServerCard known_servers = 7;
Invitation invitation = 8; // invitation answer, for the third steps of any invitation
repeated PackedUserMessage device_messages = 9; // messages from other devices belonging to the same user
}
message MatriochkaServer {