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
Compare revisions
d2bb5223f2bd40a675cac4def5624f671b888d39 to 216be42b2a6cc5632d427cf222c789d34026a274
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
sweng-group-15/signalbuddy
Select target project
No results found
216be42b2a6cc5632d427cf222c789d34026a274
Select Git revision
Branches
master
no-server
Swap
Target
sweng-group-15/signalbuddy
Select target project
sweng-group-15/signalbuddy
1 result
d2bb5223f2bd40a675cac4def5624f671b888d39
Select Git revision
Branches
master
no-server
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (4)
(ml5717) Added secure STUN server and TURN REST API
· 95e2da85
Moritz Langenstein
authored
5 years ago
95e2da85
(ml5717) Send temporary TURN servers on offer, join and clients
· 04ea4e50
Moritz Langenstein
authored
5 years ago
04ea4e50
(ml5717) Allocate uuidv4 IDs to connecting clients
· 1e44fad4
Moritz Langenstein
authored
5 years ago
1e44fad4
(ml5717) Fixed TURN server username for UUIDs
· 216be42b
Moritz Langenstein
authored
5 years ago
216be42b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dist/sockets.js
+39
-11
39 additions, 11 deletions
dist/sockets.js
package.json
+1
-1
1 addition, 1 deletion
package.json
src/sockets.js
+34
-9
34 additions, 9 deletions
src/sockets.js
with
74 additions
and
21 deletions
dist/sockets.js
View file @
216be42b
...
...
@@ -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
};
}
...
...
@@ -20,11 +24,17 @@ function signalbuddy(server, config) {
var
_arguments
=
arguments
;
var
io
=
_socket2
.
default
.
listen
(
server
);
io
.
engine
.
generateId
=
function
()
/*req, callback*/
{
return
(
0
,
_v2
.
default
)();
};
io
.
on
(
'
connection
'
,
function
(
client
)
{
client
.
resources
=
{
screen
:
false
,
video
:
true
,
audio
:
false
video
:
false
,
audio
:
false
,
data
:
true
};
// pass a message to another id
...
...
@@ -33,6 +43,9 @@ function signalbuddy(server, config) {
var
otherClient
=
io
.
to
(
details
.
to
);
if
(
!
otherClient
)
return
;
details
.
from
=
client
.
id
;
if
(
details
.
type
===
'
offer
'
)
{
details
.
turnservers
=
getTurnServers
(
details
.
to
+
"
..
"
+
client
.
id
);
}
otherClient
.
emit
(
'
message
'
,
details
);
});
...
...
@@ -78,7 +91,7 @@ function signalbuddy(server, config) {
describeRoom
(
roomName
).
then
(
function
(
description
)
{
var
obj
=
{
clients
:
{}
};
description
.
forEach
(
function
(
k
)
{
obj
.
clients
[
k
]
=
client
.
resources
;
obj
.
clients
[
k
]
=
Object
.
assign
({},
client
.
resources
,
{
turnservers
:
getTurnServers
(
client
.
id
+
"
..
"
+
k
)
})
;
});
(
0
,
_util
.
safeCb
)(
callback
)(
null
,
obj
);
}).
catch
(
function
(
err
)
{
...
...
@@ -125,12 +138,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
(
username
)
{
// 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
+
"
-
"
+
username
.
replace
(
/-/g
,
""
);
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
(
username
,
cb
)
{
(
0
,
_util
.
safeCb
)(
cb
)(
null
,
getTurnServers
(
username
));
});
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
View file @
216be42b
...
...
@@ -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
View file @
216be42b
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
);
io
.
engine
.
generateId
=
function
(
/*req, callback*/
)
{
return
uuidv4
();
};
io
.
on
(
'
connection
'
,
(
client
)
=>
{
client
.
resources
=
{
screen
:
false
,
video
:
true
,
audio
:
false
video
:
false
,
audio
:
false
,
data
:
true
,
};
// pass a message to another id
...
...
@@ -18,6 +25,9 @@ function signalbuddy(server, config) {
const
otherClient
=
io
.
to
(
details
.
to
);
if
(
!
otherClient
)
return
;
details
.
from
=
client
.
id
;
if
(
details
.
type
===
'
offer
'
)
{
details
.
turnservers
=
getTurnServers
(
details
.
to
+
"
..
"
+
client
.
id
)
}
otherClient
.
emit
(
'
message
'
,
details
);
});
...
...
@@ -63,7 +73,7 @@ function signalbuddy(server, config) {
.
then
((
description
)
=>
{
const
obj
=
{
clients
:
{}
};
description
.
forEach
((
k
)
=>
{
obj
.
clients
[
k
]
=
client
.
resources
;
obj
.
clients
[
k
]
=
Object
.
assign
({},
client
.
resources
,
{
turnservers
:
getTurnServers
(
client
.
id
+
"
..
"
+
k
)
})
;
});
safeCb
(
callback
)(
null
,
obj
);
})
...
...
@@ -110,12 +120,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
(
username
)
{
// 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
)
+
"
-
"
+
username
.
replace
(
/-/g
,
""
)
const
acting_ice_turn_password
=
crypto
.
createHmac
(
'
sha1
'
,
config
.
ice
.
turn
.
secret
).
update
(
acting_ice_turn_username
).
digest
(
'
base64
'
)
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
'
,
(
username
,
cb
)
=>
{
safeCb
(
cb
)(
null
,
getTurnServers
(
username
))
});
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.