114 Commits

Author SHA1 Message Date
Tanguy
cf8b8ce235
Remove newRng (#132) 2022-11-21 19:29:20 +01:00
Tanguy
acbe30e9ca
Fix compilation on nim devel (#130) 2022-10-24 13:29:13 +02:00
Etan Kissling
2424f2b215
configure SNI hostname when connecting WSS (#128)
When connecting to WebSocket via TLS, certain servers require hostname
to be sent as part of SNI extension. This was done when using `news`
backend, but not when using `nim-websock` backend. Aligned both impls.
2022-09-16 21:38:37 +02: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
Jacek Sieka
af8779d9d9
Note that chronos is required 2022-08-16 13:17:58 +02:00
tersec
8a72c0f769
--styleCheck:error (#122)
* --styleCheck:error

* --styleCheck:error iff >= Nim 1.6
2022-07-21 15:38:13 +00:00
Ivan Yonchovski
f2fb0c3695
Add setup/lock files (#120) 2022-07-12 21:33:50 +03:00
Dustin Brody
8a433c6ba4
stylecheck: tkSemcol -> tkSemCol 2022-07-05 21:24:30 +00:00
Dustin Brody
47ceac54c2
stylecheck: payLoad -> payload 2022-07-05 17:02:05 +00:00
Tanguy
27e4b3aff7
Fix compilation for ARC/ORC (#119) 2022-07-04 15:43:44 +02:00
Tanguy
92d350fe88
Fix fragmented message sending (#116)
We previously crashed when sending things over 1mb
2022-06-30 17:14:07 +02:00
Miran
283a9bb1fc
move -d:nimRawSetjmp to nim.cfg (#114)
Refs https://github.com/status-im/nimbus-build-system/issues/44
2022-06-20 09:20:01 +02: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
Jacek Sieka
fc6538fa85
bearssl: use rand helpers (#113) 2022-06-17 15:03:38 +02:00
Tanguy
47b486b52f
Fix: handle simultaneous closing properly (#112)
Since we use readFrame instead of readMsg, we need to handle
it's possible exceptions. Closes #111
2022-05-25 16:02:46 +02:00
Tanguy
8927db93f6
Read frames instead of messages on close
Since #109, there can be only one concurrent user
of recvMsg. So in case someone is already reading,
better to readFrames
2022-05-19 14:27:44 +02:00
Tanguy
edfbb169c8
Fix some issues with recv hanging (#109)
* Crash on concurrent reads
* Fix some issues with recv hanging
2022-05-18 14:37:53 +02:00
Tanguy
5311a6e0b8
TLS1.2 by default (#110)
closes #107
2022-05-18 08:51:45 +02:00
Jacek Sieka
14d852e0d4
style fixes (#108) 2022-04-08 11:11:53 +02:00
jangko
4a7a058843
add http header hook
fix #101
2022-03-16 08:24:16 +07:00
andri lim
6e73e34975
regenerate ssl certificate and private key for autobahn server (#106)
The new certificate:
Valid From: 2022-03-11 04:12:50 UTC
Valid To: 2032-03-08 04:12:50 UTC

checked with https://www.geocerts.com/certificate-decoder
2022-03-11 14:27:13 -06:00
Tanguy
d79ad840e7
Update autobahn TLS cert (#105) 2022-03-10 14:36:51 +01:00
Tanguy
853299e399
Accept timeout (#102) 2022-03-09 14:38:45 +01:00
Ștefan Talpalaru
73edde4417
CI: test with multiple Nim versions (#99)
* CI: test with multiple Nim versions
2022-01-02 05:49:29 +01:00
Tanguy
908632aa07
Fix for styleCheck:usages (#96) 2021-12-27 11:27:21 +01:00
markspanbroek
c2aae352f7
Remove version pin on chronicles (#97)
* Remove version pin on chronicles

Caused dependency conflicts when combining websock with other
packages that depend on chronicles, now that chronicles has
a new version (0.10.2).

* Ensure that chronicles version supports isLogFormatUsed
2021-12-16 14:26:49 +01:00
Zahary Karadjov
a697e3585d
Don't use URL dependencies in nimble (due to their known bugs) 2021-11-22 19:15:26 +02:00
markspanbroek
1abf5f2f91
Merge pull request #93 from status-im/update-asynctest
Update asynctest and fix warnings
2021-09-23 13:47:24 +02:00
Mark Spanbroek
f4e5e6f766 Fix chronos warning 2021-09-21 09:48:36 +02:00
Mark Spanbroek
6f3d5cdb2d Fix remaining GCUnsafe2 warnings
Removes last use of globals in async tests.
2021-09-21 09:45:09 +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
Tanguy
e199aa57da
Handle hostname option properly (#92) 2021-09-20 15:55:38 +02:00
Tanguy Cizain
f354dfebe9
allow accept cancellation (#91) 2021-08-31 16:30:09 +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
Jordan Hrycaj
00440b6eff Use caps for log-levels in tests
why;
  Using nimble installed chronicles (as documented in the readme) fails
  to compile unless the log-level "info" is spelled "INFO".
2021-07-29 08:02:59 +01:00
Dmitriy Ryajov
2af07c5736
"Host" header override (#87)
Override "Host" header for externally resolved addresses
2021-07-28 11:54:09 -06:00
andri lim
d60df8176d
restructure CI jobs to parallelise autobahn test (#70)
previously we are using bash to run parallel autobahn test.
now we leverage CI jobs to run parallel tests.

with the inclusion of compression extension,
the autobahn test suite took significant time
to pass. move it to manually triggered CI
as it cannot make the main CI to fail anyway.

we only run basic autobahn tests in regular CI.
2021-07-19 10:15:52 -06:00
Dmitriy Ryajov
7756dd1e77
Make HttpServer a case object (#84)
* cleanup examples

* more examples cleanup

* make HttServer a case object

* propagate errors when handling requests

* don't extend HttpServer

* remove port from create that takes a string host

make more consistent with client's `connect`
2021-07-15 14:17:55 -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
Tanguy Cizain
fec0f2bac1
add websock topic (#83) 2021-07-14 11:26:46 -06:00
jangko
eabf183e6d
add websock logo to readme.md 2021-06-29 08:50:34 +07:00
jangko
b3c60bbd4e
rename nim-ws to nim-websock 2021-06-29 08:50:29 +07:00
Tanguy Cizain
cb5255ea5f
update for chronicles 2021-06-28 15:07:06 +02:00
Tanguy Cizain
6de3895580
switch to isLogFormatUsed 2021-06-28 15:07:06 +02:00
Tanguy Cizain
78f2af5bac
import json_ser and use ord 2021-06-28 15:07:06 +02:00
jangko
7e668c4c85
fix compile time error when using chronicles sink:json
fixes #73
2021-06-28 15:07:06 +02:00
Tanguy Cizain
781cb35200
Fix mutual closing (#76)
* add mutual closing test

* fix mutual closing
2021-06-28 14:52:18 +02:00
jangko
2ee209af39
update .nimble [skip ci]
- change nim dependency from "1.2.6" to "1.2.0" because
  nimble refuse to install it when we are using
  nimbus-build-system
- fixes skipdir entry
2021-06-23 16:00:02 +07:00
jangko
e56447dda3
update comments in compression extensions [skip ci]
fixes #14
2021-06-21 14:02:29 +07:00