core: update remote host session state, terminate TLS in one more case (#3364)

* core: update remote host session state, terminate TLS in one more case

* name
This commit is contained in:
Evgeny Poberezkin
2023-11-13 20:16:34 +00:00
committed by GitHub
parent 598b6659cc
commit c91625b32a
7 changed files with 69 additions and 34 deletions
+22 -2
View File
@@ -3,6 +3,7 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
@@ -63,7 +64,8 @@ data RHPendingSession = RHPendingSession
data RemoteHostSession
= RHSessionStarting
| RHSessionConnecting {rhPendingSession :: RHPendingSession}
| RHSessionConnecting {invitation :: Text, rhPendingSession :: RHPendingSession}
| RHSessionPendingConfirmation {sessionCode :: Text, tls :: TLS, rhPendingSession :: RHPendingSession}
| RHSessionConfirmed {tls :: TLS, rhPendingSession :: RHPendingSession}
| RHSessionConnected
{ rchClient :: RCHostClient,
@@ -73,6 +75,22 @@ data RemoteHostSession
storePath :: FilePath
}
data RemoteHostSessionState
= RHSStarting
| RHSConnecting {invitation :: Text}
| RHSPendingConfirmation {sessionCode :: Text}
| RHSConfirmed
| RHSConnected
deriving (Show)
rhsSessionState :: RemoteHostSession -> RemoteHostSessionState
rhsSessionState = \case
RHSessionStarting -> RHSStarting
RHSessionConnecting {invitation} -> RHSConnecting {invitation}
RHSessionPendingConfirmation {sessionCode} -> RHSPendingConfirmation {sessionCode}
RHSessionConfirmed {} -> RHSConfirmed
RHSessionConnected {} -> RHSConnected
data RemoteProtocolError
= -- | size prefix is malformed
RPEInvalidSize
@@ -112,7 +130,7 @@ data RemoteHostInfo = RemoteHostInfo
{ remoteHostId :: RemoteHostId,
hostDeviceName :: Text,
storePath :: FilePath,
sessionActive :: Bool
sessionState :: Maybe RemoteHostSessionState
}
deriving (Show)
@@ -174,6 +192,8 @@ $(J.deriveJSON (sumTypeJSON $ dropPrefix "RH") ''RHKey)
$(J.deriveJSON (enumJSON $ dropPrefix "PE") ''PlatformEncoding)
$(J.deriveJSON (sumTypeJSON $ dropPrefix "RHS") ''RemoteHostSessionState)
$(J.deriveJSON defaultJSON ''RemoteHostInfo)
$(J.deriveJSON defaultJSON ''RemoteCtrlInfo)