Commit Graph

38 Commits

Author SHA1 Message Date
Evgeny Poberezkin 4b9ebbbab2 move SMP server from agent commands NEW/JOIN to agent config (#129)
* move SMP server from agent commands NEW/JOIN to agent config

* fix SMPServer parser

* update agent protocol - server management

* enable agent test

* agent test with 2 servers

* create reply queue on the configured server

* choose random server

* swap bind
2021-05-06 18:53:34 +01:00
Evgeny Poberezkin 6ceeb2c9db save keys as binary to db, remove legacy encoding (#114)
* save keys as binary to db, remove legacy encoding

* import list
2021-04-30 09:13:18 +01:00
Evgeny Poberezkin 729cf10ad8 test: SMP server store log (#109)
* test: SMP server store log

* test: extend store log test: queue deletion, log compacted

* test: check store log length in lines
2021-04-29 07:23:32 +01:00
Evgeny Poberezkin afc09a6ec4 Store log (#108)
* StoreLog (WIP)

* add log records to map

* revert Protocol change

* revert Server change

* fix parseLogRecord

* optionally save/restore queues to/from store log

* refactor

* refactor delQueueAndMsgs

* move store log to /var/opt/simplex

* use ini file
2021-04-26 20:34:28 +01:00
Evgeny Poberezkin cddff78719 binary X509 encoding for RSA key send during transport handshake (#105) 2021-04-24 12:46:57 +01:00
Evgeny Poberezkin 5e3bc7ee6c improve error handling (#101)
* inventory of error handling problems and types

* Change SMP protocol errors syntax

* connection errors in agent protocol (ERR CONN), STORE error -> AGENT error

* include exception in SEInternal error

* add MESSAGE errors, remove CRYPTO and SIZE errors

* agent protocol SYNTAX and AGENT errors

* BROKER errors

* group all client command (and agent response) errors

* BROKER TRANSPORT error

* simplify Client

* clean up

* transport errors

* simplify client

* parse / serialize agent errors

* differentiate crypto errors

* update errors.md

* make agent and SMP protocol errors consistent, simplify

* update doc

* test: parse / serialize protocol errors with QuickCheck

* add String to internal error

* exponential back-off when retrying to send HELLO

* refactor Client.hs

* replace fold with recursion in startTCPClient

* fail test if server did not start, refactor

* test: wait till TCP server stops

* test: refactor waiting for server to stop

* test: fail with error if server did not start/stop
2021-04-18 18:37:54 +01:00
Evgeny Poberezkin 326050651a Merge branch 'master' into v2 2021-04-14 21:30:30 +01:00
Evgeny Poberezkin 0028939155 standard X509/PKCS8 encoding for RSA keys (#98)
* key encoding primitives (WIP)

* use X509/PKCS8 to read/write server key files

* make PrivateKey type class

* clean up

* remove separate public key file

* specific import
2021-04-14 21:20:08 +01:00
Efim Poberezkin 2eb5ce24ec tests: block on tcp server creation (#99)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-04-14 02:25:57 +04:00
Evgeny Poberezkin ad73298936 Read server keys from files or create if absent (#79)
* move server keys to config

* add server keys from files

* create server keys if key files do not exist

* validate loaded server key pair

* refactor fromString functions

* key files in /etc/opt/simplex
2021-04-07 22:59:57 +01:00
Evgeny Poberezkin 0fbf406800 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
2021-04-05 13:10:16 +01:00
Efim Poberezkin 660e35d1d1 check that sqlite library is compiled with threadsafe code (#63) 2021-03-02 22:30:59 +04:00
Evgeny Poberezkin 927ff230da Separate db connection for each TCP client connection (#60)
* use separate db connections for each TCP client connection

* refactor atomically, increast delay in tests

* increase test delay for SMP server to start

* increase SMP ping frequency

* remove comment

* separate SQLite connection per thread, to support multi-threaded mode

* remove redundant import
2021-02-28 14:59:29 +00:00
Evgeny Poberezkin 0fe41dbf16 Sign / verify SMP commands (#37)
* generate key pair

* crypto: sign/verify functions

* remove extension

* parse/serialize keys

* use RSA recipient/sender keys (TODO sign/verify)

* make PublicKey newtype, assign 0s to private_p & private_q

* replace SMP command parsing with Attoparsec

* rename types: Signed->Transmission, Transmission->SignedTransmission

* sign and verify commands (server tests skipped, agent tests pass)

* SMP client: avoid seralizing transmission twice when sending commands

* update SMP server tests to use command signatures

* remove support for "SEND :msg" syntax from SMP server protocol

* rename RSA module name to R to avoid confusion with C used for S.M.Crypto

* update key sizes to use bits `div` 8

* tidy up
2021-02-26 18:14:22 +04:00
Evgeny Poberezkin 4b5349fb94 Refactor END notifications (#31)
* kill TCP server client threads when the main server thread is killed; test END notification when server connection dies

* revert to using forkIO in the tests

* make subscriptions state change atomic

* remove commented out code

* Revert "revert to using forkIO in the tests"

This reverts commit c0bacd92e4.
2021-02-26 18:13:04 +04:00
Efim Poberezkin f50da16d0a reorganize Protocol and Agent Store (#25)
* chore: move members from Server/Transmission.hs to Protocol.hs

* chore: revert qualified SMP import for server and client

* chore: fix corrId call

* chore: move common types to Common.hs

* chore: decompose SQLite.hs

* chore: rename Agent/Transmission.hs ErrorType -> AgentErrorType

* chore: move Protocol ErrorType -> Common SMPErrorType

* chore: rename Common -> Types

* chore: revert SMPErrorType -> ErrorType
2021-02-26 18:11:22 +04:00
Evgeny Poberezkin 70fe7616f2 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
2021-02-26 18:11:22 +04:00
Evgeny Poberezkin 6f8b3787b0 server: refactor syntax tests to only allow one command (#5)
* server: refactor syntax tests to only allow one command

* simplify smpServerTest
2021-01-11 14:04:21 +00:00
Evgeny Poberezkin 42ab7fb6ac test against localhost 2020-12-30 21:26:46 +00:00
Evgeny Poberezkin 80b4ff365d TCP client: try all resolved addresses, not just the first 2020-12-30 21:25:49 +00:00
Evgeny Poberezkin f3cd3eac58 add protocol version in TCP welcome 2020-12-30 18:50:50 +00:00
Evgeny Poberezkin 4b8f6417f8 add correlationId to SMP transmissions, fix tests 2020-12-28 13:55:53 +00:00
Evgeny Poberezkin 2ed24e683e rename Config to ServerConfig 2020-12-25 16:46:17 +00:00
Evgeny Poberezkin 3cb2421373 move modules to folder Simplex.Messaging.Server 2020-11-22 18:22:20 +00:00
Evgeny Poberezkin 35f83b604a rename "connection" to "queue" 2020-10-22 12:50:55 +01:00
Evgeny Poberezkin acef2bf638 tests: deleting undelivered messages, re-delivery when message not ACKed 2020-10-18 10:15:30 +01:00
Evgeny Poberezkin 0dec506ce6 test: duplex communication over 2 SMP connections 2020-10-17 19:42:15 +01:00
Evgeny Poberezkin eba6dfc343 make sizes of IDs a server configuration 2020-10-17 18:13:20 +01:00
Evgeny Poberezkin 98a85ddf5d load 3 lines before parsing 2020-10-17 17:29:23 +01:00
Evgeny Poberezkin 3255682bf2 use base64 encoded IDs and bytestrings instead of strings 2020-10-17 15:01:25 +01:00
Evgeny Poberezkin 5a0402d0c4 random connection and message IDs 2020-10-17 11:07:09 +01:00
Evgeny Poberezkin ee40927506 random connection and message IDs 2020-10-17 11:03:38 +01:00
Evgeny Poberezkin 7cb289e88a refactor: TCP transport 2020-10-15 07:08:21 +01:00
Evgeny Poberezkin 2ba27ed852 SECURE command, tests 2020-10-14 21:03:37 +01:00
Evgeny Poberezkin c7e194d3c7 replace TChan with TBQueue 2020-10-14 14:37:29 +01:00
Evgeny Poberezkin 1daae74c67 syntax tests for all commands 2020-10-13 18:44:40 +01:00
Evgeny Poberezkin 00f61c1f68 protocol syntax tests 2020-10-13 18:17:41 +01:00
Evgeny Poberezkin e75a3c44df test client (WIP) 2020-10-13 12:43:44 +01:00