Alexander Bondarenko
7c27357eb2
server: stop inactive clients without subscriptions, additional monitoring via control port ( #901 )
...
* fix thread labelling points
* add subscription thread labels
* add explicit sections for sockets/sessions/disconnects
* adjust label threads wrt. next blocking op
* WIP: emit event on server finish
So the event log wouldn't be cut short giving
false impression of unterminated sessions.
* add handshake timeout
* hack server socket stats
* trace closeTLS exceptions
* fix build
* clean up disconnectTransport
* make disconnectTransport terminating
Thus, participating in racyAny_ around it.
* trach snd/rcv time separately, log clients as CSV
* add direct client counting/stats
* add csv dump for socket threads
* guard socket threads dump from older GHC
* cut socket thread listing into socket-threads command
* store client creation time for stats
* wrap tls setup in timeout and labels
* server: expire clients without subscriptions
* fix check for subscriptions
* remove excess tracing
* move hardcoded timeouts to configs
* cleanup
* fix tests
* wrap direct queue waits in timeout
* rewrite old TCP wrappers with their SocketState variants
* add testInactiveWithSubs
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com >
2023-12-19 15:50:45 +00:00
Alexander Bondarenko
6bffcc8503
compatibility with GHC 8.10.7 ( #906 )
...
* build with ghc-8.10
* add 8.10 to matrix
* cleanup
* stats
* remove getField
* agent
* server
* remote
* space
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com >
2023-11-29 12:53:06 +00:00
Moritz Angermann
002f36dde0
5.4.0.0: use ghc 9.6.2 ( #791 )
...
* Add 9.6 compat
* compile with GHC9.6.2: dependencies, imports, code
* refactor typeclasses
* refactor record dot
* update cabal version
* update github actions
* update direct-sqlcipher
* 5.4.0.0
* update cabal.project
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com >
2023-08-24 20:22:02 +01:00
Evgeny Poberezkin
b001b748db
agent: rename functions, remove unused code, stabilize tests ( #830 )
...
* agent: rename functions, stabilize tests
* test pattern match
2023-08-24 19:52:58 +01:00
Evgeny Poberezkin
44abb90c63
agent: fix async join to avoid sending HELLO again after restart ( #829 )
...
* agent: fix async join to avoid sending HELLO again after restart
* update test
* add callstack to test
* improve test
2023-08-21 14:35:46 +01:00
Evgeny Poberezkin
4fae7dcaee
server: control port ( #804 )
...
* server: control port
* do not remove messages when saving via control port
* remove unused record fields
* fix tests
2023-07-15 13:33:00 +01:00
Evgeny Poberezkin
1901e96ecc
server: make main SMP server queues unbounded ( #802 )
2023-07-14 21:07:45 +01:00
Evgeny Poberezkin
94540a2c71
servers: add TCP timeouts to avoid memory leaks ( #776 )
...
* servers: add TCP timeouts to avoid memory leaks
* fix tests
* only use RecvTimeOut
* servers: simple timeout for TCP transport
* revert dependency change
* simplify
* simplify
* simplify 2
2023-06-30 16:22:01 +01:00
Evgeny Poberezkin
4a927d1ae2
ntf server: better batching and logging ( #780 )
...
* ntf server: better batching and logging
* reduce batch delay for ntf server
* comments
* 5.1.3, ntf 1.4.2
* more logging
* more logging
* split large batches, more logging
* remove some logs
2023-06-26 20:14:35 +01:00
spaced4ndy
9f0b9a83d6
xftp: use chunk digest as entity id for transport session ( #725 )
2023-04-14 13:01:14 +04:00
Evgeny Poberezkin
44f0dd39f3
ci: disable 2 tests on linux only, switch to ubuntu 20 and 22 ( #705 )
...
* ci: disable 2 tests on linux only, switch to ubuntu 20 and 22
* fix platform name
* keep ubuntu 22 binaries
* Revert "keep ubuntu 22 binaries"
This reverts commit a1bbb12870 .
* skip 1 more test
* skip 1 more test
* log os
* log os
* unconditionally skip test
* skip 1 more test in CI
* fix tests
2023-04-04 12:19:38 +01:00
Evgeny Poberezkin
5d8febc353
avoid possible race conditions when cancelled clients/asyncs can be removed after the new ones are added (so that the new are removed as well) ( #627 )
2023-01-30 17:46:06 +00:00
Evgeny Poberezkin
f4ad3a983e
support users in agent to isolate traffic of different users ( #598 )
...
* users table, isolate traffic sessions by users or by queues
* remove extra indices
* corrections
Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com >
Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com >
2023-01-11 17:47:20 +04:00
Evgeny Poberezkin
874f9f5cd6
option to enable/disable TLS handshake error logs (disable by default) ( #581 )
...
* option to enable/disable TLS handshake error logs (disable by default)
* refactor
2022-12-27 10:13:51 +00:00
Evgeny Poberezkin
e281efdcb8
server: SMP basic auth ( #561 )
...
* server: SMP basic auth
* update ini default
* rfc, types
* tests
* update INI file
* typo
Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com >
* refactor
* update INI options, log new queue creation mode on start (on/off/requires auth)
Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com >
2022-11-12 22:29:36 +00:00
Evgeny Poberezkin
374526a11b
server: specialize monad ( #557 )
2022-11-03 11:47:28 +00:00
Evgeny Poberezkin
68138c08d2
support multiple server hostnames per queue ( #494 )
...
* store SMP client version per queue
* use versioned format for queue addresses (not compatible with v1)
* multiple server hosts in queue URI/data, versioned encoding (cross-version tests fail)
* choose server host based on socksProxy setting
* test works
* multiple server addresses mostly work
* add onion hosts for provided servers
* update SMP hosts
2022-08-12 11:32:04 +01:00
Evgeny Poberezkin
d788c3ca95
access servers via SOCKS proxy ( #482 )
...
* access servers via SOCKS proxy
* config to pass tcp timeout and option SOCKS5 proxy to the agent
2022-07-23 13:57:10 +01:00
Evgeny Poberezkin
6bbe1dfc66
use batch commands to resubscribe agent on server re-connection ( #473 )
2022-07-18 07:26:41 +01:00
Evgeny Poberezkin
a6f401041a
SMP protocol v4: batching multiple server commands/responses in a transport block ( #470 )
...
* batch server commands in one transport block
* subscribe to multiple queues using batched commands
* agent method to subscribe to multiple queues using batched commands
* refactor
* test for batched subscriptions
* delete part of connections in batched test
* add resubscribeConnections
* remove comment
* update SMP protocol doc
2022-07-17 10:10:38 +01:00
Evgeny Poberezkin
cde8a11693
update stats logging and make it opt-in ( #472 )
...
* update stats logging and make it opt-in
* hSetBuffering
* update var name
2022-07-15 13:21:02 +01:00
Evgeny Poberezkin
9c1b43791c
SMP v3: encrypt message timestamp and flags together with the body between server and recipient ( #457 )
...
* SMP v3: encrypt message timestamp and flags together with the body between server and recipient
* v3 tests
* update protocol doc
* add test for max size message
* delay in notifications test
* simplify v3
* encrypt server message to the recipient when sent
* refactor
* exit on error restoring the messages
* refactor, increase test timeout
* style
* add prints to the test
* remove error from unsafeMaxLenBS
* update protocol
* lint, improve test, change func param
2022-07-05 21:08:05 +01:00
Evgeny Poberezkin
bc26dc1d68
save and restore server stats on restart ( #460 )
2022-07-04 10:45:35 +01:00
Evgeny Poberezkin
91802fe94f
Merge branch 'master' into f/notifications
2022-06-12 16:49:56 +01:00
Evgeny Poberezkin
0a71822dd0
v2.3.0: save and restore messages when the server is restarted ( #395 )
...
* save and restore messages when server is restarted
* read file line by line
* add import
* optmize restoring messages by reading the whole file
* update version to 2.3.0
* update scripts
* add script
* update readme
2022-06-12 15:59:14 +01:00
Evgeny Poberezkin
c1348aa54f
SMP connection handshake v2 ( #390 )
...
* SMP connection handshake v2
* hadshake v2 [mostly] works
* all tests pass, some race conditions remain
* fix build
* fix race conditions, send CON after all HELLOs in duplexHandshake mode
* add comments
* comment
* add comments
2022-06-09 13:47:07 +01:00
Evgeny Poberezkin
ace94d7c69
log server stats ( #367 )
...
* log server stats
* separate stats updates from the existing transactions
2022-04-30 13:47:21 +01:00
Evgeny Poberezkin
1064e9c315
disconnect inactive clients ( #366 )
...
* disconnect inactive clients
* update test description
* use one thread per client to disconnect inactive clients
* remove comments
* more comments
2022-04-30 10:56:01 +01:00
Evgeny Poberezkin
60d0f19121
Merge branch 'master' into notifications-server
2022-04-20 08:23:26 +01:00
Evgeny Poberezkin
68f52c47dd
message TTL and periodic expiration; setting to prevent creation of the new queues ( #355 )
...
* message TTL and periodic expiration; setting to prevent creation of the new queues
* fix expiration interval
2022-04-20 08:14:26 +01:00
Evgeny Poberezkin
45ddecc4b8
APNS/HTTP2 push client for notifications server ( #350 )
...
* APN push client (WIP)
* APNS push client works
* TODO comments
* comment
* send notification and process the response
* config
* e2e encryption for notification parameter
* read apns key filename and ID from env
* connect APNS client to server, fix notification JSON encoding to use dash case
* do not connect to APNS on start to pass CI tests
* fix CI test
* remove redundant import
2022-04-14 11:33:17 +01:00
Evgeny Poberezkin
fb26916eea
ntf-server CLI, re-use SMP server CLI as a library ( #347 )
...
* ntf-server CLI, re-use SMP server CLI as a library
* add executable name
2022-04-03 10:37:32 +01:00
Evgeny Poberezkin
f466fa76e5
notifications: protocol, server ( #335 )
...
* notifications: protocol
* update protocol to include subscription ID and DH public key
* update protocol, started server
* add notification server subscription DH key
* use the same command type in notifications protocol, protocol parsing, server frame
* remove empty files
2022-03-27 08:36:00 +01:00
Evgeny Poberezkin
a37b24a8c2
use TCP keep-alive instead of SMP protocol PING ( #330 )
...
* use TCP keep-alive instead of SMP protocol PING
* update header files
* use CInt
* use Int again
* use network-3.1.2.7
* use https in cabal.project
* confitional keep-alive parameters to work on mac
* pass keep-alive opts via client/agent options
* remove space
2022-03-21 16:13:34 +00:00
Evgeny Poberezkin
b777a4fd93
split the server dependencies from the agent ( #310 )
...
* split the server dependencies from the agent
* remove redundant imports
* fix Main.hs
2022-01-21 17:33:47 +00:00
Efim Poberezkin
d48da40f7e
add IP and FQDN to online certificate ( #278 )
2022-01-11 16:35:06 +04:00
Evgeny Poberezkin
f3523bbba9
make KeyHash non-optional, verify KeyHash in SMP handshake, use StrEncoding class ( #250 )
...
* make KeyHash non-optional, StrEncoding class
* change server URI format in agent config, refactor with StrEncoding
* refactor Crypto using checkAlgorithm
* refactor parsing connection requests
* prepare to validate CA fingerprint sent in client handshake
* KeyHash check in handshake
* rename type to CliCommand
* server validates keyhash sent by the client
* validate -a option when parsing
* more of StrEncoding
2022-01-02 22:24:43 +00:00
Efim Poberezkin
33bb38299b
refactor server Main.hs ( #248 )
2022-01-02 21:49:40 +04:00
Evgeny Poberezkin
5e29e3698e
binary SMP protocol encoding, split Command type to two types ( #245 )
...
* binary SMP protocol encoding (server tests fail)
* use 1 byte for bytestring length when encoding/decoding
* Encoding class, binary tags
* update server tests
* negotiate SMP version in client/server handshake
* add version columns to queues and connections
* split parsing SMP client commands and server responses to different functions
* check uniqueness of protocol tags
* split client commands and server responses/messages to separate types
* update types in SMP client
* remove pattern synonyms for SMP errors
* simplify getHandshake
* update SMP protocol encoding in protocol spec
* encode time as a number of seconds (64-bit integer) since epoch
2022-01-01 13:10:19 +00:00
Evgeny Poberezkin
73cad5a6c4
simple per-queue e2e encryption with NaCl crypto_box ( #242 )
...
* simple per-queue e2e encryption with NaCl crypto_box
* add e2e keys and DH secrets to schema
* agree and save shared DH secret per queue (not used yet)
* protocol changes for uniform padding and message part lengths
* correct message structure diagrams
* make per-queue E2E encryption non-optional
* refactor crypto keys
* use NaCl crypto_box for per-queue E2E encryption, remove RSA keys from queues
* remove RSA support
* merge migration with E2E DH keys
* clean up
* remove unused methods
* parsing/serializing agent messages
* remove sender timestamp from DB and code
* clean up
* slean up
* s/SMPConfMsg/SMPConfirmation/
* serializeAgentMessage = serializeClientMessage . agentToClientMsg
* simplify error handling
* update protocol docs
2021-12-29 14:27:10 +00:00
Efim Poberezkin
0c866105d2
chain of two certificates - offline (identity) and online; switch certificates to v3 ( #238 )
2021-12-23 21:20:41 +04:00
Efim Poberezkin
e2cd370513
certificate validation on client side; check stored fingerprint on server start-up; non-optional fingerprint parsing ( #234 , closes #155 )
...
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com >
2021-12-22 23:24:58 +04:00
Efim Poberezkin
129246c9e6
unencrypted SMP transport over TLS; simplified handshake ( #229 )
...
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com >
2021-12-19 13:04:44 +04:00
Evgeny Poberezkin
e0acb42a28
Merge branch 'stable'
2021-12-17 15:44:58 +00:00
Evgeny Poberezkin
5f7fe8b0dc
remove client from servers subscribers map after client disconnection ( #228 )
...
Co-authored-by: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com >
2021-12-17 16:28:48 +04:00
Evgeny Poberezkin
323fb1f03c
remove SMP server signing responses ( #226 )
...
* remove SMP server signing responses
* keep only one session ID
2021-12-16 07:15:45 +00:00
Evgeny Poberezkin
5aa0e97cd9
sign server responses
2021-12-15 11:52:09 +00:00
Evgeny Poberezkin
cf3d0dfdc3
Transaction fields for size, session IDs, refactor ( #222 )
...
* add SMP session IDs/tls-unique to transmission
* refactor SMP transmissions: precise transmission types in server & client
* use correct session IDs
* remove TSession
2021-12-15 08:06:34 +00:00
Evgeny Poberezkin
83d352cfbe
TLS 1.3 transport ( #203 )
...
* TLS as Transport class instance with pre-defined server certificate/key
* refactor error logging
* remove Ed25519
* refactor TLS.cGet
* TLS over TCP for Transport
* Plain -> TLS
* comment
* getLn, change supported cipher
* use non fixed certificates
* comment
* check options earlier
* wording
* headers
* Update apps/smp-server/Main.hs
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com >
* Update apps/smp-server/Main.hs
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com >
* localhost -> server
* Update apps/smp-server/Main.hs
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com >
* remove comment
* agent key and cert fixtures WIP
* certificate and key in correct order
* exitFailure
* refactor loadServerCertificate
* remove liftIO
Co-authored-by: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com >
2021-12-15 07:48:57 +00:00
Evgeny Poberezkin
95fbd70346
encrypt recipient message bodies with crypto_box
2021-12-13 10:56:26 +00:00