From 662717a25bd7dfeeebf2d4a5a3613268860e14cd Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sun, 11 Oct 2020 11:00:25 +0100 Subject: [PATCH 01/16] initial --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..ec7b78b64f --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# simplex-messaging From 11580d993880e05dd0acf924fe9a4f6107165d53 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sun, 18 Oct 2020 21:28:37 +0100 Subject: [PATCH 02/16] docs: readme, system design --- README.md | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/README.md b/README.md index ec7b78b64f..1cda22211f 100644 --- a/README.md +++ b/README.md @@ -1 +1,93 @@ # simplex-messaging + +## SMP server demo + +This is a demo implementation of SMP (simplex messaging protocol) server. + +This is not usable for real applications, as it lacks the following protocol features: + +- cryptographic signature verification, instead it simply compares provided "signature" with stored "public key", effectively treating them as plain text passwords. +- there is no transport encryption + +These limitations make it easy to experiment with the protocol logic via telnet. + +You can either run it locally or try with the deployed demo server: + +```bash +telnet smp.simplex.im 5223 +``` + +## Run locally + +[Install stack](https://docs.haskellstack.org/en/stable/install_and_upgrade/) and `stack run`. + +## Usage example + +Lines you should send are prefixed with `>` character, you should not type them. + +Comments are prefixed with `--`, they are not part of transmission. + +`>` on its own means you need to press return - telnet should be configured to send CRLF. + +1. Create simplex message queue: + +```telnet +> +> +> CONN 1234 -- 1234 is recipient's key + + +IDS QuCLU4YxgS7wcPFA YB4CCATREHkaQcEh -- recipient and sender ID for the queue +``` + +2. Sender can send their "key" to the connection: + +```telnet +> -- no signature (just press enter) +> YB4CCATREHkaQcEh -- sender ID for the queue +> SEND :key abcd + +YB4CCATREHkaQcEh +OK +``` + +3. Secure queue with sender's "key" + +```telnet +> 1234 -- "signature" - same as "key" in the demo +> QuCLU4YxgS7wcPFA -- recipient ID +> KEY abcd -- "key" provided by sender + +QuCLU4YxgS7wcPFA +OK +``` + +4. Sender can now send messages to the queue + +```telnet +> abcd +> YB4CCATREHkaQcEh +> SEND :hello + +YB4CCATREHkaQcEh +OK +``` + +5. Recipient recieves the message and acknowledges it to receive further messages + +```telnet + +QuCLU4YxgS7wcPFA +MSG ECA3w3ID 2020-10-18T20:19:36.874Z 5 +hello +> 1234 +> QuCLU4YxgS7wcPFA +> ACK + +QuCLU4YxgS7wcPFA +OK +``` + +## Desgin + +![server design](design/server.svg) From 9b3c63deaa40a8bf28f6fdb12e818aa9c9bce1a0 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sun, 18 Oct 2020 21:31:51 +0100 Subject: [PATCH 03/16] readme corrections --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1cda22211f..8ee5d3901f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## SMP server demo -This is a demo implementation of SMP (simplex messaging protocol) server. +This is a demo implementation of SMP ([simplex messaging protocol](https://github.com/simplex-chat/protocol/blob/master/simplex-messaging.md)) server. This is not usable for real applications, as it lacks the following protocol features: @@ -54,7 +54,7 @@ OK 3. Secure queue with sender's "key" ```telnet -> 1234 -- "signature" - same as "key" in the demo +> 1234 -- recipient's "signature" - same as "key" in the demo > QuCLU4YxgS7wcPFA -- recipient ID > KEY abcd -- "key" provided by sender @@ -65,8 +65,8 @@ OK 4. Sender can now send messages to the queue ```telnet -> abcd -> YB4CCATREHkaQcEh +> abcd -- sender's "signature" - same as "key" in the demo +> YB4CCATREHkaQcEh -- sender ID > SEND :hello YB4CCATREHkaQcEh @@ -88,6 +88,6 @@ QuCLU4YxgS7wcPFA OK ``` -## Desgin +## Design ![server design](design/server.svg) From b399ee78daa8c034fd90f9d6dc477f65fb0501aa Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 22 Oct 2020 14:13:06 +0100 Subject: [PATCH 04/16] update readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8ee5d3901f..ef15a71f2f 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ This is a demo implementation of SMP ([simplex messaging protocol](https://github.com/simplex-chat/protocol/blob/master/simplex-messaging.md)) server. -This is not usable for real applications, as it lacks the following protocol features: +It has a very limited utility (if any) for real applications, as it lacks the following protocol features: - cryptographic signature verification, instead it simply compares provided "signature" with stored "public key", effectively treating them as plain text passwords. - there is no transport encryption -These limitations make it easy to experiment with the protocol logic via telnet. +Because of these limitations, it is easy to experiment with the protocol logic via telnet. You can either run it locally or try with the deployed demo server: @@ -25,22 +25,22 @@ telnet smp.simplex.im 5223 Lines you should send are prefixed with `>` character, you should not type them. -Comments are prefixed with `--`, they are not part of transmission. +Comments are prefixed with `--`, they are not part of transmissions. -`>` on its own means you need to press return - telnet should be configured to send CRLF. +`>` on its own means you need to press `return` - telnet should be configured to send it as CRLF. 1. Create simplex message queue: ```telnet > > -> CONN 1234 -- 1234 is recipient's key +> NEW 1234 -- 1234 is recipient's key -IDS QuCLU4YxgS7wcPFA YB4CCATREHkaQcEh -- recipient and sender ID for the queue +IDS QuCLU4YxgS7wcPFA YB4CCATREHkaQcEh -- recipient and sender IDs for the queue ``` -2. Sender can send their "key" to the connection: +2. Sender can send their "key" to the queue: ```telnet > -- no signature (just press enter) From df181bb0f0c71d5230d81c394e3d9037e274ea3b Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Mon, 28 Dec 2020 16:28:57 +0000 Subject: [PATCH 05/16] docs: add correlation IDs to examples --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index ef15a71f2f..09ed01cd77 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,11 @@ Comments are prefixed with `--`, they are not part of transmissions. ```telnet > +> abcd -- correlation ID, any string > > NEW 1234 -- 1234 is recipient's key +abcd IDS QuCLU4YxgS7wcPFA YB4CCATREHkaQcEh -- recipient and sender IDs for the queue ``` @@ -44,9 +46,11 @@ IDS QuCLU4YxgS7wcPFA YB4CCATREHkaQcEh -- recipient and sender IDs for the queue ```telnet > -- no signature (just press enter) +> bcda -- correlation ID, any string > YB4CCATREHkaQcEh -- sender ID for the queue > SEND :key abcd +bcda YB4CCATREHkaQcEh OK ``` @@ -55,9 +59,11 @@ OK ```telnet > 1234 -- recipient's "signature" - same as "key" in the demo +> cdab > QuCLU4YxgS7wcPFA -- recipient ID > KEY abcd -- "key" provided by sender +cdab QuCLU4YxgS7wcPFA OK ``` @@ -66,9 +72,11 @@ OK ```telnet > abcd -- sender's "signature" - same as "key" in the demo +> dabc -- correlation ID > YB4CCATREHkaQcEh -- sender ID > SEND :hello +dabc YB4CCATREHkaQcEh OK ``` @@ -77,13 +85,16 @@ OK ```telnet +-- no correlation ID for messages delivered without client command QuCLU4YxgS7wcPFA MSG ECA3w3ID 2020-10-18T20:19:36.874Z 5 hello > 1234 +> abcd > QuCLU4YxgS7wcPFA > ACK +abcd QuCLU4YxgS7wcPFA OK ``` From eede6c5da904dee424046fb228ba7b8f720e301c Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Mon, 11 Jan 2021 19:14:54 +0000 Subject: [PATCH 06/16] readme: released version link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 09ed01cd77..034d34c57d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # simplex-messaging +The released version is [v0.1.0.0](https://github.com/simplex-chat/simplex-messaging/tree/v0.1.0.0) + ## SMP server demo This is a demo implementation of SMP ([simplex messaging protocol](https://github.com/simplex-chat/protocol/blob/master/simplex-messaging.md)) server. From 1c2ac43a13bf41ed7810950e14826403268fb504 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Mon, 11 Jan 2021 19:23:36 +0000 Subject: [PATCH 07/16] rename workflow, build/version badges --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 034d34c57d..869f44afde 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # simplex-messaging -The released version is [v0.1.0.0](https://github.com/simplex-chat/simplex-messaging/tree/v0.1.0.0) +[![GitHub build](https://github.com/simplex-chat/simplex-messaging/workflows/build/badge.svg)](https://github.com/simplex-chat/simplex-messaging/actions?query=workflow%3Abuild) +![GitHub release](https://img.shields.io/github/v/release/simplex-chat/simplex-messaging) ## SMP server demo From 062934ec1e4eb325a1a95b376e23165260ef1b51 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Mon, 11 Jan 2021 19:25:37 +0000 Subject: [PATCH 08/16] readme: link to releases --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 869f44afde..eab4c1dba7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # simplex-messaging [![GitHub build](https://github.com/simplex-chat/simplex-messaging/workflows/build/badge.svg)](https://github.com/simplex-chat/simplex-messaging/actions?query=workflow%3Abuild) -![GitHub release](https://img.shields.io/github/v/release/simplex-chat/simplex-messaging) +[![GitHub release](https://img.shields.io/github/v/release/simplex-chat/simplex-messaging)](https://github.com/simplex-chat/simplex-messaging/releases) ## SMP server demo From 54e818bd394f970d64c76eb7db6be3e2408181de Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Wed, 20 Jan 2021 21:01:54 +0000 Subject: [PATCH 09/16] Sending messages end to end (#21) * duplex connection end-to-end (working, debug logs) * agent: send, receive, acknowledge messages * logging proposal * logging: client/server (dis)connections * agent scenario testing framework * add tests, remove logs * clean up --- docs/logging.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 docs/logging.md diff --git a/docs/logging.md b/docs/logging.md new file mode 100644 index 0000000000..04d2784aaf --- /dev/null +++ b/docs/logging.md @@ -0,0 +1,70 @@ +# SMP agent logging + +## Problem and proposed solution. + +SMP agent performs multiple actions in response to the client commands and to the messages received from other SMP agents (wrapped in SMP protocol messages). + +Customary approach for the network protocol clients is to have a debug/verbose mode that enables logging of all sent and received messages and any other actions that the client performs. + +This document proposes a logging format for SMP agent that would be enabled if the agent is run with `--verbose` / `-v` command line option. + +We can also consider logging the database operations that change the data. + +## Types of actions and the associated log line format. + +### Client connected / disconnected + +``` +client n connected to Agent +client n disconnected from Agent +``` + +where `n` is a sequential number of a connected agent client, starting from 1 (over the agent run-time). + +### Server connected / disconnected + +``` +Agent connected to host:port +Agent disconnected from host:port +``` + +### Received command from the client + +``` +n --> A : corrId connAlias parsed_command // raw_command +``` + +`raw_command` is added only in case of parsing failure. + +### Sent command to SMP server + +``` +A --> host:port : corrId queueId parsed_command +``` + +### Received response / message from the SMP server + +``` +A <-- host:port : corrId queueId parsed_command // raw_command +``` + +In case the response is a message or notification, corrId should be replaced with `_` + +### Interpreted ("unwrapped") SMP message as agent message + +``` +Agent msg : connAlias parsed_message // raw_message +``` + +### Sent response / message to the client + +``` +n <-- A : corrId connAlias parsed_command // raw_command +``` + +### Database changes + +``` +DB : insert/delete/update table key +DB : insert/delete/update table key +``` \ No newline at end of file From 5489e92e31dda8818e7b7e5a40823cda2634c9e1 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 28 Jan 2021 20:51:17 +0000 Subject: [PATCH 10/16] message management (#32) * message management rfc * update message management rfc * message management ideas (WIP) * message management updated * messages RFC * update agent MSG constructor to include recipient/broker/sender message IDs and timestamps * remove agent command ACK - agent automatically acknowledges server messages * correct messages doc --- docs/logging.md | 70 ------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 docs/logging.md diff --git a/docs/logging.md b/docs/logging.md deleted file mode 100644 index 04d2784aaf..0000000000 --- a/docs/logging.md +++ /dev/null @@ -1,70 +0,0 @@ -# SMP agent logging - -## Problem and proposed solution. - -SMP agent performs multiple actions in response to the client commands and to the messages received from other SMP agents (wrapped in SMP protocol messages). - -Customary approach for the network protocol clients is to have a debug/verbose mode that enables logging of all sent and received messages and any other actions that the client performs. - -This document proposes a logging format for SMP agent that would be enabled if the agent is run with `--verbose` / `-v` command line option. - -We can also consider logging the database operations that change the data. - -## Types of actions and the associated log line format. - -### Client connected / disconnected - -``` -client n connected to Agent -client n disconnected from Agent -``` - -where `n` is a sequential number of a connected agent client, starting from 1 (over the agent run-time). - -### Server connected / disconnected - -``` -Agent connected to host:port -Agent disconnected from host:port -``` - -### Received command from the client - -``` -n --> A : corrId connAlias parsed_command // raw_command -``` - -`raw_command` is added only in case of parsing failure. - -### Sent command to SMP server - -``` -A --> host:port : corrId queueId parsed_command -``` - -### Received response / message from the SMP server - -``` -A <-- host:port : corrId queueId parsed_command // raw_command -``` - -In case the response is a message or notification, corrId should be replaced with `_` - -### Interpreted ("unwrapped") SMP message as agent message - -``` -Agent msg : connAlias parsed_message // raw_message -``` - -### Sent response / message to the client - -``` -n <-- A : corrId connAlias parsed_command // raw_command -``` - -### Database changes - -``` -DB : insert/delete/update table key -DB : insert/delete/update table key -``` \ No newline at end of file From 2ad54cf1d316bb220840154c6b8457ea14285ece Mon Sep 17 00:00:00 2001 From: Efim Poberezkin Date: Tue, 16 Feb 2021 01:01:46 +0400 Subject: [PATCH 11/16] add instructions on how to run chat client to README (#43) * add instructions on how to run chat client to README * wording * wording * corrections to the manual Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- README.md | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eab4c1dba7..ad2e8423bc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,91 @@ [![GitHub build](https://github.com/simplex-chat/simplex-messaging/workflows/build/badge.svg)](https://github.com/simplex-chat/simplex-messaging/actions?query=workflow%3Abuild) [![GitHub release](https://img.shields.io/github/v/release/simplex-chat/simplex-messaging)](https://github.com/simplex-chat/simplex-messaging/releases) -## SMP server demo +## Federated chat - private, secure, decentralised + +See [simplex.chat](https://simplex.chat) website for chat demo and the explanations of the system and how SMP protocol works. + +SMP protocol is semi-formally defined [here](https://github.com/simplex-chat/protocol). + +Currently only these features are available: +- simple 1-2-1 chat with multiple people in the same terminal window. +- auto-populated recipient name - just type your messages. +- default server is available to play with - `smp.simplex.im:5223` - and you can deploy your own (`smp-server` executable in this repo). +- no global identity or names visible to the server(s) - for the privacy of contacts and conversations. +- E2E encryption, with public key that has to be passed out-of-band (see below) +- authentication of each command/message with automatically generated RSA key pairs, separate for each conversation, the keys are not used as identity (2048 bit keys are used, it can be changed in [code via rsaKeySize setting](https://github.com/simplex-chat/simplex-messaging/blob/master/apps/dog-food/Main.hs)) + +Limitations/disclaimers: +- no support for chat groups. It is coming in the next major version (i.e., not very soon:) +- no delivery notifications - coming soon +- no TCP transport encryption - coming soon (messages are encrypted e2e though, only random connection IDs and server commands are visible, but not the contents of the message) +- system and protocol security was not audited yet, so you probably should NOT use it yet for high security communications - unless you know what you are doing. + +## How to run chat client locally + +Install [Haskell platform](https://www.haskell.org/platform/) (ghc, cabal, stack) and build the project: + +```shell +$ git clone git@github.com:simplex-chat/simplex-messaging.git +$ cd simplex-messaging +$ stack install +$ dog-food +``` + +`dog-food` (as in "eating your own dog food" - it is an early prototype) starts chat client with default parameters. By default, SQLite database file is created in the working directory (`smp-chat.db`), and the default SMP server is `smp.simplex.im:5223`. + +To specify a different chat database location run: + +```bash +mkdir ~/simplex +dog-food -d ~/simplex/my-chat.db +``` + +You can deploy your own server and set client to use it via command line option: + +```bash +dog-food -s smp.example.com:5223 +``` + +You can still talk to people using default or any other server, it only affects the location of the message queue when you initiate the connection (and the reply queue can be on another server, as set by the other party's client). + +Run `dog-food --help` to see all available options. + +### Using chat client + +Once chat client is started, use `/add ` to create a new connection and generate an invitation to send to your contact via any other communication channel (`` - is any name you want to use for that contact). + +Invitation has format `smp::::::` - this needs to be shared with another party, via any other chat. It can only be used once - even if this is intercepted, the attacker would not be able to use it to send you the messages via this queue once your contact confirms that the connection is established. + +The party that received the invitation should use `/accept ` to accept the connection (`` is any name that the accepting party wants to use for you). + +For example, if Alice and Bob want to chat, with Alice initiating, Alice would use [in her chat client]: + +``` +/add bob +``` + +And then send the generated invitation to Bob out-of-band. Bob then would use [in his chat client]: + +``` +/accept alice +``` + +They would then use `@ ` commands to send messages. One may also press Space or just start typing a message to send a message to the contact that was the last. + +If you exit from chat client (or if internet connection is interrupted) you need to use `/chat ` to activate conversation with respective contact - it is not resumed automatically (it will improve soon). + +Since SMP doesn't use global identity (all account information is managed by clients), you should configure your name to use in invitations for your contacts: + +``` +/name alice +``` + +Now Alice's invitations would be generated with her name in it for others' convenience. + +Use `/help` in chat to see the list of available commands and their explanation. + +## 🚧 [further README not up to date] SMP server demo 🏗 This is a demo implementation of SMP ([simplex messaging protocol](https://github.com/simplex-chat/protocol/blob/master/simplex-messaging.md)) server. From b5bfa3ac8c9a580e5486c7a7d5a91c5dca29234f Mon Sep 17 00:00:00 2001 From: Efim Poberezkin Date: Sun, 21 Feb 2021 19:59:52 +0400 Subject: [PATCH 12/16] add Dockerfile for building chat executable and instructions on running it (#48) * [WIP] add instructions how to build project inside docker container * docker run -> docker create * add Dockerfile for building chat executable and instructions --- Dockerfile | 10 ++++++++++ README.md | 21 ++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..c03da4ac63 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM haskell:8.8.4 AS build-stage +# if you encounter "version `GLIBC_2.28' not found" error when running +# chat client executable, build with the following base image instead: +# FROM haskell:8.8.4-stretch AS build-stage +COPY . /project +WORKDIR /project +RUN stack install + +FROM scratch AS export-stage +COPY --from=build-stage /root/.local/bin/dog-food / diff --git a/README.md b/README.md index ad2e8423bc..37be83c6d5 100644 --- a/README.md +++ b/README.md @@ -34,19 +34,30 @@ $ stack install $ dog-food ``` +If you'd prefer to not set up Haskell locally, you may instead build the chat client executable using [docker build with custom output](https://docs.docker.com/engine/reference/commandline/build/#custom-build-outputs): + +```shell +$ git clone git@github.com:simplex-chat/simplex-messaging.git +$ cd simplex-messaging +$ DOCKER_BUILDKIT=1 docker build --output ~/.local/bin . +$ dog-food +``` + +> **NOTE:** when running chat client executable built with the latter approach, if you encounter ``version `GLIBC_2.28' not found`` error, rebuild it with `haskell:8.8.4-stretch` base image instead (you'd have to change it in your local [Dockerfile](Dockerfile)). + `dog-food` (as in "eating your own dog food" - it is an early prototype) starts chat client with default parameters. By default, SQLite database file is created in the working directory (`smp-chat.db`), and the default SMP server is `smp.simplex.im:5223`. To specify a different chat database location run: -```bash -mkdir ~/simplex -dog-food -d ~/simplex/my-chat.db +```shell +$ mkdir ~/simplex +$ dog-food -d ~/simplex/my-chat.db ``` You can deploy your own server and set client to use it via command line option: -```bash -dog-food -s smp.example.com:5223 +```shell +$ dog-food -s smp.example.com:5223 ``` You can still talk to people using default or any other server, it only affects the location of the message queue when you initiate the connection (and the reply queue can be on another server, as set by the other party's client). From fe8b28a655a186ad67597cc1dceab8aaf13d1832 Mon Sep 17 00:00:00 2001 From: Efim Poberezkin Date: Fri, 26 Feb 2021 18:53:50 +0400 Subject: [PATCH 13/16] add chat history instructions to README (#56) --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 37be83c6d5..938880b4b2 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ $ DOCKER_BUILDKIT=1 docker build --output ~/.local/bin . $ dog-food ``` -> **NOTE:** when running chat client executable built with the latter approach, if you encounter ``version `GLIBC_2.28' not found`` error, rebuild it with `haskell:8.8.4-stretch` base image instead (you'd have to change it in your local [Dockerfile](Dockerfile)). +> **NOTE:** When running chat client executable built with the latter approach, if you encounter ``version `GLIBC_2.28' not found`` error, rebuild it with `haskell:8.8.4-stretch` base image instead (you'd have to change it in your local [Dockerfile](Dockerfile)). `dog-food` (as in "eating your own dog food" - it is an early prototype) starts chat client with default parameters. By default, SQLite database file is created in the working directory (`smp-chat.db`), and the default SMP server is `smp.simplex.im:5223`. @@ -98,6 +98,22 @@ Now Alice's invitations would be generated with her name in it for others' conve Use `/help` in chat to see the list of available commands and their explanation. +### Accessing chat history + +You can access your chat history by opening a connection to your SQLite database file and querying `messages` table, for example: + +```sql +select * from messages +where conn_alias = cast('alice' as blob) +order by internal_id desc; + +select * from messages +where conn_alias = cast('alice' as blob) +and body like '%cats%'; +``` + +> **NOTE:** Beware that SQLite foreign key constraints are disabled by default, and must be **[enabled separately for each database connection](https://sqlite.org/foreignkeys.html#fk_enable)**. The latter can be achieved by running `PRAGMA foreign_keys = ON;` command on an open database connection. By running data altering queries without enabling foreign keys prior to that, you may risk putting your database in an inconsistent state. + ## 🚧 [further README not up to date] SMP server demo 🏗 This is a demo implementation of SMP ([simplex messaging protocol](https://github.com/simplex-chat/protocol/blob/master/simplex-messaging.md)) server. From a602587046aabd77eb3dda433ac44b17d67b3c5d Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Tue, 9 Mar 2021 07:08:36 +0000 Subject: [PATCH 14/16] simplify installation instruction (#72) --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 938880b4b2..5538f3f556 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,13 @@ Limitations/disclaimers: ## How to run chat client locally -Install [Haskell platform](https://www.haskell.org/platform/) (ghc, cabal, stack) and build the project: +Install [Haskell stack](https://docs.haskellstack.org/en/stable/README/): + +```shell +curl -sSL https://get.haskellstack.org/ | sh +``` + +and build the project: ```shell $ git clone git@github.com:simplex-chat/simplex-messaging.git From 251f453c914947584d414bc358fa806e1c266972 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Tue, 9 Mar 2021 07:17:11 +0000 Subject: [PATCH 15/16] readme: note on docker (#73) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5538f3f556..8adda583d5 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ $ stack install $ dog-food ``` -If you'd prefer to not set up Haskell locally, you may instead build the chat client executable using [docker build with custom output](https://docs.docker.com/engine/reference/commandline/build/#custom-build-outputs): +If you'd prefer to not set up Haskell locally, on Linux you may instead build the chat client executable using [docker build with custom output](https://docs.docker.com/engine/reference/commandline/build/#custom-build-outputs): ```shell $ git clone git@github.com:simplex-chat/simplex-messaging.git From 31b0cf8a8eaf68a772150af51e24525261393720 Mon Sep 17 00:00:00 2001 From: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> Date: Mon, 29 Mar 2021 19:18:54 +0400 Subject: [PATCH 16/16] agent sqlite: initialize database in home directory by default (#74) --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8adda583d5..5058fe2eaa 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ See [simplex.chat](https://simplex.chat) website for chat demo and the explanati SMP protocol is semi-formally defined [here](https://github.com/simplex-chat/protocol). Currently only these features are available: -- simple 1-2-1 chat with multiple people in the same terminal window. +- simple 1-to-1 chat with multiple people in the same terminal window. - auto-populated recipient name - just type your messages. - default server is available to play with - `smp.simplex.im:5223` - and you can deploy your own (`smp-server` executable in this repo). - no global identity or names visible to the server(s) - for the privacy of contacts and conversations. @@ -51,16 +51,15 @@ $ dog-food > **NOTE:** When running chat client executable built with the latter approach, if you encounter ``version `GLIBC_2.28' not found`` error, rebuild it with `haskell:8.8.4-stretch` base image instead (you'd have to change it in your local [Dockerfile](Dockerfile)). -`dog-food` (as in "eating your own dog food" - it is an early prototype) starts chat client with default parameters. By default, SQLite database file is created in the working directory (`smp-chat.db`), and the default SMP server is `smp.simplex.im:5223`. +`dog-food` (as in "eating your own dog food" - it is an early prototype) starts chat client with default parameters. By default, app data directory is created in the home directory (`~/.simplex`, or `%APPDATA%/simplex` on Windows), and SQLite database file `smp-chat.db` is initialized in it. The default SMP server is `smp.simplex.im:5223`. -To specify a different chat database location run: +To specify a different file path for the chat database use `-d` command line option: ```shell -$ mkdir ~/simplex -$ dog-food -d ~/simplex/my-chat.db +$ dog-food -d my-chat.db ``` -You can deploy your own server and set client to use it via command line option: +If you deployed your own SMP server you can set client to use it via `-s` option: ```shell $ dog-food -s smp.example.com:5223