mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 20:52:20 +00: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:
parent
3b8c149e38
commit
4546f3b8fb
@ -73,7 +73,7 @@ srt:
|
|||||||
telnet:
|
telnet:
|
||||||
# By default, this easter egg is disabled.
|
# By default, this easter egg is disabled.
|
||||||
# You must enable it to use it.
|
# You must enable it to use it.
|
||||||
#enable: false
|
#enabled: false
|
||||||
|
|
||||||
#listenAddress: :8023
|
#listenAddress: :8023
|
||||||
|
|
||||||
@ -115,11 +115,13 @@ web:
|
|||||||
#
|
#
|
||||||
#name: Ghostream
|
#name: Ghostream
|
||||||
|
|
||||||
# Use the domain name as the stream name
|
# Use the domain name as the stream name for some hosts
|
||||||
# e.g., on http://example.com:8080/ the stream served will be "example.com"
|
# e.g., on http://stream.example.com:8080/, if the domain stream.example.com is mapped to "example",
|
||||||
|
# the stream served will be "example".
|
||||||
# This implies that your domain will be able to serve only one stream.
|
# This implies that your domain will be able to serve only one stream.
|
||||||
#
|
#
|
||||||
#oneStreamPerDomain: false
|
#mapDomainToStream:
|
||||||
|
# stream.example.com: example
|
||||||
|
|
||||||
# Stream player poster
|
# Stream player poster
|
||||||
# Shown when stream is loading or inactive.
|
# Shown when stream is loading or inactive.
|
||||||
|
@ -71,7 +71,7 @@ func New() *Config {
|
|||||||
Hostname: "localhost",
|
Hostname: "localhost",
|
||||||
ListenAddress: ":8080",
|
ListenAddress: ":8080",
|
||||||
Name: "Ghostream",
|
Name: "Ghostream",
|
||||||
OneStreamPerDomain: false,
|
MapDomainToStream: make(map[string]string),
|
||||||
PlayerPoster: "/static/img/no_stream.svg",
|
PlayerPoster: "/static/img/no_stream.svg",
|
||||||
ViewersCounterRefreshPeriod: 20000,
|
ViewersCounterRefreshPeriod: 20000,
|
||||||
},
|
},
|
||||||
|
@ -24,7 +24,6 @@ func viewerPostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// Get stream ID from URL, or from domain name
|
// Get stream ID from URL, or from domain name
|
||||||
path := r.URL.Path[1:]
|
path := r.URL.Path[1:]
|
||||||
if cfg.OneStreamPerDomain {
|
|
||||||
host := r.Host
|
host := r.Host
|
||||||
if strings.Contains(host, ":") {
|
if strings.Contains(host, ":") {
|
||||||
realHost, _, err := net.SplitHostPort(r.Host)
|
realHost, _, err := net.SplitHostPort(r.Host)
|
||||||
@ -34,7 +33,8 @@ func viewerPostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
host = realHost
|
host = realHost
|
||||||
}
|
}
|
||||||
path = host
|
if streamID, ok := cfg.MapDomainToStream[host]; ok {
|
||||||
|
path = streamID
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode client description
|
// Decode client description
|
||||||
@ -73,7 +73,6 @@ func viewerPostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
func viewerGetHandler(w http.ResponseWriter, r *http.Request) {
|
func viewerGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// Get stream ID from URL, or from domain name
|
// Get stream ID from URL, or from domain name
|
||||||
path := r.URL.Path[1:]
|
path := r.URL.Path[1:]
|
||||||
if cfg.OneStreamPerDomain {
|
|
||||||
host := r.Host
|
host := r.Host
|
||||||
if strings.Contains(host, ":") {
|
if strings.Contains(host, ":") {
|
||||||
realHost, _, err := net.SplitHostPort(r.Host)
|
realHost, _, err := net.SplitHostPort(r.Host)
|
||||||
@ -83,10 +82,11 @@ func viewerGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
host = realHost
|
host = realHost
|
||||||
}
|
}
|
||||||
|
if streamID, ok := cfg.MapDomainToStream[host]; ok {
|
||||||
if path == "about" {
|
if path == "about" {
|
||||||
path = ""
|
path = ""
|
||||||
} else {
|
} else {
|
||||||
path = host
|
path = streamID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<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/style.css">
|
||||||
<link rel="stylesheet" href="static/css/player.css">
|
<link rel="stylesheet" href="static/css/player.css">
|
||||||
{{if .Cfg.CustomCSS}}<link rel="stylesheet" href="{{.Cfg.CustomCSS}}">{{end}}
|
{{if .Cfg.CustomCSS}}<link rel="stylesheet" href="{{.Cfg.CustomCSS}}">{{end}}
|
||||||
|
@ -22,7 +22,7 @@ type Options struct {
|
|||||||
Hostname string
|
Hostname string
|
||||||
ListenAddress string
|
ListenAddress string
|
||||||
Name string
|
Name string
|
||||||
OneStreamPerDomain bool
|
MapDomainToStream map[string]string
|
||||||
PlayerPoster string
|
PlayerPoster string
|
||||||
SRTServerPort string
|
SRTServerPort string
|
||||||
STUNServers []string
|
STUNServers []string
|
||||||
|
Loading…
Reference in New Issue
Block a user