| Copyright | (c) simplex.chat |
|---|---|
| License | AGPL-3 |
| Maintainer | chat@simplex.chat |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Simplex.Messaging.Agent
Contents
Description
This module defines SMP protocol agent with SQLite persistence.
See https://github.com/simplex-chat/simplexmq/blob/master/protocol/agent-protocol.md
Synopsis
- data AgentClient = AgentClient {
- acThread :: TVar (Maybe (Weak ThreadId))
- active :: TVar Bool
- subQ :: TBQueue ATransmission
- msgQ :: TBQueue (ServerTransmissionBatch SMPVersion ErrorType BrokerMsg)
- smpServers :: TMap UserId (UserServers 'PSMP)
- smpClients :: TMap SMPTransportSession SMPClientVar
- smpProxiedRelays :: TMap SMPTransportSession SMPServerWithAuth
- ntfServers :: TVar [NtfServer]
- ntfClients :: TMap NtfTransportSession NtfClientVar
- xftpServers :: TMap UserId (UserServers 'PXFTP)
- xftpClients :: TMap XFTPTransportSession XFTPClientVar
- useNetworkConfig :: TVar (NetworkConfig, NetworkConfig)
- presetDomains :: [HostName]
- presetServers :: [SMPServer]
- userNetworkInfo :: TVar UserNetworkInfo
- userNetworkUpdated :: TVar (Maybe UTCTime)
- subscrConns :: TVar (Set ConnId)
- currentSubs :: TSessionSubs
- removedSubs :: TMap (UserId, SMPServer) (TMap RecipientId SMPClientError)
- clientNotices :: TMap (Maybe SMPServer) (Maybe SystemSeconds)
- clientNoticesLock :: TMVar ()
- workerSeq :: TVar Int
- smpDeliveryWorkers :: TMap SndQAddr (Worker, TMVar ())
- asyncCmdWorkers :: TMap (ConnId, Maybe SMPServer) Worker
- ntfNetworkOp :: TVar AgentOpState
- rcvNetworkOp :: TVar AgentOpState
- msgDeliveryOp :: TVar AgentOpState
- sndNetworkOp :: TVar AgentOpState
- databaseOp :: TVar AgentOpState
- agentState :: TVar AgentState
- getMsgLocks :: TMap (SMPServer, RecipientId) (TMVar ())
- connLocks :: TMap ConnId Lock
- invLocks :: TMap ByteString Lock
- deleteLock :: Lock
- smpSubWorkers :: TMap SMPTransportSession (SessionVar (Async ()))
- clientId :: Int
- agentEnv :: Env
- proxySessTs :: TVar UTCTime
- smpServersStats :: TMap (UserId, SMPServer) AgentSMPServerStats
- xftpServersStats :: TMap (UserId, XFTPServer) AgentXFTPServerStats
- ntfServersStats :: TMap (UserId, NtfServer) AgentNtfServerStats
- srvStatsStartedAt :: TVar UTCTime
- type AE a = ExceptT AgentErrorType IO a
- data SubscriptionsInfo = SubscriptionsInfo {}
- type MsgReq = (ConnId, PQEncryption, MsgFlags, ValueOrRef MsgBody)
- data ValueOrRef a
- vrValue :: a -> ValueOrRef a
- getSMPAgentClient :: AgentConfig -> InitialAgentServers -> DBStore -> Bool -> IO AgentClient
- getSMPAgentClient_ :: Int -> AgentConfig -> InitialAgentServers -> DBStore -> Bool -> IO AgentClient
- disconnectAgentClient :: AgentClient -> IO ()
- disposeAgentClient :: AgentClient -> IO ()
- resumeAgentClient :: AgentClient -> IO ()
- withConnLock :: AgentClient -> ConnId -> Text -> AM a -> AM a
- withInvLock :: AgentClient -> ByteString -> Text -> AM a -> AM a
- createUser :: AgentClient -> NonEmpty (ServerCfg 'PSMP) -> NonEmpty (ServerCfg 'PXFTP) -> AE UserId
- deleteUser :: AgentClient -> UserId -> Bool -> AE ()
- connRequestPQSupport :: AgentClient -> PQSupport -> ConnectionRequestUri c -> IO (Maybe (VersionSMPA, PQSupport))
- createConnectionAsync :: ConnectionModeI c => AgentClient -> UserId -> ACorrId -> Bool -> SConnectionMode c -> InitialKeys -> SubscriptionMode -> AE ConnId
- setConnShortLinkAsync :: AgentClient -> ACorrId -> ConnId -> UserConnLinkData 'CMContact -> Maybe CRClientData -> AE ()
- getConnShortLinkAsync :: AgentClient -> UserId -> ACorrId -> Maybe ConnId -> ConnShortLink 'CMContact -> AE ConnId
- joinConnectionAsync :: AgentClient -> UserId -> ACorrId -> Maybe ConnId -> Bool -> ConnectionRequestUri c -> ConnInfo -> PQSupport -> SubscriptionMode -> AE ConnId
- allowConnectionAsync :: AgentClient -> ACorrId -> ConnId -> ConfirmationId -> ConnInfo -> AE ()
- acceptContactAsync :: AgentClient -> UserId -> ACorrId -> Bool -> ConfirmationId -> ConnInfo -> PQSupport -> SubscriptionMode -> AE ConnId
- ackMessageAsync :: AgentClient -> ACorrId -> ConnId -> AgentMsgId -> Maybe MsgReceiptInfo -> AE ()
- switchConnectionAsync :: AgentClient -> ACorrId -> ConnId -> AE ConnectionStats
- deleteConnectionAsync :: AgentClient -> Bool -> ConnId -> AE ()
- deleteConnectionsAsync :: AgentClient -> Bool -> [ConnId] -> AE ()
- createConnection :: ConnectionModeI c => AgentClient -> NetworkRequestMode -> UserId -> Bool -> Bool -> SConnectionMode c -> Maybe (UserConnLinkData c) -> Maybe CRClientData -> InitialKeys -> SubscriptionMode -> AE (ConnId, (CreatedConnLink c, Maybe ClientServiceId))
- prepareConnectionLink :: AgentClient -> UserId -> KeyPairEd25519 -> ByteString -> Bool -> Maybe CRClientData -> AE (CreatedConnLink 'CMContact, PreparedLinkParams)
- createConnectionForLink :: AgentClient -> NetworkRequestMode -> UserId -> Bool -> CreatedConnLink 'CMContact -> PreparedLinkParams -> UserConnLinkData 'CMContact -> InitialKeys -> SubscriptionMode -> AE ConnId
- setConnShortLink :: AgentClient -> NetworkRequestMode -> ConnId -> SConnectionMode c -> UserConnLinkData c -> Maybe CRClientData -> AE (ConnShortLink c)
- deleteConnShortLink :: AgentClient -> NetworkRequestMode -> ConnId -> SConnectionMode c -> AE ()
- getConnShortLink :: AgentClient -> NetworkRequestMode -> UserId -> ConnShortLink c -> AE (FixedLinkData c, ConnLinkData c)
- getConnLinkPrivKey :: AgentClient -> ConnId -> AE (Maybe PrivateKeyEd25519)
- deleteLocalInvShortLink :: AgentClient -> ConnShortLink 'CMInvitation -> AE ()
- changeConnectionUser :: AgentClient -> UserId -> ConnId -> UserId -> AE ()
- prepareConnectionToJoin :: AgentClient -> UserId -> Bool -> ConnectionRequestUri c -> PQSupport -> AE ConnId
- prepareConnectionToAccept :: AgentClient -> UserId -> Bool -> ConfirmationId -> PQSupport -> AE ConnId
- joinConnection :: AgentClient -> NetworkRequestMode -> UserId -> ConnId -> Bool -> ConnectionRequestUri c -> ConnInfo -> PQSupport -> SubscriptionMode -> AE (SndQueueSecured, Maybe ClientServiceId)
- allowConnection :: AgentClient -> ConnId -> ConfirmationId -> ConnInfo -> AE ()
- acceptContact :: AgentClient -> NetworkRequestMode -> UserId -> ConnId -> Bool -> ConfirmationId -> ConnInfo -> PQSupport -> SubscriptionMode -> AE (SndQueueSecured, Maybe ClientServiceId)
- rejectContact :: AgentClient -> ConfirmationId -> AE ()
- data DatabaseDiff a = DatabaseDiff {
- missingIds :: [a]
- extraIds :: [a]
- compareConnections :: AgentClient -> [UserId] -> [ConnId] -> AE (DatabaseDiff UserId, DatabaseDiff ConnId)
- syncConnections :: AgentClient -> [UserId] -> [ConnId] -> AE (DatabaseDiff UserId, DatabaseDiff ConnId)
- subscribeConnection :: AgentClient -> ConnId -> AE (Maybe ClientServiceId)
- subscribeConnections :: AgentClient -> [ConnId] -> AE (Map ConnId (Either AgentErrorType (Maybe ClientServiceId)))
- subscribeAllConnections :: AgentClient -> Bool -> Maybe UserId -> AE ()
- getConnectionMessages :: AgentClient -> NonEmpty ConnMsgReq -> IO (NonEmpty (Either AgentErrorType (Maybe SMPMsgMeta)))
- getNotificationConns :: AgentClient -> CbNonce -> ByteString -> AE (NonEmpty NotificationInfo)
- resubscribeConnection :: AgentClient -> ConnId -> AE (Maybe ClientServiceId)
- resubscribeConnections :: AgentClient -> [ConnId] -> AE (Map ConnId (Either AgentErrorType (Maybe ClientServiceId)))
- subscribeClientService :: AgentClient -> ClientServiceId -> AE Int
- sendMessage :: AgentClient -> ConnId -> PQEncryption -> MsgFlags -> MsgBody -> AE (AgentMsgId, PQEncryption)
- sendMessages :: AgentClient -> [MsgReq] -> AE [Either AgentErrorType (AgentMsgId, PQEncryption)]
- sendMessagesB :: Traversable t => AgentClient -> t (Either AgentErrorType MsgReq) -> AE (t (Either AgentErrorType (AgentMsgId, PQEncryption)))
- ackMessage :: AgentClient -> ConnId -> AgentMsgId -> Maybe MsgReceiptInfo -> AE ()
- getConnectionQueueInfo :: AgentClient -> NetworkRequestMode -> ConnId -> AE ServerQueueInfo
- switchConnection :: AgentClient -> NetworkRequestMode -> ConnId -> AE ConnectionStats
- abortConnectionSwitch :: AgentClient -> ConnId -> AE ConnectionStats
- synchronizeRatchet :: AgentClient -> ConnId -> PQSupport -> Bool -> AE ConnectionStats
- suspendConnection :: AgentClient -> NetworkRequestMode -> ConnId -> AE ()
- deleteConnection :: AgentClient -> NetworkRequestMode -> ConnId -> AE ()
- deleteConnections :: AgentClient -> NetworkRequestMode -> [ConnId] -> AE (Map ConnId (Either AgentErrorType ()))
- getConnectionServers :: AgentClient -> ConnId -> AE ConnectionStats
- getConnectionRatchetAdHash :: AgentClient -> ConnId -> AE ByteString
- setProtocolServers :: forall p. (ProtocolTypeI p, UserProtocol p) => AgentClient -> UserId -> NonEmpty (ServerCfg p) -> IO ()
- checkUserServers :: Text -> NonEmpty (ServerCfg p) -> IO ()
- testProtocolServer :: forall p. ProtocolTypeI p => AgentClient -> NetworkRequestMode -> UserId -> ProtoServerWithAuth p -> IO (Maybe ProtocolTestFailure)
- setNtfServers :: AgentClient -> [NtfServer] -> IO ()
- setNetworkConfig :: AgentClient -> NetworkConfig -> IO ()
- setUserNetworkInfo :: AgentClient -> UserNetworkInfo -> IO ()
- reconnectAllServers :: AgentClient -> IO ()
- reconnectSMPServer :: AgentClient -> UserId -> SMPServer -> IO ()
- registerNtfToken :: AgentClient -> NetworkRequestMode -> DeviceToken -> NotificationsMode -> AE NtfTknStatus
- verifyNtfToken :: AgentClient -> NetworkRequestMode -> DeviceToken -> CbNonce -> ByteString -> AE ()
- checkNtfToken :: AgentClient -> NetworkRequestMode -> DeviceToken -> AE NtfTknStatus
- deleteNtfToken :: AgentClient -> DeviceToken -> AE ()
- getNtfToken :: AgentClient -> AE (DeviceToken, NtfTknStatus, NotificationsMode, NtfServer)
- getNtfTokenData :: AgentClient -> AE NtfToken
- toggleConnectionNtfs :: AgentClient -> ConnId -> Bool -> AE ()
- xftpStartWorkers :: AgentClient -> Maybe FilePath -> AE ()
- xftpStartSndWorkers :: AgentClient -> Maybe FilePath -> AE ()
- xftpReceiveFile :: AgentClient -> UserId -> ValidFileDescription 'FRecipient -> Maybe CryptoFileArgs -> Bool -> AE RcvFileId
- xftpDeleteRcvFile :: AgentClient -> RcvFileId -> IO ()
- xftpDeleteRcvFiles :: AgentClient -> [RcvFileId] -> IO ()
- xftpSendFile :: AgentClient -> UserId -> CryptoFile -> Int -> AE SndFileId
- xftpSendDescription :: AgentClient -> UserId -> ValidFileDescription 'FRecipient -> Int -> AE SndFileId
- xftpDeleteSndFileInternal :: AgentClient -> SndFileId -> IO ()
- xftpDeleteSndFilesInternal :: AgentClient -> [SndFileId] -> IO ()
- xftpDeleteSndFileRemote :: AgentClient -> UserId -> SndFileId -> ValidFileDescription 'FSender -> IO ()
- xftpDeleteSndFilesRemote :: AgentClient -> UserId -> [(SndFileId, ValidFileDescription 'FSender)] -> IO ()
- rcNewHostPairing :: AgentClient -> IO RCHostPairing
- rcConnectHost :: AgentClient -> RCHostPairing -> Value -> Bool -> Maybe RCCtrlAddress -> Maybe Word16 -> AE RCHostConnection
- rcConnectCtrl :: AgentClient -> RCVerifiedInvitation -> Maybe RCCtrlPairing -> Value -> AE RCCtrlConnection
- rcDiscoverCtrl :: AgentClient -> NonEmpty RCCtrlPairing -> AE (RCCtrlPairing, RCVerifiedInvitation)
- getAgentSubsTotal :: AgentClient -> [UserId] -> IO (SMPServerSubs, Bool)
- getAgentServersSummary :: AgentClient -> IO AgentServersSummary
- resetAgentServersStats :: AgentClient -> AE ()
- foregroundAgent :: AgentClient -> IO ()
- suspendAgent :: AgentClient -> Int -> IO ()
- execAgentStoreSQL :: AgentClient -> Text -> AE [Text]
- getAgentMigrations :: AgentClient -> AE [UpMigration]
- debugAgentLocks :: AgentClient -> IO AgentLocks
- getAgentSubscriptions :: AgentClient -> IO SubscriptionsInfo
- logConnection :: AgentClient -> Bool -> IO ()
- withAgentEnv :: AgentClient -> AM a -> AE a
SMP agent functional API
data AgentClient Source #
Constructors
type AE a = ExceptT AgentErrorType IO a Source #
data SubscriptionsInfo Source #
Constructors
| SubscriptionsInfo | |
Fields
| |
Instances
| FromJSON SubscriptionsInfo Source # | |
Defined in Simplex.Messaging.Agent.Client Methods parseJSON :: Value -> Parser SubscriptionsInfo parseJSONList :: Value -> Parser [SubscriptionsInfo] omittedField :: Maybe SubscriptionsInfo | |
| ToJSON SubscriptionsInfo Source # | |
Defined in Simplex.Messaging.Agent.Client Methods toJSON :: SubscriptionsInfo -> Value toEncoding :: SubscriptionsInfo -> Encoding toJSONList :: [SubscriptionsInfo] -> Value toEncodingList :: [SubscriptionsInfo] -> Encoding omitField :: SubscriptionsInfo -> Bool | |
| Show SubscriptionsInfo Source # | |
Defined in Simplex.Messaging.Agent.Client Methods showsPrec :: Int -> SubscriptionsInfo -> ShowS show :: SubscriptionsInfo -> String showList :: [SubscriptionsInfo] -> ShowS | |
type MsgReq = (ConnId, PQEncryption, MsgFlags, ValueOrRef MsgBody) Source #
data ValueOrRef a Source #
Instances
| Functor ValueOrRef Source # | |
Defined in Simplex.Messaging.Agent | |
vrValue :: a -> ValueOrRef a Source #
getSMPAgentClient :: AgentConfig -> InitialAgentServers -> DBStore -> Bool -> IO AgentClient Source #
Creates an SMP agent client instance
getSMPAgentClient_ :: Int -> AgentConfig -> InitialAgentServers -> DBStore -> Bool -> IO AgentClient Source #
disconnectAgentClient :: AgentClient -> IO () Source #
disposeAgentClient :: AgentClient -> IO () Source #
resumeAgentClient :: AgentClient -> IO () Source #
withConnLock :: AgentClient -> ConnId -> Text -> AM a -> AM a Source #
withInvLock :: AgentClient -> ByteString -> Text -> AM a -> AM a Source #
createUser :: AgentClient -> NonEmpty (ServerCfg 'PSMP) -> NonEmpty (ServerCfg 'PXFTP) -> AE UserId Source #
deleteUser :: AgentClient -> UserId -> Bool -> AE () Source #
Delete user record optionally deleting all user's connections on SMP servers
connRequestPQSupport :: AgentClient -> PQSupport -> ConnectionRequestUri c -> IO (Maybe (VersionSMPA, PQSupport)) Source #
createConnectionAsync :: ConnectionModeI c => AgentClient -> UserId -> ACorrId -> Bool -> SConnectionMode c -> InitialKeys -> SubscriptionMode -> AE ConnId Source #
Create SMP agent connection (NEW command) asynchronously, synchronous response is new connection id
setConnShortLinkAsync :: AgentClient -> ACorrId -> ConnId -> UserConnLinkData 'CMContact -> Maybe CRClientData -> AE () Source #
Create or update user's contact connection short link (LSET command) asynchronously, no synchronous response
getConnShortLinkAsync :: AgentClient -> UserId -> ACorrId -> Maybe ConnId -> ConnShortLink 'CMContact -> AE ConnId Source #
Get and verify data from short link (LGETLKEY command) asynchronously, synchronous response is newpassed connection id
joinConnectionAsync :: AgentClient -> UserId -> ACorrId -> Maybe ConnId -> Bool -> ConnectionRequestUri c -> ConnInfo -> PQSupport -> SubscriptionMode -> AE ConnId Source #
Join SMP agent connection (JOIN command) asynchronously, synchronous response is new connection id. If connId is provided (for contact URIs), it updates the existing connection record created by getConnShortLinkAsync.
allowConnectionAsync :: AgentClient -> ACorrId -> ConnId -> ConfirmationId -> ConnInfo -> AE () Source #
Allow connection to continue after CONF notification (LET command), no synchronous response
acceptContactAsync :: AgentClient -> UserId -> ACorrId -> Bool -> ConfirmationId -> ConnInfo -> PQSupport -> SubscriptionMode -> AE ConnId Source #
Accept contact after REQ notification (ACPT command) asynchronously, synchronous response is new connection id
ackMessageAsync :: AgentClient -> ACorrId -> ConnId -> AgentMsgId -> Maybe MsgReceiptInfo -> AE () Source #
Acknowledge message (ACK command) asynchronously, no synchronous response
switchConnectionAsync :: AgentClient -> ACorrId -> ConnId -> AE ConnectionStats Source #
Switch connection to the new receive queue
deleteConnectionAsync :: AgentClient -> Bool -> ConnId -> AE () Source #
Delete SMP agent connection (DEL command) asynchronously, no synchronous response
deleteConnectionsAsync :: AgentClient -> Bool -> [ConnId] -> AE () Source #
Delete SMP agent connections using batch commands asynchronously, no synchronous response
createConnection :: ConnectionModeI c => AgentClient -> NetworkRequestMode -> UserId -> Bool -> Bool -> SConnectionMode c -> Maybe (UserConnLinkData c) -> Maybe CRClientData -> InitialKeys -> SubscriptionMode -> AE (ConnId, (CreatedConnLink c, Maybe ClientServiceId)) Source #
Create SMP agent connection (NEW command)
prepareConnectionLink :: AgentClient -> UserId -> KeyPairEd25519 -> ByteString -> Bool -> Maybe CRClientData -> AE (CreatedConnLink 'CMContact, PreparedLinkParams) Source #
Prepare connection link for contact mode (no network call). Caller provides root signing key pair and link entity ID. Returns the created link and internal params. The link address is fully determined at this point.
createConnectionForLink :: AgentClient -> NetworkRequestMode -> UserId -> Bool -> CreatedConnLink 'CMContact -> PreparedLinkParams -> UserConnLinkData 'CMContact -> InitialKeys -> SubscriptionMode -> AE ConnId Source #
Create connection for prepared link (single network call). Validates that server response matches the prepared link.
setConnShortLink :: AgentClient -> NetworkRequestMode -> ConnId -> SConnectionMode c -> UserConnLinkData c -> Maybe CRClientData -> AE (ConnShortLink c) Source #
Create or update user's contact connection short link
deleteConnShortLink :: AgentClient -> NetworkRequestMode -> ConnId -> SConnectionMode c -> AE () Source #
getConnShortLink :: AgentClient -> NetworkRequestMode -> UserId -> ConnShortLink c -> AE (FixedLinkData c, ConnLinkData c) Source #
Get and verify data from short link. For 1-time invitations it preserves the key to allow retries
getConnLinkPrivKey :: AgentClient -> ConnId -> AE (Maybe PrivateKeyEd25519) Source #
deleteLocalInvShortLink :: AgentClient -> ConnShortLink 'CMInvitation -> AE () Source #
This irreversibly deletes short link data, and it won't be retrievable again
changeConnectionUser :: AgentClient -> UserId -> ConnId -> UserId -> AE () Source #
Changes the user id associated with a connection
prepareConnectionToJoin :: AgentClient -> UserId -> Bool -> ConnectionRequestUri c -> PQSupport -> AE ConnId Source #
Create SMP agent connection without queue (to be joined with joinConnection passing connection ID). This method is required to prevent race condition when confirmation from peer is received before the caller of joinConnection saves connection ID to the database. Instead of it we could send confirmation asynchronously, but then it would be harder to report "link deleted" (SMP AUTH) interactively, so this approach is simpler overall.
prepareConnectionToAccept :: AgentClient -> UserId -> Bool -> ConfirmationId -> PQSupport -> AE ConnId Source #
Create SMP agent connection without queue (to be joined with acceptContact passing invitation ID).
joinConnection :: AgentClient -> NetworkRequestMode -> UserId -> ConnId -> Bool -> ConnectionRequestUri c -> ConnInfo -> PQSupport -> SubscriptionMode -> AE (SndQueueSecured, Maybe ClientServiceId) Source #
Join SMP agent connection (JOIN command).
allowConnection :: AgentClient -> ConnId -> ConfirmationId -> ConnInfo -> AE () Source #
Allow connection to continue after CONF notification (LET command)
acceptContact :: AgentClient -> NetworkRequestMode -> UserId -> ConnId -> Bool -> ConfirmationId -> ConnInfo -> PQSupport -> SubscriptionMode -> AE (SndQueueSecured, Maybe ClientServiceId) Source #
Accept contact after REQ notification (ACPT command)
rejectContact :: AgentClient -> ConfirmationId -> AE () Source #
Reject contact (RJCT command)
data DatabaseDiff a Source #
Constructors
| DatabaseDiff | |
Fields
| |
Instances
| Functor DatabaseDiff Source # | |
Defined in Simplex.Messaging.Agent Methods fmap :: (a -> b) -> DatabaseDiff a -> DatabaseDiff b (<$) :: a -> DatabaseDiff b -> DatabaseDiff a | |
| FromJSON a => FromJSON (DatabaseDiff a) Source # | |
Defined in Simplex.Messaging.Agent Methods parseJSON :: Value -> Parser (DatabaseDiff a) parseJSONList :: Value -> Parser [DatabaseDiff a] omittedField :: Maybe (DatabaseDiff a) | |
| ToJSON a => ToJSON (DatabaseDiff a) Source # | |
Defined in Simplex.Messaging.Agent Methods toJSON :: DatabaseDiff a -> Value toEncoding :: DatabaseDiff a -> Encoding toJSONList :: [DatabaseDiff a] -> Value toEncodingList :: [DatabaseDiff a] -> Encoding omitField :: DatabaseDiff a -> Bool | |
| Show a => Show (DatabaseDiff a) Source # | |
Defined in Simplex.Messaging.Agent Methods showsPrec :: Int -> DatabaseDiff a -> ShowS show :: DatabaseDiff a -> String showList :: [DatabaseDiff a] -> ShowS | |
compareConnections :: AgentClient -> [UserId] -> [ConnId] -> AE (DatabaseDiff UserId, DatabaseDiff ConnId) Source #
syncConnections :: AgentClient -> [UserId] -> [ConnId] -> AE (DatabaseDiff UserId, DatabaseDiff ConnId) Source #
subscribeConnection :: AgentClient -> ConnId -> AE (Maybe ClientServiceId) Source #
Subscribe to receive connection messages (SUB command)
subscribeConnections :: AgentClient -> [ConnId] -> AE (Map ConnId (Either AgentErrorType (Maybe ClientServiceId))) Source #
Subscribe to receive connection messages from multiple connections, batching commands when possible
subscribeAllConnections :: AgentClient -> Bool -> Maybe UserId -> AE () Source #
Subscribe to all connections
getConnectionMessages :: AgentClient -> NonEmpty ConnMsgReq -> IO (NonEmpty (Either AgentErrorType (Maybe SMPMsgMeta))) Source #
Get messages for connections (GET commands)
getNotificationConns :: AgentClient -> CbNonce -> ByteString -> AE (NonEmpty NotificationInfo) Source #
Get connections for received notification
resubscribeConnection :: AgentClient -> ConnId -> AE (Maybe ClientServiceId) Source #
resubscribeConnections :: AgentClient -> [ConnId] -> AE (Map ConnId (Either AgentErrorType (Maybe ClientServiceId))) Source #
subscribeClientService :: AgentClient -> ClientServiceId -> AE Int Source #
sendMessage :: AgentClient -> ConnId -> PQEncryption -> MsgFlags -> MsgBody -> AE (AgentMsgId, PQEncryption) Source #
Send message to the connection (SEND command)
sendMessages :: AgentClient -> [MsgReq] -> AE [Either AgentErrorType (AgentMsgId, PQEncryption)] Source #
Send multiple messages to different connections (SEND command)
sendMessagesB :: Traversable t => AgentClient -> t (Either AgentErrorType MsgReq) -> AE (t (Either AgentErrorType (AgentMsgId, PQEncryption))) Source #
ackMessage :: AgentClient -> ConnId -> AgentMsgId -> Maybe MsgReceiptInfo -> AE () Source #
getConnectionQueueInfo :: AgentClient -> NetworkRequestMode -> ConnId -> AE ServerQueueInfo Source #
switchConnection :: AgentClient -> NetworkRequestMode -> ConnId -> AE ConnectionStats Source #
Switch connection to the new receive queue
abortConnectionSwitch :: AgentClient -> ConnId -> AE ConnectionStats Source #
Abort switching connection to the new receive queue
synchronizeRatchet :: AgentClient -> ConnId -> PQSupport -> Bool -> AE ConnectionStats Source #
Re-synchronize connection ratchet keys
suspendConnection :: AgentClient -> NetworkRequestMode -> ConnId -> AE () Source #
Suspend SMP agent connection (OFF command)
deleteConnection :: AgentClient -> NetworkRequestMode -> ConnId -> AE () Source #
Delete SMP agent connection (DEL command)
deleteConnections :: AgentClient -> NetworkRequestMode -> [ConnId] -> AE (Map ConnId (Either AgentErrorType ())) Source #
Delete multiple connections, batching commands when possible
getConnectionServers :: AgentClient -> ConnId -> AE ConnectionStats Source #
get servers used for connection
getConnectionRatchetAdHash :: AgentClient -> ConnId -> AE ByteString Source #
get connection ratchet associated data hash for verification (should match peer AD hash)
setProtocolServers :: forall p. (ProtocolTypeI p, UserProtocol p) => AgentClient -> UserId -> NonEmpty (ServerCfg p) -> IO () Source #
Change servers to be used for creating new queues. This function will set all servers as enabled in case all passed servers are disabled.
checkUserServers :: Text -> NonEmpty (ServerCfg p) -> IO () Source #
testProtocolServer :: forall p. ProtocolTypeI p => AgentClient -> NetworkRequestMode -> UserId -> ProtoServerWithAuth p -> IO (Maybe ProtocolTestFailure) Source #
Test protocol server
setNtfServers :: AgentClient -> [NtfServer] -> IO () Source #
setNetworkConfig :: AgentClient -> NetworkConfig -> IO () Source #
set SOCKS5 proxy on/off and optionally set TCP timeouts for fast network
setUserNetworkInfo :: AgentClient -> UserNetworkInfo -> IO () Source #
reconnectAllServers :: AgentClient -> IO () Source #
reconnectSMPServer :: AgentClient -> UserId -> SMPServer -> IO () Source #
registerNtfToken :: AgentClient -> NetworkRequestMode -> DeviceToken -> NotificationsMode -> AE NtfTknStatus Source #
Register device notifications token
verifyNtfToken :: AgentClient -> NetworkRequestMode -> DeviceToken -> CbNonce -> ByteString -> AE () Source #
Verify device notifications token
checkNtfToken :: AgentClient -> NetworkRequestMode -> DeviceToken -> AE NtfTknStatus Source #
deleteNtfToken :: AgentClient -> DeviceToken -> AE () Source #
getNtfTokenData :: AgentClient -> AE NtfToken Source #
toggleConnectionNtfs :: AgentClient -> ConnId -> Bool -> AE () Source #
Set connection notifications on/off
xftpStartWorkers :: AgentClient -> Maybe FilePath -> AE () Source #
xftpStartSndWorkers :: AgentClient -> Maybe FilePath -> AE () Source #
xftpReceiveFile :: AgentClient -> UserId -> ValidFileDescription 'FRecipient -> Maybe CryptoFileArgs -> Bool -> AE RcvFileId Source #
Receive XFTP file
xftpDeleteRcvFile :: AgentClient -> RcvFileId -> IO () Source #
Delete XFTP rcv file (deletes work files from file system and db records)
xftpDeleteRcvFiles :: AgentClient -> [RcvFileId] -> IO () Source #
Delete multiple rcv files, batching operations when possible (deletes work files from file system and db records)
xftpSendFile :: AgentClient -> UserId -> CryptoFile -> Int -> AE SndFileId Source #
Send XFTP file
xftpSendDescription :: AgentClient -> UserId -> ValidFileDescription 'FRecipient -> Int -> AE SndFileId Source #
Send XFTP file
xftpDeleteSndFileInternal :: AgentClient -> SndFileId -> IO () Source #
Delete XFTP snd file internally (deletes work files from file system and db records)
xftpDeleteSndFilesInternal :: AgentClient -> [SndFileId] -> IO () Source #
Delete multiple snd files internally, batching operations when possible (deletes work files from file system and db records)
xftpDeleteSndFileRemote :: AgentClient -> UserId -> SndFileId -> ValidFileDescription 'FSender -> IO () Source #
Delete XFTP snd file chunks on servers
xftpDeleteSndFilesRemote :: AgentClient -> UserId -> [(SndFileId, ValidFileDescription 'FSender)] -> IO () Source #
Delete XFTP snd file chunks on servers for multiple snd files, batching operations when possible
rcNewHostPairing :: AgentClient -> IO RCHostPairing Source #
Create new remote host pairing
rcConnectHost :: AgentClient -> RCHostPairing -> Value -> Bool -> Maybe RCCtrlAddress -> Maybe Word16 -> AE RCHostConnection Source #
start TLS server for remote host with optional multicast
rcConnectCtrl :: AgentClient -> RCVerifiedInvitation -> Maybe RCCtrlPairing -> Value -> AE RCCtrlConnection Source #
connect to remote controller via URI
rcDiscoverCtrl :: AgentClient -> NonEmpty RCCtrlPairing -> AE (RCCtrlPairing, RCVerifiedInvitation) Source #
connect to known remote controller via multicast
getAgentSubsTotal :: AgentClient -> [UserId] -> IO (SMPServerSubs, Bool) Source #
resetAgentServersStats :: AgentClient -> AE () Source #
foregroundAgent :: AgentClient -> IO () Source #
Activate operations
suspendAgent :: AgentClient -> Int -> IO () Source #
Suspend operations with max delay to deliver pending messages
execAgentStoreSQL :: AgentClient -> Text -> AE [Text] Source #
getAgentMigrations :: AgentClient -> AE [UpMigration] Source #
debugAgentLocks :: AgentClient -> IO AgentLocks Source #
logConnection :: AgentClient -> Bool -> IO () Source #
withAgentEnv :: AgentClient -> AM a -> AE a Source #