mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-11-22 19:58:39 +00:00
agent: accept confirmations only with the client version that the agent version implies (#2053)
* agent: accept confirmations only with the client version that the agent version implies * tests: connections with apps of earlier versions * agent: send confirmation with the client version agreed when the join is retried
This commit is contained in:
1 parent
ca43321733
commit
c973de8676
3 files changed
+186
-1
No files matched your search
@@ -1541,7 +1541,8 @@ startJoinInvitation c userId connId sq_ enableNtfs cReqUri pqSupport =
|
||||
Left e -> do
|
||||
nonBlockingWriteTBQueue (subQ c) ("", connId, AEvt SAEConn (ERR $ INTERNAL $ "no snd ratchet " <> show e))
|
||||
runExceptT $ snd <$> createRatchet_ db g connId maxSupported pqSupport e2eRcvParams
|
||||
pure ((cData, sq), (Just e2eSndParams, Nothing))
|
||||
let Compatible SMPQueueInfo {clientVersion} = qInfo
|
||||
pure ((cData, (sq :: SndQueue) {smpClientVersion = clientVersion}), (Just e2eSndParams, Nothing))
|
||||
_ -> do
|
||||
let Compatible SMPQueueInfo {queueAddress = SMPQueueAddress {smpServer, senderId}} = qInfo
|
||||
invLink_ <- withStore' c $ \db -> getInvShortLinkKeys db smpServer senderId
|
||||
@@ -3931,6 +3932,7 @@ processSMPTransmissions c@AgentClient {subQ, smpServersStats} (tSess@(userId, sr
|
||||
let compatible =
|
||||
(agentVersion `isCompatible` smpAgentVRange || agentVersion <= agreedAgentVersion)
|
||||
&& (phVer `isCompatible` smpClientVRange || phVer <= agreedClientVerion)
|
||||
&& phVer >= min agreedClientVerion (minSMPClientVersion agentVersion)
|
||||
unless compatible $ throwE $ AGENT A_VERSION
|
||||
|
||||
smpConfirmation :: SMP.MsgId -> Connection c -> Maybe C.APublicAuthKey -> C.PublicKeyX25519 -> Maybe (CR.SndE2ERatchetParams 'C.X448) -> ByteString -> VersionSMPC -> VersionSMPA -> AM ()
|
||||
|
||||
@@ -45,6 +45,7 @@ module Simplex.Messaging.Agent.Protocol
|
||||
rpcAddressSMPAgentVersion,
|
||||
currentSMPAgentVersion,
|
||||
supportedSMPAgentVRange,
|
||||
minSMPClientVersion,
|
||||
e2eEncConnInfoLength,
|
||||
e2eEncAgentMsgLength,
|
||||
|
||||
@@ -333,6 +334,12 @@ currentSMPAgentVersion = VersionSMPA 8
|
||||
supportedSMPAgentVRange :: VersionRangeSMPA
|
||||
supportedSMPAgentVRange = mkVersionRange minSupportedSMPAgentVersion currentSMPAgentVersion
|
||||
|
||||
minSMPClientVersion :: VersionSMPA -> VersionSMPC
|
||||
minSMPClientVersion v
|
||||
| v >= rpcAddressSMPAgentVersion = shortLinksSMPClientVersion
|
||||
| v >= ratchetOnConfSMPAgentVersion = sndAuthKeySMPClientVersion
|
||||
| otherwise = initialSMPClientVersion
|
||||
|
||||
-- it is shorter to allow all handshake headers,
|
||||
-- including E2E (double-ratchet) parameters and
|
||||
-- signing key of the sender for the server
|
||||
|
||||
Reference in new issue
Block a user