Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 1df81d1

Browse files
authored
Implement close for QUIC stream. (#882)
This change also closes unauthenticated connections in expected time and avoid duplicated signaling streams.
1 parent e686e40 commit 1df81d1

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

source/agent/addons/quic/QuicTransportStream.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ NAN_METHOD(QuicTransportStream::write)
104104
info.GetReturnValue().Set(Nan::New(static_cast<int>(written)));
105105
}
106106

107+
NAN_METHOD(QuicTransportStream::close)
108+
{
109+
QuicTransportStream* obj = Nan::ObjectWrap::Unwrap<QuicTransportStream>(info.Holder());
110+
obj->m_stream->Close();
111+
}
112+
107113
NAN_METHOD(QuicTransportStream::addDestination)
108114
{
109115
QuicTransportStream* obj = Nan::ObjectWrap::Unwrap<QuicTransportStream>(info.Holder());

source/agent/addons/quic/QuicTransportStream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class QuicTransportStream : public owt_base::FrameSource, public owt_base::Frame
3232
static NAN_MODULE_INIT(init);
3333
static NAN_METHOD(newInstance);
3434
static NAN_METHOD(write);
35+
static NAN_METHOD(close);
3536
static NAN_METHOD(addDestination);
3637
static NAN_METHOD(removeDestination);
3738
static NAUV_WORK_CB(onContentSessionId);

source/agent/quic/webtransport/quicTransportServer.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,25 @@ module.exports = class QuicTransportServer extends EventEmitter {
3838
if (!connection.transportId) {
3939
connection.close();
4040
}
41-
}, authenticationTimeout * 1000000);
41+
}, authenticationTimeout * 1000);
4242
connection.onincomingstream = (stream) => {
4343
log.info('New incoming stream.');
4444
stream.oncontentsessionid = (id) => {
4545
const streamId = this._uuidBytesToString(new Uint8Array(id))
4646
stream.contentSessionId = streamId;
4747
stream.transportId = connection.transportId;
4848
if (streamId === zeroUuid) {
49-
// Signaling stream. Waiting for transport ID.
50-
log.info('Zero content session ID.');
49+
if (connection.transportId) {
50+
log.error(
51+
'Received a new signaling stream on an authenticated connection. Close connection.')
52+
connection.close();
53+
}
54+
// Signaling stream. Waiting for transport ID then.
5155
} else if (!connection.transportId) {
5256
log.error(
5357
'Stream ' + streamId +
54-
' added on unauthroized transport. Close connection.');
58+
' added on unauthenticated transport. Close connection.');
59+
connection.close();
5560
} else {
5661
log.debug(
5762
'A new stream ' + streamId + ' is created on transport ' +

source/agent/quic/webtransport/quicTransportStreamPipeline.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ module.exports = class QuicTransportStreamPipeline {
5151
};
5252

5353
this.close = function(){
54-
return;
5554
this._quicStream.close();
5655
}
5756
}

0 commit comments

Comments
 (0)