mirror of
https://github.com/owncast/owncast.git
synced 2024-11-21 20:28:15 +03:00
Added a check for the port before calling the splitHostPort function (#3372)
Co-authored-by: Aziz Rmadi <azizrmadi@Azizs-MacBook-Air.local>
This commit is contained in:
parent
47d5b3c92f
commit
6b27d850d8
1 changed files with 8 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue