Use UserAgent in server-side client ID to allow multiple clients on the same IP to count as new viewers
This commit is contained in:
parent
a9662e7c1e
commit
dfae6f56dc
8
utils.go
8
utils.go
@ -74,18 +74,18 @@ func resetDirectories(configuration Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getClientIDFromRequest(req *http.Request) string {
|
func getClientIDFromRequest(req *http.Request) string {
|
||||||
var ipAddress string
|
var clientID string
|
||||||
xForwardedFor := req.Header.Get("X-FORWARDED-FOR")
|
xForwardedFor := req.Header.Get("X-FORWARDED-FOR")
|
||||||
if xForwardedFor != "" {
|
if xForwardedFor != "" {
|
||||||
ipAddress = xForwardedFor
|
clientID = xForwardedFor
|
||||||
} else {
|
} else {
|
||||||
ipAddressString := req.RemoteAddr
|
ipAddressString := req.RemoteAddr
|
||||||
ipAddressComponents := strings.Split(ipAddressString, ":")
|
ipAddressComponents := strings.Split(ipAddressString, ":")
|
||||||
ipAddressComponents[len(ipAddressComponents)-1] = ""
|
ipAddressComponents[len(ipAddressComponents)-1] = ""
|
||||||
ipAddress = strings.Join(ipAddressComponents, ":")
|
clientID = strings.Join(ipAddressComponents, ":")
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Println("IP address determined to be", ipAddress)
|
// fmt.Println("IP address determined to be", ipAddress)
|
||||||
|
|
||||||
return ipAddress
|
return clientID + req.UserAgent()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user