1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-23 01:32:19 +00:00

Don't split domain if we use standard HTTP ports

This commit is contained in:
Yohann D'ANELLO 2020-10-04 18:10:11 +02:00
parent d5ada0bce7
commit 7831238375

View File

@ -7,6 +7,7 @@ import (
"log" "log"
"net" "net"
"net/http" "net/http"
"strings"
"github.com/markbates/pkger" "github.com/markbates/pkger"
"gitlab.crans.org/nounous/ghostream/internal/monitoring" "gitlab.crans.org/nounous/ghostream/internal/monitoring"
@ -49,11 +50,15 @@ 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 { if cfg.OneStreamPerDomain {
host, _, err := net.SplitHostPort(r.Host) var host = r.Host
if strings.Contains(host, ":") {
realHost, _, err := net.SplitHostPort(r.Host)
if err != nil { if err != nil {
log.Printf("Failed to split host and port from %s", r.Host) log.Printf("Failed to split host and port from %s", r.Host)
return return
} }
host = realHost
}
path = host path = host
} }