request jobs generation
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		@@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"math/rand"
 | 
						"math/rand"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"forge.redroom.link/yves/meowlib"
 | 
						"forge.redroom.link/yves/meowlib"
 | 
				
			||||||
@@ -187,8 +188,8 @@ func (id *Identity) HidePeer(peerIdx int, password string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (id *Identity) generateRandomHiddenStuff() {
 | 
					func (id *Identity) generateRandomHiddenStuff() {
 | 
				
			||||||
	rand.Seed(time.Now().UnixNano())
 | 
						r := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
				
			||||||
	count := rand.Intn(maxHiddenCount) + 1
 | 
						count := r.Intn(maxHiddenCount) + 1
 | 
				
			||||||
	for i := 1; i < count; i++ {
 | 
						for i := 1; i < count; i++ {
 | 
				
			||||||
		var p Peer
 | 
							var p Peer
 | 
				
			||||||
		p.Name = randomLenString(4, 20)
 | 
							p.Name = randomLenString(4, 20)
 | 
				
			||||||
@@ -202,21 +203,72 @@ func (id *Identity) generateRandomHiddenStuff() {
 | 
				
			|||||||
		p.Contact.AddUrls([]string{randomLenString(14, 60), randomLenString(14, 60)})
 | 
							p.Contact.AddUrls([]string{randomLenString(14, 60), randomLenString(14, 60)})
 | 
				
			||||||
		id.Peers = append(id.Peers, p)
 | 
							id.Peers = append(id.Peers, p)
 | 
				
			||||||
		id.HidePeer(0, randomLenString(8, 14))
 | 
							id.HidePeer(0, randomLenString(8, 14))
 | 
				
			||||||
		// TODO Add conversations
 | 
							// TODO Add random conversations
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type RequestsJob struct {
 | 
				
			||||||
 | 
						server     Server            `json:"server,omitempty"`
 | 
				
			||||||
 | 
						lookupKeys []meowlib.KeyPair `json:"lookup_keys,omitempty"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (id *Identity) GetRequestJobs() []*RequestsJob {
 | 
				
			||||||
 | 
						var list []*RequestsJob
 | 
				
			||||||
 | 
						srvs := map[string]*RequestsJob{}
 | 
				
			||||||
 | 
						// build a server map
 | 
				
			||||||
 | 
						for _, server := range id.MessageServers.Servers {
 | 
				
			||||||
 | 
							var rj RequestsJob
 | 
				
			||||||
 | 
							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)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// add hidden peers
 | 
				
			||||||
 | 
						for _, peer := range id.unlockedHiddenPeers {
 | 
				
			||||||
 | 
							for _, server := range peer.MyPullServers {
 | 
				
			||||||
 | 
								srvs[server.GetUid()].lookupKeys = append(srvs[server.GetUid()].lookupKeys, peer.MyLookupKp)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// todo add garbage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// todo reorder shit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// build list
 | 
				
			||||||
 | 
						for _, value := range srvs {
 | 
				
			||||||
 | 
							list = append(list, value)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return list
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (id *Identity) SaveRequestJobs() error {
 | 
				
			||||||
 | 
						jobs := id.GetRequestJobs()
 | 
				
			||||||
 | 
						jsonjobs, err := json.Marshal(jobs)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						err = os.WriteFile(filepath.Join(GetConfig().StoragePath, ".jobs"), jsonjobs, 0644)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func randomLenString(min int, max int) string {
 | 
					func randomLenString(min int, max int) string {
 | 
				
			||||||
	rand.Seed(time.Now().UnixNano())
 | 
						r := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
				
			||||||
	n := rand.Intn(max-min) + min
 | 
						n := r.Intn(max-min) + min
 | 
				
			||||||
	return randomString(n)
 | 
						return randomString(n)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func randomString(n int) string {
 | 
					func randomString(n int) string {
 | 
				
			||||||
 | 
						r := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
				
			||||||
	var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
 | 
						var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
 | 
				
			||||||
	s := make([]rune, n)
 | 
						s := make([]rune, n)
 | 
				
			||||||
	for i := range s {
 | 
						for i := range s {
 | 
				
			||||||
		s[i] = letters[rand.Intn(len(letters))]
 | 
							s[i] = letters[r.Intn(len(letters))]
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return string(s)
 | 
						return string(s)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,13 @@ Some of them might be marked as trusted.
 | 
				
			|||||||
Random delays and random payload padding might be set for each forwarding step, making the overall message tracking much more difficult, even for organizations having capabilities of global network surveillance.
 | 
					Random delays and random payload padding might be set for each forwarding step, making the overall message tracking much more difficult, even for organizations having capabilities of global network surveillance.
 | 
				
			||||||
It is strongly advised to use trusted servers as your first node and message server (the one that holds your incoming messages).
 | 
					It is strongly advised to use trusted servers as your first node and message server (the one that holds your incoming messages).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\subsubsection{Presence protocol for direct messaging}
 | 
					\subsubsection{Message lookup obfuscation}
 | 
				
			||||||
 | 
					Your device will request for messages using conversation keys on a very regular basis to youy messaging(s) server(s).
 | 
				
			||||||
 | 
					The device will check for conversation keys for all your contacts. If you check that option, it will also check for hidden contact keys. 
 | 
				
			||||||
 | 
					In case of data interception on your device link, in order to prevent statistical analysis, every request might be answered with random data.
 | 
				
			||||||
 | 
					Moreover, some random keys will be added to your requests list.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\subsubsection{Presence protocol for direct messaging TBC}
 | 
				
			||||||
A presence service associating your conversation keys to your IP address for direct peer to peer connection is also provided.
 | 
					A presence service associating your conversation keys to your IP address for direct peer to peer connection is also provided.
 | 
				
			||||||
The presence protocol is simply activated by setting a flag in the message poll requests. 
 | 
					The presence protocol is simply activated by setting a flag in the message poll requests. 
 | 
				
			||||||
If that flag is set, your encrypted IP will be published on the server, allowing your only your peer(s) to decrypt it and directly communicate with your terminal.
 | 
					If that flag is set, your encrypted IP will be published on the server, allowing your only your peer(s) to decrypt it and directly communicate with your terminal.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										633
									
								
								messages.pb.go
									
									
									
									
									
								
							
							
						
						
									
										633
									
								
								messages.pb.go
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -37,10 +37,15 @@ message Invitation {
 | 
				
			|||||||
message ConversationRequest {  
 | 
					message ConversationRequest {  
 | 
				
			||||||
    string lookupKey = 1; // lookup key for a conversation
 | 
					    string lookupKey = 1; // lookup key for a conversation
 | 
				
			||||||
    string lastServerUuidOK = 2; // Last Server message UUID received (send me all after that one)
 | 
					    string lastServerUuidOK = 2; // Last Server message UUID received (send me all after that one)
 | 
				
			||||||
    bool publishOnline = 3; // ?? Publish my online status for that contact ?
 | 
					    int64 sendTimestamp = 3;
 | 
				
			||||||
    string lookupSignature = 4; // prove that I own the private key by signing that block
 | 
					    string lookupSignature = 4; // prove that I own the private key by signing that block
 | 
				
			||||||
} 
 | 
					} 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					message Meet {
 | 
				
			||||||
 | 
					    string public_status = 1; // Publish my online status, if the server is a meeting server 
 | 
				
			||||||
 | 
					    ContactCard contact_card = 2; // mine or the requester
 | 
				
			||||||
 | 
					    string message = 3; // short description
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// structure defining a message for a server, that will be encrypted, then sent in a "packedmessage" payload
 | 
					// structure defining a message for a server, that will be encrypted, then sent in a "packedmessage" payload
 | 
				
			||||||
message ToServerMessage {
 | 
					message ToServerMessage {
 | 
				
			||||||
@@ -48,13 +53,13 @@ message ToServerMessage {
 | 
				
			|||||||
	string from = 2 ; // My pub key for the server to send me an encrypter answer
 | 
						string from = 2 ; // My pub key for the server to send me an encrypter answer
 | 
				
			||||||
	bytes payload = 3 ; // optional payload for server
 | 
						bytes payload = 3 ; // optional payload for server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    repeated ConversationRequest pullRequest = 4; 
 | 
					    repeated ConversationRequest pull_request = 4; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	repeated PackedUserMessage messages = 5; 
 | 
						repeated PackedUserMessage messages = 5; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    repeated ServerCard knownServers = 6; 
 | 
					    repeated ServerCard known_servers = 6; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Matriochka matriochkaMessage = 7;
 | 
					    Matriochka matriochka_message = 7;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    string uuid = 8;
 | 
					    string uuid = 8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								servercard.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								servercard.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					package meowlib
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (sc *ServerCard) GetUid() string {
 | 
				
			||||||
 | 
						return sc.Login + ":" + sc.Password + "@" + sc.Url
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (sc *ServerCard) IsSame(sc1 *ServerCard) bool {
 | 
				
			||||||
 | 
						return sc.GetUid() == sc1.GetUid()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user