mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 15:02:19 +00:00
Add oneStreamPerDomain mode
This commit is contained in:
parent
10312667d8
commit
6cf24cfb85
@ -45,6 +45,10 @@ web:
|
||||
widgetURL: https://example.com/stream_{{.Path}}
|
||||
viewersCounterRefreshPeriod: 20000
|
||||
|
||||
# When oneStreamPerDomain is enabled, the stream name will be the domain name.
|
||||
# For example, on http://example.com:8080/ the stream will always be "example.com"
|
||||
oneStreamPerDomain: false
|
||||
|
||||
# Configure WebRTC server
|
||||
webrtc:
|
||||
# UDP port range used to stream
|
||||
|
9
main.go
9
main.go
@ -52,18 +52,19 @@ func loadConfiguration() {
|
||||
})
|
||||
viper.SetDefault("Auth.LDAP.URI", "ldap://127.0.0.1:389")
|
||||
viper.SetDefault("Auth.LDAP.UserDn", "cn=users,dc=example,dc=com")
|
||||
viper.SetDefault("Forwarding", make(map[string][]string))
|
||||
viper.SetDefault("Monitoring.ListenAddress", ":2112")
|
||||
viper.SetDefault("Srt.ListenAddress", ":9710")
|
||||
viper.SetDefault("Srt.MaxClients", 64)
|
||||
viper.SetDefault("Web.Favicon", "/static/img/favicon.svg")
|
||||
viper.SetDefault("Web.Hostname", "localhost")
|
||||
viper.SetDefault("Web.ListenAddress", ":8080")
|
||||
viper.SetDefault("Web.Name", "Ghostream")
|
||||
viper.SetDefault("Web.Hostname", "localhost")
|
||||
viper.SetDefault("Web.Favicon", "/static/img/favicon.svg")
|
||||
viper.SetDefault("Web.OneStreamPerDomain", false)
|
||||
viper.SetDefault("Web.ViewersCounterRefreshPeriod", 20000)
|
||||
viper.SetDefault("WebRTC.MinPortUDP", 10000)
|
||||
viper.SetDefault("WebRTC.MaxPortUDP", 10005)
|
||||
viper.SetDefault("WebRTC.MinPortUDP", 10000)
|
||||
viper.SetDefault("WebRTC.STUNServers", []string{"stun:stun.l.google.com:19302"})
|
||||
viper.SetDefault("Forwarding", make(map[string][]string))
|
||||
|
||||
// Copy STUN configuration to clients
|
||||
viper.Set("Web.STUNServers", viper.Get("WebRTC.STUNServers"))
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/markbates/pkger"
|
||||
@ -45,14 +46,26 @@ func viewerPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func viewerGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Get stream ID from URL, or from domain name
|
||||
path := r.URL.Path[1:]
|
||||
if cfg.OneStreamPerDomain {
|
||||
host, _, err := net.SplitHostPort(r.Host)
|
||||
if err != nil {
|
||||
log.Printf("Failed to split host and port from %s", r.Host)
|
||||
return
|
||||
}
|
||||
path = host
|
||||
}
|
||||
|
||||
// Render template
|
||||
data := struct {
|
||||
Cfg *Options
|
||||
Path string
|
||||
WidgetURL string
|
||||
}{Path: r.URL.Path[1:], Cfg: cfg}
|
||||
}{Path: path, Cfg: cfg}
|
||||
|
||||
// Compute the WidgetURL with the stream path
|
||||
b := &bytes.Buffer{}
|
||||
// Update the WidgetURL with the stream path
|
||||
_ = template.Must(template.New("").Parse(cfg.WidgetURL)).Execute(b, data)
|
||||
data.WidgetURL = b.String()
|
||||
|
||||
|
11
web/web.go
11
web/web.go
@ -15,16 +15,15 @@ import (
|
||||
|
||||
// Options holds web package configuration
|
||||
type Options struct {
|
||||
Favicon string
|
||||
Hostname string
|
||||
ListenAddress string
|
||||
Name string
|
||||
Hostname string
|
||||
Favicon string
|
||||
OneStreamPerDomain bool
|
||||
SRTServerPort string
|
||||
WidgetURL string
|
||||
STUNServers []string
|
||||
ViewersCounterRefreshPeriod int
|
||||
|
||||
// Copied from WebRTC configuration
|
||||
STUNServers []string
|
||||
WidgetURL string
|
||||
}
|
||||
|
||||
var (
|
||||
|
Loading…
Reference in New Issue
Block a user