mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00: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
724d7a5068
commit
7997f760b8
@ -26,6 +26,7 @@ func GetIPAddressFromRequest(req *http.Request) string {
|
||||
xForwardedFor := req.Header.Get("X-FORWARDED-FOR")
|
||||
if xForwardedFor != "" {
|
||||
clientIpString := strings.Split(xForwardedFor, ", ")[0]
|
||||
if strings.Contains(clientIpString, ":") {
|
||||
ip, _, err := net.SplitHostPort(clientIpString)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
@ -33,7 +34,8 @@ func GetIPAddressFromRequest(req *http.Request) string {
|
||||
}
|
||||
return ip
|
||||
}
|
||||
|
||||
return clientIpString
|
||||
}
|
||||
ip, _, err := net.SplitHostPort(ipAddressString)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user