Skip to content

smp-server: add serverInfoBytes to THandleParams and related functions#1825

Open
ed-asriyan wants to merge 1 commit into
simplex-chat:masterfrom
ed-asriyan:server-info
Open

smp-server: add serverInfoBytes to THandleParams and related functions#1825
ed-asriyan wants to merge 1 commit into
simplex-chat:masterfrom
ed-asriyan:server-info

Conversation

@ed-asriyan

Copy link
Copy Markdown

No description provided.

serviceAuth :: Bool
serviceAuth :: Bool,
-- | JSON-encoded ServerPublicInfo from handshake, present when server version >= serverInfoSMPVersion
serverInfoBytes :: Maybe ByteString

@epoberezkin epoberezkin Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not include the actual type here, and parse JSON in parser? Or you think there is a value in lenient parser? but then you could just include Nothing if JSON fails to parse, or Either String ServerInfo (it would help to know in test that info was sent but was invalid).

Suggested change
serverInfoBytes :: Maybe ByteString
serverInfo :: Either String ServerPublicInfo

authPubKey :: Maybe CertChainPubKey
authPubKey :: Maybe CertChainPubKey,
-- | optional server public information (JSON-encoded ServerPublicInfo), sent when version >= serverInfoSMPVersion
serverInfo :: Maybe ByteString

@epoberezkin epoberezkin Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
serverInfo :: Maybe ByteString
serverInfo :: Either String ServerPublicInfo

import Control.Monad.Trans.Except
import Crypto.Random (ChaChaDRG)
import qualified Data.Aeson as J
import qualified Data.Aeson as Aeson

@epoberezkin epoberezkin Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import qualified Data.Aeson as Aeson

Already imported above as J, but it'll move to transport if we put it into handshake

deriving (Eq, Show)

runSMPServerTest :: AgentClient -> NetworkRequestMode -> UserId -> SMPServerWithAuth -> AM' (Maybe ProtocolTestFailure)
runSMPServerTest :: AgentClient -> NetworkRequestMode -> UserId -> SMPServerWithAuth -> AM' (Either ProtocolTestFailure (Maybe ServerPublicInfo))

@epoberezkin epoberezkin Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runSMPServerTest :: AgentClient -> NetworkRequestMode -> UserId -> SMPServerWithAuth -> AM' (Either ProtocolTestFailure (Maybe ServerPublicInfo))
runSMPServerTest :: AgentClient -> NetworkRequestMode -> UserId -> SMPServerWithAuth -> AM' (Either ProtocolTestFailure (Either String ServerPublicInfo))

It would help differentiate info not sent/failed to parse scenarios, and this type would already be included into handshake and handle, so all parsing would be in one place, and not split between transport and client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants