Documentation
¶
Index ¶
- func AddLogger(l zerolog.Logger)
- func DeleteSendJob(storagePath, queue string, id int64) error
- func FilePreview(filename string, password string) ([]byte, error)
- func FindMessageByUuid(peer *Peer, messageUuid string, password string) (string, int64, *meowlib.DbMessage, error)
- func GetDbMessage(dbFile string, dbId int64, password string) (*meowlib.DbMessage, error)
- func GetMessagePreview(dbFile string, dbId int64, password string) ([]byte, error)
- func InternalUserMessagePreview(msg *InternalUserMessage, password string) ([]byte, error)
- func InternalUserMessageToDbMessage(ium *InternalUserMessage) *meowlib.DbMessage
- func ProcessForOutput(usermessage *meowlib.UserMessage, peer *Peer, servers *ServerList, ...) ([]byte, error)
- func ProcessOutboundTextMessage(peer *Peer, text string, srv *Server) ([]byte, error)
- func PushSendJob(storagePath string, job *SendJob) error
- func SetMessageServerDelivery(dbFile string, dbId int64, serverUid string, receiveTime uint64, ...) error
- func UpdateDbMessage(dbm *meowlib.DbMessage, dbFile string, dbId int64, password string) error
- func UpdateMessageAck(peer *Peer, messageUuid string, receivedAt uint64, processedAt uint64, ...) error
- func UpdateSendJob(storagePath, queue string, job *SendJob) error
- func UserMessageToDbMessage(outbound bool, um *meowlib.UserMessage, filepaths []string) *meowlib.DbMessage
- type Avatar
- type BackgroundJob
- type Config
- func (c *Config) AddAdditionalPassword(password string)
- func (c *Config) Clean()
- func (c *Config) ClearAdditionalPasswords()
- func (c *Config) GetAdditionalPasswordAt(index int) (string, error)
- func (c *Config) GetAdditionalPasswords() ([]string, error)
- func (c *Config) GetIdentity() *Identity
- func (c *Config) GetMemPass() (string, error)
- func (c *Config) Load(filename string) error
- func (c *Config) RemoveAdditionalPasswordAt(index int) error
- func (c *Config) Save(filename string) error
- func (c *Config) SaveIdentity() error
- func (c *Config) SetIdentity(id *Identity)
- func (c *Config) SetMemPass(pass string) error
- func (c *Config) Validate() error
- type Identity
- func (id *Identity) CheckInvitation(ReceivedContact *meowlib.ContactCard) (isAnswer bool, proposedNick string, receivedNick string, ...)
- func (id *Identity) CreateFolder() error
- func (id *Identity) GetRequestJobs() []RequestsJob
- func (id *Identity) InvitationStep1(MyName string, ContactName string, MessageServerUids []string, ...) (*meowlib.InvitationInitPayload, *Peer, error)
- func (id *Identity) InvitationStep2(MyName string, ContactName string, MessageServerUids []string, ...) (*Peer, error)
- func (id *Identity) InvitationStep3(inviteeContact *meowlib.ContactCard) (*meowlib.ContactCard, *Peer, error)
- func (id *Identity) InvitationStep4(initiatorContact *meowlib.ContactCard) error
- func (id *Identity) Save() error
- func (id *Identity) SaveCheckJobs() error
- func (id *Identity) TryUnlockHidden(password string) error
- func (id *Identity) WipeFolder() error
- type InternalUserMessage
- type Peer
- func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMessage []byte, err error)
- func (p *Peer) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, error)
- func (p *Peer) BuildInvitationStep2Message(myContactCard *meowlib.ContactCard) (*meowlib.UserMessage, error)
- func (p *Peer) BuildInvitationStep3Message(myContactCard *meowlib.ContactCard) (*meowlib.UserMessage, error)
- func (p *Peer) BuildInvitationStep4Message() (*meowlib.UserMessage, error)
- func (p *Peer) BuildSimpleUserMessage(message []byte) (*meowlib.UserMessage, error)
- func (p *Peer) BuildSingleFileMessage(filename string, message []byte) ([]meowlib.UserMessage, error)
- func (p *Peer) DeserializeUserMessage(data []byte) (*meowlib.UserMessage, error)
- func (p *Peer) GetContact() *meowlib.ContactCard
- func (p *Peer) GetConversationRequest() *meowlib.ConversationRequest
- func (p *Peer) GetDRSession() (doubleratchet.Session, error)
- func (p *Peer) GetDbPassword() (string, error)
- func (p *Peer) GetFilePreview(filename string) ([]byte, error)
- func (p *Peer) GetLastMessageUuid(msg []byte)
- func (p *Peer) GetMyContact() *meowlib.ContactCard
- func (p *Peer) InvitationPending() bool
- func (p *Peer) LoadMessage(uid string) (*InternalUserMessage, error)
- func (p *Peer) LoadMessagesHistory(alreadyLoadedCount int, oldestMessageId int, qty int) ([]InternalUserMessage, error)
- func (p *Peer) LoadNewMessages(lastMessageId int) ([]*InternalUserMessage, error)
- func (p *Peer) PackUserMessage(message []byte, signature []byte) *meowlib.PackedUserMessage
- func (p *Peer) ProcessInboundStep2UserMessage(packed *meowlib.PackedUserMessage, inviteePublicKey string) (*meowlib.UserMessage, error)
- func (p *Peer) ProcessInboundStep3UserMessage(packed *meowlib.PackedUserMessage) (*meowlib.UserMessage, error)
- func (p *Peer) ProcessInboundUserMessage(packed *meowlib.PackedUserMessage) (*meowlib.UserMessage, error)
- func (p *Peer) ProcessOutboundUserMessage(usermessage *meowlib.UserMessage) (*meowlib.PackedUserMessage, error)
- func (p *Peer) SerializeUserMessage(msg *meowlib.UserMessage) ([]byte, error)
- func (p *Peer) SetDbPassword(password string)
- func (p *Peer) StoreMessage(msg *meowlib.UserMessage, filenames []string) error
- func (p *Peer) SymDecryptPayload(data []byte) ([]byte, error)
- func (p *Peer) SymEncryptPayload(data []byte) ([]byte, error)
- func (p *Peer) UnPackUserMessage(protoPackedMessage []byte) (payload []byte, signature []byte, err error)
- func (p *Peer) UpdateMessage(msg InternalUserMessage) error
- type PeerList
- type PeerStorage
- func (ps *PeerStorage) CheckInvitation(ReceivedContact *meowlib.ContactCard) (isAnswer bool, proposedNick string, receivedNick string, ...)
- func (ps *PeerStorage) DeletePeer(uid string) error
- func (ps *PeerStorage) FinalizeInvitation(ReceivedContact *meowlib.ContactCard) error
- func (ps *PeerStorage) GetFromInvitationId(invitationId string) *Peer
- func (ps *PeerStorage) GetFromMyLookupKey(publickey string) *Peer
- func (ps *PeerStorage) GetFromName(name string) *Peer
- func (ps *PeerStorage) GetFromPublicKey(publickey string) *Peer
- func (ps *PeerStorage) GetFromUid(uid string) *Peer
- func (ps *PeerStorage) GetPeers() ([]*Peer, error)
- func (ps *PeerStorage) LoadPeer(uid string, password string) (*Peer, error)
- func (ps *PeerStorage) LoadPeers(password string) ([]*Peer, error)
- func (ps *PeerStorage) NameExists(name string) bool
- func (ps *PeerStorage) StorePeer(peer *Peer) error
- type RequestsJob
- type SendJob
- type SendStatus
- type Server
- func CreateServerFromInvitationLink(meowurl string) (*Server, error)
- func CreateServerFromMeowUrl(meowurl string) (*Server, error)
- func CreateServerFromServerCard(server *meowlib.ServerCard) (*Server, error)
- func CreateServerFromUid(uid string) (*Server, error)
- func CreateServerFromUrl(url string) (*Server, error)
- func (ints *Server) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMessage []byte, err error)
- func (ints *Server) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, error)
- func (ints *Server) BuildMessageRequestMessage(lookupKeys []string) ([]byte, error)
- func (ints *Server) BuildMessageSendingMessage(usermsg *meowlib.PackedUserMessage) ([]byte, error)
- func (ints *Server) BuildToServerMessageFromUserMessage(usermsg *meowlib.PackedUserMessage) *meowlib.ToServerMessage
- func (ints *Server) BuildToServerMessageInvitationAnswer(invitationAnswer *meowlib.PackedUserMessage, myPublicKeyForThatPeer string, ...) (*meowlib.ToServerMessage, error)
- func (ints *Server) BuildToServerMessageInvitationAnswerRequest(invitationId string) (*meowlib.ToServerMessage, error)
- func (ints *Server) BuildToServerMessageInvitationRequest(shortcode string, password string) (*meowlib.ToServerMessage, error)
- func (ints *Server) BuildToServerMessageInvitationStep1(initPayload *meowlib.InvitationInitPayload, password string, timeout int, ...) (*meowlib.ToServerMessage, error)
- func (ints *Server) BuildVideoRoomRequestMessage(users []string, expiry uint64) (*meowlib.ToServerMessage, error)
- func (sc *Server) GetMeowUrl() string
- func (ints *Server) GetServerCard() *meowlib.ServerCard
- func (sc *Server) GetUid() string
- func (ints *Server) PackServerMessage(payload []byte, signature []byte) (protoPackedMessage []byte, err error)
- func (srv *Server) ProcessInboundServerResponse(msg []byte) (*meowlib.FromServerMessage, error)
- func (srv *Server) ProcessOutboundMessage(toServerMessage *meowlib.ToServerMessage) ([]byte, error)
- func (ints *Server) UnPackServerMessage(protoPackedMessage []byte) (payload []byte, signature []byte, err error)
- type ServerList
- type ServerStorage
- func (ss *ServerStorage) DeleteServer(uid string) error
- func (ss *ServerStorage) LoadAllServerCards() ([]*meowlib.ServerCard, error)
- func (ss *ServerStorage) LoadAllServers() ([]*Server, error)
- func (ss *ServerStorage) LoadServer(uid string) (*Server, error)
- func (ss *ServerStorage) LoadServerCardsFromUids(uids []string) ([]*meowlib.ServerCard, error)
- func (ss *ServerStorage) LoadServersFromUids(uids []string) ([]*Server, error)
- func (ss *ServerStorage) ServerExists(sc *Server) (bool, error)
- func (ss *ServerStorage) StoreServer(sc *Server) error
- func (ss *ServerStorage) StoreServerIfNotExists(sc *Server) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteSendJob ¶
DeleteSendJob removes a row by id from the named queue. If the queue is empty after deletion, the DB file is removed.
func FindMessageByUuid ¶
func FindMessageByUuid(peer *Peer, messageUuid string, password string) (string, int64, *meowlib.DbMessage, error)
FindMessageByUuid scans all DB files for a peer (newest first) and returns the dbFile, row ID, and DbMessage for the message whose Status.Uuid matches.
func GetDbMessage ¶
func GetMessagePreview ¶
func InternalUserMessagePreview ¶
func InternalUserMessagePreview(msg *InternalUserMessage, password string) ([]byte, error)
func InternalUserMessageToDbMessage ¶
func InternalUserMessageToDbMessage(ium *InternalUserMessage) *meowlib.DbMessage
func ProcessForOutput ¶
func ProcessForOutput(usermessage *meowlib.UserMessage, peer *Peer, servers *ServerList, trackingLookupKey string) ([]byte, error)
func PushSendJob ¶
PushSendJob appends a SendJob to the SQLite queue identified by job.Queue inside storagePath. The initial retry counters are set to zero for each server.
func SetMessageServerDelivery ¶
func SetMessageServerDelivery(dbFile string, dbId int64, serverUid string, receiveTime uint64, password string) error
SetMessageServerDelivery updates the server delivery UUID and timestamp for a stored message.
func UpdateDbMessage ¶
func UpdateMessageAck ¶
func UpdateMessageAck(peer *Peer, messageUuid string, receivedAt uint64, processedAt uint64, password string) error
UpdateMessageAck finds a stored outbound message by UUID and stamps it with the received and/or processed timestamps from an inbound ACK message.
func UpdateSendJob ¶
UpdateSendJob persists the tracking fields (status, sent_at, retries, successful_server) for a job that was previously returned by PeekSendJob.
func UserMessageToDbMessage ¶
Types ¶
type BackgroundJob ¶
type BackgroundJob struct {
RootPublic string `json:"root_public,omitempty"`
Device *meowlib.KeyPair `json:"device,omitempty"`
Jobs []RequestsJob `json:"jobs,omitempty"`
}
type Config ¶
type Config struct {
// UserConfig
SavePassword bool `json:"save_password,omitempty"`
SavedPassword string `json:"saved_password,omitempty"`
PasswordTip string `json:"password_tip,omitempty"`
PasswordTipUnlock string `json:"password_tip_unlock,omitempty"`
// Technical
IdentityFile string `json:"identity_file,omitempty"`
StoragePath string `json:"storage_path,omitempty"`
MaxIdsPerUser int `json:"max_ids_per_user,omitempty"`
MsgDbRollingPeriod int `json:"msg_db_rolling_period,omitempty"`
Chunksize int64 `json:"chunksize,omitempty"`
DbSize int `json:"db_size,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
// Network
ServerPollInterval int `json:"server_poll_interval,omitempty"`
HttpTimeOut int `json:"http_timeout,omitempty"`
HttpLongPoll int `json:"http_long_poll,omitempty"`
// GUI
LastOpenChat string `json:"last_open_chat,omitempty"`
SoundNotificationEnable bool `json:"sound_notification_enable,omitempty"`
DefaultNotificationSound string `json:"default_notification_sound,omitempty"`
NotificationVibeEnable bool `json:"notification_vibe_enable,omitempty"`
DefaultNotificationVibe string `json:"default_notification_vibe,omitempty"`
NotificationLEDEnable bool `json:"notification_led_enable,omitempty"`
DefaultNotificationLEDColor string `json:"default_notification_led_color,omitempty"`
VisualNotificationEnable bool `json:"visual_notification_enable,omitempty"`
VisualNotificationModes string `json:"visual_notifiaction_modes,omitempty"`
PrivateChatNotificationsEnable bool `json:"private_chat_notifiactions_enable,omitempty"`
GroupChatNotificationsEnable bool `json:"group_chat_notifiactions_enable,omitempty"`
ChannelNotificationsEnable bool `json:"channel_notifications_enable,omitempty"`
Language string `json:"language,omitempty"`
Theme string `json:"theme,omitempty"`
FingerprintEnable bool `json:"fingerprint_enable,omitempty"`
ShowFavoriteContacts bool `json:"show_favorite_contacts,omitempty"`
NightModeEnable bool `json:"night_mode_enable,omitempty"`
// Debug
DbSuffix string `json:"db_suffix,omitempty"`
// contains filtered or unexported fields
}
func (*Config) AddAdditionalPassword ¶
AddAdditionalPassword securely stores an additional password in protected memory
func (*Config) ClearAdditionalPasswords ¶
func (c *Config) ClearAdditionalPasswords()
ClearAdditionalPasswords removes and destroys all additional passwords
func (*Config) GetAdditionalPasswordAt ¶
GetAdditionalPasswordAt returns the password at the specified index
func (*Config) GetAdditionalPasswords ¶
GetAdditionalPasswords returns all additional passwords as strings
func (*Config) GetIdentity ¶
func (*Config) GetMemPass ¶
func (*Config) RemoveAdditionalPasswordAt ¶
RemoveAdditionalPasswordAt removes and destroys the password at the specified index
func (*Config) SaveIdentity ¶
func (*Config) SetIdentity ¶
func (*Config) SetMemPass ¶
type Identity ¶
type Identity struct {
Nickname string `json:"nickname,omitempty"`
DefaultAvatar string `json:"default_avatar,omitempty"`
Avatars []Avatar `json:"avatars,omitempty"`
RootKp *meowlib.KeyPair `json:"id_kp,omitempty"`
Status string `json:"status,omitempty"`
Peers PeerStorage `json:"peers,omitempty"`
HiddenPeers [][]byte `json:"hidden_peers,omitempty"`
Personae PeerList `json:"faces,omitempty"`
Device *meowlib.KeyPair `json:"device,omitempty"`
KnownServers ServerList `json:"known_servers,omitempty"`
MessageServers ServerStorage `json:"message_servers,omitempty"`
DefaultDbPassword string `json:"default_db_password,omitempty"`
DbPasswordStore bool `json:"db_password_store,omitempty"`
OwnedDevices PeerList `json:"owned_devices,omitempty"`
StaticMtkServerPaths []ServerList `json:"static_mtk_server_paths,omitempty"`
DynamicMtkServeRules []string `json:"dynamic_mtk_serve_rules,omitempty"`
InvitationTimeout int `json:"invitation_timeout,omitempty"`
Uuid string `json:"uuid,omitempty"`
// contains filtered or unexported fields
}
func CreateIdentity ¶
func LoadIdentity ¶
LoadIdentity loads an identity from an encrypted file
func (*Identity) CheckInvitation ¶
func (id *Identity) CheckInvitation(ReceivedContact *meowlib.ContactCard) (isAnswer bool, proposedNick string, receivedNick string, invitationMessage string)
CheckInvitation checks if the received ContactCard is an answer to one of our pending invitations. Returns true when it is, with the proposed and received nicknames.
func (*Identity) CreateFolder ¶
func (*Identity) GetRequestJobs ¶
func (id *Identity) GetRequestJobs() []RequestsJob
func (*Identity) InvitationStep1 ¶
func (id *Identity) InvitationStep1(MyName string, ContactName string, MessageServerUids []string, InvitationMessage string) (*meowlib.InvitationInitPayload, *Peer, error)
InvitationStep1 creates a minimal pending peer with only a temporary keypair and returns the InvitationInitPayload to be transmitted to the invitee (via file, QR code, or server). Full keypairs are only generated in InvitationStep3, after the invitee's answer is received.
func (*Identity) InvitationStep2 ¶
func (id *Identity) InvitationStep2(MyName string, ContactName string, MessageServerUids []string, payload *meowlib.InvitationInitPayload) (*Peer, error)
InvitationStep2 creates the invitee's peer entry from the received InvitationInitPayload and returns the peer. The invitee generates their full keypairs here. The initiator's temporary public key (payload.PublicKey) is used both as the encryption target for the step-2 answer and as the server-side lookup address.
func (*Identity) InvitationStep3 ¶
func (id *Identity) InvitationStep3(inviteeContact *meowlib.ContactCard) (*meowlib.ContactCard, *Peer, error)
InvitationStep3 is called by the initiator after receiving and decrypting the invitee's ContactCard (step-2 answer). It generates the initiator's full keypairs and DR material, updates the pending peer with the invitee's contact info, and returns the initiator's full ContactCard to be sent to the invitee (STEP_3_SEND).
func (*Identity) InvitationStep4 ¶
func (id *Identity) InvitationStep4(initiatorContact *meowlib.ContactCard) error
InvitationStep4 is called by the invitee upon receiving the initiator's full ContactCard (carried as a regular UserMessage with invitation.step=3). It finalizes the peer entry.
func (*Identity) SaveCheckJobs ¶
func (*Identity) TryUnlockHidden ¶
func (*Identity) WipeFolder ¶
type InternalUserMessage ¶
type InternalUserMessage struct {
Outbound bool `json:"outbound"`
Messagetype string `json:"messagetype,omitempty"`
Message string `json:"message,omitempty"`
Status *meowlib.ConversationStatus `json:"conversation_status,omitempty"`
Contact *meowlib.ContactCard `json:"contact,omitempty"`
ServerDeliveryUuid string `json:"server_delivery_uuid,omitempty"`
ServerDeliveryTimestamp uint64 `json:"server_delivery_timestamp,omitempty"`
//Group group
FilePaths []string `json:"file_paths,omitempty"`
CurrentLocation *meowlib.Location `json:"current_location,omitempty"`
Appdata []byte `json:"appdata,omitempty"`
Dbfile string `json:"dbfile,omitempty"`
Dbid int64 `json:"dbid,omitempty"`
}
func DbMessageToInternalUserMessage ¶
func DbMessageToInternalUserMessage(id int64, dbFile string, dbm *meowlib.DbMessage) *InternalUserMessage
func InternalUserMessageFromUserMessage ¶
func InternalUserMessageFromUserMessage(peer *Peer, msg *meowlib.UserMessage) *InternalUserMessage
InternalUserMessageFromUserMessage creates an InternalUserMessage from a UserMessage
type Peer ¶
type Peer struct {
Uid string `json:"uid,omitempty"`
Name string `json:"name,omitempty"`
Avatar string `json:"avatar,omitempty"`
Avatars []Avatar `json:"avatars,omitempty"`
MyName string `json:"my_name,omitempty"`
MyAvatar string `json:"my_avatar,omitempty"`
// Conversation []InternalMessage `json:"conversation,omitempty"`
// My own keys for that peer
MyIdentity *meowlib.KeyPair `json:"my_identity,omitempty"`
MyEncryptionKp *meowlib.KeyPair `json:"my_encryption_kp,omitempty"`
MyLookupKp *meowlib.KeyPair `json:"my_lookup_kp,omitempty"`
MySymKey string `json:"my_sym_key,omitempty"`
MyPullServers []string `json:"my_pull_servers,omitempty"`
// Peer keys and infos
//Contact meowlib.ContactCard `json:"contact,omitempty"` // todo : remove
ContactPublicKey string `json:"contact_public_key,omitempty"`
ContactLookupKey string `json:"contact_lookup_key,omitempty"`
ContactEncryption string `json:"contact_encryption,omitempty"`
ContactPullServers []string `json:"contact_pull_servers,omitempty"`
InvitationId string `json:"invitation_id,omitempty"`
InvitationUrl string `json:"invitation_url,omitempty"`
InvitationMessage string `json:"invitation_message,omitempty"`
InvitationExpiry time.Time `json:"invitation_expiry,omitempty"`
LastMessage *InternalUserMessage `json:"last_message,omitempty"`
// Internal management attributes
Visible bool `json:"visible,omitempty"`
SendDeliveryAck bool `json:"send_delivery_ack,omitempty"`
SendProcessingAck bool `json:"send_processing_ack,omitempty"`
VisiblePassword string `json:"visible_password,omitempty"`
PasswordType string `json:"password_type,omitempty"`
Blocked bool `json:"blocked,omitempty"`
MessageNotification string `json:"message_notification,omitempty"`
MatriochkaMode bool `json:"matriochka_mode,omitempty"`
ServerDeliveryInfo bool `json:"server_delivery_info,omitempty"`
CallsAllowed bool `json:"calls_allowed,omitempty"`
DirectMode bool `json:"direct_mode,omitempty"`
DbIds []string `json:"db_ids,omitempty"`
Type string `json:"type,omitempty"`
PersonnaeDbId string `json:"personnae_db_id,omitempty"`
// Invitation temporary keypair (step 1 only — discarded after step 3)
InvitationKp *meowlib.KeyPair `json:"invitation_kp,omitempty"`
// Double Ratchet state
DrKpPublic string `json:"dr_kp_public,omitempty"`
DrKpPrivate string `json:"dr_kp_private,omitempty"`
DrRootKey string `json:"dr_root_key,omitempty"`
DrInitiator bool `json:"dr_initiator,omitempty"`
ContactDrPublicKey string `json:"contact_dr_public_key,omitempty"`
DrStateJson string `json:"dr_state_json,omitempty"`
// contains filtered or unexported fields
}
Peer manages the peer messaging functions
- Building simple user messages
- Utility functions for packing/unpacking, encrypting/decrypting messages for peer communication
- Peer might be of type "contact" "group" "personnae" "channel" "device" "sensor"
func (*Peer) AsymDecryptMessage ¶
func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMessage []byte, err error)
AsymDecryptMessage reads a message from a specific peer contact
func (*Peer) AsymEncryptMessage ¶
func (p *Peer) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, error)
AsymEncryptMessage prepares a message to send to a specific peer contact
func (*Peer) BuildInvitationStep2Message ¶
func (p *Peer) BuildInvitationStep2Message(myContactCard *meowlib.ContactCard) (*meowlib.UserMessage, error)
BuildInvitationStep2Message builds the invitee's answer UserMessage (STEP_2_SEND). The ContactCard is encrypted with the initiator's temp public key via ProcessOutboundUserMessage.
func (*Peer) BuildInvitationStep3Message ¶
func (p *Peer) BuildInvitationStep3Message(myContactCard *meowlib.ContactCard) (*meowlib.UserMessage, error)
BuildInvitationStep3Message builds the initiator's full ContactCard UserMessage (STEP_3_SEND). Sent through the invitee's servers after the initiator has finalized their keypairs.
func (*Peer) BuildInvitationStep4Message ¶
func (p *Peer) BuildInvitationStep4Message() (*meowlib.UserMessage, error)
BuildInvitationStep4Message builds the invitee's confirmation UserMessage (STEP_4). Sent through the initiator's servers to signal the invitation is complete.
func (*Peer) BuildSimpleUserMessage ¶
func (p *Peer) BuildSimpleUserMessage(message []byte) (*meowlib.UserMessage, error)
func (*Peer) BuildSingleFileMessage ¶
func (*Peer) DeserializeUserMessage ¶
func (p *Peer) DeserializeUserMessage(data []byte) (*meowlib.UserMessage, error)
func (*Peer) GetContact ¶
func (p *Peer) GetContact() *meowlib.ContactCard
func (*Peer) GetConversationRequest ¶
func (p *Peer) GetConversationRequest() *meowlib.ConversationRequest
func (*Peer) GetDRSession ¶
func (p *Peer) GetDRSession() (doubleratchet.Session, error)
GetDRSession returns an active DR session for the peer, creating one if needed.
func (*Peer) GetDbPassword ¶
func (*Peer) GetLastMessageUuid ¶
func (*Peer) GetMyContact ¶
func (p *Peer) GetMyContact() *meowlib.ContactCard
func (*Peer) InvitationPending ¶
func (*Peer) LoadMessage ¶
func (p *Peer) LoadMessage(uid string) (*InternalUserMessage, error)
func (*Peer) LoadMessagesHistory ¶
func (*Peer) LoadNewMessages ¶
func (p *Peer) LoadNewMessages(lastMessageId int) ([]*InternalUserMessage, error)
func (*Peer) PackUserMessage ¶
func (p *Peer) PackUserMessage(message []byte, signature []byte) *meowlib.PackedUserMessage
PackUserMessage will package the previously encrypted message
func (*Peer) ProcessInboundStep2UserMessage ¶
func (p *Peer) ProcessInboundStep2UserMessage(packed *meowlib.PackedUserMessage, inviteePublicKey string) (*meowlib.UserMessage, error)
ProcessInboundStep2UserMessage decrypts the invitee's step-2 answer using the initiator's temporary InvitationKp private key. inviteePublicKey is the sender's identity public key (carried in Invitation.From by the server).
func (*Peer) ProcessInboundStep3UserMessage ¶
func (p *Peer) ProcessInboundStep3UserMessage(packed *meowlib.PackedUserMessage) (*meowlib.UserMessage, error)
ProcessInboundStep3UserMessage decrypts the initiator's step-3 full ContactCard using the invitee's MyEncryptionKp. Signature verification is skipped because the initiator's identity key is not yet known — it is extracted from the decrypted payload.
func (*Peer) ProcessInboundUserMessage ¶
func (p *Peer) ProcessInboundUserMessage(packed *meowlib.PackedUserMessage) (*meowlib.UserMessage, error)
ProcessInboundUserMessage is a helper function that decrypts and deserializes a user message
func (*Peer) ProcessOutboundUserMessage ¶
func (p *Peer) ProcessOutboundUserMessage(usermessage *meowlib.UserMessage) (*meowlib.PackedUserMessage, error)
ProcessOutboundUserMessage is a helper function that serializes, encrypts and packs a user message
func (*Peer) SerializeUserMessage ¶
func (p *Peer) SerializeUserMessage(msg *meowlib.UserMessage) ([]byte, error)
func (*Peer) SetDbPassword ¶
SetDbPassword sets a specific password for a hidden user, it won't be saved, but kept in memory only for the next operations
func (*Peer) StoreMessage ¶
func (p *Peer) StoreMessage(msg *meowlib.UserMessage, filenames []string) error
func (*Peer) SymDecryptPayload ¶
SymDecryptPayload removes the outer symmetric encryption layer. If MySymKey is empty, data is returned unchanged.
func (*Peer) SymEncryptPayload ¶
SymEncryptPayload applies the shared symmetric key over already-encrypted data. If MySymKey is empty, data is returned unchanged (peer has no symkey configured).
func (*Peer) UnPackUserMessage ¶
func (p *Peer) UnPackUserMessage(protoPackedMessage []byte) (payload []byte, signature []byte, err error)
UnPackUserMessage unpacks a user message
func (*Peer) UpdateMessage ¶
func (p *Peer) UpdateMessage(msg InternalUserMessage) error
type PeerList ¶
type PeerList []*Peer
func (*PeerList) GetFromInvitationId ¶
func (*PeerList) GetFromMyLookupKey ¶
func (*PeerList) GetFromName ¶
func (*PeerList) GetFromPublicKey ¶
type PeerStorage ¶
type PeerStorage struct {
DbFile string `json:"db_file,omitempty"`
// contains filtered or unexported fields
}
func (*PeerStorage) CheckInvitation ¶
func (ps *PeerStorage) CheckInvitation(ReceivedContact *meowlib.ContactCard) (isAnswer bool, proposedNick string, receivedNick string, invitationMessage string)
CheckInvitation checks if the received contact card is an answer to an invitation.
func (*PeerStorage) DeletePeer ¶
func (ps *PeerStorage) DeletePeer(uid string) error
DeletePeer deletes a Peer from the Badger database with Peer.GetUid() as key.
func (*PeerStorage) FinalizeInvitation ¶
func (ps *PeerStorage) FinalizeInvitation(ReceivedContact *meowlib.ContactCard) error
FinalizeInvitation completes an invitation handshake and persists the updated peer.
func (*PeerStorage) GetFromInvitationId ¶
func (ps *PeerStorage) GetFromInvitationId(invitationId string) *Peer
func (*PeerStorage) GetFromMyLookupKey ¶
func (ps *PeerStorage) GetFromMyLookupKey(publickey string) *Peer
func (*PeerStorage) GetFromName ¶
func (ps *PeerStorage) GetFromName(name string) *Peer
func (*PeerStorage) GetFromPublicKey ¶
func (ps *PeerStorage) GetFromPublicKey(publickey string) *Peer
func (*PeerStorage) GetFromUid ¶
func (ps *PeerStorage) GetFromUid(uid string) *Peer
func (*PeerStorage) GetPeers ¶
func (ps *PeerStorage) GetPeers() ([]*Peer, error)
GetPeers returns all peers from the cache as a sorted slice.
func (*PeerStorage) LoadPeer ¶
func (ps *PeerStorage) LoadPeer(uid string, password string) (*Peer, error)
LoadPeer loads a Peer from the Badger database with Peer.GetUid() as key.
func (*PeerStorage) LoadPeers ¶
func (ps *PeerStorage) LoadPeers(password string) ([]*Peer, error)
LoadPeers loads all Peers from the Badger database and populates the cache.
func (*PeerStorage) NameExists ¶
func (ps *PeerStorage) NameExists(name string) bool
func (*PeerStorage) StorePeer ¶
func (ps *PeerStorage) StorePeer(peer *Peer) error
StorePeer stores a peer in the Badger database with Peer.Uid as key.
type RequestsJob ¶
type SendJob ¶
type SendJob struct {
// --- caller-supplied fields ---
Queue string `json:"queue,omitempty"` // uid of destination peer, used for naming the queue sqlite db
File string `json:"file,omitempty"` // outbox file path; basename must be {dbFile}_{dbId}
Servers []Server `json:"servers,omitempty"`
Timeout int `json:"timeout,omitempty"` // seconds; 0 = no timeout
// --- DB-managed tracking fields (not serialised by the caller) ---
ID int64
InsertedAt time.Time
Status SendStatus
SentAt *time.Time
Retries []int // retry count per server index
SuccessfulServer *int // index into Servers of the server that accepted
}
SendJob describes a message to send, together with its delivery tracking state.
The File field holds the path to an outbox file written by CreateUserMessageAndSendJob. It must follow the naming convention outbox/{dbFile}_{dbId} so that ProcessSentMessages can recover the message DB location from the filename alone. Servers is tried in order; after MaxRetriesPerServer failures on one server the next one is attempted.
Tracking fields (ID, InsertedAt, Status, SentAt, Retries, SuccessfulServer) are managed by the queue functions and must not be set by the caller.
func GetSendJob ¶
GetSendJob retrieves any job by row id regardless of its status. Returns nil, nil when no row with that id exists.
func GetSentJobs ¶
GetSentJobs returns all successfully-sent jobs from the named queue, ordered oldest first. Use this to reconcile delivery status with the message store and clean up completed entries.
type SendStatus ¶
type SendStatus int
SendStatus represents the delivery state of a queued send job.
const ( SendStatusPending SendStatus = 0 // waiting to be sent SendStatusSent SendStatus = 1 // successfully delivered SendStatusFailed SendStatus = 2 // all servers exhausted or timed out )
type Server ¶
type Server struct {
//ServerCard meowlib.ServerCard `json:"server_data,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
PublicKey string `json:"public_key,omitempty"`
Url string `json:"url,omitempty"`
Login string `json:"login,omitempty"`
Password string `json:"password,omitempty"`
Presence bool `json:"presence,omitempty"`
LastCheck time.Time `json:"last_check,omitempty"`
Uptime time.Duration `json:"uptime,omitempty"`
UserKp *meowlib.KeyPair `json:"user_kp,omitempty"`
ManagerKp *meowlib.KeyPair `json:"manager_kp,omitempty"`
Country string `json:"country,omitempty"`
AllowedDelay int `json:"allowed_delay,omitempty"`
Backup bool `json:"backup,omitempty"`
WebRTC bool `json:"webrtc,omitempty"`
}
Server manages server related operations
- Sending messages for server usage
- Two first steps of an invitation
- User message sending with UserKp identification
- Messages lookup requests
- Utility functions for packing/unpacking, encrypting/decrypting messages for server communication
- Server remote management if ManagerKp is available for that server
func CreateServerFromInvitationLink ¶
CreateServerFromInvitationLink creates a server from a meow url, ex : meow://mylogin:mypassword@https://my.meowserver.example:8443/meow?invitationCode
func CreateServerFromMeowUrl ¶
CreateServerFromMeowUrl creates a server from a meow url, ex : meow://mylogin:mypassword@https://my.meowserver.example:8443/meow/
func CreateServerFromServerCard ¶
func CreateServerFromServerCard(server *meowlib.ServerCard) (*Server, error)
Create a server from a server card
func CreateServerFromUid ¶
CreateServerFromUid creates a server from a uid string, ex : mylogin:mypassword@https://my.meowserver.example:8443/meow/
func CreateServerFromUrl ¶
CreateServerFromUrl creates a server from a basic url, ex : https://my.meowserver.example:8443/meow/
func (*Server) AsymDecryptMessage ¶
func (ints *Server) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMessage []byte, err error)
AsymDecryptMessage reads a message from a specific internal server
func (*Server) AsymEncryptMessage ¶
func (ints *Server) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, error)
AsymEncryptMessage prepares a message to send to a specific internal server
func (*Server) BuildMessageRequestMessage ¶
! Unfinished unused ? BuildMessageRequestMessage creates a message lookup message to server and returns it as protobuf serialized byte array
func (*Server) BuildMessageSendingMessage ¶
func (ints *Server) BuildMessageSendingMessage(usermsg *meowlib.PackedUserMessage) ([]byte, error)
BuildMessageSendingMessage creates a basic message to server from a single packed user message and returns it as protobuf serialized byte array
func (*Server) BuildToServerMessageFromUserMessage ¶
func (ints *Server) BuildToServerMessageFromUserMessage(usermsg *meowlib.PackedUserMessage) *meowlib.ToServerMessage
BuildToServerMessageFromUserMessage creates a basic message to server from a single packed user message and returns a meowlib.ToServerMessage
func (*Server) BuildToServerMessageInvitationAnswer ¶
func (ints *Server) BuildToServerMessageInvitationAnswer(invitationAnswer *meowlib.PackedUserMessage, myPublicKeyForThatPeer string, invitation_id string, timeout int) (*meowlib.ToServerMessage, error)
BuildToServerMessageInvitationAnswer creates an invitation answer to server and returns it as a meowlib.ToServerMessage it takes as input a contactcard generated by Identity.InvitePeer
func (*Server) BuildToServerMessageInvitationAnswerRequest ¶
func (ints *Server) BuildToServerMessageInvitationAnswerRequest(invitationId string) (*meowlib.ToServerMessage, error)
BuildToServerMessageInvitationAnswerRequest requests invitation answer with provided id from server and returns it as a meowlib.ToServerMessage
func (*Server) BuildToServerMessageInvitationRequest ¶
func (ints *Server) BuildToServerMessageInvitationRequest(shortcode string, password string) (*meowlib.ToServerMessage, error)
BuildToServerMessageInvitationRequest requests invitation with provided id from server and returns it as a meowlib.ToServerMessage
func (*Server) BuildToServerMessageInvitationStep1 ¶
func (ints *Server) BuildToServerMessageInvitationStep1(initPayload *meowlib.InvitationInitPayload, password string, timeout int, shortCodeLen int) (*meowlib.ToServerMessage, error)
BuildToServerMessageInvitationStep1 sends the InvitationInitPayload to the server (STEP_1). The server stores it and returns a shortcode URL.
func (*Server) BuildVideoRoomRequestMessage ¶
func (ints *Server) BuildVideoRoomRequestMessage(users []string, expiry uint64) (*meowlib.ToServerMessage, error)
BuildVideoRoomRequestMessage creates a video room request to server and returns it as protobuf serialized byte array
func (*Server) GetMeowUrl ¶
func (*Server) GetServerCard ¶
func (ints *Server) GetServerCard() *meowlib.ServerCard
GetServerCard returns a server card from a server
func (*Server) PackServerMessage ¶
func (ints *Server) PackServerMessage(payload []byte, signature []byte) (protoPackedMessage []byte, err error)
PackServerMessage
func (*Server) ProcessInboundServerResponse ¶
func (srv *Server) ProcessInboundServerResponse(msg []byte) (*meowlib.FromServerMessage, error)
func (*Server) ProcessOutboundMessage ¶
func (srv *Server) ProcessOutboundMessage(toServerMessage *meowlib.ToServerMessage) ([]byte, error)
type ServerList ¶
type ServerList struct {
Name string `json:"name,omitempty"`
Servers []*Server `json:"servers,omitempty"`
}
ServerList manages lists that are used in Identity
- Message servers list
- ArchiveServers lists
- Owned servers lists
- Matriochka paths
func (*ServerList) AddUrls ¶
func (sl *ServerList) AddUrls(urls []string) error
AddUrls is a simple utility functon used mainly as a shortcut for testing purposes
func (*ServerList) FilterByIdxs ¶
func (sl *ServerList) FilterByIdxs(MessageServerIdxs []int) (filtered *ServerList, err error)
FilterByIdxs returns a filtered server list filtered according to an index list
func (*ServerList) GetServerByIdx ¶
func (sl *ServerList) GetServerByIdx(idx int) (server *Server, err error)
GetServerByIdx returns a server from it's index
func (*ServerList) GetServerByPubkey ¶
func (sl *ServerList) GetServerByPubkey(pubkey string) (filtered *Server)
GetServerByPubkey returns a server from it's public key
type ServerStorage ¶
type ServerStorage struct {
DbFile string `json:"db_file,omitempty"`
// contains filtered or unexported fields
}
func (*ServerStorage) DeleteServer ¶
func (ss *ServerStorage) DeleteServer(uid string) error
DeleteServer deletes a Server from the Badger database by uid.
func (*ServerStorage) LoadAllServerCards ¶
func (ss *ServerStorage) LoadAllServerCards() ([]*meowlib.ServerCard, error)
LoadAllServerCards loads all ServerCards from the Badger database.
func (*ServerStorage) LoadAllServers ¶
func (ss *ServerStorage) LoadAllServers() ([]*Server, error)
LoadAllServers loads all Servers from the Badger database.
func (*ServerStorage) LoadServer ¶
func (ss *ServerStorage) LoadServer(uid string) (*Server, error)
LoadServer loads a Server from the Badger database by uid.
func (*ServerStorage) LoadServerCardsFromUids ¶
func (ss *ServerStorage) LoadServerCardsFromUids(uids []string) ([]*meowlib.ServerCard, error)
LoadServerCardsFromUids loads ServerCards whose UIDs are in the provided slice.
func (*ServerStorage) LoadServersFromUids ¶
func (ss *ServerStorage) LoadServersFromUids(uids []string) ([]*Server, error)
LoadServersFromUids loads Servers whose UIDs are in the provided slice.
func (*ServerStorage) ServerExists ¶
func (ss *ServerStorage) ServerExists(sc *Server) (bool, error)
ServerExists checks if a server exists in the Badger database.
func (*ServerStorage) StoreServer ¶
func (ss *ServerStorage) StoreServer(sc *Server) error
StoreServer stores a server in the Badger database with Server.GetUid() as key.
func (*ServerStorage) StoreServerIfNotExists ¶
func (ss *ServerStorage) StoreServerIfNotExists(sc *Server) error
StoreServerIfNotExists stores a server only if it is not already present.