quic 0.0.7 → 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.
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
- attr_reader remote_address: Addrinfo
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
- attr_reader remote_address: Addrinfo
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
 
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Nakamura