mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 15:02: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!
|
||||
#backend: bypass
|
||||
|
||||
#
|
||||
# Example of LDAP server login
|
||||
#backend: ldap
|
||||
#ldap:
|
||||
@ -41,3 +41,7 @@ webrtc:
|
||||
# UDP port range used to stream
|
||||
minPortUDP: 10000
|
||||
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("WebRTC.MinPortUDP", 10000)
|
||||
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() {
|
||||
|
@ -18,6 +18,8 @@ import (
|
||||
type Options struct {
|
||||
MinPortUDP uint16
|
||||
MaxPortUDP uint16
|
||||
|
||||
STUNServers []string
|
||||
}
|
||||
|
||||
// SessionDescription contains SDP data
|
||||
@ -65,11 +67,7 @@ func newPeerHandler(remoteSdp webrtc.SessionDescription, cfg *Options) webrtc.Se
|
||||
webrtc.WithSettingEngine(settingsEngine),
|
||||
)
|
||||
peerConnection, err := api.NewPeerConnection(webrtc.Configuration{
|
||||
ICEServers: []webrtc.ICEServer{
|
||||
{
|
||||
URLs: []string{"stun:stun.l.google.com:19302"},
|
||||
},
|
||||
},
|
||||
ICEServers: []webrtc.ICEServer{{URLs: cfg.STUNServers}},
|
||||
})
|
||||
if err != nil {
|
||||
log.Println("Failed to initiate peer connection", err)
|
||||
|
@ -3,12 +3,7 @@ let peerConnection;
|
||||
startPeerConnection = () => {
|
||||
// Init peer connection
|
||||
peerConnection = new RTCPeerConnection({
|
||||
iceServers: [
|
||||
{
|
||||
// FIXME: let admin customize the stun server
|
||||
urls: 'stun:stun.l.google.com:19302'
|
||||
}
|
||||
]
|
||||
iceServers: [{ urls: stunServers }]
|
||||
})
|
||||
|
||||
// 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/viewer.js"></script>
|
||||
<script>
|
||||
const stunServers = [
|
||||
{{range $id, $value := .Cfg.STUNServers}}
|
||||
'{{$value}}',
|
||||
{{end}}
|
||||
]
|
||||
startPeerConnection()
|
||||
</script>
|
||||
{{end}}
|
@ -20,6 +20,9 @@ type Options struct {
|
||||
Hostname string
|
||||
Favicon string
|
||||
WidgetURL string
|
||||
|
||||
// Copied from WebRTC configuration
|
||||
STUNServers []string
|
||||
}
|
||||
|
||||
var (
|
||||
|
Loading…
Reference in New Issue
Block a user