core: remote host/controller types (#3104)

* Start sprinkling ZoneId everywhere

* Draft zone/satellite/host api

* Add zone dispatching

* Add command relaying handler

* Parse commands and begin DB

* Implement discussed things

* Resolve some comments

* Resolve more stuff

* Make bots ignore remoteHostId from queues

* Fix tests and stub more

* Untangle cmd relaying

* Resolve comments

* Add more http2 client funs

* refactor, rename

* rename

* remove empty tests

---------

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
Alexander Bondarenko
2023-09-27 11:41:02 +03:00
committed by GitHub
parent 50d624ef6b
commit 3e29c664ac
21 changed files with 413 additions and 25 deletions
+46
View File
@@ -0,0 +1,46 @@
{-# LANGUAGE DuplicateRecordFields #-}
module Simplex.Chat.Remote.Types where
import Control.Concurrent.Async (Async)
import Data.ByteString.Char8 (ByteString)
import Data.Int (Int64)
import Data.Text (Text)
import qualified Simplex.Messaging.Crypto as C
import Simplex.Messaging.Transport.HTTP2.Client (HTTP2Client)
type RemoteHostId = Int64
data RemoteHost = RemoteHost
{ remoteHostId :: RemoteHostId,
displayName :: Text,
-- | Path to store replicated files
storePath :: FilePath,
-- | A stable part of X509 credentials used to access the host
caCert :: ByteString,
-- | Credentials signing key for root and session certs
caKey :: C.Key
}
type RemoteCtrlId = Int
data RemoteCtrl = RemoteCtrl
{ remoteCtrlId :: RemoteCtrlId,
displayName :: Text,
fingerprint :: Text
}
data RemoteHostSession = RemoteHostSession
{ -- | process to communicate with the host
hostAsync :: Async (),
-- | Path for local resources to be synchronized with host
storePath :: FilePath,
ctrlClient :: HTTP2Client
}
-- | Host-side dual to RemoteHostSession, on-methods represent HTTP API.
data RemoteCtrlSession = RemoteCtrlSession
{ -- | process to communicate with the remote controller
ctrlAsync :: Async ()
-- server :: HTTP2Server
}