File tree 4 files changed +38
-22
lines changed
4 files changed +38
-22
lines changed Original file line number Diff line number Diff line change @@ -175,14 +175,19 @@ class QuicIncoming {
175
175
return op_quic_incoming_remote_addr_validated ( this . #incoming) ;
176
176
}
177
177
178
- async accept ( ) {
179
- const conn = await op_quic_incoming_accept ( this . #incoming) ;
180
- return new QuicConn ( conn , this . #endpoint) ;
181
- }
182
-
183
- accept0rtt ( ) {
184
- const conn = op_quic_incoming_accept_0rtt ( this . #incoming) ;
185
- return new QuicConn ( conn , this . #endpoint) ;
178
+ accept ( options ) {
179
+ const tOptions = options ? transportOptions ( options ) : null ;
180
+ if ( options ?. zeroRtt ) {
181
+ const conn = op_quic_incoming_accept_0rtt (
182
+ this . #incoming,
183
+ tOptions ,
184
+ ) ;
185
+ return new QuicConn ( conn , this . #endpoint) ;
186
+ }
187
+ return PromisePrototypeThen (
188
+ op_quic_incoming_accept ( this . #incoming, tOptions ) ,
189
+ ( conn ) => new QuicConn ( conn , this . #endpoint) ,
190
+ ) ;
186
191
}
187
192
188
193
refuse ( ) {
@@ -411,7 +416,7 @@ function connectQuic(options) {
411
416
keyPair ,
412
417
) ;
413
418
414
- if ( options . zrtt ) {
419
+ if ( options . zeroRtt ) {
415
420
const conn = op_quic_connecting_0rtt ( connecting ) ;
416
421
if ( conn ) {
417
422
return new QuicConn ( conn , endpoint ) ;
Original file line number Diff line number Diff line change @@ -536,7 +536,7 @@ declare namespace Deno {
536
536
* the TLS handshake completes is vulnerable to replay attacks.
537
537
* @default {false}
538
538
*/
539
- zrtt ?: ZRTT ;
539
+ zeroRtt ?: ZRTT ;
540
540
}
541
541
542
542
/**
@@ -555,6 +555,21 @@ declare namespace Deno {
555
555
alpnProtocols : string [ ] ;
556
556
}
557
557
558
+ /**
559
+ * **UNSTABLE**: New API, yet to be vetted.
560
+ * @experimental
561
+ * @category Network
562
+ */
563
+ export interface QuicAcceptOptions < ZRTT extends boolean >
564
+ extends QuicTransportOptions {
565
+ /**
566
+ * Convert this connection into 0.5-RTT at the cost of weakened security, as
567
+ * 0.5-RTT data may be sent before TLS client authentication has occurred.
568
+ * @default {false}
569
+ */
570
+ zeroRtt ?: ZRTT ;
571
+ }
572
+
558
573
/**
559
574
* **UNSTABLE**: New API, yet to be vetted.
560
575
* @experimental
@@ -673,13 +688,9 @@ declare namespace Deno {
673
688
/**
674
689
* Accept this incoming connection.
675
690
*/
676
- accept ( ) : Promise < QuicConn > ;
677
-
678
- /**
679
- * Convert this connection into 0.5-RTT at the cost of weakened security, as
680
- * 0.5-RTT data may be sent before TLS client authentication has occurred.
681
- */
682
- accept0rtt ( ) : QuicConn ;
691
+ accept < ZRTT extends boolean > (
692
+ options ?: QuicAcceptOptions < ZRTT > ,
693
+ ) : ZRTT extends true ? QuicConn : Promise < QuicConn > ;
683
694
684
695
/**
685
696
* Refuse this incoming connection.
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ struct ListenArgs {
100
100
alpn_protocols : Option < Vec < String > > ,
101
101
}
102
102
103
- #[ derive( Deserialize ) ]
103
+ #[ derive( Deserialize , Default , PartialEq ) ]
104
104
#[ serde( rename_all = "camelCase" ) ]
105
105
struct TransportConfig {
106
106
keep_alive_interval : Option < u64 > ,
@@ -379,13 +379,13 @@ fn quic_incoming_accept(
379
379
return Err ( QuicError :: BadResource ( "QuicIncoming" ) ) ;
380
380
} ;
381
381
match transport_config {
382
- Some ( transport_config) => {
382
+ Some ( transport_config) if transport_config != Default :: default ( ) => {
383
383
let mut config =
384
384
quinn:: ServerConfig :: with_crypto ( incoming_resource. 1 . clone ( ) ) ;
385
385
apply_server_transport_config ( & mut config, transport_config) ?;
386
386
Ok ( incoming. accept_with ( Arc :: new ( config) ) ?)
387
387
}
388
- None => Ok ( incoming. accept ( ) ?) ,
388
+ _ => Ok ( incoming. accept ( ) ?) ,
389
389
}
390
390
}
391
391
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ Deno.test("0rtt", async () => {
190
190
}
191
191
throw e ;
192
192
}
193
- const conn = incoming . accept0rtt ( ) ;
193
+ const conn = incoming . accept ( { zeroRtt : true } ) ;
194
194
conn . handshake . then ( ( ) => {
195
195
conn . close ( ) ;
196
196
} ) ;
@@ -214,7 +214,7 @@ Deno.test("0rtt", async () => {
214
214
port : sEndpoint . addr . port ,
215
215
caCerts,
216
216
alpnProtocols : [ "deno-test" ] ,
217
- zrtt : true ,
217
+ zeroRtt : true ,
218
218
endpoint,
219
219
} ) ;
220
220
You can’t perform that action at this time.
0 commit comments