Commit Graph

315 Commits

Author SHA1 Message Date
Mark Spanbroek 2161c3b769 Combine testNgtcp2Connection & testQuicConnection 2021-01-04 10:05:34 +01:00
Mark Spanbroek cf40bc35e5 Fix onNewId() and onRemoveId() for QuicConnection 2021-01-04 10:05:34 +01:00
Mark Spanbroek e4842f9433 Run tests against QuicConnection, instead of Ngtcp2Connection 2021-01-04 10:05:34 +01:00
Mark Spanbroek d97ceef326 Use Datagram parameter instead of openArray 2021-01-04 10:05:34 +01:00
Mark Spanbroek 2b63899c74 Fix warnings about lock level
See also: https://nim-lang.github.io/Nim/manual_experimental.html#guards-and-locks-lock-levels
2021-01-04 10:05:34 +01:00
Mark Spanbroek 4d226f7906 Add unit test for example in Readme 2021-01-04 10:05:34 +01:00
Mark Spanbroek 1ba8606a7b Add allSucceeded() to async test helper. 2021-01-04 10:05:34 +01:00
Mark Spanbroek ca06e74957 Remember final connection ids when draining
Fixes problem where not all connection ids were removed
from the listener, leading to datagrams being received by
a closed connection.
2021-01-04 10:05:34 +01:00
Mark Spanbroek a01669bc5c Listener handles incoming datagrams synchrononously 2021-01-04 10:05:34 +01:00
Mark Spanbroek 0bce82225e Add Connection.close() 2021-01-04 10:05:34 +01:00
Mark Spanbroek 8899b4d9f3 Replace QuicConnection.close() with QuicConnection.drain() 2021-01-04 10:05:34 +01:00
Mark Spanbroek d2038f4fe4 Close connection gracefully 2021-01-04 10:05:34 +01:00
Mark Spanbroek 47e9bf7a36 Simplify connection states
Introduces 'enter' method that supplies the connection, instead of
having it as an argument to all other methods.
2021-01-04 10:05:34 +01:00
Mark Spanbroek 364f1221c0 Simplify stream states
Introduces 'enter' method that supplies the stream, instead of
having it as an argument to all other methods.
2021-01-04 10:05:34 +01:00
Mark Spanbroek 029b3735b3 Replace object of procs with methods for stream state 2021-01-04 10:05:34 +01:00
Mark Spanbroek 589b3758c5 Replace object of procs with methods for connection state 2021-01-04 10:05:34 +01:00
Mark Spanbroek 8d5fb399a2 Add tests for connection in closed state 2021-01-04 10:05:34 +01:00
Mark Spanbroek 2596b65352 Rename tests to better describe the current situation 2021-01-04 10:05:34 +01:00
Mark Spanbroek e6d17d59f1 Introduce closed state for connections 2021-01-04 10:05:34 +01:00
Mark Spanbroek 9c392c37b2 Rename stream state constructors
newState -> newStreamState
newOpenState -> newOpenStream
newClosedState -> newClosedStream
2021-01-04 10:05:34 +01:00
Mark Spanbroek 376c359a5f Rename ngtcp2 connection constructors
newClientConnection -> newNgtcp2Client
newServerConnection -> newNgtcp2Server
2021-01-04 10:05:34 +01:00
Mark Spanbroek 61d1f07df8 Introduce state pattern for Quic Connections
Separates a Connection from its ngtcp2 implementation specifics.
Currently only one state (open); other states will be added soon.
2021-01-04 10:05:34 +01:00
Mark Spanbroek 012d4dafcd Separate udp, transport and helper folders 2021-01-04 10:05:34 +01:00
Mark Spanbroek a50a987542 Introduce state pattern for Streams
Streams can now be in one of two states: open or closed.
Separates a Stream from its ngtcp2 implementation specifics.
Breaks the circular dependency between Connection and Stream,
allowing them to be defined in separate modules.
2021-01-04 10:05:34 +01:00
Mark Spanbroek 4c005eee37 Rename: Connection.close() -> Connection.drop() 2021-01-04 10:05:34 +01:00
Mark Spanbroek cb29e8242a Add examples and update roadmap in Readme 2021-01-04 10:05:34 +01:00
Mark Spanbroek e9248dce75 Api for reading from and writing to streams 2021-01-04 10:05:34 +01:00
Mark Spanbroek bf00310a2c Remove connection ids when they expire 2021-01-04 10:05:34 +01:00
Mark Spanbroek 226198b544 Remove ids from listener when closing connection 2021-01-04 10:05:34 +01:00
Mark Spanbroek 206117ab40 Move most of the logic from api into listener and connection
Ensures that the internals of listener and connection are hidden.
2021-01-04 10:05:34 +01:00
Mark Spanbroek eb82f37ac7 Do not close udp listening socket when closing connection 2021-01-04 10:05:34 +01:00
Mark Spanbroek 3b9dfbd544 Ensure that all connections are closed in listener test 2021-01-04 10:05:34 +01:00
Mark Spanbroek db54516c0f Formatting 2021-01-04 10:05:34 +01:00
Mark Spanbroek 124ac8152f Listener only creates new connection for unknown connection id 2021-01-04 10:05:34 +01:00
Mark Spanbroek 49350432af Add test for listener 2021-01-04 10:05:34 +01:00
Mark Spanbroek 389357b5d1 Add test helper for sending udp datagrams 2021-01-04 10:05:34 +01:00
Mark Spanbroek 58516598ab Add async test helper for callback functions 2021-01-04 10:05:34 +01:00
Mark Spanbroek 2883d3b92b Handle zero-length connection ids 2021-01-04 10:05:34 +01:00
Mark Spanbroek 7ab0ecbaf8 Accept multiple incoming connections
Introduces table to keep track of connection ids.
2021-01-04 10:05:34 +01:00
Mark Spanbroek 56586c7573 Add Ngtcp2Connection.ids 2021-01-04 10:05:34 +01:00
Mark Spanbroek 2154437c93 Prepare listener for upcoming addition of a connection table 2021-01-04 10:05:34 +01:00
Mark Spanbroek 5bd7476fb8 Rename: testConnection -> testApi 2021-01-04 10:05:34 +01:00
Mark Spanbroek a5eb222c98 Remove everything but the API from the main module 2021-01-04 10:05:34 +01:00
Mark Spanbroek de1952a234 Move API and Listener into separate modules 2021-01-04 10:05:34 +01:00
Mark Spanbroek 1ce370d24b Callback for new connection ids 2021-01-04 10:05:34 +01:00
Mark Spanbroek bb5e82514a Introduce parseDatagram() to extract ids and version from packet 2021-01-04 10:05:34 +01:00
Mark Spanbroek 8d2121fa5d Rewrite test that writes long message over stream
Previous test could fail every now and then, because at the
time that the message is written, the message counter might
not have been updated completely.
2021-01-04 10:05:34 +01:00
Mark Spanbroek 1d4dafd8f9 Do not bind DatagramTransport to remote address on init
Fixes "Socket is already connected" error on macOS.
2021-01-04 10:05:34 +01:00
Mark Spanbroek e8bc63de57 Ensure that unexpected errors in send loops are raised immediately
Before this change they were silently ignored.
2021-01-04 10:05:34 +01:00
Mark Spanbroek 42115c90b5 Introduce new API for setting up connections
Unlike the ngtcp2 connections, these connections include
the UDP transport. The API is similar to BSD sockets:
dial, listen, accept.
2021-01-04 10:05:34 +01:00