mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-06-28 16:32:46 +02:00
Map domain to streamid instead of considering that the domain is the streamid: no need to pass a YAML key that contains dots
This commit is contained in:
@ -24,17 +24,17 @@ func viewerPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Get stream ID from URL, or from domain name
|
||||
path := r.URL.Path[1:]
|
||||
if cfg.OneStreamPerDomain {
|
||||
host := r.Host
|
||||
if strings.Contains(host, ":") {
|
||||
realHost, _, err := net.SplitHostPort(r.Host)
|
||||
if err != nil {
|
||||
log.Printf("Failed to split host and port from %s", r.Host)
|
||||
return
|
||||
}
|
||||
host = realHost
|
||||
host := r.Host
|
||||
if strings.Contains(host, ":") {
|
||||
realHost, _, err := net.SplitHostPort(r.Host)
|
||||
if err != nil {
|
||||
log.Printf("Failed to split host and port from %s", r.Host)
|
||||
return
|
||||
}
|
||||
path = host
|
||||
host = realHost
|
||||
}
|
||||
if streamID, ok := cfg.MapDomainToStream[host]; ok {
|
||||
path = streamID
|
||||
}
|
||||
|
||||
// Decode client description
|
||||
@ -73,20 +73,20 @@ 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 := r.Host
|
||||
if strings.Contains(host, ":") {
|
||||
realHost, _, err := net.SplitHostPort(r.Host)
|
||||
if err != nil {
|
||||
log.Printf("Failed to split host and port from %s", r.Host)
|
||||
return
|
||||
}
|
||||
host = realHost
|
||||
host := r.Host
|
||||
if strings.Contains(host, ":") {
|
||||
realHost, _, err := net.SplitHostPort(r.Host)
|
||||
if err != nil {
|
||||
log.Printf("Failed to split host and port from %s", r.Host)
|
||||
return
|
||||
}
|
||||
host = realHost
|
||||
}
|
||||
if streamID, ok := cfg.MapDomainToStream[host]; ok {
|
||||
if path == "about" {
|
||||
path = ""
|
||||
} else {
|
||||
path = host
|
||||
path = streamID
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{if .Path}}{{if not .Cfg.OneStreamPerDomain}}{{.Path}} - {{end}}{{end}}{{.Cfg.Name}}</title>
|
||||
<title>{{if .Path}}{{.Path}} - {{end}}{{.Cfg.Name}}</title>
|
||||
<link rel="stylesheet" href="static/css/style.css">
|
||||
<link rel="stylesheet" href="static/css/player.css">
|
||||
{{if .Cfg.CustomCSS}}<link rel="stylesheet" href="{{.Cfg.CustomCSS}}">{{end}}
|
||||
|
@ -22,7 +22,7 @@ type Options struct {
|
||||
Hostname string
|
||||
ListenAddress string
|
||||
Name string
|
||||
OneStreamPerDomain bool
|
||||
MapDomainToStream map[string]string
|
||||
PlayerPoster string
|
||||
SRTServerPort string
|
||||
STUNServers []string
|
||||
|
Reference in New Issue
Block a user