Only use last X-Forwarded-For address as visitor address, closes #328
This commit is contained in:
parent
1fae61e78f
commit
9918f4965d
5 changed files with 53 additions and 2 deletions
|
@ -88,6 +88,14 @@ func SplitKV(s string, sep string) (key string, value string) {
|
|||
return "", strings.TrimSpace(kv[0])
|
||||
}
|
||||
|
||||
// LastString returns the last string in a slice, or def if s is empty
|
||||
func LastString(s []string, def string) string {
|
||||
if len(s) == 0 {
|
||||
return def
|
||||
}
|
||||
return s[len(s)-1]
|
||||
}
|
||||
|
||||
// RandomString returns a random string with a given length
|
||||
func RandomString(length int) string {
|
||||
randomMutex.Lock() // Who would have thought that random.Intn() is not thread-safe?!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue