mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 16:12:19 +00:00
Make STUN server configurable
This commit is contained in:
parent
1c98754624
commit
95f4b81f01
@ -10,7 +10,7 @@ auth:
|
|||||||
|
|
||||||
# Example to bypass login, dangerous!
|
# Example to bypass login, dangerous!
|
||||||
#backend: bypass
|
#backend: bypass
|
||||||
|
#
|
||||||
# Example of LDAP server login
|
# Example of LDAP server login
|
||||||
#backend: ldap
|
#backend: ldap
|
||||||
#ldap:
|
#ldap:
|
||||||
@ -41,3 +41,7 @@ webrtc:
|
|||||||
# UDP port range used to stream
|
# UDP port range used to stream
|
||||||
minPortUDP: 10000
|
minPortUDP: 10000
|
||||||
maxPortUDP: 10005
|
maxPortUDP: 10005
|
||||||
|
|
||||||
|
# STUN servers, you should host your own Coturn instance
|
||||||
|
STUNServers:
|
||||||
|
- stun:stun.l.google.com:19302
|
||||||
|
4
main.go
4
main.go
@ -55,6 +55,10 @@ func loadConfiguration() {
|
|||||||
viper.SetDefault("Web.Favicon", "/favicon.ico")
|
viper.SetDefault("Web.Favicon", "/favicon.ico")
|
||||||
viper.SetDefault("WebRTC.MinPortUDP", 10000)
|
viper.SetDefault("WebRTC.MinPortUDP", 10000)
|
||||||
viper.SetDefault("WebRTC.MaxPortUDP", 10005)
|
viper.SetDefault("WebRTC.MaxPortUDP", 10005)
|
||||||
|
viper.SetDefault("WebRTC.STUNServers", []string{"stun:stun.l.google.com:19302"})
|
||||||
|
|
||||||
|
// Copy STUN configuration to clients
|
||||||
|
viper.Set("Web.STUNServers", viper.Get("WebRTC.STUNServers"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -18,6 +18,8 @@ import (
|
|||||||
type Options struct {
|
type Options struct {
|
||||||
MinPortUDP uint16
|
MinPortUDP uint16
|
||||||
MaxPortUDP uint16
|
MaxPortUDP uint16
|
||||||
|
|
||||||
|
STUNServers []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SessionDescription contains SDP data
|
// SessionDescription contains SDP data
|
||||||
@ -65,11 +67,7 @@ func newPeerHandler(remoteSdp webrtc.SessionDescription, cfg *Options) webrtc.Se
|
|||||||
webrtc.WithSettingEngine(settingsEngine),
|
webrtc.WithSettingEngine(settingsEngine),
|
||||||
)
|
)
|
||||||
peerConnection, err := api.NewPeerConnection(webrtc.Configuration{
|
peerConnection, err := api.NewPeerConnection(webrtc.Configuration{
|
||||||
ICEServers: []webrtc.ICEServer{
|
ICEServers: []webrtc.ICEServer{{URLs: cfg.STUNServers}},
|
||||||
{
|
|
||||||
URLs: []string{"stun:stun.l.google.com:19302"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Failed to initiate peer connection", err)
|
log.Println("Failed to initiate peer connection", err)
|
||||||
|
@ -3,12 +3,7 @@ let peerConnection;
|
|||||||
startPeerConnection = () => {
|
startPeerConnection = () => {
|
||||||
// Init peer connection
|
// Init peer connection
|
||||||
peerConnection = new RTCPeerConnection({
|
peerConnection = new RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [{ urls: stunServers }]
|
||||||
{
|
|
||||||
// FIXME: let admin customize the stun server
|
|
||||||
urls: 'stun:stun.l.google.com:19302'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// On connection change, change indicator color
|
// On connection change, change indicator color
|
||||||
@ -80,6 +75,3 @@ startPeerConnection = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start
|
|
||||||
startPeerConnection()
|
|
||||||
|
@ -36,4 +36,12 @@
|
|||||||
|
|
||||||
<script src="/static/js/sideWidget.js"></script>
|
<script src="/static/js/sideWidget.js"></script>
|
||||||
<script src="/static/js/viewer.js"></script>
|
<script src="/static/js/viewer.js"></script>
|
||||||
|
<script>
|
||||||
|
const stunServers = [
|
||||||
|
{{range $id, $value := .Cfg.STUNServers}}
|
||||||
|
'{{$value}}',
|
||||||
|
{{end}}
|
||||||
|
]
|
||||||
|
startPeerConnection()
|
||||||
|
</script>
|
||||||
{{end}}
|
{{end}}
|
@ -20,6 +20,9 @@ type Options struct {
|
|||||||
Hostname string
|
Hostname string
|
||||||
Favicon string
|
Favicon string
|
||||||
WidgetURL string
|
WidgetURL string
|
||||||
|
|
||||||
|
// Copied from WebRTC configuration
|
||||||
|
STUNServers []string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user