Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsupermanhd committed Sep 14, 2024
1 parent 7f08b04 commit b1fcfa9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
36 changes: 36 additions & 0 deletions connfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log"
"regexp"
"slices"
"strconv"
"sync"
Expand Down Expand Up @@ -158,6 +159,41 @@ where g.game_time < 60000 and g.time_started + $1::interval > now() and (i.pkey
}
}

// stage 7 ip based mute
ipmutes := map[string]bool{}
for i := len(inst.cfgs) - 1; i >= 0; i-- {
o, ok := inst.cfgs[i].GetKeys("ipmute")
if !ok {
continue
}
for _, k := range o {
s, ok := inst.cfgs[i].GetBool("ipmute", k)
if !ok {
continue
}
if !s {
delete(ipmutes, k)
} else {
ipmutes[k] = s
}
}
}
for kip, v := range ipmutes {
if !v {
continue
}
reg, err := regexp.Compile(kip)
if err != nil {
inst.logger.Printf("Failed to compile regexp %q: %s", kip, err.Error())
continue
}
if reg.Match([]byte(ip)) {
if jd.AllowChat {
jd.AllowChat = false
}
}
}

inst.logger.Printf("connfilter resolved key %v nljoin %v (acc %v) nlplay %v (action %v) nlchat %v (allowed %v)",
pubkeyB64,
allowNonLinkedJoin, account,
Expand Down
9 changes: 9 additions & 0 deletions gamesubmit.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func submitBegin(inst *instance, reportBytes []byte) int {
return err
}
for _, v := range report.PlayerData {
if v.PublicKey == "" {
continue
}
PublicKeyBytes, err := base64.StdEncoding.DecodeString(v.PublicKey)
if err != nil {
return err
Expand Down Expand Up @@ -129,6 +132,9 @@ func submitFrame(inst *instance, reportBytes []byte) {
RecentStructurePowerLost: make([]int, len(report.PlayerData)),
}
for i, v := range report.PlayerData {
if v.PublicKey == "" {
continue
}
frame.Kills[i] = v.Kills
frame.Power[i] = v.Power
frame.Score[i] = v.Score
Expand Down Expand Up @@ -181,6 +187,9 @@ func submitEnd(inst *instance, reportBytes []byte) {
}
err = dbpool.BeginFunc(context.Background(), func(tx pgx.Tx) error {
for _, v := range report.PlayerData {
if v.PublicKey == "" {
continue
}
_, err := dbpool.Exec(context.Background(), `update players set usertype = $1, props = $2 where game = $3 and position = $4`,
v.Usertype, v.GameReportPlayerStatistics, inst.GameId, v.Position)
if err != nil {
Expand Down

0 comments on commit b1fcfa9

Please sign in to comment.