downgrade to 1.24

This commit is contained in:
Vicente Ferrari Smith 2026-05-10 14:16:11 +02:00
parent c3308feff6
commit 312cf602c7
9 changed files with 46 additions and 40 deletions

View File

@ -62,7 +62,7 @@ deploy/teardown: confirm
## deploy/migrate: run database migrations on production ## deploy/migrate: run database migrations on production
.PHONY: deploy/migrate .PHONY: deploy/migrate
deploy/migrate: confirm deploy/migrate: confirm
ssh ${production_user}@${production_host} \ ssh -t ${production_user}@${production_host} \
'set -a; . /etc/party/environment; set +a; migrate -path /usr/share/party/migrations -database $$PARTY_DB_DSN up' 'set -a; . /etc/party/environment; set +a; migrate -path /usr/share/party/migrations -database $$PARTY_DB_DSN up'
## deploy: pull latest, build .deb on server, and install it ## deploy: pull latest, build .deb on server, and install it

View File

@ -5,7 +5,7 @@ MIGRATE_VERSION=v4.18.1
REPO_URL=https://git.losandesgames.com/vfs/party REPO_URL=https://git.losandesgames.com/vfs/party
apt-get update -q apt-get update -q
apt-get install -y -q git golang-go apt-get install -y -q git golang-go build-essential wget
# Install golang-migrate (not in Debian repos) # Install golang-migrate (not in Debian repos)
if ! command -v migrate &>/dev/null; then if ! command -v migrate &>/dev/null; then
@ -24,6 +24,7 @@ fi
echo "" echo ""
echo "Setup complete. Next steps:" echo "Setup complete. Next steps:"
echo " 1. make deploy/migrate" echo " 1. make deploy"
echo " 2. Edit /etc/party/environment with your DB DSN and secrets" echo " 2. ssh root@<server> and edit /etc/party/environment with real credentials"
echo " 3. systemctl restart party" echo " 3. make deploy/migrate"
echo " 4. systemctl restart party"

View File

@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
# Purge the installed package — removes binary, web assets, /etc/party, and the party user # Purge the installed package — removes binary, web assets, /etc/party, and the party user
if dpkg -s party &>/dev/null 2>&1; then if dpkg -s party &>/dev/null; then
dpkg --purge party dpkg --purge party
fi fi
@ -13,7 +13,7 @@ rm -rf /srv/party
rm -f /usr/local/bin/migrate rm -f /usr/local/bin/migrate
# Remove Go # Remove Go
apt-get remove -y golang-go apt-get remove -y golang-go build-essential wget
apt-get autoremove -y apt-get autoremove -y
echo "Teardown complete." echo "Teardown complete."

4
go.mod
View File

@ -7,14 +7,14 @@ require (
github.com/gorilla/websocket v1.5.3 github.com/gorilla/websocket v1.5.3
github.com/julienschmidt/httprouter v1.3.0 github.com/julienschmidt/httprouter v1.3.0
github.com/lib/pq v1.12.0 github.com/lib/pq v1.12.0
github.com/sideshow/apns2 v0.25.0
github.com/wneessen/go-mail v0.7.2 github.com/wneessen/go-mail v0.7.2
golang.org/x/crypto v0.37.0 golang.org/x/crypto v0.37.0
golang.org/x/time v0.15.0 golang.org/x/time v0.5.0
) )
require ( require (
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/sideshow/apns2 v0.25.0 // indirect
golang.org/x/net v0.21.0 // indirect golang.org/x/net v0.21.0 // indirect
golang.org/x/text v0.29.0 // indirect golang.org/x/text v0.29.0 // indirect
) )

8
go.sum
View File

@ -1,5 +1,6 @@
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20201120081800-1786d5ef83d4/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/alecthomas/units v0.0.0-20201120081800-1786d5ef83d4/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
@ -11,11 +12,13 @@ github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4d
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/lib/pq v1.12.0 h1:mC1zeiNamwKBecjHarAr26c/+d8V5w/u4J0I/yASbJo= github.com/lib/pq v1.12.0 h1:mC1zeiNamwKBecjHarAr26c/+d8V5w/u4J0I/yASbJo=
github.com/lib/pq v1.12.0/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA= github.com/lib/pq v1.12.0/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sideshow/apns2 v0.25.0 h1:XOzanncO9MQxkb03T/2uU2KcdVjYiIf0TMLzec0FTW4= github.com/sideshow/apns2 v0.25.0 h1:XOzanncO9MQxkb03T/2uU2KcdVjYiIf0TMLzec0FTW4=
github.com/sideshow/apns2 v0.25.0/go.mod h1:7Fceu+sL0XscxrfLSkAoH6UtvKefq3Kq1n4W3ayQZqE= github.com/sideshow/apns2 v0.25.0/go.mod h1:7Fceu+sL0XscxrfLSkAoH6UtvKefq3Kq1n4W3ayQZqE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/wneessen/go-mail v0.7.2 h1:xxPnhZ6IZLSgxShebmZ6DPKh1b6OJcoHfzy7UjOkzS8= github.com/wneessen/go-mail v0.7.2 h1:xxPnhZ6IZLSgxShebmZ6DPKh1b6OJcoHfzy7UjOkzS8=
github.com/wneessen/go-mail v0.7.2/go.mod h1:+TkW6QP3EVkgTEqHtVmnAE/1MRhmzb8Y9/W3pweuS+k= github.com/wneessen/go-mail v0.7.2/go.mod h1:+TkW6QP3EVkgTEqHtVmnAE/1MRhmzb8Y9/W3pweuS+k=
@ -31,10 +34,11 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

4
vendor/golang.org/x/time/LICENSE generated vendored
View File

@ -1,4 +1,4 @@
Copyright 2009 The Go Authors. Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
copyright notice, this list of conditions and the following disclaimer copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the in the documentation and/or other materials provided with the
distribution. distribution.
* Neither the name of Google LLC nor the names of its * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from contributors may be used to endorse or promote products derived from
this software without specific prior written permission. this software without specific prior written permission.

View File

@ -85,7 +85,7 @@ func (lim *Limiter) Burst() int {
// TokensAt returns the number of tokens available at time t. // TokensAt returns the number of tokens available at time t.
func (lim *Limiter) TokensAt(t time.Time) float64 { func (lim *Limiter) TokensAt(t time.Time) float64 {
lim.mu.Lock() lim.mu.Lock()
tokens := lim.advance(t) // does not mutate lim _, tokens := lim.advance(t) // does not mutate lim
lim.mu.Unlock() lim.mu.Unlock()
return tokens return tokens
} }
@ -99,9 +99,8 @@ func (lim *Limiter) Tokens() float64 {
// bursts of at most b tokens. // bursts of at most b tokens.
func NewLimiter(r Limit, b int) *Limiter { func NewLimiter(r Limit, b int) *Limiter {
return &Limiter{ return &Limiter{
limit: r, limit: r,
burst: b, burst: b,
tokens: float64(b),
} }
} }
@ -186,7 +185,7 @@ func (r *Reservation) CancelAt(t time.Time) {
return return
} }
// advance time to now // advance time to now
tokens := r.lim.advance(t) t, tokens := r.lim.advance(t)
// calculate new number of tokens // calculate new number of tokens
tokens += restoreTokens tokens += restoreTokens
if burst := float64(r.lim.burst); tokens > burst { if burst := float64(r.lim.burst); tokens > burst {
@ -195,7 +194,7 @@ func (r *Reservation) CancelAt(t time.Time) {
// update state // update state
r.lim.last = t r.lim.last = t
r.lim.tokens = tokens r.lim.tokens = tokens
if r.timeToAct.Equal(r.lim.lastEvent) { if r.timeToAct == r.lim.lastEvent {
prevEvent := r.timeToAct.Add(r.limit.durationFromTokens(float64(-r.tokens))) prevEvent := r.timeToAct.Add(r.limit.durationFromTokens(float64(-r.tokens)))
if !prevEvent.Before(t) { if !prevEvent.Before(t) {
r.lim.lastEvent = prevEvent r.lim.lastEvent = prevEvent
@ -307,7 +306,7 @@ func (lim *Limiter) SetLimitAt(t time.Time, newLimit Limit) {
lim.mu.Lock() lim.mu.Lock()
defer lim.mu.Unlock() defer lim.mu.Unlock()
tokens := lim.advance(t) t, tokens := lim.advance(t)
lim.last = t lim.last = t
lim.tokens = tokens lim.tokens = tokens
@ -324,7 +323,7 @@ func (lim *Limiter) SetBurstAt(t time.Time, newBurst int) {
lim.mu.Lock() lim.mu.Lock()
defer lim.mu.Unlock() defer lim.mu.Unlock()
tokens := lim.advance(t) t, tokens := lim.advance(t)
lim.last = t lim.last = t
lim.tokens = tokens lim.tokens = tokens
@ -345,9 +344,21 @@ func (lim *Limiter) reserveN(t time.Time, n int, maxFutureReserve time.Duration)
tokens: n, tokens: n,
timeToAct: t, timeToAct: t,
} }
} else if lim.limit == 0 {
var ok bool
if lim.burst >= n {
ok = true
lim.burst -= n
}
return Reservation{
ok: ok,
lim: lim,
tokens: lim.burst,
timeToAct: t,
}
} }
tokens := lim.advance(t) t, tokens := lim.advance(t)
// Calculate the remaining number of tokens resulting from the request. // Calculate the remaining number of tokens resulting from the request.
tokens -= float64(n) tokens -= float64(n)
@ -380,11 +391,10 @@ func (lim *Limiter) reserveN(t time.Time, n int, maxFutureReserve time.Duration)
return r return r
} }
// advance calculates and returns an updated number of tokens for lim // advance calculates and returns an updated state for lim resulting from the passage of time.
// resulting from the passage of time.
// lim is not changed. // lim is not changed.
// advance requires that lim.mu is held. // advance requires that lim.mu is held.
func (lim *Limiter) advance(t time.Time) (newTokens float64) { func (lim *Limiter) advance(t time.Time) (newT time.Time, newTokens float64) {
last := lim.last last := lim.last
if t.Before(last) { if t.Before(last) {
last = t last = t
@ -397,7 +407,7 @@ func (lim *Limiter) advance(t time.Time) (newTokens float64) {
if burst := float64(lim.burst); tokens > burst { if burst := float64(lim.burst); tokens > burst {
tokens = burst tokens = burst
} }
return tokens return t, tokens
} }
// durationFromTokens is a unit conversion function from the number of tokens to the duration // durationFromTokens is a unit conversion function from the number of tokens to the duration
@ -406,15 +416,8 @@ func (limit Limit) durationFromTokens(tokens float64) time.Duration {
if limit <= 0 { if limit <= 0 {
return InfDuration return InfDuration
} }
seconds := tokens / float64(limit)
duration := (tokens / float64(limit)) * float64(time.Second) return time.Duration(float64(time.Second) * seconds)
// Cap the duration to the maximum representable int64 value, to avoid overflow.
if duration > float64(math.MaxInt64) {
return InfDuration
}
return time.Duration(duration)
} }
// tokensFromDuration is a unit conversion function from a time duration to the number of tokens // tokensFromDuration is a unit conversion function from a time duration to the number of tokens

View File

@ -61,9 +61,7 @@ func (s *Sometimes) Do(f func()) {
(s.Every > 0 && s.count%s.Every == 0) || (s.Every > 0 && s.count%s.Every == 0) ||
(s.Interval > 0 && time.Since(s.last) >= s.Interval) { (s.Interval > 0 && time.Since(s.last) >= s.Interval) {
f() f()
if s.Interval > 0 { s.last = time.Now()
s.last = time.Now()
}
} }
s.count++ s.count++
} }

4
vendor/modules.txt vendored
View File

@ -57,6 +57,6 @@ golang.org/x/text/transform
golang.org/x/text/unicode/bidi golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/norm golang.org/x/text/unicode/norm
golang.org/x/text/width golang.org/x/text/width
# golang.org/x/time v0.15.0 # golang.org/x/time v0.5.0
## explicit; go 1.25.0 ## explicit; go 1.18
golang.org/x/time/rate golang.org/x/time/rate