Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Added a check for the port before calling the splitHostPort function (#3372)

armadi1809bb1ecc1bd023
diff --git a/utils/clientId.go b/utils/clientId.go
index 38188bcdca..6a85557506 100644
--- a/utils/clientId.go
+++ b/utils/clientId.go
@@ -26,14 +26,16 @@ func GetIPAddressFromRequest(req *http.Request) string {
xForwardedFor := req.Header.Get("X-FORWARDED-FOR")
if xForwardedFor != "" {
clientIpString := strings.Split(xForwardedFor, ", ")[0]
- ip, _, err := net.SplitHostPort(clientIpString)
- if err != nil {
- log.Errorln(err)
- return ""
+ if strings.Contains(clientIpString, ":") {
+ ip, _, err := net.SplitHostPort(clientIpString)
+ if err != nil {
+ log.Errorln(err)
+ return ""
+ }
+ return ip
}
- return ip
+ return clientIpString
}
-
ip, _, err := net.SplitHostPort(ipAddressString)
if err != nil {
log.Errorln(err)