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

Commit 63fee64

Browse files
committed
Port number is configurable.
1 parent 7d48bc3 commit 63fee64

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

source/agent/addons/quic/QuicTransportServer.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ Nan::Persistent<v8::Function> QuicTransportServer::s_constructor;
2121

2222
DEFINE_LOGGER(QuicTransportServer, "QuicTransportServer");
2323

24-
QuicTransportServer::QuicTransportServer(int port)
25-
: m_quicServer(QuicFactory::getQuicTransportFactory()->CreateQuicTransportServer(port, "", "", ""))
24+
// TODO: Certificate and key path is hard coded here. Read them from toml file later.
25+
const std::string certPath = "/tmp/certs/leaf_cert.pem";
26+
const std::string keyPath = "/tmp/certs/leaf_cert.pkcs8";
27+
28+
QuicTransportServer::QuicTransportServer(int port, const std::string& certPath, const std::string& keyPath)
29+
: m_quicServer(QuicFactory::getQuicTransportFactory()->CreateQuicTransportServer(port, certPath.c_str(), keyPath.c_str()))
2630
{
2731
m_quicServer->SetVisitor(this);
2832
ELOG_DEBUG("QuicTransportServer::QuicTransportServer");
@@ -52,7 +56,8 @@ NAN_METHOD(QuicTransportServer::newInstance)
5256
return Nan::ThrowTypeError("Port is required.");
5357
}
5458
// Default port number is not specified in https://tools.ietf.org/html/draft-vvv-webtransport-quic-01.
55-
QuicTransportServer* obj = new QuicTransportServer(7700);
59+
int minPort = info[0]->IntegerValue();
60+
QuicTransportServer* obj = new QuicTransportServer(minPort, certPath, keyPath);
5661
obj->Wrap(info.This());
5762
uv_async_init(uv_default_loop(), &obj->m_asyncOnConnection, &QuicTransportServer::onConnectionCallback);
5863
info.GetReturnValue().Set(info.This());

source/agent/addons/quic/QuicTransportServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class QuicTransportServer : public Nan::ObjectWrap, owt::quic::QuicTransportServ
3333
void onClose() override;
3434

3535
QuicTransportServer() = delete;
36-
explicit QuicTransportServer(int port);
36+
explicit QuicTransportServer(int port, const std::string& certPath, const std::string& keyPath);
3737

3838
private:
3939
static NAN_METHOD(newInstance);

source/agent/quic/agent.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ minport = 0 #default: 0
4848

4949
#########################################################################################
5050
[quic]
51-
#The network inferface all peer-connections will be established through. All network interfaces in the system will be adopted if this item is not specified or specified with an empty array.
52-
##Valid value is an array of objects that has two properties: name and replaced_ip_address. name is the name of network interface that will be used, replaced_ip_address is the IP address used for replacing the internal IP address in locally generated SDP's and ICE candidates during establishing the peer-connection(useful when behind NATs). replaced_ip_address is optional, if it is not specified, IP address from corresponding network interface will not be replaced.
53-
#Example of valid value: [{name = "eth1"}, {name = "eth2", replaced_ip_address = "192.0.2.2"}].
54-
network_interfaces = [] # default: []
55-
51+
# Key store path doesn't work right now.
5652
keystorePath = "./cert/certificate.pfx"
57-
#note, this won't work with all versions of libnice. With 0 all the available ports are used
53+
54+
# Port of QUIC agent is going to listen on. Default port for WebTransport is not defined in WebTransport spec. We will update it when it's defined.
55+
minport = 7700 #default: 7700
56+
# maxport = 7799 #default: 7799

source/agent/quic/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,23 @@ const addon = require('./build/Release/quic');
2727
log.info('QUIC transport node.')
2828

2929
module.exports = function (rpcClient, selfRpcId, parentRpcId, clusterWorkerIP) {
30-
var that = {
30+
const that = {
3131
agentID: parentRpcId,
3232
clusterIP: clusterWorkerIP
3333
};
34-
var connections = new Connections;
35-
var internalConnFactory = new InternalConnectionFactory;
34+
const connections = new Connections;
35+
const internalConnFactory = new InternalConnectionFactory;
3636
const incomingStreamPipelines =
3737
new Map(); // Key is publication ID, value is stream pipeline.
3838
const outgoingStreamPipelines =
3939
new Map(); // Key is subscription ID, value is stream pipeline.
4040

41-
var notifyStatus = (controller, sessionId, direction, status) => {
41+
const notifyStatus = (controller, sessionId, direction, status) => {
4242
rpcClient.remoteCast(controller, 'onSessionProgress', [sessionId, direction, status]);
4343
};
4444

45-
const quicTransportServer = new QuicTransportServer(addon);
45+
const quicTransportServer =
46+
new QuicTransportServer(addon, global.config.quic.minport);
4647
quicTransportServer.start();
4748
quicTransportServer.on('streamadded', (stream) => {
4849
const conn = connections.getConnection(stream.contentSessionId);

0 commit comments

Comments
 (0)