From 0d81557009e325b80f689b0f16efeee77bc27ed1 Mon Sep 17 00:00:00 2001 From: Azareal Date: Thu, 2 Jan 2020 16:04:10 +1000 Subject: [PATCH] Add DisableLastIP configuration setting. Reduce default PollIPCutoff to 365. --- common/routes_common.go | 2 +- common/site.go | 6 ++++-- docs/configuration.md | 2 ++ tickloop.go | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/routes_common.go b/common/routes_common.go index 876c7f68..1d675277 100644 --- a/common/routes_common.go +++ b/common/routes_common.go @@ -316,7 +316,7 @@ func preRoute(w http.ResponseWriter, r *http.Request) (User, bool) { } } - if usercpy.Loggedin && host != usercpy.GetIP() { + if !Config.DisableLastIP && usercpy.Loggedin && host != usercpy.GetIP() { mon := time.Now().Month() err = usercpy.UpdateIP(strconv.Itoa(int(mon)) + "-" + host) if err != nil { diff --git a/common/site.go b/common/site.go index 67beeb85..de33661b 100644 --- a/common/site.go +++ b/common/site.go @@ -93,9 +93,11 @@ type config struct { ServerCount int LastIPCutoff int // Currently just -1, non--1, but will accept the number of months a user's last IP should be retained for in the future before being purged. Please note that the other two cutoffs below operate off the numbers of days instead. PostIPCutoff int - PollIPCutoff int + PollIPCutoff int LogPruneCutoff int + DisableLastIP bool + DisableLiveTopicList bool DisableJSAntispam bool //LooseCSP bool @@ -230,7 +232,7 @@ func ProcessConfig() (err error) { Config.LastIPCutoff = 12 } if Config.PollIPCutoff == 0 { - Config.PollIPCutoff = 720 // Default cutoff + Config.PollIPCutoff = 365 // Default cutoff } if Config.NoEmbed { DefaultParseSettings.NoEmbed = true diff --git a/docs/configuration.md b/docs/configuration.md index ce2ba3a8..1942d840 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -90,6 +90,8 @@ PostIPCutoff - The number of days which need to pass before the IP data for a po PollIPCutoff - The number of days which need to pass before the IP data for a poll is automatically deleted. 0 defaults to whatever the current default is, currently -1 and -1 disables this feature. +DisableLastIP - Disable storing last IPs for users and purge any existing user last IP data. Default: false + LogPruneCutoff - The number of days which need to pass before the login and registration logs are pruned. 0 defaults to whatever the current default is, currently 180 and -1 disables this feature. DisableLiveTopicList - This switch allows you to disable the live topic list. Default: false diff --git a/tickloop.go b/tickloop.go index f8188f4c..a65c99a6 100644 --- a/tickloop.go +++ b/tickloop.go @@ -205,12 +205,12 @@ func dailies() { } // TODO: lastActiveAt isn't currently set, so we can't rely on this to purge last_ips of users who haven't been on in a while - /*if c.Config.LastIPCutoff == -1 { + if c.Config.DisableLastIP { _, err := qgen.NewAcc().Update("users").Set("last_ip=0").Where("last_ip!=0").Exec() if err != nil { c.LogError(err) } - } else */if c.Config.LastIPCutoff > 0 { + } else if c.Config.LastIPCutoff > 0 { /*_, err = qgen.NewAcc().Update("users").Set("last_ip='0'").DateOlderThan("lastActiveAt",c.Config.PostIPCutoff,"day").Where("last_ip!='0'").Exec() if err != nil { c.LogError(err)