Commit Graph

36 Commits

Author SHA1 Message Date
Eugene Kabanov 155d89450e
Trackers refactoring. (#416)
* Refactor chronos trackers to be more simple.

* Refactor trackers.
Add HTTP server trackers.
Refactor HTTP main processing loop.

* Compatibility fixes.
Add checkLeaks().

* Fix posix test issue.

* Add httpdebug module which introduces HTTP connection dumping helpers.
Add tests for it.

* Recover and deprecate old version of Trackers.

* Make public iterators to iterate over all tracker counters available.
Fix asynctests to use public iterators instead private one.
2023-07-14 13:35:08 +03:00
Eugene Kabanov 73fd1206ab
Disable HTTP/1.1 pipeline support for HTTP/S server by default. (#410)
* Disable HTTP/1.1 pipeline support for HTTP/S server by default.
Add tests.

* Fix tests according to new behavior.
Fix tests to use random assigned OS ports instead of predefined.

* Fix flaky tests in testasyncstream.
2023-06-26 16:28:33 +03:00
Tanguy ab5a8c2e0f
Add `localAddress` support to `stream.connect` (#362)
* Add `localAddress` support to `stream.connect`

* fix windows

* TransportAddress() instead of AnyAddress

* tweak flags

* Better flags

* try to workaround nim 1.2 issue

* Handle ReusePort in createStreamServer and improve tests

* Rename ClientFlags to SocketFlags

---------

Co-authored-by: Diego <diego@status.im>
2023-04-03 15:34:35 +03:00
Jacek Sieka 229de5f842
Compile-time configuration (#371)
This PR moves all compile-time configuration to a single module,
simplifying documentation and access to these features.

Upcomfing features may be enabled either individually, or through a new
`chronosPreviewV4` catch-all designed to allow code to be prepared for
increased strictness in future chronos releases.

`-d:chronosDebug` may be used to enable the existing debugging helpers
together.
2023-03-31 07:35:04 +02:00
Matt Haggard 1b69b5e808
Allow passing in trustAnchors to newTLSClientAsyncStream (#355)
* Allow passing in trustAnchors to newTLSClientAsyncStream

* Store X509TrustAnchors in a memory-secure, but memory-friendly way

* Remove forgotten import

* Change some waitFor to await in tests; add comment about trustAnchors reuse

* Remove use of result in newTrustAnchorStore
2023-02-21 20:38:53 +02:00
Eugene Kabanov 945c304197
Address #329. (#330)
* Address #329.

* Refactor AsyncStreamReader/Writer `state` helper functions.
Fix some compilation warnings in `debugutils`.
Add multiple writes into test to check consistency.

* Fix Linux issue.
Fix warnings.
2023-01-10 18:08:54 +02:00
Eugene Kabanov 519ca463df
Fix transport.write() unable to send data through OS pipes. (#256)
* Fix transport.write() unable to send data through pipe.
Add test for pipes.

* Fix flaky test.

* Add workaround for Nim's issue #19425.
2022-01-20 18:38:41 +02:00
Eugene Kabanov fed6b0ac92
Restore functionality of zero-sized bounded reader/writer streams. (#184)
* Restore functionality of zero-sized bounded reader/writer streams.
Adding tests for it.

* run build_nim.sh unconditionally

Co-authored-by: Ștefan Talpalaru <stefantalpalaru@yahoo.com>
2021-05-07 18:52:44 +03:00
Eugene Kabanov 39f4060e07
Refactor and optimization of BoundedStream. (#180)
Documentation for BoundedStream.
Fix HttpServer bounding.
2021-04-26 14:05:37 +03:00
Eugene Kabanov 833d968782
Fix upload() issue and adding tests. (#179) 2021-04-24 20:32:21 +03:00
Eugene Kabanov e6ba00cb81
Fix reading could stuck on very big chunked headers and tests. (#178) 2021-04-22 15:32:28 +03:00
Jacek Sieka 4abd7a5645
exception tracking (#166)
* exception tracking

This PR adds minimal exception tracking to chronos, moving the goalpost
one step further.

In particular, it becomes invalid to raise exceptions from `callSoon`
callbacks: this is critical for writing correct error handling because
there's no reasonable way that a user of chronos can possibly _reason_
about exceptions coming out of there: the event loop will be in an
indeterminite state when the loop is executing an _random_ callback.

As expected, there are several issues in the error handling of chronos:
in particular, it will end up in an inconsistent internal state whenever
the selector loop operations fail, because the internal state update
functions are not written in an exception-safe way. This PR turns this
into a Defect, which probably is not the optimal way of handling things
- expect more work to be done here.

Some API have no way of reporting back errors to callers - for example,
when something fails in the accept loop, there's not much it can do, and
no way to report it back to the user of the API - this has been fixed
with the new accept flow - the old one should be deprecated.

Finally, there is information loss in the API: in composite operations
like `poll` and `waitFor` there's no way to differentiate internal
errors from user-level errors originating from callbacks.

* store `CatchableError` in future
* annotate proc's with correct raises information
* `selectors2` to avoid non-CatchableError IOSelectorsException
* `$` should never raise
* remove unnecessary gcsafe annotations
* fix exceptions leaking out of timer waits
* fix some imports
* functions must signal raising the union of all exceptions across all
platforms to enable cross-platform code
* switch to unittest2
* add `selectors2` which supercedes the std library version and fixes
several exception handling issues in there

* fixes

* docs, platform-independent eh specifiers for some functions

* add feature flag for strict exception mode

also bump version to 3.0.0 - _most_ existing code should be compatible
with this version of exception handling but some things might need
fixing - callbacks, existing raises specifications etc.

* fix AsyncCheck for non-void T
2021-03-24 10:08:33 +01:00
cheatfate 25688cd0aa Add hexValue tests. 2021-02-18 22:16:04 +02:00
cheatfate eb81018d02 Address review comments and fix issues found.
Adding more tests.
2021-02-18 22:16:04 +02:00
cheatfate 9b48496513 Fix compilation error with nimcrypto/utils import. 2021-02-18 22:16:04 +02:00
cheatfate 3e9ffae407 Properly fix case when request body size exceeds maximum allowed size. 2021-02-18 22:16:04 +02:00
cheatfate 970e5641d7 Add less strict rules for BoundStream reader/writer. 2021-02-18 22:16:04 +02:00
cheatfate 0b396c34d8 Add newline. 2021-02-18 22:16:04 +02:00
cheatfate 2defc4b822 Add sequence of bytes as boundary to BoundStream and tests. 2021-02-18 22:16:04 +02:00
cheatfate 13eddf382d Simplification and fixes for TLSStream state machine. 2021-02-18 22:16:04 +02:00
cheatfate e8d2a3ca0a Attempt #5. 2021-02-18 22:16:04 +02:00
cheatfate 49fd70f504 Attempt #4. 2021-02-18 22:16:04 +02:00
cheatfate bb176ba574 Investigation of Linux freezes #1. 2021-02-18 22:16:04 +02:00
cheatfate ac8b11d6ca close() procedure should not raise, otherwise its impossible to cleanup. 2021-02-18 22:16:04 +02:00
cheatfate 0cb6840f03 Big refactoring of AsyncStreams.
1. Implement all read() primitives using readLoop() like it was done in streams.
2. Fix readLine() bug.
3. Add readMessage() primitive.
4. Fixing exception hierarchy, handling code and simplification of (break/continue + exception).
5. Fix TLSStream closure procedure.
6. Add BoundedStream stream and tests.
7. Remove `result` usage from the code.
2021-02-18 22:16:04 +02:00
Eugene Kabanov b5915ecd29
Small fixes (#134)
* Fix cancellation behavior.
Fix some compilation warnings.

* Fix cancelAndWait() and add proper documentation.

* Add completed(Future) and done(Future) calls to check if Future[T] completed without an error.

* Add stepsAsync() and tests.

* Fix comments.

* Fix new primitive comment, to avoid usage for task switches.
2020-11-13 14:22:58 +02:00
Eugene Kabanov d3018ae908
Fix TLSStream SSL errors while in handshake could stuck connection. (#133)
Fix expired SSL certificate in tests.
2020-10-13 02:12:52 +03:00
cheatfate fb00b20cfa
Fix all compilation warnings for 1.0.2.
Fix all related problems.
2019-10-29 23:19:41 +02:00
cheatfate 5f1391f39f
Fix unused imports. 2019-10-24 16:21:31 +03:00
cheatfate 29d9274e03
Fix some compilation warnings. 2019-10-24 16:01:57 +03:00
cheatfate d008fa2087
Fix make serverName mandatory and check for empty serverName. 2019-10-16 09:07:46 +03:00
cheatfate a92ad6d2d2
Add TLS inbound stream.
Fix some review comments.
2019-10-16 09:01:52 +03:00
cheatfate c27624cfc0
Add TlsStream with client-only connections. 2019-10-08 18:46:27 +03:00
cheatfate 454571f943
Fix tests to consume all the bytes from the nested stream.
Add error messages for nested exceptions.
2019-05-08 12:44:00 +03:00
cheatfate 296b8c23a5
Fix tests compilation. 2019-05-07 23:20:06 +03:00
cheatfate 1763c9dcff
Add AsyncStreams.
Add Chunked-Encoding AsyncStream reader/writer.
Add tests.
2019-05-07 23:11:40 +03:00