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

Commit b5919b7

Browse files
committed
Fix linting problems in portal code
1 parent 0379a2e commit b5919b7

35 files changed

+456
-188
lines changed

doc/certificates.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Client side certificate management
2+
3+
We recommand to use default credential storage to verify and manage certificates on different platforms.
4+
Windows: (https://docs.microsoft.com/en-us/windows-hardware/drivers/install/certificate-stores)
5+
IOS: (https://developer.apple.com/documentation/security/certificate_key_and_trust_services/certificates)
6+
Android: (https://developer.android.com/training/articles/security-config)

doc/design/quic-programming-guide.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,12 @@ Please follow [Conference Server build instructions](https://github.com/open-web
126126
Steps to run Conference Server with pre-built binary:
127127

128128
1. Go to the untarred conference server dir, and run `./bin/init-all.sh --deps`; this would try to install mongodb and rabbitmq-server. Don't set any password for rabbitmq or mongodb.
129-
2. Still in the same dir, run `bin/init-all.sh`.
130-
3. Update quic_agent/agent.toml, set `hostname` to the hostname quic agent is running on.
131-
4. run `bin/start-all.sh`.
132-
5. Open [https://localhost:3004/quic.html](https://localhost:3004/quic.html) on the same host with Chrome browser to visit the web sample page. Due to the test certificate, you may need confirm this unsafe access.
133-
6. Press 'Start Sending' button to start transferring data to conference server. Press 'Stop Sending' button on the web page to stop sending.. If there's no error in the console, that implies server is correctly setup.
129+
1. Still in the same dir, run `bin/init-all.sh`.
130+
1. Update quic_agent/agent.toml, set `hostname` to the hostname quic agent is running on.
131+
1. Update management_api/management_api.toml, set `enableWebTransport` to `true`.
132+
1. run `bin/start-all.sh`.
133+
1. Open [https://localhost:3004/quic.html](https://localhost:3004/quic.html) on the same host with Chrome browser to visit the web sample page. Due to the test certificate, you may need confirm this unsafe access.
134+
1. Press 'Start Sending' button to start transferring data to conference server. Press 'Stop Sending' button on the web page to stop sending.. If there's no error in the console, that implies server is correctly setup.
134135

135136
# OWT QUIC Windows Sample
136137

@@ -152,7 +153,7 @@ OWT Conference Server is using a self-signed certificate during development phas
152153
- Make sure generate-certs.sh is exectuable. If not, run `chmod +x generate-certs.sh`;
153154
- Remove the `out` dir in case it exists.
154155
- Under the downloaded tool dir, run `./generate-certs.sh`. It is expected to generate a series of files under out dir.
155-
- Under the downloaded tool dir, run `openssl pkcs12 -inkey out/leaf_certs.key -in out/leaf_cert.pem -export -out out/certificate.pfx`. This will prompt for password for the pfx. Make sure you always use `abc123` as the password.
156+
- Under the downloaded tool dir, run `openssl pkcs12 -inkey out/leaf_cert.key -in out/leaf_cert.pem -export -out out/certificate.pfx`. This will prompt for password for the pfx. Make sure you always use `abc123` as the password.
156157
- Under the downloaded tool dir, run `openssl x509 -noout -fingerprint -sha256 -inform pem -in out/leaf_cert.pem`. You will get the fingerprint string in the form of "XX:XX:XX....XX:XX".
157158

158159
## Use the Certificate

scripts/pack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ function isLibAllowed(libSrc) {
456456
const whiteList = [
457457
'rtcadapter',
458458
'libssl.so.1.1',
459-
'libcrypto',
459+
'libcrypto.so.1.1',
460460
'libnice',
461461
'libSvtHevcEnc',
462462
'libusrsctp',

source/.eslintrc.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1+
// Copyright (C) <2018> Intel Corporation
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
14
{
25
"env": {
3-
"browser": true,
4-
"es2021": true
6+
"es2021": true,
7+
"node": true
58
},
6-
"extends": "eslint:recommended",
9+
"extends": ["eslint:recommended", "google"],
710
"parserOptions": {
8-
"ecmaVersion": 12,
9-
"sourceType": "module"
11+
"ecmaVersion": 12,
12+
"sourceType": "module"
1013
},
1114
"rules": {
15+
"max-len": ["error", {
16+
// This line is part of the MIT license.
17+
"ignorePattern": "The above copyright notice and this permission notice shall be included in all",
18+
// Some lines for JSDoc is longer than 80.
19+
"ignoreComments": true
20+
}],
21+
"indent": ["warn"],
22+
"camelcase": 0,
23+
"prefer-promise-reject-errors": "off",
24+
"guard-for-in": "off",
25+
"require-jsdoc": "off",
26+
"no-invalid-this": "off",
27+
"new-cap": "off"
1228
}
1329
}

source/agent/InternalConnectionFactory.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ try {
3939
}
4040

4141
// Wrapper object for sctp-connection and tcp/udp-connection
42-
function InConnection(prot, minport, maxport) {
42+
function InConnection(prot, minport, maxport, ticket) {
4343
var conn = null;
4444
var protocol = "quic";
4545

4646
switch (prot) {
4747
case 'tcp':
4848
case 'udp':
4949
protocol = prot;
50-
conn = new InternalIn(prot, minport, maxport);
50+
conn = new InternalIn(prot, minport, maxport, ticket);
5151
break;
5252
case 'quic':
5353
conn = new quicIO.in(cf, kf);
@@ -78,7 +78,7 @@ function InConnection(prot, minport, maxport) {
7878
}
7979

8080
// Wrapper object for sctp-connection and tcp/udp-connection
81-
function OutConnection(prot, minport, maxport) {
81+
function OutConnection(prot, minport, maxport, ticket) {
8282
var that = {};
8383
var conn = null;
8484
var protocol = "quic";
@@ -111,7 +111,7 @@ function OutConnection(prot, minport, maxport) {
111111
} else if (protocol === 'quic') {
112112
conn = new quicIO.out(connectOpt.ip, connectOpt.port);
113113
} else {
114-
conn = new InternalOut(protocol, connectOpt.ip, connectOpt.port);
114+
conn = new InternalOut(protocol, connectOpt.ip, connectOpt.port, ticket);
115115
}
116116
};
117117

@@ -139,6 +139,7 @@ module.exports = function() {
139139
var prot = internalOpt.protocol;
140140
var minport = internalOpt.minport || 0;
141141
var maxport = internalOpt.maxport || 0;
142+
var ticket = internalOpt.ticket;
142143

143144
if (preparedSet[connId]) {
144145
log.warn('Internal Connection already prepared:', connId);
@@ -147,7 +148,9 @@ module.exports = function() {
147148
// right call sequence in upper layer.
148149
return preparedSet[connId].connection.getListeningPort();
149150
}
150-
var conn = (direction === 'in')? InConnection(prot, minport, maxport) : OutConnection(prot, minport, maxport);
151+
var conn = (direction === 'in')
152+
? InConnection(prot, minport, maxport, ticket)
153+
: OutConnection(prot, minport, maxport, ticket);
151154

152155
preparedSet[connId] = {connection: conn, direction: direction};
153156
return conn.getListeningPort();

source/agent/addons/internalIO/InternalInWrapper.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,23 @@ void InternalIn::New(const FunctionCallbackInfo<Value>& args) {
3737
String::Utf8Value param0(args[0]->ToString());
3838
std::string protocol = std::string(*param0);
3939
unsigned int minPort = 0, maxPort = 0;
40+
std::string ticket;
4041

4142
if (args.Length() >= 3) {
4243
minPort = args[1]->Uint32Value();
4344
maxPort = args[2]->Uint32Value();
4445
}
46+
if (args.Length() > 3) {
47+
String::Utf8Value param3(args[3]->ToString());
48+
ticket = std::string(*param3);
49+
}
4550

4651
InternalIn* obj = new InternalIn();
47-
obj->me = new owt_base::InternalIn(protocol, minPort, maxPort);
52+
if (ticket.empty()) {
53+
obj->me = new owt_base::InternalIn(protocol, minPort, maxPort);
54+
} else {
55+
obj->me = new owt_base::InternalIn(protocol, ticket, minPort, maxPort);
56+
}
4857
obj->src = obj->me;
4958

5059
obj->Wrap(args.This());

source/agent/addons/internalIO/InternalOutWrapper.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ void InternalOut::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
3636
String::Utf8Value param1(args[1]->ToString());
3737
std::string dest_ip = std::string(*param1);
3838
unsigned int dest_port = args[2]->Uint32Value();
39+
std::string ticket;
40+
if (args.Length() > 3) {
41+
String::Utf8Value param3(args[3]->ToString());
42+
ticket = std::string(*param3);
43+
}
3944

4045
InternalOut* obj = new InternalOut();
41-
obj->me = new owt_base::InternalOut(protocol, dest_ip, dest_port);
46+
if (ticket.empty()) {
47+
obj->me = new owt_base::InternalOut(protocol, dest_ip, dest_port);
48+
} else {
49+
obj->me = new owt_base::InternalOut(protocol, ticket, dest_ip, dest_port);
50+
}
4251
obj->dest = obj->me;
4352

4453
obj->Wrap(args.This());
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
67301606083eec702fbbe12c768b56948b419c01
1+
4fda6ee03d3d0a305fe239d968ca4af46f4fda05

source/agent/addons/quic/test/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/agent/analytics/analytics-agent.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ class AnalyticsAgent extends BaseAgent {
2525
this.engine = new VideoAnalyzer();
2626

2727
this.flag = 0;
28+
this.ticket = null;
2829
}
2930

3031
// override
3132
createInternalConnection(connectionId, direction, internalOpt) {
3233
internalOpt.minport = global.config.internal.minport;
3334
internalOpt.maxport = global.config.internal.maxport;
35+
this.ticket = internalOpt.ticket;
3436
if (direction == 'in') {
35-
this.engine.emitListenTo(internalOpt.minport,internalOpt.maxport);
37+
this.engine.emitListenTo(internalOpt.minport,internalOpt.maxport, this.ticket);
3638
const portInfo = this.engine.getListeningPort();
3739
// Create internal connection always success
3840
return Promise.resolve({ip: global.config.internal.ip_address, port: portInfo});

source/agent/analytics/videoGstPipeline/GstInternalIn.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ static void dump(void* index, uint8_t* buf, int len)
1919
}
2020

2121
DEFINE_LOGGER(GstInternalIn, "GstInternalIn");
22-
GstInternalIn::GstInternalIn(GstAppSrc *data, unsigned int minPort, unsigned int maxPort)
22+
GstInternalIn::GstInternalIn(GstAppSrc *data, unsigned int minPort, unsigned int maxPort, std::string ticket)
2323
{
2424
m_transport.reset(new owt_base::RawTransport<owt_base::TCP>(this));
2525

26+
m_transport->initTicket(ticket);
2627
if (minPort > 0 && minPort <= maxPort) {
2728
m_transport->listenTo(minPort, maxPort);
2829
} else {

source/agent/analytics/videoGstPipeline/GstInternalIn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class GstInternalIn : public owt_base::RawTransportListener{
1717
DECLARE_LOGGER();
1818
public:
19-
GstInternalIn(GstAppSrc *data, unsigned int minPort = 0, unsigned int maxPort = 0);
19+
GstInternalIn(GstAppSrc *data, unsigned int minPort = 0, unsigned int maxPort = 0, std::string ticket = NULL);
2020
virtual ~GstInternalIn();
2121

2222
unsigned int getListeningPort();

source/agent/analytics/videoGstPipeline/VideoGstAnalyzer.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,9 @@ int VideoGstAnalyzer::setPlaying()
352352
return 0;
353353
}
354354

355-
void VideoGstAnalyzer::emitListenTo(int minPort, int maxPort)
356-
{
355+
void VideoGstAnalyzer::emitListenTo(int minPort, int maxPort, std::string ticket) {
357356
ELOG_DEBUG("Listening\n");
358-
m_internalin.reset(new GstInternalIn((GstAppSrc*)source, minPort, maxPort));
357+
m_internalin.reset(new GstInternalIn((GstAppSrc*)source, minPort, maxPort, ticket));
359358
}
360359

361360
void VideoGstAnalyzer::addOutput(int connectionID, owt_base::FrameDestination* out)

source/agent/analytics/videoGstPipeline/VideoGstAnalyzer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class VideoGstAnalyzer : public EventRegistry {
3030
void clearPipeline();
3131
void destroyPipeline();
3232
int getListeningPort();
33-
void emitListenTo(int minPort,int maxPort);
33+
void emitListenTo(int minPort, int maxPort, std::string ticket);
3434
int setPlaying();
3535

3636
int addElementMany();

source/agent/analytics/videoGstPipeline/VideoGstAnalyzerWrap.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,17 @@ void VideoGstAnalyzerWrap::emitListenTo(const FunctionCallbackInfo<Value>& args)
9797
mcu::VideoGstAnalyzer* me = obj->me;
9898

9999
unsigned int minPort = 0, maxPort = 0;
100+
std::string ticket;
100101

102+
if (args.Length() >= 3) {
101103
minPort = args[0]->Uint32Value();
102104
maxPort = args[1]->Uint32Value();
103105

104-
me->emitListenTo(minPort,maxPort);
106+
String::Utf8Value param3(args[2]->ToString());
107+
ticket = std::string(*param3);
108+
}
109+
me->emitListenTo(minPort, maxPort, ticket);
110+
105111
}
106112

107113

source/agent/conference/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"node-getopt": "*",
88
"toml": "*",
99
"mongoose": "^5.9.6",
10+
"uuid": "^8.0.0",
1011
"fraction.js": "^4.0.12"
1112
},
1213
"devDependencies": {

source/agent/conference/roomController.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var makeRPC = require('./makeRPC').makeRPC;
1111
// Logger
1212
var log = logger.getLogger('RoomController');
1313

14+
const { v4 : uuid } = require('uuid');
15+
1416
const {
1517
isVideoFmtCompatible,
1618
isResolutionEqual,
@@ -40,12 +42,14 @@ module.exports.create = function (spec, on_init_ok, on_init_failed) {
4042
rpcClient = spec.rpcClient,
4143
config = spec.config,
4244
room_id = spec.room,
43-
origin = spec.origin,
45+
origin = spec.origin,
4446
selfRpcId = spec.selfRpcId,
4547
enable_audio_transcoding = config.transcoding && !!config.transcoding.audio,
4648
enable_video_transcoding = config.transcoding && !!config.transcoding.video,
4749
internal_conn_protocol = config.internalConnProtocol;
4850

51+
var internalTicket = uuid().replace(/-/g, '');
52+
4953
/*
5054
mix_views = {
5155
view: {
@@ -524,7 +528,8 @@ module.exports.create = function (spec, on_init_ok, on_init_failed) {
524528

525529
// Transport protocol for creating internal connection
526530
var internalOpt = {
527-
protocol: internal_conn_protocol
531+
protocol: internal_conn_protocol,
532+
ticket: internalTicket,
528533
};
529534
var from, to, has_published, has_subscribed;
530535

source/agent/nodeManager.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,12 @@ module.exports = function (spec, spawnOptions, onNodeAbnormallyQuit, onTaskAdded
129129
} else {
130130
child.READY = false;
131131
child.kill();
132-
fs.closeSync(child.out_log_fd);
133-
fs.closeSync(child.err_log_fd);
132+
try {
133+
fs.closeSync(child.out_log_fd);
134+
fs.closeSync(child.err_log_fd);
135+
} catch (e) {
136+
log.warn('Close fd failed');
137+
}
134138
cleanupNode(id);
135139
}
136140
});

source/agent/workingNode.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ process.on('exit', function () {
9696
//rpc.disconnect();
9797
});
9898

99+
process.on('uncaughtException', async (err) => {
100+
log.error(err);
101+
try {
102+
await rpc.disconnect();
103+
} catch(e) {
104+
log.warn('Exiting e:', e);
105+
}
106+
process.exit(1);
107+
});
108+
99109
process.on('unhandledRejection', (reason) => {
100110
log.info('Reason: ' + reason);
101111
});

0 commit comments

Comments
 (0)