Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
signalbuddy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sweng-group-15
signalbuddy
Commits
95e2da85
Commit
95e2da85
authored
5 years ago
by
Moritz Langenstein
Browse files
Options
Downloads
Patches
Plain Diff
(ml5717) Added secure STUN server and TURN REST API
parent
d2bb5223
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dist/sockets.js
+27
-8
27 additions, 8 deletions
dist/sockets.js
package.json
+1
-1
1 addition, 1 deletion
package.json
src/sockets.js
+22
-6
22 additions, 6 deletions
src/sockets.js
with
50 additions
and
15 deletions
dist/sockets.js
+
27
−
8
View file @
95e2da85
...
...
@@ -8,11 +8,15 @@ var _v = require('uuid/v4');
var
_v2
=
_interopRequireDefault
(
_v
);
var
_
freeice
=
require
(
'
freeice
'
);
var
_
util
=
require
(
'
./util
'
);
var
_
freeice2
=
_interopRequireDefault
(
_freeice
);
var
_
crypto
=
require
(
'
crypto
'
);
var
_util
=
require
(
'
./util
'
);
var
_crypto2
=
_interopRequireDefault
(
_crypto
);
var
_normalice
=
require
(
'
normalice
'
);
var
_normalice2
=
_interopRequireDefault
(
_normalice
);
function
_interopRequireDefault
(
obj
)
{
return
obj
&&
obj
.
__esModule
?
obj
:
{
default
:
obj
};
}
...
...
@@ -125,12 +129,27 @@ function signalbuddy(server, config) {
});
});
// tell client about stun and turn servers and generate nonces
client
.
emit
(
'
stunservers
'
,
(
0
,
_freeice2
.
default
)({
stunCount
:
config
.
stunCount
,
turnCount
:
-
1
}).
map
(
function
(
server
)
{
return
{
urls
:
server
.
url
};
}));
function
getStunServers
()
{
return
[(
0
,
_normalice2
.
default
)(
'
stun:
'
+
config
.
ice
.
stun
.
username
+
'
:
'
+
config
.
ice
.
stun
.
password
+
'
@
'
+
config
.
ice
.
host
+
'
:
'
+
config
.
ice
.
port
)];
}
function
getTurnServers
()
{
// See https://github.com/coturn/coturn/wiki/turnserver#turn-rest-api for details
var
acting_ice_turn_username
=
Math
.
floor
(
Date
.
now
()
/
1000
)
+
config
.
ice
.
turn
.
timeout
+
"
-
"
+
config
.
ice
.
stun
.
username
;
var
acting_ice_turn_password
=
_crypto2
.
default
.
createHmac
(
'
sha1
'
,
config
.
ice
.
turn
.
secret
).
update
(
acting_ice_turn_username
).
digest
(
'
base64
'
);
return
[(
0
,
_normalice2
.
default
)(
'
turn:
'
+
acting_ice_turn_username
+
'
:
'
+
acting_ice_turn_password
+
'
@
'
+
config
.
ice
.
host
+
'
:
'
+
config
.
ice
.
port
)];
}
client
.
on
(
'
stunservers
'
,
function
(
cb
)
{
(
0
,
_util
.
safeCb
)(
cb
)(
null
,
getStunServers
());
});
client
.
on
(
'
turnservers
'
,
function
(
cb
)
{
(
0
,
_util
.
safeCb
)(
cb
)(
null
,
getTurnServers
());
});
client
.
emit
(
'
tu
r
nservers
'
,
(
0
,
_freeice2
.
default
)({
stunCount
:
-
1
,
turnCount
:
config
.
turnCount
}
));
client
.
emit
(
'
s
tunservers
'
,
getStunServers
(
));
});
function
describeRoom
(
roomName
)
{
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
95e2da85
...
...
@@ -3,7 +3,7 @@
"description"
:
"A scalable socket.io signaling solution for WebRTC using NodeJS cluster and Redis."
,
"version"
:
"1.0.0"
,
"dependencies"
:
{
"
free
ice
"
:
"
^
2.2.2
"
,
"
normal
ice
"
:
"
^
1.0.1
"
,
"
socket.io
"
:
"
^2.3.0
"
,
"
uuid
"
:
"
^3.3.3
"
},
...
...
This diff is collapsed.
Click to expand it.
src/sockets.js
+
22
−
6
View file @
95e2da85
import
socketIO
from
'
socket.io
'
;
import
uuidv4
from
'
uuid/v4
'
;
import
freeice
from
'
freeice
'
;
import
{
safeCb
}
from
'
./util
'
;
import
crypto
from
'
crypto
'
;
import
normalice
from
'
normalice
'
;
function
signalbuddy
(
server
,
config
)
{
const
io
=
socketIO
.
listen
(
server
);
...
...
@@ -110,12 +111,27 @@ function signalbuddy(server, config) {
});
});
// tell client about stun and turn servers and generate nonces
client
.
emit
(
'
stunservers
'
,
freeice
({
stunCount
:
config
.
stunCount
,
turnCount
:
-
1
}).
map
(
server
=>
{
return
{
urls
:
server
.
url
}
}));
function
getStunServers
()
{
return
[
normalice
(
`stun:
${
config
.
ice
.
stun
.
username
}
:
${
config
.
ice
.
stun
.
password
}
@
${
config
.
ice
.
host
}
:
${
config
.
ice
.
port
}
`
)]
}
function
getTurnServers
()
{
// See https://github.com/coturn/coturn/wiki/turnserver#turn-rest-api for details
const
acting_ice_turn_username
=
(
Math
.
floor
(
Date
.
now
()
/
1000
)
+
config
.
ice
.
turn
.
timeout
)
+
"
-
"
+
config
.
ice
.
stun
.
username
const
acting_ice_turn_password
=
crypto
.
createHmac
(
'
sha1
'
,
config
.
ice
.
turn
.
secret
).
update
(
acting_ice_turn_username
).
digest
(
'
base64
'
)
Tiger Wang
@ztw17
·
Oct 21, 2019
Maintainer
I need some time to
digest
these changes.
I need some time to *digest* these changes.
Please
register
or
sign in
to reply
return
[
normalice
(
`turn:
${
acting_ice_turn_username
}
:
${
acting_ice_turn_password
}
@
${
config
.
ice
.
host
}
:
${
config
.
ice
.
port
}
`
)]
}
client
.
on
(
'
stunservers
'
,
(
cb
)
=>
{
safeCb
(
cb
)(
null
,
getStunServers
())
});
client
.
on
(
'
turnservers
'
,
(
cb
)
=>
{
safeCb
(
cb
)(
null
,
getTurnServers
())
});
client
.
emit
(
'
tu
r
nservers
'
,
freeice
({
stunCount
:
-
1
,
turnCount
:
config
.
turnCount
}
))
;
client
.
emit
(
'
s
tunservers
'
,
getStunServers
(
))
});
function
describeRoom
(
roomName
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment