quic 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +51 -2
- data/ext/quic/connection_client.c +271 -72
- data/ext/quic/connection_common.c +464 -462
- data/ext/quic/connection_common.h +138 -20
- data/ext/quic/connection_server.c +20 -7
- data/ext/quic/endpoint.c +28 -6
- data/ext/quic/ext_api.c +12 -0
- data/ext/quic/include/quic/ext.h +5 -0
- data/ext/quic/quic.c +8 -0
- data/ext/quic/quic.h +1 -0
- data/ext/quic/stream.c +434 -45
- data/ext/quic/stream.h +68 -22
- data/lib/quic/connection.rb +40 -11
- data/lib/quic/settings.rb +50 -4
- data/lib/quic/version.rb +1 -1
- data/sig/quic.rbs +110 -14
- metadata +3 -3
data/ext/quic/stream.h
CHANGED
|
@@ -1,27 +1,47 @@
|
|
|
1
1
|
#ifndef QUIC_STREAM_H
|
|
2
2
|
#define QUIC_STREAM_H 1
|
|
3
3
|
|
|
4
|
+
#include "connection_common.h"
|
|
4
5
|
#include "quic.h"
|
|
5
6
|
|
|
6
7
|
extern VALUE rb_cQUICStream;
|
|
7
8
|
|
|
8
9
|
void Init_quic_stream(VALUE rb_mQUICArg);
|
|
9
10
|
|
|
10
|
-
/*
|
|
11
|
-
|
|
11
|
+
/* One write's bytes, kept until the peer acknowledges them. Outside the
|
|
12
|
+
Ruby heap: ngtcp2 keeps pointers into data to retransmit from, and
|
|
13
|
+
GC.compact moves an embedded String. */
|
|
14
|
+
typedef struct quic_send_chunk {
|
|
15
|
+
struct quic_send_chunk *next;
|
|
16
|
+
size_t len;
|
|
17
|
+
uint8_t data[];
|
|
18
|
+
} quic_send_chunk;
|
|
12
19
|
|
|
13
20
|
typedef struct {
|
|
21
|
+
/* The QUIC::Stream wrapping this struct, for the stream callbacks, which
|
|
22
|
+
get the struct from ngtcp2's stream_user_data. It needs no mark, as it
|
|
23
|
+
holds the struct; quic_stream_compact follows it when GC.compact moves
|
|
24
|
+
it. */
|
|
25
|
+
VALUE self;
|
|
14
26
|
int64_t stream_id;
|
|
15
|
-
/*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
/* The send buffer: what #write queued and the peer has not acknowledged,
|
|
28
|
+
as chunks in stream order. Every offset below is a position in the
|
|
29
|
+
stream. The buffer is freed only where ngtcp2 can no longer read it:
|
|
30
|
+
as the peer acknowledges it, when the stream closes, and in dfree. */
|
|
31
|
+
quic_send_chunk *send_head;
|
|
32
|
+
quic_send_chunk *send_tail;
|
|
33
|
+
/* The chunk holding the next byte to hand to ngtcp2 (sent_offset), and
|
|
34
|
+
where in it; NULL once everything queued has been handed over. That
|
|
35
|
+
chunk ends after sent_offset, which acked_offset never passes, so an
|
|
36
|
+
acknowledgement never frees it. */
|
|
37
|
+
quic_send_chunk *send_next;
|
|
38
|
+
size_t send_next_off;
|
|
39
|
+
uint64_t head_offset; /* where send_head->data[0] sits */
|
|
40
|
+
uint64_t queued_offset; /* just past the last byte queued */
|
|
41
|
+
uint64_t sent_offset; /* just past the last byte handed to ngtcp2 */
|
|
42
|
+
uint64_t acked_offset; /* just past the last byte acknowledged */
|
|
43
|
+
/* What the chunks take from xmalloc, headers included; part of dsize. */
|
|
44
|
+
size_t buffered;
|
|
25
45
|
bool fin_received; /* recv_stream_data delivered FIN */
|
|
26
46
|
bool fin_sent; /* #write(fin: true) queued FIN */
|
|
27
47
|
bool fin_flushed; /* write_pkt actually wrote the FIN frame */
|
|
@@ -29,10 +49,13 @@ typedef struct {
|
|
|
29
49
|
bool closed; /* stream_close callback fired */
|
|
30
50
|
uint64_t close_app_error_code;
|
|
31
51
|
bool close_has_app_error_code;
|
|
32
|
-
/* The send side is shut: the peer's STOP_SENDING
|
|
33
|
-
reported the send side shut while
|
|
34
|
-
|
|
35
|
-
skips the stream
|
|
52
|
+
/* The send side is shut (quic_stream_stop): the peer's STOP_SENDING
|
|
53
|
+
arrived, #reset was called, ngtcp2 reported the send side shut while
|
|
54
|
+
writing, or the stream closed. Nothing queued goes out any more,
|
|
55
|
+
#write_pkt skips the stream, and what it had not sent no longer counts
|
|
56
|
+
in quic_conn_t.stream_unsent. The send buffer stays until the stream
|
|
57
|
+
closes: ngtcp2 may still hold pointers into it at this point
|
|
58
|
+
(recv_stop_sending runs before it drops the stream's queued frames). */
|
|
36
59
|
bool stopped;
|
|
37
60
|
uint64_t stop_app_error_code; /* the STOP_SENDING's, 0 if none arrived */
|
|
38
61
|
/* Set once a peer-initiated stream has been pushed onto the owning
|
|
@@ -46,12 +69,35 @@ typedef struct {
|
|
|
46
69
|
bool peer_stream_held;
|
|
47
70
|
} quic_stream_t;
|
|
48
71
|
|
|
49
|
-
|
|
72
|
+
/* What a connection without a stream handler does with its streams, as
|
|
73
|
+
QUIC::Streams. connection_common.c hands its ngtcp2 stream callbacks and
|
|
74
|
+
#write_pkt here, and keeps only the choice between this and the
|
|
75
|
+
handler. */
|
|
50
76
|
|
|
51
|
-
/*
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
/* Make a QUIC::Stream for stream_id, a stream #open_bidi_stream or
|
|
78
|
+
#open_uni_stream has just opened on the connection self (wrapping c),
|
|
79
|
+
and register it. Returns the Stream. */
|
|
80
|
+
VALUE quic_stream_open_local(VALUE self, quic_conn_t *c, int64_t stream_id);
|
|
81
|
+
|
|
82
|
+
/* The ngtcp2 stream callbacks. s is the stream's stream_user_data: NULL for
|
|
83
|
+
a stream whose QUIC::Stream could not be made, which they ignore. Those
|
|
84
|
+
returning int return 0, or NGTCP2_ERR_CALLBACK_FAILURE when Ruby code
|
|
85
|
+
raised; the exception waits in c->pending_exc. */
|
|
86
|
+
int quic_stream_on_open(quic_conn_t *c, int64_t stream_id);
|
|
87
|
+
int quic_stream_on_recv_data(quic_conn_t *c, quic_stream_t *s, uint32_t flags,
|
|
88
|
+
const uint8_t *data, size_t datalen);
|
|
89
|
+
void quic_stream_on_acked(quic_stream_t *s, uint64_t offset, uint64_t datalen);
|
|
90
|
+
int quic_stream_on_close(quic_conn_t *c, quic_stream_t *s, int64_t stream_id,
|
|
91
|
+
uint32_t flags, uint64_t app_error_code);
|
|
92
|
+
void quic_stream_on_reset(quic_stream_t *s, uint64_t app_error_code);
|
|
93
|
+
void quic_stream_on_recv_stop_sending(quic_conn_t *c, quic_stream_t *s,
|
|
94
|
+
uint64_t app_error_code);
|
|
95
|
+
|
|
96
|
+
/* #write_pkt for the connection self (wrapping c): build the next packet
|
|
97
|
+
into dest, with data from the first stream in @streams that has any.
|
|
98
|
+
Returns what ngtcp2_conn_writev_stream returned. Raises nothing. */
|
|
99
|
+
ngtcp2_ssize quic_streams_write_pkt(VALUE self, quic_conn_t *c,
|
|
100
|
+
ngtcp2_path *path, ngtcp2_pkt_info *pi,
|
|
101
|
+
uint8_t *dest, size_t destlen);
|
|
56
102
|
|
|
57
103
|
#endif /* QUIC_STREAM_H */
|
data/lib/quic/connection.rb
CHANGED
|
@@ -12,7 +12,8 @@ module QUIC
|
|
|
12
12
|
# Attach an IO.select / #send / #recvfrom-compatible UDP socket so that
|
|
13
13
|
# #run and Stream blocking I/O can drive the wire transparently. Caller
|
|
14
14
|
# is responsible for socket lifetime; we do not close it. The socket
|
|
15
|
-
# must already be #connect'd to the peer (we read
|
|
15
|
+
# must already be #connect'd to the peer (we read the socket's
|
|
16
|
+
# #remote_address).
|
|
16
17
|
def bind(sock)
|
|
17
18
|
@sock = sock
|
|
18
19
|
self
|
|
@@ -108,6 +109,39 @@ module QUIC
|
|
|
108
109
|
stream
|
|
109
110
|
end
|
|
110
111
|
|
|
112
|
+
# Send an application CONNECTION_CLOSE carrying error_code and reason and
|
|
113
|
+
# enter the closing period. Raises QUIC::Error::NotBound unless #bind was
|
|
114
|
+
# called, except on a connection an Endpoint made, whose CONNECTION_CLOSE
|
|
115
|
+
# goes out through Endpoint#write_pkt. A no-op once the connection is
|
|
116
|
+
# closing or draining.
|
|
117
|
+
def close(error_code: 0, reason: nil)
|
|
118
|
+
packet = _close(error_code, reason)
|
|
119
|
+
@sock.send(packet, 0) if packet
|
|
120
|
+
nil
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# The peer of the connection's current path, as a UDP Addrinfo. It
|
|
124
|
+
# follows the peer to a new address when an Endpoint's connection
|
|
125
|
+
# migrates; a Client or Server.accept connection keeps one path.
|
|
126
|
+
# Raises QUIC::Error::InvalidState when there is no ngtcp2 connection
|
|
127
|
+
# behind the object.
|
|
128
|
+
#
|
|
129
|
+
# Telling whether the address is the same as before takes care:
|
|
130
|
+
# - Each call makes a new Addrinfo, and Addrinfo defines neither ==
|
|
131
|
+
# nor eql?/hash (it inherits the identity checks). So two
|
|
132
|
+
# calls never compare equal even for the same address, and the
|
|
133
|
+
# Addrinfos do not dedupe as Hash keys or with #uniq. Compare
|
|
134
|
+
# #to_sockaddr (or use it as the key) instead.
|
|
135
|
+
# - #to_sockaddr holds the bytes the connection was given (the address
|
|
136
|
+
# Client.new resolved, or the remote sockaddr passed to read_pkt),
|
|
137
|
+
# not normalized. An IPv4 peer read through a dual-stack IPv6
|
|
138
|
+
# socket is an IPv4-mapped AF_INET6 address (::ffff:a.b.c.d), whose
|
|
139
|
+
# bytes differ from the AF_INET sockaddr of the same peer. Compare
|
|
140
|
+
# sockaddrs that come from the same socket.
|
|
141
|
+
def remote_address
|
|
142
|
+
Addrinfo.new(_remote_sockaddr, nil, :DGRAM, Socket::IPPROTO_UDP)
|
|
143
|
+
end
|
|
144
|
+
|
|
111
145
|
private
|
|
112
146
|
|
|
113
147
|
# A C stream handler (quic/ext.h) registered on the connection owns
|
|
@@ -149,14 +183,13 @@ module QUIC
|
|
|
149
183
|
class Client
|
|
150
184
|
include Pump
|
|
151
185
|
|
|
152
|
-
attr_reader :remote_address
|
|
153
|
-
|
|
154
186
|
# Build a Client and pin a single peer address. address_family takes a
|
|
155
187
|
# Symbol (:inet for IPv4, :inet6 for IPv6) or nil to defer family
|
|
156
|
-
# selection to Addrinfo.udp's implicit resolution.
|
|
157
|
-
#
|
|
158
|
-
#
|
|
159
|
-
# sock.connect can produce a path that ngtcp2
|
|
188
|
+
# selection to Addrinfo.udp's implicit resolution. The resolved address
|
|
189
|
+
# becomes the connection's path, which #remote_address returns, so
|
|
190
|
+
# callers can connect their UDPSocket to it (otherwise DNS round-robin
|
|
191
|
+
# between Client.new and sock.connect can produce a path that ngtcp2
|
|
192
|
+
# silently drops).
|
|
160
193
|
def self.new(host:, port:, address_family: nil, transport_params: nil, settings: nil)
|
|
161
194
|
family = case address_family
|
|
162
195
|
when nil then nil
|
|
@@ -186,7 +219,6 @@ module QUIC
|
|
|
186
219
|
)
|
|
187
220
|
client.instance_variable_set(:@host, host)
|
|
188
221
|
client.instance_variable_set(:@port, port)
|
|
189
|
-
client.instance_variable_set(:@remote_address, remote_address)
|
|
190
222
|
client
|
|
191
223
|
end
|
|
192
224
|
end
|
|
@@ -198,8 +230,6 @@ module QUIC
|
|
|
198
230
|
class Server
|
|
199
231
|
include Pump
|
|
200
232
|
|
|
201
|
-
attr_reader :remote_address
|
|
202
|
-
|
|
203
233
|
private_class_method :new
|
|
204
234
|
|
|
205
235
|
# Wait for the first datagram on sock and build a connection for its
|
|
@@ -239,7 +269,6 @@ module QUIC
|
|
|
239
269
|
)
|
|
240
270
|
server.instance_variable_set(:@local_sockaddr, local_sockaddr)
|
|
241
271
|
server.instance_variable_set(:@remote_sockaddr, remote_sockaddr)
|
|
242
|
-
server.instance_variable_set(:@remote_address, sock.remote_address)
|
|
243
272
|
server.bind(sock)
|
|
244
273
|
server.read_pkt(data, local_sockaddr: local_sockaddr, remote_sockaddr: remote_sockaddr)
|
|
245
274
|
server
|
data/lib/quic/settings.rb
CHANGED
|
@@ -12,10 +12,18 @@ module QUIC
|
|
|
12
12
|
:verify_mode,
|
|
13
13
|
:ca_file,
|
|
14
14
|
:ca_path,
|
|
15
|
-
:qlog_dir
|
|
15
|
+
:qlog_dir,
|
|
16
|
+
:version,
|
|
17
|
+
:preferred_versions,
|
|
18
|
+
:available_versions,
|
|
19
|
+
:qlog_max_bytes
|
|
16
20
|
)
|
|
17
21
|
|
|
18
22
|
class Settings
|
|
23
|
+
DEFAULT_VERSIONS = [:v2, :v1].freeze
|
|
24
|
+
DEFAULT_QLOG_MAX_BYTES = 64 * 1024 * 1024
|
|
25
|
+
private_constant :DEFAULT_VERSIONS, :DEFAULT_QLOG_MAX_BYTES
|
|
26
|
+
|
|
19
27
|
# verify_mode (:peer or :none), ca_file and ca_path control server
|
|
20
28
|
# certificate verification. They default here so that callers building a
|
|
21
29
|
# Settings without them keep working.
|
|
@@ -33,8 +41,42 @@ module QUIC
|
|
|
33
41
|
# qlog_dir (a String or Pathname) makes every connection write its qlog
|
|
34
42
|
# to <qlog_dir>/<its first source connection ID in hex>.sqlog. A file
|
|
35
43
|
# that cannot be opened when a connection is made only costs that
|
|
36
|
-
# connection's qlog.
|
|
37
|
-
|
|
44
|
+
# connection's qlog. Records are buffered, and written out whole when
|
|
45
|
+
# the buffer (16 KiB) fills up, on Connection#flush_qlog and when the
|
|
46
|
+
# connection ends or its qlog stops.
|
|
47
|
+
#
|
|
48
|
+
# qlog_max_bytes caps each qlog file: an Integer from 1 to 2**63 - 1
|
|
49
|
+
# (64 MiB unless given), or nil for no limit. The record that would
|
|
50
|
+
# take a file past it is dropped with every one after it, and the file,
|
|
51
|
+
# which ends with the last whole record, is closed; the connection goes
|
|
52
|
+
# on without qlog. A client that connects again after Version
|
|
53
|
+
# Negotiation counts its new file from 0. Client.new,
|
|
54
|
+
# Connection::Server.accept and Endpoint.new raise ArgumentError for
|
|
55
|
+
# anything else, with or without qlog_dir.
|
|
56
|
+
#
|
|
57
|
+
# version, preferred_versions and available_versions choose the QUIC
|
|
58
|
+
# versions (:v1 for RFC 9000, :v2 for RFC 9369):
|
|
59
|
+
#
|
|
60
|
+
# - version is the one a client starts with. A server does not read it.
|
|
61
|
+
# - preferred_versions lists the versions in order of preference. A server
|
|
62
|
+
# upgrades a client to the first of them the client can use (compatible
|
|
63
|
+
# version negotiation) and lists them in its Version Negotiation
|
|
64
|
+
# packets.
|
|
65
|
+
# - available_versions is what goes into the version_information
|
|
66
|
+
# transport parameter.
|
|
67
|
+
#
|
|
68
|
+
# A server accepts a client that starts with any version in either list.
|
|
69
|
+
# With the defaults on both ends, a client starts with v1 and the server
|
|
70
|
+
# moves the connection to v2; a peer that knows only v1 stays on v1.
|
|
71
|
+
#
|
|
72
|
+
# Both lists are copied and frozen here, so changing the Array that was
|
|
73
|
+
# passed in later changes no Settings.
|
|
74
|
+
def initialize(verify_mode: :peer, ca_file: nil, ca_path: nil, qlog_dir: nil,
|
|
75
|
+
version: :v1, preferred_versions: DEFAULT_VERSIONS, available_versions: DEFAULT_VERSIONS,
|
|
76
|
+
qlog_max_bytes: DEFAULT_QLOG_MAX_BYTES, **rest)
|
|
77
|
+
# Anything but an Array is left for the C extension to reject.
|
|
78
|
+
preferred_versions = preferred_versions.dup.freeze if preferred_versions.is_a?(Array)
|
|
79
|
+
available_versions = available_versions.dup.freeze if available_versions.is_a?(Array)
|
|
38
80
|
super
|
|
39
81
|
end
|
|
40
82
|
|
|
@@ -50,7 +92,11 @@ module QUIC
|
|
|
50
92
|
verify_mode: :peer,
|
|
51
93
|
ca_file: nil,
|
|
52
94
|
ca_path: nil,
|
|
53
|
-
qlog_dir: nil
|
|
95
|
+
qlog_dir: nil,
|
|
96
|
+
version: :v1,
|
|
97
|
+
preferred_versions: DEFAULT_VERSIONS,
|
|
98
|
+
available_versions: DEFAULT_VERSIONS,
|
|
99
|
+
qlog_max_bytes: DEFAULT_QLOG_MAX_BYTES
|
|
54
100
|
)
|
|
55
101
|
end
|
|
56
102
|
|
data/lib/quic/version.rb
CHANGED
data/sig/quic.rbs
CHANGED
|
@@ -65,6 +65,11 @@ module QUIC
|
|
|
65
65
|
# stream handler registered through quic/ext.h.
|
|
66
66
|
class InvalidState < Error
|
|
67
67
|
end
|
|
68
|
+
|
|
69
|
+
# No QUIC version in common with the peer, or ngtcp2 found that the
|
|
70
|
+
# version was forced down to one it should not have chosen.
|
|
71
|
+
class VersionNegotiation < Error
|
|
72
|
+
end
|
|
68
73
|
end
|
|
69
74
|
|
|
70
75
|
class TransportParams < Data
|
|
@@ -101,6 +106,23 @@ module QUIC
|
|
|
101
106
|
# connection's qlog.
|
|
102
107
|
attr_reader qlog_dir: (String | _ToPath)?
|
|
103
108
|
|
|
109
|
+
# The QUIC version a client starts with (default :v1). A server does
|
|
110
|
+
# not read it.
|
|
111
|
+
attr_reader version: :v1 | :v2
|
|
112
|
+
# In order of preference (default [:v2, :v1]): what a server upgrades a
|
|
113
|
+
# client to and lists in Version Negotiation.
|
|
114
|
+
attr_reader preferred_versions: Array[:v1 | :v2]
|
|
115
|
+
# The version_information transport parameter (default [:v2, :v1]). A
|
|
116
|
+
# server accepts a client starting with any version in either list.
|
|
117
|
+
attr_reader available_versions: Array[:v1 | :v2]
|
|
118
|
+
# The most bytes one qlog file holds: an Integer from 1 to 2**63 - 1
|
|
119
|
+
# (64 MiB unless given), or nil for no limit. The record that would go
|
|
120
|
+
# past it is dropped with every one after it, and the file is closed,
|
|
121
|
+
# ending with the last whole record. Client.new,
|
|
122
|
+
# Connection::Server.accept and Endpoint.new raise ArgumentError for
|
|
123
|
+
# anything else.
|
|
124
|
+
attr_reader qlog_max_bytes: Integer?
|
|
125
|
+
|
|
104
126
|
def self.default: () -> Settings
|
|
105
127
|
|
|
106
128
|
# Raises ArgumentError unless qlog_dir is nil or a directory this
|
|
@@ -143,7 +165,15 @@ module QUIC
|
|
|
143
165
|
class Client
|
|
144
166
|
include Pump
|
|
145
167
|
|
|
146
|
-
|
|
168
|
+
# The server's address on the connection's path: the address Client.new
|
|
169
|
+
# resolved, as a UDP Addrinfo. Kept after the connection closes. A new
|
|
170
|
+
# Addrinfo on each call, and Addrinfo has no == (nor eql?/hash), so
|
|
171
|
+
# compare #to_sockaddr; those bytes are not normalized, and an
|
|
172
|
+
# IPv4-mapped IPv6 address differs from the plain IPv4 one.
|
|
173
|
+
# Raises QUIC::Error::InvalidState when there is no connection behind
|
|
174
|
+
# the object (.allocate, or a failed reconnect after Version
|
|
175
|
+
# Negotiation).
|
|
176
|
+
def remote_address: () -> Addrinfo
|
|
147
177
|
|
|
148
178
|
def self.new: (host: String, port: Integer, ?address_family: Symbol?, ?transport_params: TransportParams?, ?settings: Settings?) -> Client
|
|
149
179
|
|
|
@@ -164,6 +194,21 @@ module QUIC
|
|
|
164
194
|
def expiry: () -> Integer?
|
|
165
195
|
def handle_expiry: () -> nil
|
|
166
196
|
def handshake_completed?: () -> bool
|
|
197
|
+
# :v1 or :v2 once the version is settled, nil before.
|
|
198
|
+
def negotiated_version: () -> (:v1 | :v2)?
|
|
199
|
+
# The ALPN protocol the server chose (frozen, ASCII-8BIT), set by the
|
|
200
|
+
# server's EncryptedExtensions; nil before, and nil for good when the
|
|
201
|
+
# server's EncryptedExtensions carried none (which a server may do
|
|
202
|
+
# when settings.alpn offered none; this gem's server refuses such a
|
|
203
|
+
# client instead). Raises QUIC::Error::InvalidState when there is no
|
|
204
|
+
# connection behind the object.
|
|
205
|
+
def alpn_protocol: () -> String?
|
|
206
|
+
# The cipher suite's IANA name, e.g. "TLS_AES_128_GCM_SHA256" (frozen,
|
|
207
|
+
# US-ASCII, the same object on every call), set by the server's first
|
|
208
|
+
# ServerHello or HelloRetryRequest; nil before. Raises
|
|
209
|
+
# QUIC::Error::InvalidState when there is no connection behind the
|
|
210
|
+
# object.
|
|
211
|
+
def cipher_suite: () -> String?
|
|
167
212
|
def in_closing_period?: () -> bool
|
|
168
213
|
def in_draining_period?: () -> bool
|
|
169
214
|
|
|
@@ -177,12 +222,37 @@ module QUIC
|
|
|
177
222
|
|
|
178
223
|
# Always nil: only a connection an Endpoint made has a closing reason.
|
|
179
224
|
def error: () -> Exception?
|
|
225
|
+
|
|
226
|
+
# The absolute path of this connection's qlog file, frozen and the
|
|
227
|
+
# same object on every call; nil without Settings#qlog_dir or when the
|
|
228
|
+
# file could not be opened. Kept after the file is closed. After a
|
|
229
|
+
# reconnect following Version Negotiation, the new connection's file,
|
|
230
|
+
# or nil if that could not be opened.
|
|
231
|
+
def qlog_path: () -> String?
|
|
232
|
+
|
|
233
|
+
# Writes out the qlog records buffered so far (at most 16 KiB), so
|
|
234
|
+
# that the file at #qlog_path holds every record logged until now,
|
|
235
|
+
# or until the qlog stopped at Settings#qlog_max_bytes or a failed
|
|
236
|
+
# write. No fsync. Does nothing without an open qlog file; a failed
|
|
237
|
+
# write stops the qlog as it would otherwise, and raises nothing.
|
|
238
|
+
def flush_qlog: () -> nil
|
|
180
239
|
end
|
|
181
240
|
|
|
182
241
|
class Server
|
|
183
242
|
include Pump
|
|
184
243
|
|
|
185
|
-
|
|
244
|
+
# The client's address on the connection's current path, as a UDP
|
|
245
|
+
# Addrinfo. A new Addrinfo on each call, and Addrinfo has no == (nor
|
|
246
|
+
# eql?/hash), so compare #to_sockaddr to tell whether it changed;
|
|
247
|
+
# those bytes are what read_pkt was given, not normalized, and an
|
|
248
|
+
# IPv4-mapped IPv6 address differs from the plain IPv4 one. On a
|
|
249
|
+
# connection an Endpoint made, it follows the client to a new
|
|
250
|
+
# address: ngtcp2 switches the path as soon as a non-probing packet
|
|
251
|
+
# comes from there, before validating it, and switches back if the
|
|
252
|
+
# validation fails. A Server.accept connection keeps the address it
|
|
253
|
+
# accepted. Kept after the connection closes. Raises
|
|
254
|
+
# QUIC::Error::InvalidState on an object made with .allocate.
|
|
255
|
+
def remote_address: () -> Addrinfo
|
|
186
256
|
|
|
187
257
|
# Waits for the first datagram on sock (bound to the listen address,
|
|
188
258
|
# not connected), connects sock to its sender, and returns a Server
|
|
@@ -227,6 +297,18 @@ module QUIC
|
|
|
227
297
|
def expiry: () -> Integer?
|
|
228
298
|
def handle_expiry: () -> nil
|
|
229
299
|
def handshake_completed?: () -> bool
|
|
300
|
+
# :v1 or :v2 once the version is settled, nil before.
|
|
301
|
+
def negotiated_version: () -> (:v1 | :v2)?
|
|
302
|
+
# The ALPN protocol chosen from the client's offer (frozen,
|
|
303
|
+
# ASCII-8BIT), set on the first ClientHello, so already there when
|
|
304
|
+
# Server.accept returns or an Endpoint has read the first Initial.
|
|
305
|
+
# Raises QUIC::Error::InvalidState on an object made with .allocate.
|
|
306
|
+
def alpn_protocol: () -> String?
|
|
307
|
+
# The cipher suite's IANA name, e.g. "TLS_AES_128_GCM_SHA256" (frozen,
|
|
308
|
+
# US-ASCII, the same object on every call), set on the first
|
|
309
|
+
# ClientHello. Raises QUIC::Error::InvalidState on an object made with
|
|
310
|
+
# .allocate.
|
|
311
|
+
def cipher_suite: () -> String?
|
|
230
312
|
def in_closing_period?: () -> bool
|
|
231
313
|
def in_draining_period?: () -> bool
|
|
232
314
|
|
|
@@ -246,6 +328,18 @@ module QUIC
|
|
|
246
328
|
# raised) from ngtcp2's error code. Always nil for a connection no
|
|
247
329
|
# Endpoint made.
|
|
248
330
|
def error: () -> Exception?
|
|
331
|
+
|
|
332
|
+
# The absolute path of this connection's qlog file, frozen and the
|
|
333
|
+
# same object on every call; nil without Settings#qlog_dir or when the
|
|
334
|
+
# file could not be opened. Kept after the file is closed.
|
|
335
|
+
def qlog_path: () -> String?
|
|
336
|
+
|
|
337
|
+
# Writes out the qlog records buffered so far (at most 16 KiB), so
|
|
338
|
+
# that the file at #qlog_path holds every record logged until now,
|
|
339
|
+
# or until the qlog stopped at Settings#qlog_max_bytes or a failed
|
|
340
|
+
# write. No fsync. Does nothing without an open qlog file; a failed
|
|
341
|
+
# write stops the qlog as it would otherwise, and raises nothing.
|
|
342
|
+
def flush_qlog: () -> nil
|
|
249
343
|
end
|
|
250
344
|
end
|
|
251
345
|
|
|
@@ -321,21 +415,23 @@ module QUIC
|
|
|
321
415
|
|
|
322
416
|
# Blocks (by internally calling #pump_once on the owning Client or
|
|
323
417
|
# Server) until the peer's flow control window has room for the full
|
|
324
|
-
# payload, then queues all bytes and returns data.bytesize.
|
|
325
|
-
#
|
|
326
|
-
#
|
|
327
|
-
#
|
|
328
|
-
#
|
|
329
|
-
#
|
|
418
|
+
# payload, then queues all bytes and returns data.bytesize. The window is
|
|
419
|
+
# the smaller of the stream's and the connection's, and the connection's
|
|
420
|
+
# is shared with what the other streams of the connection have queued
|
|
421
|
+
# but not yet sent. Requires the owning connection to be bound to a
|
|
422
|
+
# socket via #bind; raises QUIC::Error::NotBound otherwise. Raises
|
|
423
|
+
# QUIC::Error::StreamClosed, while waiting too, once the stream has been
|
|
424
|
+
# reset or closed, or the peer has sent STOP_SENDING. STOP_SENDING also
|
|
425
|
+
# drops what was queued but not yet sent.
|
|
330
426
|
def write: (String data, ?fin: bool) -> Integer
|
|
331
427
|
|
|
332
428
|
# Non-blocking variant. Queues as much of `data` as the current flow
|
|
333
|
-
# control window allows and returns the byte count actually
|
|
334
|
-
# Raises QUIC::Error::WaitWritable (mixed in with
|
|
335
|
-
# the window is zero and the payload is non-empty,
|
|
336
|
-
# QUIC::Error::StreamClosed as #write does. If only a partial prefix
|
|
337
|
-
# accepted, `fin: true` is NOT propagated; the caller must re-issue
|
|
338
|
-
# `fin: true` on the trailing chunk.
|
|
429
|
+
# control window (see #write) allows and returns the byte count actually
|
|
430
|
+
# queued. Raises QUIC::Error::WaitWritable (mixed in with
|
|
431
|
+
# IO::WaitWritable) when the window is zero and the payload is non-empty,
|
|
432
|
+
# and QUIC::Error::StreamClosed as #write does. If only a partial prefix
|
|
433
|
+
# is accepted, `fin: true` is NOT propagated; the caller must re-issue
|
|
434
|
+
# with `fin: true` on the trailing chunk.
|
|
339
435
|
def write_nonblock: (String data, ?fin: bool) -> Integer
|
|
340
436
|
def eof?: () -> bool
|
|
341
437
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: quic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yusuke Nakamura
|
|
@@ -93,14 +93,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
93
93
|
requirements:
|
|
94
94
|
- - ">="
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version:
|
|
96
|
+
version: '0'
|
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
|
99
99
|
- - ">="
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '0'
|
|
102
102
|
requirements: []
|
|
103
|
-
rubygems_version: 4.0.
|
|
103
|
+
rubygems_version: 4.0.20
|
|
104
104
|
specification_version: 4
|
|
105
105
|
summary: Thin Ruby binding around ngtcp2 for the QUIC transport protocol, using picotls
|
|
106
106
|
for TLS 1.3 over the system OpenSSL.
|