Efim Poberezkin 7e9cfcce8c agent sqlite: rework schema, make methods transactional, enable foreign keys (#34)
* agent sqlite: rework schema

* agent sqlite: explicitly mark primary keys as NOT NULL

* agent sqlite: adjust connections and queues fkeys

* agent sqlite: remove ack_mode from queues tables

* [WIP] agent sqlite: refactor methods

* agent sqlite: implement transactional createRcvConn

* add comment

* agent sqlite: remove ConnAlias from createRcvConn signature

* agent sqlite: implement transactional createSndConn

* agent sqlite: remove monadic stack from store util methods

* agent sqlite: refactor getConn

* agent sqlite: rename conn -> dbConn

* agent sqlite: move transactional logic to utils

* agent sqlite: remove addServer from store interface

* fix comment

* agent sqlite: refactor getRcvQueue

* agent sqlite: refactor deleteConn

* agent sqlite: remove old deleteConn

* agent sqlite: enable FKs

* agent sqlite: refactor methods upgrading connection to duplex

* agent sqlite: uncomment not implemented methods

* agent sqlite: rename methods upgrading connection to duplex

* use liftEither

* agent sqlite: refactor update queue status methods

* agent sqlite: refactor createMsg

* clean up

* fix compilation errors in src

* fix existing tests

* clean up tests

* agent sqlite: test that foreign keys are enabled

* change private members naming

* tests: expect specific error code

* clean up

* agent sqlite: consistently separate lifts from logic to their own lines
2021-02-04 19:23:43 +04:00
2021-02-26 18:13:04 +04:00
2021-02-26 18:13:04 +04:00
2021-02-26 18:13:04 +04:00
2020-10-13 18:48:41 +01:00
2021-02-26 18:13:04 +04:00
2021-01-11 19:25:37 +00:00
2020-10-11 11:00:25 +01:00
2021-02-26 18:11:22 +04:00

simplex-messaging

GitHub build GitHub release

SMP server demo

This is a demo implementation of SMP (simplex messaging protocol) server.

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

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:

telnet smp.simplex.im 5223

Run locally

Install stack 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 transmissions.

> on its own means you need to press return - telnet should be configured to send it as CRLF.

  1. Create simplex message queue:
>
> abcd -- correlation ID, any string
>
> NEW 1234 -- 1234 is recipient's key

abcd

IDS QuCLU4YxgS7wcPFA YB4CCATREHkaQcEh -- recipient and sender IDs for the queue
  1. Sender can send their "key" to the queue:
> -- no signature (just press enter)
> bcda -- correlation ID, any string
> YB4CCATREHkaQcEh -- sender ID for the queue
> SEND :key abcd

bcda
YB4CCATREHkaQcEh
OK
  1. Secure queue with sender's "key"
> 1234 -- recipient's "signature" - same as "key" in the demo
> cdab
> QuCLU4YxgS7wcPFA -- recipient ID
> KEY abcd -- "key" provided by sender

cdab
QuCLU4YxgS7wcPFA
OK
  1. Sender can now send messages to the queue
> abcd -- sender's "signature" - same as "key" in the demo
> dabc -- correlation ID
> YB4CCATREHkaQcEh -- sender ID
> SEND :hello

dabc
YB4CCATREHkaQcEh
OK
  1. Recipient recieves the message and acknowledges it to receive further messages

-- 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

Design

server design

Description
No description provided
Readme AGPL-3.0 35 MiB
Languages
Haskell 90.7%
HTML 3.4%
Shell 2.5%
CSS 1.7%
C 0.8%
Other 0.8%