mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-29 01:10:08 +00:00
transport encryption (#65)
* transport encryption (WIP - using fixed key, parsing/serialization works, SMP tests fail) * transport encryption * transport encryption: separate keys to receive and to send, counter-based IVs * docs: update transport encryption and handshake * transport encryption handshake (TODO: validate key hash, welcome block, move keys to system environment) * change KeyHash type to newtype of Digest SHA256 * transport encryption: validate public key hash * send and receive welcome block with SMP version * refactor: parsing SMPServer * remove unused function * verify that client version is compatible with server version (major version is not smaller) * update (fix) SMP server tests
This commit is contained in:
committed by
GitHub
parent
578e06cd75
commit
0ccde5871c
+2
-2
@@ -2,10 +2,10 @@
|
||||
|
||||
module ChatOptions (getChatOpts, ChatOpts (..)) where
|
||||
|
||||
import qualified Data.Attoparsec.ByteString.Char8 as A
|
||||
import qualified Data.ByteString.Char8 as B
|
||||
import Options.Applicative
|
||||
import Simplex.Messaging.Agent.Transmission (SMPServer (..), smpServerP)
|
||||
import Simplex.Messaging.Parsers (parseAll)
|
||||
import System.FilePath (combine)
|
||||
import System.Info (os)
|
||||
import Types
|
||||
@@ -58,7 +58,7 @@ chatOpts appDir =
|
||||
| otherwise = TermModeEditor
|
||||
|
||||
parseSMPServer :: ReadM SMPServer
|
||||
parseSMPServer = eitherReader $ A.parseOnly (smpServerP <* A.endOfInput) . B.pack
|
||||
parseSMPServer = eitherReader $ parseAll smpServerP . B.pack
|
||||
|
||||
parseTermMode :: ReadM TermMode
|
||||
parseTermMode = maybeReader $ \case
|
||||
|
||||
@@ -26,6 +26,7 @@ import Simplex.Messaging.Agent.Client (AgentClient (..))
|
||||
import Simplex.Messaging.Agent.Env.SQLite
|
||||
import Simplex.Messaging.Agent.Transmission
|
||||
import Simplex.Messaging.Client (smpDefaultConfig)
|
||||
import Simplex.Messaging.Parsers (parseAll)
|
||||
import Simplex.Messaging.Util (bshow, raceAny_)
|
||||
import System.Directory (getAppUserDataDirectory)
|
||||
import System.Exit (exitFailure)
|
||||
@@ -124,7 +125,7 @@ main = do
|
||||
t <- getChatClient smpServer user
|
||||
ct <- newChatTerminal (tbqSize cfg) user termMode
|
||||
-- setLogLevel LogInfo -- LogError
|
||||
-- withGlobalLogging logCfg $
|
||||
-- withGlobalLogging logCfg $ do
|
||||
env <- newSMPAgentEnv cfg {dbFile = dbFileName}
|
||||
dogFoodChat t ct env
|
||||
|
||||
@@ -172,7 +173,7 @@ newChatClient qSize smpServer name = do
|
||||
receiveFromChatTerm :: ChatClient -> ChatTerminal -> IO ()
|
||||
receiveFromChatTerm t ct = forever $ do
|
||||
atomically (readTBQueue $ inputQ ct)
|
||||
>>= processOrError . A.parseOnly (chatCommandP <* A.endOfInput)
|
||||
>>= processOrError . parseAll chatCommandP
|
||||
where
|
||||
processOrError = \case
|
||||
Left err -> atomically . writeTBQueue (outQ t) . ErrorInput $ B.pack err
|
||||
|
||||
Reference in New Issue
Block a user