Handle viewer counts outside of websocket connections
This commit is contained in:
18
utils.go
18
utils.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@@ -65,3 +66,20 @@ func resetDirectories(configuration Config) {
|
||||
os.MkdirAll(path.Join(configuration.PublicHLSPath, strconv.Itoa(index)), 0777)
|
||||
}
|
||||
}
|
||||
|
||||
func getClientIDFromRequest(req *http.Request) string {
|
||||
var ipAddress string
|
||||
xForwardedFor := req.Header.Get("X-FORWARDED-FOR")
|
||||
if xForwardedFor != "" {
|
||||
ipAddress = xForwardedFor
|
||||
} else {
|
||||
ipAddressString := req.RemoteAddr
|
||||
ipAddressComponents := strings.Split(ipAddressString, ":")
|
||||
ipAddressComponents[len(ipAddressComponents)-1] = ""
|
||||
ipAddress = strings.Join(ipAddressComponents, ":")
|
||||
}
|
||||
|
||||
// fmt.Println("IP address determined to be", ipAddress)
|
||||
|
||||
return ipAddress
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user