Commit Graph

15 Commits

Author SHA1 Message Date
andri lim 282773af69
Reduce compiler warnings when using new chronos (#149)
* Reduce compiler warnings when using new chronos

* chronos req

* Reduce more warnings
2024-01-22 19:08:17 +07:00
Etan Kissling f8ed9b40a5
replace `utils` module with direct `generate` calls (#148)
The `utils` module uses a convoluted mechanism for filling byte arrays
with random data. The `generate` function can be used directly, making
the `utils` module obsolete.
2023-07-24 22:38:21 +02:00
Tanguy cf8b8ce235
Remove newRng (#132) 2022-11-21 19:29:20 +01:00
Etan Kissling 7b2ed397d6
properly support concurrent message sending (#126)
`nim-websock` suffered from a number of issues that are being addressed:

1. Long messages > `frameSize` (default 1 MB) were split into fragments
   of `frameSize` each. However, when a concurrent message is sent, it
   may be interleaved among the fragments of an already-sending message.
   This is only allowed for control packets without a mux extension.

2. When the WebSocket session is closed, a msg may have been partially
   received. This partial frame was reported as a full message, without
   indication that the receiving was canceled. This behaviour is fixed
   by raising a `WSClosedError` instead of reporting the partial msg.

3. When an individual `send` operation was canceled, it would actually
   stop sending the remainder of a potentially partially sent messages.
   This would corrupt the stream for concurrent and followup operations.
   Cancellation is now inhibited for the message currently sending.
   It is still possible to cancel messages that are not yet scheduled.

4. Messages could get reordered when using asynchronous encoders. This
   is addressed by delaying followup messages until the current message
   is fully encoded and transmitted (except for control packets).

Co-authored-by: Tanguy <tanguy@status.im>
2022-09-06 11:09:21 +02:00
tersec 8a72c0f769
--styleCheck:error (#122)
* --styleCheck:error

* --styleCheck:error iff >= Nim 1.6
2022-07-21 15:38:13 +00:00
Jacek Sieka e974acbe0a
test fixes (#115)
* don't use global for server instance
  * it gets shared between tests and causes gcsafe to trigger
* enable `chronosStrictException` in tests
* avoid asynctests dep
* testcommon -> all_tests (like the other projects)
2022-06-20 09:19:38 +02:00
Mark Spanbroek 80f62e8fdd Remove unused imports 2021-09-21 09:44:07 +02:00
Mark Spanbroek e974a866b6 Update to latest asynctest, with unittest2 support
Also fixes a number of GcUnsafe2 warnings,
by placing var declarations inside the suite.
2021-09-21 09:35:12 +02:00
Dmitriy Ryajov 0ec755738c
Perform utf-8 validation at message boundaries (#90)
* validate utf8 at the message level

* move utf-8 validation to message

* rename `recv` to `recvMsg`

* add partial frame validation tests

* use `recvMsg` instead of `recv`
2021-08-04 10:23:56 -06:00
Dmitriy Ryajov 06ae75cf7f
add support for DNS resolution (#81)
* add support for DNS resolution

- reworked API to be more consistent
  - string addresses and Uri types will be now resolved
- made the API more consistent

* log failed connection attempt

* agent string can't contain spaces

* add websock topic (#83)

* style

Co-authored-by: Tanguy Cizain <tanguycizain@gmail.com>
2021-07-14 18:51:39 -06:00
jangko b3c60bbd4e
rename nim-ws to nim-websock 2021-06-29 08:50:29 +07:00
jangko 5a93ad7867
add deflate compression test cases
* binary data roundtrip
* text data roundtrip
2021-06-20 14:50:54 +07:00
jangko 3a0834943d
fixes copyright header in each .nim file 2021-06-20 11:28:38 +07:00
jangko 32b62989a4
add test cases for multiple extensions flow
using dummy `base64` and `hex` extensions
- check flow client-server flow,
  `hex` to `base64` and `base64` to `hex`
- check for encode-decode roundtrip
2021-06-16 17:44:38 +07:00
Dmitriy Ryajov 3e1599d790
Fix partial frame handling and allow extensions to hijack the flow (#56)
* moving files around

* wip

* wip

* move tls example into server example

* add tls functionality

* rename

* rename

* fix tests

* move extension related files to own folder

* use trace instead of debug

* export extensions

* rework partial frame handling and closing

* rework status codes as distincts

* logging

* re-enable extensions processing for frames

* enable all test for non-tls server

* remove tlsserver

* remove offset to mask - don't think we need it

* pass sessions extensions when calling send/recv

* adding encode/decode extensions flow test

* move server/client setup to helpers

* proper frame order execution on decode

* fix tls tests
2021-06-11 14:04:09 -06:00