| Copyright | (c) simplex.chat |
|---|---|
| License | AGPL-3 |
| Maintainer | chat@simplex.chat |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Simplex.Messaging.Client
Description
This module provides a functional client API for SMP protocol.
See https://github.com/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md
Synopsis
- type TransportSession msg = (UserId, ProtoServer msg, Maybe ByteString)
- type SMPTransportSession = TransportSession BrokerMsg
- data ProtocolClient v err msg
- type SMPClient = ProtocolClient SMPVersion ErrorType BrokerMsg
- data ProxiedRelay = ProxiedRelay {
- prSessionId :: SessionId
- prVersion :: VersionSMP
- prBasicAuth :: Maybe BasicAuth
- prServerKey :: PublicKeyX25519
- getProtocolClient :: forall v err msg. Protocol v err msg => TVar ChaChaDRG -> NetworkRequestMode -> TransportSession msg -> ProtocolClientConfig v -> [HostName] -> Maybe (TBQueue (ServerTransmissionBatch v err msg)) -> UTCTime -> (ProtocolClient v err msg -> IO ()) -> IO (Either (ProtocolClientError err) (ProtocolClient v err msg))
- closeProtocolClient :: ProtocolClient v err msg -> IO ()
- protocolClientServer :: ProtocolTypeI (ProtoType msg) => ProtocolClient v err msg -> String
- protocolClientServer' :: ProtocolClient v err msg -> ProtoServer msg
- transportHost' :: ProtocolClient v err msg -> TransportHost
- transportSession' :: ProtocolClient v err msg -> TransportSession msg
- useWebPort :: NetworkConfig -> [HostName] -> ProtocolServer p -> Bool
- isPresetDomain :: [HostName] -> TransportHost -> Bool
- createSMPQueue :: SMPClient -> NetworkRequestMode -> Maybe CbNonce -> AAuthKeyPair -> RcvPublicDhKey -> Maybe BasicAuth -> SubscriptionMode -> QueueReqData -> Maybe NewNtfCreds -> ExceptT SMPClientError IO QueueIdsKeys
- subscribeSMPQueue :: SMPClient -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO (Maybe ServiceId)
- subscribeSMPQueues :: SMPClient -> NonEmpty (RecipientId, RcvPrivateAuthKey) -> IO (NonEmpty (Either SMPClientError (Maybe ServiceId)))
- streamSubscribeSMPQueues :: SMPClient -> NonEmpty (RecipientId, RcvPrivateAuthKey) -> ([(RecipientId, Either SMPClientError (Maybe ServiceId))] -> IO ()) -> IO ()
- getSMPMessage :: SMPClient -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO (Maybe RcvMessage)
- subscribeSMPQueueNotifications :: SMPClient -> NtfPrivateAuthKey -> NotifierId -> ExceptT SMPClientError IO (Maybe ServiceId)
- subscribeSMPQueuesNtfs :: SMPClient -> NonEmpty (NotifierId, NtfPrivateAuthKey) -> IO (NonEmpty (Either SMPClientError (Maybe ServiceId)))
- subscribeService :: forall p. (PartyI p, ServiceParty p) => SMPClient -> SParty p -> ExceptT SMPClientError IO Int64
- smpClientService :: SMPClient -> Maybe THClientService
- secureSMPQueue :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> RecipientId -> SndPublicAuthKey -> ExceptT SMPClientError IO ()
- secureSndSMPQueue :: SMPClient -> NetworkRequestMode -> SndPrivateAuthKey -> SenderId -> ExceptT SMPClientError IO ()
- proxySecureSndSMPQueue :: SMPClient -> NetworkRequestMode -> ProxiedRelay -> SndPrivateAuthKey -> SenderId -> ExceptT SMPClientError IO (Either ProxyClientError ())
- addSMPQueueLink :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> RecipientId -> LinkId -> QueueLinkData -> ExceptT SMPClientError IO ()
- deleteSMPQueueLink :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO ()
- secureGetSMPQueueLink :: SMPClient -> NetworkRequestMode -> SndPrivateAuthKey -> LinkId -> ExceptT SMPClientError IO (SenderId, QueueLinkData)
- proxySecureGetSMPQueueLink :: SMPClient -> NetworkRequestMode -> ProxiedRelay -> SndPrivateAuthKey -> LinkId -> ExceptT SMPClientError IO (Either ProxyClientError (SenderId, QueueLinkData))
- getSMPQueueLink :: SMPClient -> NetworkRequestMode -> LinkId -> ExceptT SMPClientError IO (SenderId, QueueLinkData)
- proxyGetSMPQueueLink :: SMPClient -> NetworkRequestMode -> ProxiedRelay -> LinkId -> ExceptT SMPClientError IO (Either ProxyClientError (SenderId, QueueLinkData))
- enableSMPQueueNotifications :: SMPClient -> RcvPrivateAuthKey -> RecipientId -> NtfPublicAuthKey -> RcvNtfPublicDhKey -> ExceptT SMPClientError IO (NotifierId, RcvNtfPublicDhKey)
- disableSMPQueueNotifications :: SMPClient -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO ()
- enableSMPQueuesNtfs :: SMPClient -> NonEmpty (RecipientId, RcvPrivateAuthKey, NtfPublicAuthKey, RcvNtfPublicDhKey) -> IO (NonEmpty (Either SMPClientError (NotifierId, RcvNtfPublicDhKey)))
- disableSMPQueuesNtfs :: SMPClient -> NonEmpty (RecipientId, RcvPrivateAuthKey) -> IO (NonEmpty (Either SMPClientError ()))
- sendSMPMessage :: SMPClient -> NetworkRequestMode -> Maybe SndPrivateAuthKey -> SenderId -> MsgFlags -> MsgBody -> ExceptT SMPClientError IO ()
- ackSMPMessage :: SMPClient -> RcvPrivateAuthKey -> QueueId -> MsgId -> ExceptT SMPClientError IO ()
- suspendSMPQueue :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> QueueId -> ExceptT SMPClientError IO ()
- deleteSMPQueue :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO ()
- deleteSMPQueues :: SMPClient -> NetworkRequestMode -> NonEmpty (RecipientId, RcvPrivateAuthKey) -> IO (NonEmpty (Either SMPClientError ()))
- connectSMPProxiedRelay :: SMPClient -> NetworkRequestMode -> SMPServer -> Maybe BasicAuth -> ExceptT SMPClientError IO ProxiedRelay
- proxySMPMessage :: SMPClient -> NetworkRequestMode -> ProxiedRelay -> Maybe SndPrivateAuthKey -> SenderId -> MsgFlags -> MsgBody -> ExceptT SMPClientError IO (Either ProxyClientError ())
- forwardSMPTransmission :: SMPClient -> CorrId -> VersionSMP -> PublicKeyX25519 -> EncTransmission -> ExceptT SMPClientError IO EncResponse
- getSMPQueueInfo :: SMPClient -> NetworkRequestMode -> APrivateAuthKey -> QueueId -> ExceptT SMPClientError IO QueueInfo
- sendProtocolCommand :: forall v err msg. Protocol v err msg => ProtocolClient v err msg -> NetworkRequestMode -> Maybe APrivateAuthKey -> EntityId -> ProtoCommand msg -> ExceptT (ProtocolClientError err) IO msg
- sendProtocolCommands :: forall v err msg. Protocol v err msg => ProtocolClient v err msg -> NetworkRequestMode -> NonEmpty (ClientCommand msg) -> IO (NonEmpty (Response err msg))
- data ProtocolClientError err
- = PCEProtocolError err
- | PCEResponseError err
- | PCEUnexpectedResponse ByteString
- | PCEResponseTimeout
- | PCENetworkError NetworkError
- | PCEIncompatibleHost
- | PCEServiceUnavailable
- | PCETransportError TransportError
- | PCECryptoError CryptoError
- | PCEIOError IOException
- type SMPClientError = ProtocolClientError ErrorType
- data ProxyClientError
- = ProxyProtocolError { }
- | ProxyUnexpectedResponse {
- responseStr :: String
- | ProxyResponseError { }
- data Response err msg = Response {
- entityId :: EntityId
- response :: Either (ProtocolClientError err) msg
- unexpectedResponse :: Show r => r -> ProtocolClientError err
- data ProtocolClientConfig v = ProtocolClientConfig {
- qSize :: Natural
- defaultTransport :: (ServiceName, ATransport 'TClient)
- networkConfig :: NetworkConfig
- clientALPN :: Maybe [ALPN]
- serviceCredentials :: Maybe ServiceCredentials
- serverVRange :: VersionRange v
- agreeSecret :: Bool
- proxyServer :: Bool
- useSNI :: Bool
- data NetworkConfig = NetworkConfig {
- socksProxy :: Maybe SocksProxyWithAuth
- socksMode :: SocksMode
- hostMode :: HostMode
- requiredHostMode :: Bool
- sessionMode :: TransportSessionMode
- smpProxyMode :: SMPProxyMode
- smpProxyFallback :: SMPProxyFallback
- smpWebPortServers :: SMPWebPortServers
- tcpConnectTimeout :: NetworkTimeout
- tcpTimeout :: NetworkTimeout
- tcpTimeoutPerKb :: Int64
- rcvConcurrency :: Int
- tcpKeepAlive :: Maybe KeepAliveOpts
- smpPingInterval :: Int64
- smpPingCount :: Int
- logTLSErrors :: Bool
- data NetworkTimeout = NetworkTimeout {
- backgroundTimeout :: Int
- interactiveTimeout :: Int
- data NetworkRequestMode
- = NRMBackground
- | NRMInteractive' {
- retryCount :: Int
- pattern NRMInteractive :: NetworkRequestMode
- data TransportSessionMode
- data HostMode
- data SocksMode
- data SMPProxyMode
- data SMPProxyFallback
- data SMPWebPortServers
- netTimeoutInt :: NetworkTimeout -> NetworkRequestMode -> Int
- defaultClientConfig :: Maybe [ALPN] -> Bool -> VersionRange v -> ProtocolClientConfig v
- defaultSMPClientConfig :: ProtocolClientConfig SMPVersion
- defaultNetworkConfig :: NetworkConfig
- transportClientConfig :: NetworkConfig -> NetworkRequestMode -> TransportHost -> Bool -> Maybe [ALPN] -> TransportClientConfig
- clientSocksCredentials :: ProtocolTypeI (ProtoType msg) => NetworkConfig -> UTCTime -> TransportSession msg -> Maybe SocksCredentials
- chooseTransportHost :: NetworkConfig -> NonEmpty TransportHost -> Either (ProtocolClientError err) TransportHost
- temporaryClientError :: ProtocolClientError err -> Bool
- smpClientServiceError :: SMPClientError -> Bool
- smpProxyError :: SMPClientError -> ErrorType
- smpErrorClientNotice :: SMPClientError -> Maybe (Maybe ClientNotice)
- textToHostMode :: Text -> Either String HostMode
- type ServerTransmissionBatch v err msg = (TransportSession msg, Version v, SessionId, NonEmpty (EntityId, ServerTransmission err msg))
- data ServerTransmission err msg
- = STEvent (Either (ProtocolClientError err) msg)
- | STResponse (ProtoCommand msg) (Either (ProtocolClientError err) msg)
- | STUnexpectedError (ProtocolClientError err)
- type ClientCommand msg = (EntityId, Maybe APrivateAuthKey, ProtoCommand msg)
- type PCTransmission err msg = (Either TransportError SentRawTransmission, Request err msg)
- mkTransmission :: Protocol v err msg => ProtocolClient v err msg -> ClientCommand msg -> IO (PCTransmission err msg)
- authTransmission :: Maybe (THandleAuth 'TClient) -> Bool -> Maybe APrivateAuthKey -> CbNonce -> ByteString -> Either TransportError (Maybe TAuthorizations)
- smpClientStub :: TVar ChaChaDRG -> ByteString -> VersionSMP -> Maybe (THandleAuth 'TClient) -> IO SMPClient
- data TBQueueInfo = TBQueueInfo {}
- getTBQueueInfo :: TBQueue a -> STM TBQueueInfo
- getProtocolClientQueuesInfo :: ProtocolClient v err msg -> IO (TBQueueInfo, TBQueueInfo)
- nonBlockingWriteTBQueue :: TBQueue a -> a -> IO ()
Connect (disconnect) client to (from) SMP server
type TransportSession msg = (UserId, ProtoServer msg, Maybe ByteString) Source #
Transport session key - includes entity ID if `sessionMode = TSMEntity`. Please note that for SMP connection ID is used as entity ID, not queue ID.
data ProtocolClient v err msg Source #
SMPClient is a handle used to send commands to a specific SMP server.
Use getSMPClient to connect to an SMP server and create a client handle.
data ProxiedRelay Source #
Constructors
| ProxiedRelay | |
Fields
| |
getProtocolClient :: forall v err msg. Protocol v err msg => TVar ChaChaDRG -> NetworkRequestMode -> TransportSession msg -> ProtocolClientConfig v -> [HostName] -> Maybe (TBQueue (ServerTransmissionBatch v err msg)) -> UTCTime -> (ProtocolClient v err msg -> IO ()) -> IO (Either (ProtocolClientError err) (ProtocolClient v err msg)) Source #
Connects to ProtocolServer using passed client configuration
and queue for messages and notifications.
A single queue can be used for multiple SMPClient instances,
as SMPServerTransmission includes server information.
closeProtocolClient :: ProtocolClient v err msg -> IO () Source #
Disconnects client from the server and terminates client threads.
protocolClientServer :: ProtocolTypeI (ProtoType msg) => ProtocolClient v err msg -> String Source #
protocolClientServer' :: ProtocolClient v err msg -> ProtoServer msg Source #
transportHost' :: ProtocolClient v err msg -> TransportHost Source #
transportSession' :: ProtocolClient v err msg -> TransportSession msg Source #
useWebPort :: NetworkConfig -> [HostName] -> ProtocolServer p -> Bool Source #
isPresetDomain :: [HostName] -> TransportHost -> Bool Source #
SMP protocol command functions
createSMPQueue :: SMPClient -> NetworkRequestMode -> Maybe CbNonce -> AAuthKeyPair -> RcvPublicDhKey -> Maybe BasicAuth -> SubscriptionMode -> QueueReqData -> Maybe NewNtfCreds -> ExceptT SMPClientError IO QueueIdsKeys Source #
subscribeSMPQueue :: SMPClient -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO (Maybe ServiceId) Source #
Subscribe to the SMP queue.
https://github.com/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md#subscribe-to-queue This command is always sent in background request mode
subscribeSMPQueues :: SMPClient -> NonEmpty (RecipientId, RcvPrivateAuthKey) -> IO (NonEmpty (Either SMPClientError (Maybe ServiceId))) Source #
Subscribe to multiple SMP queues batching commands if supported. This command is always sent in background request mode
streamSubscribeSMPQueues :: SMPClient -> NonEmpty (RecipientId, RcvPrivateAuthKey) -> ([(RecipientId, Either SMPClientError (Maybe ServiceId))] -> IO ()) -> IO () Source #
getSMPMessage :: SMPClient -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO (Maybe RcvMessage) Source #
Get message from SMP queue. The server returns ERR PROHIBITED if a client uses SUB and GET via the same transport connection for the same queue
https://github.covm/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md#receive-a-message-from-the-queue This command is always sent in interactive request mode, as NSE has limited time
subscribeSMPQueueNotifications :: SMPClient -> NtfPrivateAuthKey -> NotifierId -> ExceptT SMPClientError IO (Maybe ServiceId) Source #
Subscribe to the SMP queue notifications.
https://github.com/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md#subscribe-to-queue-notifications This command is always sent in background request mode
subscribeSMPQueuesNtfs :: SMPClient -> NonEmpty (NotifierId, NtfPrivateAuthKey) -> IO (NonEmpty (Either SMPClientError (Maybe ServiceId))) Source #
Subscribe to multiple SMP queues notifications batching commands if supported. This command is always sent in background request mode
subscribeService :: forall p. (PartyI p, ServiceParty p) => SMPClient -> SParty p -> ExceptT SMPClientError IO Int64 Source #
smpClientService :: SMPClient -> Maybe THClientService Source #
secureSMPQueue :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> RecipientId -> SndPublicAuthKey -> ExceptT SMPClientError IO () Source #
Secure the SMP queue by adding a sender public key.
secureSndSMPQueue :: SMPClient -> NetworkRequestMode -> SndPrivateAuthKey -> SenderId -> ExceptT SMPClientError IO () Source #
Secure the SMP queue via sender queue ID.
proxySecureSndSMPQueue :: SMPClient -> NetworkRequestMode -> ProxiedRelay -> SndPrivateAuthKey -> SenderId -> ExceptT SMPClientError IO (Either ProxyClientError ()) Source #
addSMPQueueLink :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> RecipientId -> LinkId -> QueueLinkData -> ExceptT SMPClientError IO () Source #
Add or update date for queue link
deleteSMPQueueLink :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO () Source #
Delete queue link
secureGetSMPQueueLink :: SMPClient -> NetworkRequestMode -> SndPrivateAuthKey -> LinkId -> ExceptT SMPClientError IO (SenderId, QueueLinkData) Source #
Get 1-time inviation SMP queue link data and secure the queue via queue link ID.
proxySecureGetSMPQueueLink :: SMPClient -> NetworkRequestMode -> ProxiedRelay -> SndPrivateAuthKey -> LinkId -> ExceptT SMPClientError IO (Either ProxyClientError (SenderId, QueueLinkData)) Source #
getSMPQueueLink :: SMPClient -> NetworkRequestMode -> LinkId -> ExceptT SMPClientError IO (SenderId, QueueLinkData) Source #
Get contact address SMP queue link data.
proxyGetSMPQueueLink :: SMPClient -> NetworkRequestMode -> ProxiedRelay -> LinkId -> ExceptT SMPClientError IO (Either ProxyClientError (SenderId, QueueLinkData)) Source #
enableSMPQueueNotifications :: SMPClient -> RcvPrivateAuthKey -> RecipientId -> NtfPublicAuthKey -> RcvNtfPublicDhKey -> ExceptT SMPClientError IO (NotifierId, RcvNtfPublicDhKey) Source #
Enable notifications for the queue for push notifications server.
disableSMPQueueNotifications :: SMPClient -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO () Source #
Disable notifications for the queue for push notifications server.
https://github.com/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md#disable-notifications-command This command is always sent in background request mode
enableSMPQueuesNtfs :: SMPClient -> NonEmpty (RecipientId, RcvPrivateAuthKey, NtfPublicAuthKey, RcvNtfPublicDhKey) -> IO (NonEmpty (Either SMPClientError (NotifierId, RcvNtfPublicDhKey))) Source #
Enable notifications for the multiple queues for push notifications server. This command is always sent in background request mode
disableSMPQueuesNtfs :: SMPClient -> NonEmpty (RecipientId, RcvPrivateAuthKey) -> IO (NonEmpty (Either SMPClientError ())) Source #
Disable notifications for multiple queues for push notifications server. This command is always sent in background request mode
sendSMPMessage :: SMPClient -> NetworkRequestMode -> Maybe SndPrivateAuthKey -> SenderId -> MsgFlags -> MsgBody -> ExceptT SMPClientError IO () Source #
ackSMPMessage :: SMPClient -> RcvPrivateAuthKey -> QueueId -> MsgId -> ExceptT SMPClientError IO () Source #
Acknowledge message delivery (server deletes the message).
https://github.com/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md#acknowledge-message-delivery This command is always sent in background request mode
suspendSMPQueue :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> QueueId -> ExceptT SMPClientError IO () Source #
Irreversibly suspend SMP queue. The existing messages from the queue will still be delivered.
https://github.com/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md#suspend-queue
deleteSMPQueue :: SMPClient -> NetworkRequestMode -> RcvPrivateAuthKey -> RecipientId -> ExceptT SMPClientError IO () Source #
Irreversibly delete SMP queue and all messages in it.
https://github.com/simplex-chat/simplexmq/blob/master/protocol/simplex-messaging.md#delete-queue
deleteSMPQueues :: SMPClient -> NetworkRequestMode -> NonEmpty (RecipientId, RcvPrivateAuthKey) -> IO (NonEmpty (Either SMPClientError ())) Source #
Delete multiple SMP queues batching commands if supported.
connectSMPProxiedRelay :: SMPClient -> NetworkRequestMode -> SMPServer -> Maybe BasicAuth -> ExceptT SMPClientError IO ProxiedRelay Source #
proxySMPMessage :: SMPClient -> NetworkRequestMode -> ProxiedRelay -> Maybe SndPrivateAuthKey -> SenderId -> MsgFlags -> MsgBody -> ExceptT SMPClientError IO (Either ProxyClientError ()) Source #
forwardSMPTransmission :: SMPClient -> CorrId -> VersionSMP -> PublicKeyX25519 -> EncTransmission -> ExceptT SMPClientError IO EncResponse Source #
getSMPQueueInfo :: SMPClient -> NetworkRequestMode -> APrivateAuthKey -> QueueId -> ExceptT SMPClientError IO QueueInfo Source #
sendProtocolCommand :: forall v err msg. Protocol v err msg => ProtocolClient v err msg -> NetworkRequestMode -> Maybe APrivateAuthKey -> EntityId -> ProtoCommand msg -> ExceptT (ProtocolClientError err) IO msg Source #
Send Protocol command
sendProtocolCommands :: forall v err msg. Protocol v err msg => ProtocolClient v err msg -> NetworkRequestMode -> NonEmpty (ClientCommand msg) -> IO (NonEmpty (Response err msg)) Source #
Send multiple commands with batching and collect responses
Supporting types and client configuration
data ProtocolClientError err Source #
SMP client error type.
Constructors
| PCEProtocolError err | Correctly parsed SMP server ERR response. This error is forwarded to the agent client as `ERR SMP err`. |
| PCEResponseError err | Invalid server response that failed to parse. Forwarded to the agent client as `ERR BROKER RESPONSE`. |
| PCEUnexpectedResponse ByteString | Different response from what is expected to a certain SMP command,
e.g. server should respond |
| PCEResponseTimeout | Used for TCP connection and command response timeouts. Forwarded to the agent client as `ERR BROKER TIMEOUT`. |
| PCENetworkError NetworkError | Failure to establish TCP connection. Forwarded to the agent client as `ERR BROKER NETWORK`. |
| PCEIncompatibleHost | No host compatible with network configuration |
| PCEServiceUnavailable | Service is unavailable for command that requires service connection |
| PCETransportError TransportError | TCP transport handshake or some other transport error. Forwarded to the agent client as `ERR BROKER TRANSPORT e`. |
| PCECryptoError CryptoError | Error when cryptographically "signing" the command or when initializing crypto_box. |
| PCEIOError IOException | IO Error |
Instances
| (Typeable err, Show err) => Exception (ProtocolClientError err) Source # | |
Defined in Simplex.Messaging.Client Methods toException :: ProtocolClientError err -> SomeException fromException :: SomeException -> Maybe (ProtocolClientError err) displayException :: ProtocolClientError err -> String | |
| Show err => Show (ProtocolClientError err) Source # | |
Defined in Simplex.Messaging.Client Methods showsPrec :: Int -> ProtocolClientError err -> ShowS show :: ProtocolClientError err -> String showList :: [ProtocolClientError err] -> ShowS | |
| Eq err => Eq (ProtocolClientError err) Source # | |
Defined in Simplex.Messaging.Client Methods (==) :: ProtocolClientError err -> ProtocolClientError err -> Bool (/=) :: ProtocolClientError err -> ProtocolClientError err -> Bool | |
data ProxyClientError Source #
Constructors
| ProxyProtocolError | protocol error response from proxy |
Fields | |
| ProxyUnexpectedResponse | unexpexted response |
Fields
| |
| ProxyResponseError | error between proxy and server |
Fields | |
Instances
data Response err msg Source #
Constructors
| Response | |
Fields
| |
unexpectedResponse :: Show r => r -> ProtocolClientError err Source #
data ProtocolClientConfig v Source #
protocol client configuration.
Constructors
| ProtocolClientConfig | |
Fields
| |
data NetworkConfig Source #
network configuration for the client
Constructors
| NetworkConfig | |
Fields
| |
Instances
| FromJSON NetworkConfig Source # | |
Defined in Simplex.Messaging.Client Methods parseJSON :: Value -> Parser NetworkConfig parseJSONList :: Value -> Parser [NetworkConfig] omittedField :: Maybe NetworkConfig | |
| ToJSON NetworkConfig Source # | |
Defined in Simplex.Messaging.Client Methods toJSON :: NetworkConfig -> Value toEncoding :: NetworkConfig -> Encoding toJSONList :: [NetworkConfig] -> Value toEncodingList :: [NetworkConfig] -> Encoding omitField :: NetworkConfig -> Bool | |
| Show NetworkConfig Source # | |
Defined in Simplex.Messaging.Client Methods showsPrec :: Int -> NetworkConfig -> ShowS show :: NetworkConfig -> String showList :: [NetworkConfig] -> ShowS | |
| Eq NetworkConfig Source # | |
Defined in Simplex.Messaging.Client | |
data NetworkTimeout Source #
Constructors
| NetworkTimeout | |
Fields
| |
Instances
| FromJSON NetworkTimeout Source # | |
Defined in Simplex.Messaging.Client Methods parseJSON :: Value -> Parser NetworkTimeout parseJSONList :: Value -> Parser [NetworkTimeout] omittedField :: Maybe NetworkTimeout | |
| ToJSON NetworkTimeout Source # | |
Defined in Simplex.Messaging.Client Methods toJSON :: NetworkTimeout -> Value toEncoding :: NetworkTimeout -> Encoding toJSONList :: [NetworkTimeout] -> Value toEncodingList :: [NetworkTimeout] -> Encoding omitField :: NetworkTimeout -> Bool | |
| Show NetworkTimeout Source # | |
Defined in Simplex.Messaging.Client Methods showsPrec :: Int -> NetworkTimeout -> ShowS show :: NetworkTimeout -> String showList :: [NetworkTimeout] -> ShowS | |
| Eq NetworkTimeout Source # | |
Defined in Simplex.Messaging.Client Methods (==) :: NetworkTimeout -> NetworkTimeout -> Bool (/=) :: NetworkTimeout -> NetworkTimeout -> Bool | |
data NetworkRequestMode Source #
Constructors
| NRMBackground | |
| NRMInteractive' | |
Fields
| |
pattern NRMInteractive :: NetworkRequestMode Source #
data TransportSessionMode Source #
Constructors
| TSMUser | |
| TSMSession | |
| TSMServer | |
| TSMEntity |
Instances
| FromJSON TransportSessionMode Source # | |
Defined in Simplex.Messaging.Client Methods parseJSON :: Value -> Parser TransportSessionMode parseJSONList :: Value -> Parser [TransportSessionMode] omittedField :: Maybe TransportSessionMode | |
| ToJSON TransportSessionMode Source # | |
Defined in Simplex.Messaging.Client Methods toJSON :: TransportSessionMode -> Value toEncoding :: TransportSessionMode -> Encoding toJSONList :: [TransportSessionMode] -> Value toEncodingList :: [TransportSessionMode] -> Encoding omitField :: TransportSessionMode -> Bool | |
| Show TransportSessionMode Source # | |
Defined in Simplex.Messaging.Client Methods showsPrec :: Int -> TransportSessionMode -> ShowS show :: TransportSessionMode -> String showList :: [TransportSessionMode] -> ShowS | |
| Eq TransportSessionMode Source # | |
Defined in Simplex.Messaging.Client Methods (==) :: TransportSessionMode -> TransportSessionMode -> Bool (/=) :: TransportSessionMode -> TransportSessionMode -> Bool | |
Constructors
| HMOnionViaSocks | prefer (or require) onion hosts when connecting via SOCKS proxy |
| HMOnion | prefer (or require) onion hosts |
| HMPublic | prefer (or require) public hosts |
Instances
| FromJSON HostMode Source # | |
Defined in Simplex.Messaging.Client Methods parseJSON :: Value -> Parser HostMode parseJSONList :: Value -> Parser [HostMode] omittedField :: Maybe HostMode | |
| ToJSON HostMode Source # | |
Defined in Simplex.Messaging.Client Methods toEncoding :: HostMode -> Encoding toJSONList :: [HostMode] -> Value toEncodingList :: [HostMode] -> Encoding | |
| Show HostMode Source # | |
| Eq HostMode Source # | |
Constructors
| SMAlways | always use SOCKS proxy when enabled |
| SMOnion | use SOCKS proxy only for .onion hosts when no public host is available This mode is used in SMP proxy and in notifications server to minimize SOCKS proxy usage. |
Instances
| FromJSON SocksMode Source # | |
Defined in Simplex.Messaging.Client Methods parseJSON :: Value -> Parser SocksMode parseJSONList :: Value -> Parser [SocksMode] omittedField :: Maybe SocksMode | |
| ToJSON SocksMode Source # | |
Defined in Simplex.Messaging.Client Methods toEncoding :: SocksMode -> Encoding toJSONList :: [SocksMode] -> Value toEncodingList :: [SocksMode] -> Encoding | |
| Show SocksMode Source # | |
| Eq SocksMode Source # | |
| StrEncoding SocksMode Source # | |
data SMPProxyMode Source #
Constructors
| SPMAlways | |
| SPMUnknown | |
| SPMUnprotected | |
| SPMNever |
Instances
| FromJSON SMPProxyMode Source # | |
Defined in Simplex.Messaging.Client Methods parseJSON :: Value -> Parser SMPProxyMode parseJSONList :: Value -> Parser [SMPProxyMode] omittedField :: Maybe SMPProxyMode | |
| ToJSON SMPProxyMode Source # | |
Defined in Simplex.Messaging.Client Methods toJSON :: SMPProxyMode -> Value toEncoding :: SMPProxyMode -> Encoding toJSONList :: [SMPProxyMode] -> Value toEncodingList :: [SMPProxyMode] -> Encoding omitField :: SMPProxyMode -> Bool | |
| Show SMPProxyMode Source # | |
Defined in Simplex.Messaging.Client Methods showsPrec :: Int -> SMPProxyMode -> ShowS show :: SMPProxyMode -> String showList :: [SMPProxyMode] -> ShowS | |
| Eq SMPProxyMode Source # | |
Defined in Simplex.Messaging.Client | |
| StrEncoding SMPProxyMode Source # | |
Defined in Simplex.Messaging.Client Methods strEncode :: SMPProxyMode -> ByteString Source # strDecode :: ByteString -> Either String SMPProxyMode Source # strP :: Parser SMPProxyMode Source # | |
data SMPProxyFallback Source #
Constructors
| SPFAllow | |
| SPFAllowProtected | |
| SPFProhibit |
Instances
data SMPWebPortServers Source #
Instances
netTimeoutInt :: NetworkTimeout -> NetworkRequestMode -> Int Source #
defaultClientConfig :: Maybe [ALPN] -> Bool -> VersionRange v -> ProtocolClientConfig v Source #
Default protocol client configuration.
transportClientConfig :: NetworkConfig -> NetworkRequestMode -> TransportHost -> Bool -> Maybe [ALPN] -> TransportClientConfig Source #
clientSocksCredentials :: ProtocolTypeI (ProtoType msg) => NetworkConfig -> UTCTime -> TransportSession msg -> Maybe SocksCredentials Source #
chooseTransportHost :: NetworkConfig -> NonEmpty TransportHost -> Either (ProtocolClientError err) TransportHost Source #
temporaryClientError :: ProtocolClientError err -> Bool Source #
smpClientServiceError :: SMPClientError -> Bool Source #
smpErrorClientNotice :: SMPClientError -> Maybe (Maybe ClientNotice) Source #
textToHostMode :: Text -> Either String HostMode Source #
type ServerTransmissionBatch v err msg = (TransportSession msg, Version v, SessionId, NonEmpty (EntityId, ServerTransmission err msg)) Source #
Type synonym for transmission from SPM servers.
Batch response is presented as a single ServerTransmissionBatch tuple.
data ServerTransmission err msg Source #
Constructors
| STEvent (Either (ProtocolClientError err) msg) | |
| STResponse (ProtoCommand msg) (Either (ProtocolClientError err) msg) | |
| STUnexpectedError (ProtocolClientError err) |
type ClientCommand msg = (EntityId, Maybe APrivateAuthKey, ProtoCommand msg) Source #
Type for client command data
For testing
type PCTransmission err msg = (Either TransportError SentRawTransmission, Request err msg) Source #
mkTransmission :: Protocol v err msg => ProtocolClient v err msg -> ClientCommand msg -> IO (PCTransmission err msg) Source #
authTransmission :: Maybe (THandleAuth 'TClient) -> Bool -> Maybe APrivateAuthKey -> CbNonce -> ByteString -> Either TransportError (Maybe TAuthorizations) Source #
smpClientStub :: TVar ChaChaDRG -> ByteString -> VersionSMP -> Maybe (THandleAuth 'TClient) -> IO SMPClient Source #
For debugging
data TBQueueInfo Source #
Constructors
| TBQueueInfo | |
Instances
| FromJSON TBQueueInfo Source # | |
Defined in Simplex.Messaging.Client Methods parseJSON :: Value -> Parser TBQueueInfo parseJSONList :: Value -> Parser [TBQueueInfo] omittedField :: Maybe TBQueueInfo | |
| ToJSON TBQueueInfo Source # | |
Defined in Simplex.Messaging.Client Methods toJSON :: TBQueueInfo -> Value toEncoding :: TBQueueInfo -> Encoding toJSONList :: [TBQueueInfo] -> Value toEncodingList :: [TBQueueInfo] -> Encoding omitField :: TBQueueInfo -> Bool | |
| Show TBQueueInfo Source # | |
Defined in Simplex.Messaging.Client Methods showsPrec :: Int -> TBQueueInfo -> ShowS show :: TBQueueInfo -> String showList :: [TBQueueInfo] -> ShowS | |
getTBQueueInfo :: TBQueue a -> STM TBQueueInfo Source #
getProtocolClientQueuesInfo :: ProtocolClient v err msg -> IO (TBQueueInfo, TBQueueInfo) Source #
nonBlockingWriteTBQueue :: TBQueue a -> a -> IO () Source #