mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 05:15:54 +00:00
Allow opt-out of user tracking
This commit is contained in:
parent
814f25ad53
commit
613d13652f
2 changed files with 22 additions and 5 deletions
|
@ -111,17 +111,32 @@ func callHandler(handler CommandHandler, conn *websocket.Conn, client *ClientInf
|
||||||
// C2SHello implements the `hello` C2S Command.
|
// C2SHello implements the `hello` C2S Command.
|
||||||
// It calls SubscribeGlobal() and SubscribeDefaults() with the client, and fills out ClientInfo.Version and ClientInfo.ClientID.
|
// It calls SubscribeGlobal() and SubscribeDefaults() with the client, and fills out ClientInfo.Version and ClientInfo.ClientID.
|
||||||
func C2SHello(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg ClientMessage, err error) {
|
func C2SHello(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (rmsg ClientMessage, err error) {
|
||||||
version, clientID, err := msg.ArgumentsAsTwoStrings()
|
ary, ok := msg.Arguments.([]interface{})
|
||||||
if err != nil {
|
if !ok {
|
||||||
|
err = ErrExpectedTwoStrings
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ary) != 2 {
|
||||||
|
err = ErrExpectedTwoStrings
|
||||||
|
return
|
||||||
|
}
|
||||||
|
version, ok := ary[0].(string)
|
||||||
|
if !ok {
|
||||||
|
err = ErrExpectedTwoStrings
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
client.VersionString = copyString(version)
|
client.VersionString = copyString(version)
|
||||||
client.Version = VersionFromString(version)
|
client.Version = VersionFromString(version)
|
||||||
|
|
||||||
client.ClientID = uuid.FromStringOrNil(clientID)
|
if clientIDStr, ok := ary[1].(string); ok {
|
||||||
if client.ClientID == uuid.Nil {
|
client.ClientID = uuid.FromStringOrNil(clientIDStr)
|
||||||
client.ClientID = uuid.NewV4()
|
if client.ClientID == uuid.Nil {
|
||||||
|
client.ClientID = uuid.NewV4()
|
||||||
|
}
|
||||||
|
} else if _, ok := ary[1].(bool); ok {
|
||||||
|
// opt out
|
||||||
|
client.ClientID = AnonymousClientID
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueUserChannel <- client.ClientID
|
uniqueUserChannel <- client.ClientID
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
|
|
||||||
const NegativeOne = ^uint64(0)
|
const NegativeOne = ^uint64(0)
|
||||||
|
|
||||||
|
var AnonymousClientID = uuid.FromStringOrNil("683b45e4-f853-4c45-bf96-7d799cc93e34")
|
||||||
|
|
||||||
type ConfigFile struct {
|
type ConfigFile struct {
|
||||||
// Numeric server id known to the backend
|
// Numeric server id known to the backend
|
||||||
ServerID int
|
ServerID int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue