From 5a74b8066f032ecf09e6cfb9a18a830ee9a6da45 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Tue, 11 Jan 2022 21:23:57 +0000 Subject: [PATCH] prepare v1 release (#189) * update servers * update version * update simplexmq version * update database file names * update server fingerprints and simlexmq * update simplexmq commit * fix port in tests * update tls fixtures (#193) * add -v cli option; print update instructions on -v and /v (#194) Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Co-authored-by: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> --- README.md | 2 +- apps/simplex-chat/Main.hs | 2 +- package.yaml | 4 ++-- simplex-chat.cabal | 8 ++++---- src/Simplex/Chat.hs | 2 +- src/Simplex/Chat/Controller.hs | 8 +++++++- src/Simplex/Chat/Options.hs | 30 +++++++++++++++--------------- src/Simplex/Chat/Store.hs | 2 +- src/Simplex/Chat/View.hs | 2 +- stack.yaml | 2 +- tests/ChatClient.hs | 4 ++-- tests/ProtocolTests.hs | 2 +- tests/fixtures/tls/.gitignore | 1 - tests/fixtures/tls/README.md | 26 -------------------------- tests/fixtures/tls/ca.crt | 19 ++++++++++--------- tests/fixtures/tls/ca.key | 4 ---- tests/fixtures/tls/openssl.cnf | 16 ---------------- tests/fixtures/tls/server.crt | 19 ++++++++++--------- tests/fixtures/tls/server.key | 4 ++-- 19 files changed, 59 insertions(+), 98 deletions(-) delete mode 100644 tests/fixtures/tls/.gitignore delete mode 100644 tests/fixtures/tls/README.md delete mode 100644 tests/fixtures/tls/ca.key delete mode 100644 tests/fixtures/tls/openssl.cnf diff --git a/README.md b/README.md index d56f74e699..cc6fc820ea 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ To specify a different file path prefix for the database files use `-d` command $ simplex-chat -d alice ``` -Running above, for example, would create `alice_chat.db` and `alice_agent.db` database files in current directory. +Running above, for example, would create `alice_v1_chat.db` and `alice_v1_agent.db` database files in current directory. Default SMP servers are hosted on Linode (London, UK and Fremont, CA) - they are [pre-configured in the app](https://github.com/simplex-chat/simplex-chat/blob/master/src/Simplex/Chat/Options.hs#L40). Base-64 encoded string after server host is the transport key digest. diff --git a/apps/simplex-chat/Main.hs b/apps/simplex-chat/Main.hs index 716dd7e39f..55fe640014 100644 --- a/apps/simplex-chat/Main.hs +++ b/apps/simplex-chat/Main.hs @@ -22,6 +22,6 @@ welcomeGetOpts = do appDir <- getAppUserDataDirectory "simplex" opts@ChatOpts {dbFile} <- getChatOpts appDir putStrLn $ "SimpleX Chat v" ++ versionNumber - putStrLn $ "db: " <> dbFile <> ".chat.db, " <> dbFile <> ".agent.db" + putStrLn $ "db: " <> dbFile <> "_chat.db, " <> dbFile <> "_agent.db" putStrLn "type \"/help\" or \"/h\" for usage info" pure opts diff --git a/package.yaml b/package.yaml index 7a5a670c5d..e34e924a2a 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: simplex-chat -version: 0.5.4 +version: 1.0.0 #synopsis: #description: homepage: https://github.com/simplex-chat/simplex-chat#readme @@ -29,7 +29,7 @@ dependencies: - optparse-applicative >= 0.15 && < 0.17 - process == 1.6.* - simple-logger == 0.1.* - - simplexmq >= 0.5.2 && < 0.6 + - simplexmq >= 1.0 && < 1.1 - sqlite-simple == 0.4.* - stm == 2.5.* - terminal == 0.2.* diff --git a/simplex-chat.cabal b/simplex-chat.cabal index 5f173b3da2..d30d63cc16 100644 --- a/simplex-chat.cabal +++ b/simplex-chat.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: simplex-chat -version: 0.5.4 +version: 1.0.0 category: Web, System, Services, Cryptography homepage: https://github.com/simplex-chat/simplex-chat#readme author: Evgeny Poberezkin @@ -56,7 +56,7 @@ library , optparse-applicative >=0.15 && <0.17 , process ==1.6.* , simple-logger ==0.1.* - , simplexmq >=0.5.2 && <0.6 + , simplexmq ==1.0.* , sqlite-simple ==0.4.* , stm ==2.5.* , terminal ==0.2.* @@ -93,7 +93,7 @@ executable simplex-chat , process ==1.6.* , simple-logger ==0.1.* , simplex-chat - , simplexmq >=0.5.2 && <0.6 + , simplexmq ==1.0.* , sqlite-simple ==0.4.* , stm ==2.5.* , terminal ==0.2.* @@ -138,7 +138,7 @@ test-suite simplex-chat-test , process ==1.6.* , simple-logger ==0.1.* , simplex-chat - , simplexmq >=0.5.2 && <0.6 + , simplexmq ==1.0.* , sqlite-simple ==0.4.* , stm ==2.5.* , terminal ==0.2.* diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 10841f6202..585b039ca6 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -142,7 +142,7 @@ newChatController config@ChatConfig {agentConfig = cfg, dbPoolSize, tbqSize} Cha chatStore <- createStore f dbPoolSize currentUser <- newTVarIO =<< getCreateActiveUser chatStore chatTerminal <- newChatTerminal t - smpAgent <- getSMPAgentClient cfg {dbFile = dbFile <> ".agent.db", smpServers} + smpAgent <- getSMPAgentClient cfg {dbFile = dbFile <> "_agent.db", smpServers} idsDrg <- newTVarIO =<< drgNew inputQ <- newTBQueueIO tbqSize notifyQ <- newTBQueueIO tbqSize diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index b8749283b5..91c3607208 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -26,7 +26,13 @@ import System.IO (Handle) import UnliftIO.STM versionNumber :: String -versionNumber = "0.5.4" +versionNumber = "1.0.0" + +versionStr :: String +versionStr = "SimpleX Chat v" <> versionNumber + +updateStr :: String +updateStr = "To update run: curl -o- https://raw.githubusercontent.com/simplex-chat/simplex-chat/master/install.sh | bash" data ChatConfig = ChatConfig { agentConfig :: AgentConfig, diff --git a/src/Simplex/Chat/Options.hs b/src/Simplex/Chat/Options.hs index d0ffa5b6f8..474af73814 100644 --- a/src/Simplex/Chat/Options.hs +++ b/src/Simplex/Chat/Options.hs @@ -7,6 +7,7 @@ import qualified Data.ByteString.Char8 as B import Data.List.NonEmpty (NonEmpty) import qualified Data.List.NonEmpty as L import Options.Applicative +import Simplex.Chat.Controller (updateStr, versionStr) import Simplex.Messaging.Agent.Protocol (SMPServer (..)) import Simplex.Messaging.Encoding.String import Simplex.Messaging.Parsers (parseAll) @@ -24,8 +25,9 @@ chatOpts appDir = ( long "database" <> short 'd' <> metavar "DB_FILE" - <> help ("sqlite database file path (" <> defaultDbFilePath <> ")") + <> help "Path prefix to chat and agent database files" <> value defaultDbFilePath + <> showDefault ) <*> option parseSMPServer @@ -33,18 +35,17 @@ chatOpts appDir = <> short 's' <> metavar "SERVER" <> help - ( "SMP server(s) to use" - <> "\n(smp2.simplex.im,smp3.simplex.im)" - ) + "Comma separated list of SMP server(s) to use \ + \(default: smp4.simplex.im,smp5.simplex.im,smp6.simplex.im)" <> value ( L.fromList - [ "smp://z5W2QLQ1Br3Yd6CoWg7bIq1bHdwK7Y8bEiEXBs_WfAg=@smp2.simplex.im", -- London, UK - "smp://nxc7HnrnM8dOKgkMp008ub_9o9LXJlxlMrMpR-mfMQw=@smp3.simplex.im" -- Fremont, CA + [ "smp://CTMzyymBBawF0yuMln3UxTip6RgFVtYPL8UYuCoIBwE=@139.162.205.110", -- London, UK + "smp://t82czNx4tiftzbk_M4KEITL1RS9CmcTWiCLHSlNsEZ8=@96.126.97.196" -- Fremont, CA ] ) ) where - defaultDbFilePath = combine appDir "simplex" + defaultDbFilePath = combine appDir "simplex_v1" parseSMPServer :: ReadM (NonEmpty SMPServer) parseSMPServer = eitherReader $ parseAll servers . B.pack @@ -52,12 +53,11 @@ parseSMPServer = eitherReader $ parseAll servers . B.pack servers = L.fromList <$> strP `A.sepBy1` A.char ',' getChatOpts :: FilePath -> IO ChatOpts -getChatOpts appDir = execParser opts +getChatOpts appDir = + execParser $ + info + (helper <*> versionOption <*> chatOpts appDir) + (header versionStr <> fullDesc <> progDesc "Start chat with DB_FILE file and use SERVER as SMP server") where - opts = - info - (chatOpts appDir <**> helper) - ( fullDesc - <> header "Chat prototype using Simplex Messaging Protocol (SMP)" - <> progDesc "Start chat with DB_FILE file and use SERVER as SMP server" - ) + versionOption = infoOption versionAndUpdate (long "version" <> short 'v' <> help "Show version") + versionAndUpdate = versionStr <> "\n" <> updateStr diff --git a/src/Simplex/Chat/Store.hs b/src/Simplex/Chat/Store.hs index 484b6e3d61..9187673a2f 100644 --- a/src/Simplex/Chat/Store.hs +++ b/src/Simplex/Chat/Store.hs @@ -145,7 +145,7 @@ createStore :: FilePath -> Int -> IO SQLiteStore createStore dbFilePath poolSize = createSQLiteStore dbFilePath poolSize migrations chatStoreFile :: FilePath -> FilePath -chatStoreFile = (<> ".chat.db") +chatStoreFile = (<> "_chat.db") checkConstraint :: StoreError -> IO (Either StoreError a) -> IO (Either StoreError a) checkConstraint err action = action `E.catch` (pure . Left . handleSQLError err) diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 8e5378b34d..6305091c94 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -834,4 +834,4 @@ styleTime :: String -> StyledString styleTime = Styled [SetColor Foreground Vivid Black] clientVersionInfo :: [StyledString] -clientVersionInfo = [plain $ "SimpleX Chat v" <> versionNumber] +clientVersionInfo = [plain versionStr, plain updateStr] diff --git a/stack.yaml b/stack.yaml index 0792aaf082..309b073e12 100644 --- a/stack.yaml +++ b/stack.yaml @@ -41,7 +41,7 @@ extra-deps: # - simplexmq-0.5.2@sha256:3544e479f353c1bbc6aa9405ef6976b78364f437d8af9cc45b9e0b228429e240,7884 # - ../simplexmq - github: simplex-chat/simplexmq - commit: 40d91e8fad499c9e3fb4317b6bcd93037b2bf1cd + commit: d8a61de290207509dc57a548f5551e294066e040 - github: simplex-chat/hs-tls commit: cea6d52c512716ff09adcac86ebc95bb0b3bb797 subdirs: diff --git a/tests/ChatClient.hs b/tests/ChatClient.hs index 19504a5e5c..d4fde905b1 100644 --- a/tests/ChatClient.hs +++ b/tests/ChatClient.hs @@ -39,7 +39,7 @@ opts :: ChatOpts opts = ChatOpts { dbFile = undefined, - smpServers = ["smp://9VjLsOY5ZvB4hoglNdBzJFAUi_vP4GkZnJFahQOXV20=@localhost:5001"] + smpServers = ["smp://LcJUMfVhwD8yxjAiSaDzzGF3-kLG4Uh0Fl_ZIjrRwjI=@localhost:5001"] } termSettings :: VirtualTerminalSettings @@ -71,7 +71,7 @@ cfg = virtualSimplexChat :: FilePath -> Profile -> IO TestCC virtualSimplexChat dbFile profile = do - st <- createStore (dbFile <> ".chat.db") 1 + st <- createStore (dbFile <> "_chat.db") 1 void . runExceptT $ createUser st profile True t <- withVirtualTerminal termSettings pure cc <- newChatController cfg opts {dbFile} t . const $ pure () -- no notifications diff --git a/tests/ProtocolTests.hs b/tests/ProtocolTests.hs index 6d642994f1..895b323206 100644 --- a/tests/ProtocolTests.hs +++ b/tests/ProtocolTests.hs @@ -23,7 +23,7 @@ srv :: SMPServer srv = SMPServer { host = "smp.simplex.im", - port = Just "5223", + port = "5223", keyHash = C.KeyHash "\215m\248\251" } diff --git a/tests/fixtures/tls/.gitignore b/tests/fixtures/tls/.gitignore deleted file mode 100644 index e988acd1be..0000000000 --- a/tests/fixtures/tls/.gitignore +++ /dev/null @@ -1 +0,0 @@ -server.csr diff --git a/tests/fixtures/tls/README.md b/tests/fixtures/tls/README.md deleted file mode 100644 index 9e12802a60..0000000000 --- a/tests/fixtures/tls/README.md +++ /dev/null @@ -1,26 +0,0 @@ -To generate fixtures: - -(keep these instructions and *openssl.cnf* consistent with certificate generation on server) - -```sh -# CA certificate (identity/offline) -openssl genpkey -algorithm ED448 -out ca.key -openssl req -new -x509 -days 999999 -config openssl.cnf -extensions v3_ca -key ca.key -out ca.crt -# server certificate (online) -openssl genpkey -algorithm ED448 -out server.key -openssl req -new -config openssl.cnf -reqexts v3_req -key server.key -out server.csr -openssl x509 -req -days 999999 -extfile openssl.cnf -extensions v3_req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -# to pretty-print -openssl x509 -in ca.crt -text -noout -openssl req -in server.csr -text -noout -openssl x509 -in server.crt -text -noout -``` - -To compute fingerprint for tests: - -```haskell -stack ghci -> import Data.X509.Validation (Fingerprint (..)) -> Fingerprint fp <- loadFingerprint "tests/fixtures/ca.crt" -> strEncode fp -``` diff --git a/tests/fixtures/tls/ca.crt b/tests/fixtures/tls/ca.crt index 290d8f32dd..e9902529bc 100644 --- a/tests/fixtures/tls/ca.crt +++ b/tests/fixtures/tls/ca.crt @@ -1,11 +1,12 @@ -----BEGIN CERTIFICATE----- -MIIBijCCAQqgAwIBAgIUf/txCk9PXE4nY2gQ/B/HG2sNzmswBQYDK2VxMBQxEjAQ -BgNVBAMMCWxvY2FsaG9zdDAgFw0yMTEyMjMxNzEzMjNaGA80NzU5MTExOTE3MTMy -M1owFDESMBAGA1UEAwwJbG9jYWxob3N0MEMwBQYDK2VxAzoAXlJkn15EFUS21zLI -I+HSKlhvt88LSXK70KkN4JRRLrXPaTYfpSchFZWmSuLmx5m6rmSg5Ywj9d2Ao1Mw -UTAdBgNVHQ4EFgQUxJBTkCx02jIpcUKU4fJYcnce59QwHwYDVR0jBBgwFoAUxJBT -kCx02jIpcUKU4fJYcnce59QwDwYDVR0TAQH/BAUwAwEB/zAFBgMrZXEDcwDlxmpY -U7j3CIVnMKAGA1rqML5lvKrDTS6DidTiq90dkMTyoXv8AE4omdiGobMnB3HZPl+B -CpdDUYCfQfkNdi8Hqj3V9viqcgahbn5mGnjUAK1+Ix6r7KLm2zeKcfGEG008ykGW -TMUFDvkQqRIlFDdOPAA= +MIIBtjCCATagAwIBAgIUe2PryrWo0xXX9vcA3WfbCzcdmgAwBQYDK2VxMCoxFjAU +BgNVBAMMDVNNUCBzZXJ2ZXIgQ0ExEDAOBgNVBAoMB1NpbXBsZVgwIBcNMjIwMTEx +MTExNjM5WhgPNDc1OTEyMDgxMTE2MzlaMCoxFjAUBgNVBAMMDVNNUCBzZXJ2ZXIg +Q0ExEDAOBgNVBAoMB1NpbXBsZVgwQzAFBgMrZXEDOgCAcvFwVicR+RLZpiEWPFNR +XYTbf+mFcX1NHIyPQDugFwOCgqJAW1fsjYgFhtQJSMH/lc1N7clfm4CjUzBRMB0G +A1UdDgQWBBQcUJvR7mm26yxMQfCsWgbnwMmJVDAfBgNVHSMEGDAWgBQcUJvR7mm2 +6yxMQfCsWgbnwMmJVDAPBgNVHRMBAf8EBTADAQH/MAUGAytlcQNzAAAP/hMPNxyW +fyJi+iJViodU+C/aklnvHtjh5P3AbiVCSUfY6+PEdvkC8Ov0pBAYpYi5ukSNNVXl +ABVRlipB+vOcLQStNyaZ7kXzQ2IO/0btmIidh+G6SP8I4aytYIYYcV5pEUZpG1L1 +57g8P29SDv81AA== -----END CERTIFICATE----- diff --git a/tests/fixtures/tls/ca.key b/tests/fixtures/tls/ca.key deleted file mode 100644 index ca14015e04..0000000000 --- a/tests/fixtures/tls/ca.key +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PRIVATE KEY----- -MEcCAQAwBQYDK2VxBDsEOZvjURTKSor4A7+45hnY721WD06L3E4UMKh9zntEY83C -CCv1Jju2fffDmtIFl6EXytF/nyEPGQfS5A== ------END PRIVATE KEY----- diff --git a/tests/fixtures/tls/openssl.cnf b/tests/fixtures/tls/openssl.cnf deleted file mode 100644 index ab53446066..0000000000 --- a/tests/fixtures/tls/openssl.cnf +++ /dev/null @@ -1,16 +0,0 @@ -[req] -distinguished_name = req_distinguished_name -prompt = no - -[req_distinguished_name] -CN = localhost - -[v3_ca] -subjectKeyIdentifier = hash -authorityKeyIdentifier = keyid:always -basicConstraints = critical,CA:true - -[v3_req] -basicConstraints = CA:FALSE -keyUsage = digitalSignature, nonRepudiation, keyAgreement -extendedKeyUsage = serverAuth diff --git a/tests/fixtures/tls/server.crt b/tests/fixtures/tls/server.crt index 2c01c21838..68234a19a8 100644 --- a/tests/fixtures/tls/server.crt +++ b/tests/fixtures/tls/server.crt @@ -1,11 +1,12 @@ -----BEGIN CERTIFICATE----- -MI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xUxNgxX4R2nA+0St866uFbdyxApiyn44giG+m+YXCXLjh +1ffKEhhqAPdlpzByLarx8EWgmOsisBCRWrmraksOV15FKxjPqm7OYKp4f9GvieAQ +o/SKOyZVVdcZX7NcuDUxAA== -----END CERTIFICATE----- diff --git a/tests/fixtures/tls/server.key b/tests/fixtures/tls/server.key index 579ac813c8..27e0b7caaa 100644 --- a/tests/fixtures/tls/server.key +++ b/tests/fixtures/tls/server.key @@ -1,4 +1,4 @@ -----BEGIN PRIVATE KEY----- -MEcCAQAwBQYDK2VxBDsEOQANqfrmSygKW1iiDCgf/G/y2AH1lp5NurM3Q73fp9Aw -nznRFYq6BvM03cMOkqtFpQd15A+DZr248A== +MEcCAQAwBQYDK2VxBDsEOZcXSjKQ3FQ9EBfqHmFIidOu4LecpUgi5NVPMhx7mS2d +QNQ0lFasp+EfvLErbs1Sd9xLVxA1hnZJng== -----END PRIVATE KEY-----