mirror of
https://github.com/lucheng0127/virtuallan.git
synced 2025-09-26 20:51:11 +08:00

Count username hash, get client ip base on it, it will make ip fixed base on client login username.
13 lines
168 B
Go
13 lines
168 B
Go
package utils
|
|
|
|
import (
|
|
"hash/fnv"
|
|
)
|
|
|
|
func IdxFromString(step int, str string) int {
|
|
h := fnv.New32a()
|
|
h.Write([]byte(str))
|
|
|
|
return int(h.Sum32() % uint32(step))
|
|
}
|